diff options
author | Lukas Stockner <lukas.stockner@freenet.de> | 2020-07-13 02:49:25 +0300 |
---|---|---|
committer | Lukas Stockner <lukas.stockner@freenet.de> | 2020-07-13 04:08:11 +0300 |
commit | 41e6f9bd437cb5f23dd6a8ad41c6142b0520f65d (patch) | |
tree | 6bdc12625e7ed2f47d3ac93fa3362a514abc8d8a /source | |
parent | e2736afdbefde486bc051627dbedeaa28cdb972e (diff) |
Cycles: Add control for sun intensity in Sky Texture and change altitude to km
Differential Revision: https://developer.blender.org/D8091
Diffstat (limited to 'source')
-rw-r--r-- | source/blender/blenloader/intern/versioning_290.c | 16 | ||||
-rw-r--r-- | source/blender/editors/space_node/drawnode.c | 6 | ||||
-rw-r--r-- | source/blender/makesdna/DNA_node_types.h | 5 | ||||
-rw-r--r-- | source/blender/makesrna/intern/rna_nodetree.c | 14 | ||||
-rw-r--r-- | source/blender/nodes/shader/nodes/node_shader_tex_sky.c | 3 |
5 files changed, 35 insertions, 9 deletions
diff --git a/source/blender/blenloader/intern/versioning_290.c b/source/blender/blenloader/intern/versioning_290.c index e608a90aab0..ba92e11cc2a 100644 --- a/source/blender/blenloader/intern/versioning_290.c +++ b/source/blender/blenloader/intern/versioning_290.c @@ -389,5 +389,21 @@ void blo_do_versions_290(FileData *fd, Library *UNUSED(lib), Main *bmain) */ { /* Keep this block, even when empty. */ + + /* Initialize additional parameter of the Nishita sky model and change altitude unit. */ + if (!DNA_struct_elem_find(fd->filesdna, "NodeTexSky", "float", "sun_intensity")) { + FOREACH_NODETREE_BEGIN (bmain, ntree, id) { + if (ntree->type == NTREE_SHADER) { + LISTBASE_FOREACH (bNode *, node, &ntree->nodes) { + if (node->type == SH_NODE_TEX_SKY && node->storage) { + NodeTexSky *tex = (NodeTexSky *)node->storage; + tex->sun_intensity = 1.0f; + tex->altitude *= 0.001f; + } + } + } + } + FOREACH_NODETREE_END; + } } } diff --git a/source/blender/editors/space_node/drawnode.c b/source/blender/editors/space_node/drawnode.c index f3207f2dc1e..780c3d6a217 100644 --- a/source/blender/editors/space_node/drawnode.c +++ b/source/blender/editors/space_node/drawnode.c @@ -860,11 +860,13 @@ static void node_shader_buts_tex_sky(uiLayout *layout, bContext *UNUSED(C), Poin if (RNA_enum_get(ptr, "sky_type") == SHD_SKY_NISHITA) { uiItemR(layout, ptr, "sun_disc", DEFAULT_FLAGS, NULL, 0); + uiLayout *col; if (RNA_boolean_get(ptr, "sun_disc")) { - uiItemR(layout, ptr, "sun_size", DEFAULT_FLAGS, NULL, ICON_NONE); + col = uiLayoutColumn(layout, true); + uiItemR(col, ptr, "sun_size", DEFAULT_FLAGS, NULL, ICON_NONE); + uiItemR(col, ptr, "sun_intensity", DEFAULT_FLAGS, NULL, ICON_NONE); } - uiLayout *col; col = uiLayoutColumn(layout, true); uiItemR(col, ptr, "sun_elevation", DEFAULT_FLAGS, NULL, ICON_NONE); uiItemR(col, ptr, "sun_rotation", DEFAULT_FLAGS, NULL, ICON_NONE); diff --git a/source/blender/makesdna/DNA_node_types.h b/source/blender/makesdna/DNA_node_types.h index 993aad92564..42ccbc657d8 100644 --- a/source/blender/makesdna/DNA_node_types.h +++ b/source/blender/makesdna/DNA_node_types.h @@ -845,14 +845,15 @@ typedef struct NodeTexSky { float turbidity; float ground_albedo; float sun_size; + float sun_intensity; float sun_elevation; float sun_rotation; - int altitude; + float altitude; float air_density; float dust_density; float ozone_density; char sun_disc; - char _pad[3]; + char _pad[7]; } NodeTexSky; typedef struct NodeTexImage { diff --git a/source/blender/makesrna/intern/rna_nodetree.c b/source/blender/makesrna/intern/rna_nodetree.c index 0658b2f048a..332108facb3 100644 --- a/source/blender/makesrna/intern/rna_nodetree.c +++ b/source/blender/makesrna/intern/rna_nodetree.c @@ -4453,6 +4453,12 @@ static void def_sh_tex_sky(StructRNA *srna) RNA_def_property_float_default(prop, DEG2RADF(0.545)); RNA_def_property_update(prop, NC_NODE | NA_EDITED, "rna_Node_update"); + prop = RNA_def_property(srna, "sun_intensity", PROP_FLOAT, PROP_NONE); + RNA_def_property_ui_text(prop, "Sun Intensity", "Strength of sun"); + RNA_def_property_range(prop, 0.0f, 1000.0f); + RNA_def_property_float_default(prop, 1.0f); + RNA_def_property_update(prop, NC_NODE | NA_EDITED, "rna_Node_update"); + prop = RNA_def_property(srna, "sun_elevation", PROP_FLOAT, PROP_ANGLE); RNA_def_property_ui_text(prop, "Sun Elevation", "Angle between sun and horizon"); RNA_def_property_range(prop, -M_PI_2, M_PI_2); @@ -4464,10 +4470,10 @@ static void def_sh_tex_sky(StructRNA *srna) RNA_def_property_float_default(prop, 0.0f); RNA_def_property_update(prop, NC_NODE | NA_EDITED, "rna_Node_update"); - prop = RNA_def_property(srna, "altitude", PROP_INT, PROP_NONE); - RNA_def_property_ui_text(prop, "Altitude", "Altitude height from sea level in meters"); - RNA_def_property_range(prop, 0, 60000); - RNA_def_property_int_default(prop, 0); + prop = RNA_def_property(srna, "altitude", PROP_FLOAT, PROP_NONE); + RNA_def_property_ui_text(prop, "Altitude", "Height from sea level in km"); + RNA_def_property_range(prop, 0.0f, 60.0f); + RNA_def_property_float_default(prop, 0.0f); RNA_def_property_update(prop, NC_NODE | NA_EDITED, "rna_Node_update"); prop = RNA_def_property(srna, "air_density", PROP_FLOAT, PROP_FACTOR); diff --git a/source/blender/nodes/shader/nodes/node_shader_tex_sky.c b/source/blender/nodes/shader/nodes/node_shader_tex_sky.c index 7e15daaf666..8753bb2c770 100644 --- a/source/blender/nodes/shader/nodes/node_shader_tex_sky.c +++ b/source/blender/nodes/shader/nodes/node_shader_tex_sky.c @@ -44,9 +44,10 @@ static void node_shader_init_tex_sky(bNodeTree *UNUSED(ntree), bNode *node) tex->ground_albedo = 0.3f; tex->sun_disc = true; tex->sun_size = DEG2RADF(0.545); + tex->sun_intensity = 1.0f; tex->sun_elevation = M_PI_2; tex->sun_rotation = 0.0f; - tex->altitude = 0; + tex->altitude = 0.0f; tex->air_density = 1.0f; tex->dust_density = 1.0f; tex->ozone_density = 1.0f; |