Probes: Add more parameters.

Add Min Max for box, and distance for sphere falloff.
Same for parallax.
Add clip distances.
This commit is contained in:
Clément Foucault 2017-06-08 23:10:28 +02:00
parent 974c0cc7b6
commit e45ebec335
6 changed files with 84 additions and 30 deletions

View File

@ -62,7 +62,11 @@ class DATA_PT_probe(DataButtonsPanel, Panel):
layout.prop(probe, "type", expand=True)
layout.prop(probe, "distance")
layout.prop(probe, "influence_distance")
layout.prop(probe, "clip_start")
layout.prop(probe, "clip_end")
# layout.prop(probe, "influence_minimum")
# layout.prop(probe, "influence_maximum")
layout.prop(probe, "falloff")

View File

@ -44,8 +44,13 @@ void BKE_probe_init(Probe *probe)
{
BLI_assert(MEMCMP_STRUCT_OFS_IS_ZERO(probe, id));
probe->dist = 5.0f;
copy_v3_fl(probe->mininf, -5.0f);
copy_v3_fl(probe->maxinf, 5.0f);
copy_v3_fl(probe->minpar, -5.0f);
copy_v3_fl(probe->maxpar, 5.0f);
probe->falloff = 0.25f;
probe->clipsta = 0.5f;
probe->clipend = 40.0f;
}
void *BKE_probe_add(Main *bmain, const char *name)

View File

