Viewport Shading: StudioLight Intensity
Add option to change the Intensity of the HDRI in the 3d viewport. This works for both EEVEE and Cycles Reviewed By: brecht, fclem Differential Revision: https://developer.blender.org/D5674
This commit is contained in:
parent
f8362836a5
commit
1b287230a4
Notes:
blender-bot
2023-02-14 05:01:20 +01:00
Referenced by issue #68928, LookDev: Add a HDRI brightness slider to the pop-over
|
@ -2086,6 +2086,7 @@ class CYCLES_VIEW3D_PT_shading_lighting(Panel):
|
|||
split = layout.split(factor=0.9)
|
||||
col = split.column()
|
||||
col.prop(shading, "studiolight_rotate_z", text="Rotation")
|
||||
col.prop(shading, "studiolight_intensity")
|
||||
col.prop(shading, "studiolight_background_alpha")
|
||||
|
||||
|
||||
|
|
|
@ -1347,6 +1347,14 @@ void BlenderSync::sync_world(BL::Depsgraph &b_depsgraph, BL::SpaceView3D &b_v3d,
|
|||
texture_environment->filename = new_viewport_parameters.studiolight_path;
|
||||
graph->add(texture_environment);
|
||||
|
||||
MixNode *mix_intensity = new MixNode();
|
||||
mix_intensity->type = NODE_MIX_MUL;
|
||||
mix_intensity->fac = 1.0f;
|
||||
mix_intensity->color2 = make_float3(new_viewport_parameters.studiolight_intensity,
|
||||
new_viewport_parameters.studiolight_intensity,
|
||||
new_viewport_parameters.studiolight_intensity);
|
||||
graph->add(mix_intensity);
|
||||
|
||||
TextureCoordinateNode *texture_coordinate = new TextureCoordinateNode();
|
||||
graph->add(texture_coordinate);
|
||||
|
||||
|
@ -1359,10 +1367,10 @@ void BlenderSync::sync_world(BL::Depsgraph &b_depsgraph, BL::SpaceView3D &b_v3d,
|
|||
|
||||
graph->connect(texture_coordinate->output("Generated"),
|
||||
texture_environment->input("Vector"));
|
||||
graph->connect(texture_environment->output("Color"), mix_intensity->input("Color1"));
|
||||
graph->connect(light_path->output("Is Camera Ray"), mix_scene_with_background->input("Fac"));
|
||||
graph->connect(texture_environment->output("Color"),
|
||||
mix_scene_with_background->input("Color1"));
|
||||
graph->connect(texture_environment->output("Color"),
|
||||
graph->connect(mix_intensity->output("Color"), mix_scene_with_background->input("Color1"));
|
||||
graph->connect(mix_intensity->output("Color"),
|
||||
mix_background_with_environment->input("Color2"));
|
||||
graph->connect(mix_background_with_environment->output("Color"),
|
||||
mix_scene_with_background->input("Color2"));
|
||||
|
|
|
@ -21,6 +21,7 @@ BlenderViewportParameters::BlenderViewportParameters()
|
|||
: use_scene_world(true),
|
||||
use_scene_lights(true),
|
||||
studiolight_rotate_z(0.0f),
|
||||
studiolight_intensity(1.0f),
|
||||
studiolight_background_alpha(1.0f),
|
||||
studiolight_path(ustring())
|
||||
{
|
||||
|
@ -36,6 +37,7 @@ BlenderViewportParameters::BlenderViewportParameters(BL::SpaceView3D &b_v3d)
|
|||
use_scene_lights = b_v3d.shading().use_scene_lights_render();
|
||||
if (!use_scene_world) {
|
||||
studiolight_rotate_z = b_v3d.shading().studiolight_rotate_z();
|
||||
studiolight_intensity = b_v3d.shading().studiolight_intensity();
|
||||
studiolight_background_alpha = b_v3d.shading().studiolight_background_alpha();
|
||||
studiolight_path = b_v3d.shading().selected_studio_light().path();
|
||||
}
|
||||
|
@ -47,6 +49,7 @@ const bool BlenderViewportParameters::modified(const BlenderViewportParameters &
|
|||
{
|
||||
return use_scene_world != other.use_scene_world || use_scene_lights != other.use_scene_lights ||
|
||||
studiolight_rotate_z != other.studiolight_rotate_z ||
|
||||
studiolight_intensity != other.studiolight_intensity ||
|
||||
studiolight_background_alpha != other.studiolight_background_alpha ||
|
||||
studiolight_path != other.studiolight_path;
|
||||
}
|
||||
|
|
|
@ -31,6 +31,7 @@ class BlenderViewportParameters {
|
|||
bool use_scene_world;
|
||||
bool use_scene_lights;
|
||||
float studiolight_rotate_z;
|
||||
float studiolight_intensity;
|
||||
float studiolight_background_alpha;
|
||||
ustring studiolight_path;
|
||||
|
||||
|
|
|
@ -5131,6 +5131,7 @@ class VIEW3D_PT_shading_lighting(Panel):
|
|||
split = layout.split(factor=0.9)
|
||||
col = split.column()
|
||||
col.prop(shading, "studiolight_rotate_z", text="Rotation")
|
||||
col.prop(shading, "studiolight_intensity")
|
||||
col.prop(shading, "studiolight_background_alpha")
|
||||
col = split.column() # to align properly with above
|
||||
|
||||
|
@ -5153,6 +5154,7 @@ class VIEW3D_PT_shading_lighting(Panel):
|
|||
split = layout.split(factor=0.9)
|
||||
col = split.column()
|
||||
col.prop(shading, "studiolight_rotate_z", text="Rotation")
|
||||
col.prop(shading, "studiolight_intensity")
|
||||
col.prop(shading, "studiolight_background_alpha")
|
||||
col = split.column() # to align properly with above
|
||||
|
||||
|
|
|
@ -869,6 +869,7 @@ void BKE_screen_view3d_shading_init(View3DShading *shading)
|
|||
shading->curvature_valley_factor = 1.0f;
|
||||
copy_v3_fl(shading->single_color, 0.8f);
|
||||
copy_v3_fl(shading->background_color, 0.05f);
|
||||
shading->studiolight_intensity = 1.0f;
|
||||
}
|
||||
|
||||
/* magic zoom calculation, no idea what
|
||||
|
|
|
@ -3767,7 +3767,6 @@ void blo_do_versions_280(FileData *fd, Library *UNUSED(lib), Main *bmain)
|
|||
|
||||
{
|
||||
/* Versioning code until next subversion bump goes here. */
|
||||
|
||||
for (bScreen *screen = bmain->screens.first; screen; screen = screen->id.next) {
|
||||
for (ScrArea *sa = screen->areabase.first; sa; sa = sa->next) {
|
||||
for (SpaceLink *sl = sa->spacedata.first; sl; sl = sl->next) {
|
||||
|
@ -3820,5 +3819,19 @@ void blo_do_versions_280(FileData *fd, Library *UNUSED(lib), Main *bmain)
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* Added studiolight intensity */
|
||||
if (!DNA_struct_elem_find(fd->filesdna, "View3DShading", "float", "studiolight_intensity")) {
|
||||
for (bScreen *screen = bmain->screens.first; screen; screen = screen->id.next) {
|
||||
for (ScrArea *sa = screen->areabase.first; sa; sa = sa->next) {
|
||||
for (SpaceLink *sl = sa->spacedata.first; sl; sl = sl->next) {
|
||||
if (sl->spacetype == SPACE_VIEW3D) {
|
||||
View3D *v3d = (View3D *)sl;
|
||||
v3d->shading.studiolight_intensity = 1.0f;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -151,6 +151,9 @@ void EEVEE_lookdev_cache_init(EEVEE_Data *vedata,
|
|||
stl->g_data->studiolight_matrix, 'Z', v3d->shading.studiolight_rot_z);
|
||||
DRW_shgroup_uniform_mat3(*grp, "StudioLightMatrix", stl->g_data->studiolight_matrix);
|
||||
DRW_shgroup_uniform_float_copy(*grp, "backgroundAlpha", background_alpha);
|
||||
DRW_shgroup_uniform_float(
|
||||
*grp, "studioLightIntensity", &v3d->shading.studiolight_intensity, 1);
|
||||
|
||||
DRW_shgroup_uniform_vec3(*grp, "color", background_color, 1);
|
||||
DRW_shgroup_call(*grp, geom, NULL);
|
||||
if (!pinfo) {
|
||||
|
@ -170,12 +173,14 @@ void EEVEE_lookdev_cache_init(EEVEE_Data *vedata,
|
|||
/* Do we need to recalc the lightprobes? */
|
||||
if (g_data->studiolight_index != sl->index ||
|
||||
g_data->studiolight_rot_z != v3d->shading.studiolight_rot_z ||
|
||||
g_data->studiolight_intensity != v3d->shading.studiolight_intensity ||
|
||||
g_data->studiolight_cubemap_res != scene->eevee.gi_cubemap_resolution ||
|
||||
g_data->studiolight_glossy_clamp != scene->eevee.gi_glossy_clamp ||
|
||||
g_data->studiolight_filter_quality != scene->eevee.gi_filter_quality) {
|
||||
stl->lookdev_lightcache->flag |= LIGHTCACHE_UPDATE_WORLD;
|
||||
g_data->studiolight_index = sl->index;
|
||||
g_data->studiolight_rot_z = v3d->shading.studiolight_rot_z;
|
||||
g_data->studiolight_intensity = v3d->shading.studiolight_intensity;
|
||||
g_data->studiolight_cubemap_res = scene->eevee.gi_cubemap_resolution;
|
||||
g_data->studiolight_glossy_clamp = scene->eevee.gi_glossy_clamp;
|
||||
g_data->studiolight_filter_quality = scene->eevee.gi_filter_quality;
|
||||
|
|
|
@ -789,6 +789,7 @@ typedef struct EEVEE_PrivateData {
|
|||
/* LookDev Settings */
|
||||
int studiolight_index;
|
||||
float studiolight_rot_z;
|
||||
float studiolight_intensity;
|
||||
int studiolight_cubemap_res;
|
||||
float studiolight_glossy_clamp;
|
||||
float studiolight_filter_quality;
|
||||
|
|
|
@ -8,6 +8,7 @@ out vec4 FragColor;
|
|||
uniform mat3 StudioLightMatrix;
|
||||
uniform sampler2D image;
|
||||
uniform float studioLightBackground = 1.0;
|
||||
uniform float studioLightIntensity = 1.0;
|
||||
in vec3 viewPosition;
|
||||
|
||||
# define M_PI 3.14159265358979323846
|
||||
|
@ -51,6 +52,7 @@ void main()
|
|||
#ifdef LOOKDEV
|
||||
vec3 worldvec = background_transform_to_world(viewPosition);
|
||||
background_color = node_tex_environment_equirectangular(StudioLightMatrix * worldvec, image).rgb;
|
||||
background_color *= studioLightIntensity;
|
||||
background_color = mix(color, background_color, studioLightBackground);
|
||||
#else
|
||||
background_color = color;
|
||||
|
|
|
@ -152,7 +152,7 @@ typedef struct View3DShading {
|
|||
char background_type;
|
||||
char cavity_type;
|
||||
char wire_color_type;
|
||||
char _pad[6];
|
||||
char _pad[2];
|
||||
|
||||
/** FILE_MAXFILE. */
|
||||
char studio_light[256];
|
||||
|
@ -166,6 +166,7 @@ typedef struct View3DShading {
|
|||
|
||||
float studiolight_rot_z;
|
||||
float studiolight_background;
|
||||
float studiolight_intensity;
|
||||
|
||||
float object_outline_color[3];
|
||||
float xray_alpha;
|
||||
|
@ -178,7 +179,6 @@ typedef struct View3DShading {
|
|||
|
||||
float curvature_ridge_factor;
|
||||
float curvature_valley_factor;
|
||||
|
||||
} View3DShading;
|
||||
|
||||
/** 3D Viewport Overlay settings. */
|
||||
|
|
|
@ -3112,9 +3112,18 @@ static void rna_def_space_view3d_shading(BlenderRNA *brna)
|
|||
RNA_def_property_clear_flag(prop, PROP_ANIMATABLE);
|
||||
RNA_def_property_update(prop, NC_SPACE | ND_SPACE_VIEW3D, NULL);
|
||||
|
||||
prop = RNA_def_property(srna, "studiolight_intensity", PROP_FLOAT, PROP_FACTOR);
|
||||
RNA_def_property_float_sdna(prop, NULL, "studiolight_intensity");
|
||||
RNA_def_property_float_default(prop, 1.0f);
|
||||
RNA_def_property_clear_flag(prop, PROP_ANIMATABLE);
|
||||
RNA_def_property_ui_text(prop, "Strength", "Strength of the studiolight");
|
||||
RNA_def_property_range(prop, 0.0f, FLT_MAX);
|
||||
RNA_def_property_ui_range(prop, 0.0f, 2.0f, 1, 3);
|
||||
RNA_def_property_update(prop, NC_SPACE | ND_SPACE_VIEW3D, NULL);
|
||||
|
||||
prop = RNA_def_property(srna, "studiolight_background_alpha", PROP_FLOAT, PROP_FACTOR);
|
||||
RNA_def_property_float_sdna(prop, NULL, "studiolight_background");
|
||||
RNA_def_property_float_default(prop, 0.0);
|
||||
RNA_def_property_float_default(prop, 0.0f);
|
||||
RNA_def_property_ui_text(prop, "Background", "Show the studiolight in the background");
|
||||
RNA_def_property_range(prop, 0.0f, 1.0f);
|
||||
RNA_def_property_ui_range(prop, 0.00f, 1.0f, 1, 3);
|
||||
|
|
Loading…
Reference in New Issue