@ -277,8 +277,8 @@ static void EEVEE_probes_updates(EEVEE_SceneLayerData *sldata)
Probe *probe = (Probe *)ob->data;
EEVEE_Probe *eprobe = &pinfo->probe_data[i];
float dist_minus_falloff = probe->dist - (1.0f - probe->falloff) * probe->dist;
eprobe->attenuation_bias = probe->dist / max_ff(1e-8f, dist_minus_falloff);
float dist_minus_falloff = probe->distinf - (1.0f - probe->falloff) * probe->distinf;
eprobe->attenuation_bias = probe->distinf / max_ff(1e-8f, dist_minus_falloff);
eprobe->attenuation_scale = 1.0f / max_ff(1e-8f, dist_minus_falloff);
}
}
@ -408,16 +408,13 @@ static void render_one_probe(EEVEE_SceneLayerData *sldata, EEVEE_PassList *psl,
{
EEVEE_ProbesInfo *pinfo = sldata->probes;
EEVEE_Probe *eprobe = &pinfo->probe_data[probe_idx];
Object *ob = NULL;
Object *ob = pinfo->probes_ref[probe_idx];
Probe *prb = (Probe *)ob->data;
float winmat[4][4], posmat[4][4];
float near = 0.1f; /* TODO parameters */
float far = 100.0f;
unit_m4(posmat);
ob = pinfo->probes_ref[probe_idx];
/* Update transforms */
copy_v3_v3(eprobe->position, ob->obmat[3]);
@ -428,7 +425,7 @@ static void render_one_probe(EEVEE_SceneLayerData *sldata, EEVEE_PassList *psl,
* We do this instead of using geometry shader because a) it's faster,
* b) it's easier than fixing the nodetree shaders (for view dependant effects). */
pinfo->layer = 0;
perspective_m4(winmat, -near, near, -near, near, near, far);
perspective_m4(winmat, -prb->clipsta, prb->clipsta, -prb->clipsta, prb->clipsta, prb->clipsta, prb->clipend);
/* Detach to rebind the right cubeface. */
DRW_framebuffer_bind(sldata->probe_fb);

View File

@ -154,9 +154,9 @@ static EnumPropertyItem field_type_items[] = {
/* copy from rna_probe.c */
static EnumPropertyItem probe_type_items[] = {
{PROBE_CAPTURE, "CAPTURE", ICON_FORCE_FORCE, "Capture", ""},
{PROBE_PLANAR, "PLANAR", ICON_FORCE_FORCE, "Planar", ""},
{PROBE_CUSTOM, "CUSTOM", ICON_FORCE_FORCE, "Custom", ""},
{PROBE_CUBE, "CUBE", ICON_MESH_UVSPHERE, "Sphere", ""},
// {PROBE_PLANAR, "PLANAR", ICON_MESH_PLANE, "Planar", ""},
// {PROBE_IMAGE, "IMAGE", ICON_NONE, "Image", ""},
{0, NULL, 0, NULL, NULL}
};

View File

@ -48,19 +48,27 @@ typedef struct Probe {
char display; /* Probe visual appearance in the viewport */
char parallax; /* Parallax type */
float dist; /* Influence radius or distance */
float falloff; /* Influence falloff */
float pad;
float distinf; /* Influence Radius */
float mininf[3]; /* Influence Bound Box */
float maxinf[3];
struct Object *parallax_ob; /* Object to use as a parallax volume */
float falloff; /* Influence falloff */
float distpar; /* Parallax Radius */
float minpar[3]; /* Parallax Bound Box */
float maxpar[3];
float clipsta, clipend;
struct Object *parallax_ob; /* Object to use as a parallax origin */
struct Image *image; /* Image to use on as lighting data */
} Probe;
/* Probe->type */
enum {
PROBE_CAPTURE = 0,
PROBE_CUBE = 0,
PROBE_PLANAR = 1,
PROBE_CUSTOM = 2,
PROBE_IMAGE = 2,
};
/* Probe->display */

View File

@ -33,6 +33,8 @@
#include "DNA_probe_types.h"
#include "WM_types.h"
#ifdef RNA_RUNTIME
#include "MEM_guardedalloc.h"
@ -46,9 +48,9 @@
#else
static EnumPropertyItem probe_type_items[] = {
{PROBE_CAPTURE, "CAPTURE", ICON_NONE, "Capture", ""},
{PROBE_PLANAR, "PLANAR", ICON_NONE, "Planar", ""},
{PROBE_CUSTOM, "CUSTOM", ICON_NONE, "Custom", ""},
{PROBE_CUBE, "CUBE", ICON_NONE, "Cubemap", ""},
// {PROBE_PLANAR, "PLANAR", ICON_NONE, "Planar", ""},
// {PROBE_IMAGE, "IMAGE", ICON_NONE, "Image", ""},
{0, NULL, 0, NULL, NULL}
};
@ -64,18 +66,56 @@ static void rna_def_probe(BlenderRNA *brna)
prop = RNA_def_property(srna, "type", PROP_ENUM, PROP_NONE);
RNA_def_property_enum_items(prop, probe_type_items);
RNA_def_property_ui_text(prop, "Type", "Type of probe");
RNA_def_property_update(prop, 0, NULL); /* TODO */
RNA_def_property_update(prop, NC_MATERIAL | ND_SHADING, NULL);
prop = RNA_def_property(srna, "distance", PROP_FLOAT, PROP_DISTANCE);
RNA_def_property_float_sdna(prop, NULL, "dist");
RNA_def_property_range(prop, 0.0f, 99999.0f);
RNA_def_property_ui_text(prop, "Distance", "All surface within this distance will recieve the probe lighting");
RNA_def_property_update(prop, 0, NULL); /* TODO */
prop = RNA_def_property(srna, "clip_start", PROP_FLOAT, PROP_DISTANCE);
RNA_def_property_float_sdna(prop, NULL, "clipsta");
RNA_def_property_range(prop, 0.0f, 999999.0f);
RNA_def_property_ui_text(prop, "Probe Clip Start",
"Probe clip start, below which objects will not appear in reflections");
RNA_def_property_update(prop, NC_MATERIAL | ND_SHADING, NULL);
prop = RNA_def_property(srna, "clip_end", PROP_FLOAT, PROP_DISTANCE);
RNA_def_property_float_sdna(prop, NULL, "clipend");
RNA_def_property_range(prop, 0.0f, 999999.0f);
RNA_def_property_ui_text(prop, "Probe Clip End",
"Probe clip end, beyond which objects will not appear in reflections");
RNA_def_property_update(prop, NC_MATERIAL | ND_SHADING, NULL);
prop = RNA_def_property(srna, "influence_distance", PROP_FLOAT, PROP_DISTANCE);
RNA_def_property_float_sdna(prop, NULL, "distinf");
RNA_def_property_ui_text(prop, "Influence Distance", "Influence distance of the probe");
RNA_def_property_update(prop, NC_MATERIAL | ND_SHADING, NULL);
prop = RNA_def_property(srna, "influence_minimum", PROP_FLOAT, PROP_TRANSLATION);
RNA_def_property_float_sdna(prop, NULL, "mininf");
RNA_def_property_ui_text(prop, "Influence Min", "Lowest corner of the influence bounding box");
RNA_def_property_update(prop, NC_MATERIAL | ND_SHADING, NULL);
prop = RNA_def_property(srna, "influence_maximum", PROP_FLOAT, PROP_TRANSLATION);
RNA_def_property_float_sdna(prop, NULL, "maxinf");
RNA_def_property_ui_text(prop, "Influence Max", "Highest corner of the influence bounding box");
RNA_def_property_update(prop, NC_MATERIAL | ND_SHADING, NULL);
prop = RNA_def_property(srna, "falloff", PROP_FLOAT, PROP_FACTOR);
RNA_def_property_range(prop, 0.0f, 1.0f);
RNA_def_property_ui_text(prop, "Falloff", "Control how fast the probe intensity decreases");
RNA_def_property_update(prop, 0, NULL); /* TODO */
RNA_def_property_ui_text(prop, "Falloff", "Control how fast the probe influence decreases");
RNA_def_property_update(prop, NC_MATERIAL | ND_SHADING, NULL);
prop = RNA_def_property(srna, "parallax_distance", PROP_FLOAT, PROP_DISTANCE);
RNA_def_property_float_sdna(prop, NULL, "distpar");
RNA_def_property_ui_text(prop, "Parallax Radius", "Lowest corner of the parallax bounding box");
RNA_def_property_update(prop, NC_MATERIAL | ND_SHADING, NULL);
prop = RNA_def_property(srna, "parallax_minimum", PROP_FLOAT, PROP_TRANSLATION);
RNA_def_property_float_sdna(prop, NULL, "minpar");
RNA_def_property_ui_text(prop, "Parallax Min", "Lowest corner of the parallax bounding box");
RNA_def_property_update(prop, NC_MATERIAL | ND_SHADING, NULL);
prop = RNA_def_property(srna, "parallax_maximum", PROP_FLOAT, PROP_TRANSLATION);
RNA_def_property_float_sdna(prop, NULL, "maxpar");
RNA_def_property_ui_text(prop, "Parallax Max", "Highest corner of the parallax bounding box");
RNA_def_property_update(prop, NC_MATERIAL | ND_SHADING, NULL);
/* common */
rna_def_animdata_common(srna);