Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorClément Foucault <foucault.clem@gmail.com>2018-11-28 17:57:40 +0300
committerClément Foucault <foucault.clem@gmail.com>2018-11-28 17:59:56 +0300
commit2d720f51cd786f3e0924602efb6ec89ef8ed077f (patch)
tree3b1ac1223a1c35e17e5085f99ef231273c801526 /source/blender/draw/engines/workbench/shaders/workbench_forward_transparent_accum_frag.glsl
parent52458ab49d40081466e369709d68c13a6a47663e (diff)
Workbench: Change Studio lighting
This is in order to have more flexible ligthing presets in the future. The diffuse lighting from hdris was nice but lacked the corresponding specular information. This is an attempt to make it possible to customize the lighting and have a cheap/easy/nice-looking pseudo-PBR workflow. * Add cheap PBR to Workbench with fresnel and better roughness support. This improves the look of the metallic surfaces and is easier to control. * Add ambient light to studio lights settings: just a constant color added to the shading. * Add Smooth option to studio lights settings: This option fakes the effect of making the light bigger making the lighting smoother for this light. Smoother lights gets reflected like a background hdri. * Change default light settings to include the smooth params. * Remove specular highlights from flat shading. (could be added back but how do we make it good looking?) * If specular lighting is disabled, use base color without using metallic. * Include a lot of code simplification/cleanup/confusion fix.
Diffstat (limited to 'source/blender/draw/engines/workbench/shaders/workbench_forward_transparent_accum_frag.glsl')
-rw-r--r--source/blender/draw/engines/workbench/shaders/workbench_forward_transparent_accum_frag.glsl33
1 files changed, 12 insertions, 21 deletions
diff --git a/source/blender/draw/engines/workbench/shaders/workbench_forward_transparent_accum_frag.glsl b/source/blender/draw/engines/workbench/shaders/workbench_forward_transparent_accum_frag.glsl
index 67a22073a4b..c00edb06100 100644
--- a/source/blender/draw/engines/workbench/shaders/workbench_forward_transparent_accum_frag.glsl
+++ b/source/blender/draw/engines/workbench/shaders/workbench_forward_transparent_accum_frag.glsl
@@ -4,7 +4,7 @@ uniform float ImageTransparencyCutoff = 0.1;
#endif
uniform mat4 ProjectionMatrix;
-uniform mat3 normalWorldMatrix;
+uniform mat4 ViewMatrixInverse;
uniform float alpha = 0.5;
uniform vec2 invertedViewportSize;
uniform vec4 viewvecs[3];
@@ -33,7 +33,6 @@ layout(location=1) out float revealageAccum; /* revealage actually stored in tra
void main()
{
vec4 diffuse_color;
- vec3 diffuse_light = vec3(1.0);
#ifdef V3D_SHADING_TEXTURE_COLOR
diffuse_color = texture(image, uv_interp);
@@ -51,30 +50,22 @@ void main()
vec3 nor = normalize(normal_viewport);
#endif
-#ifdef V3D_LIGHTING_MATCAP
+ /* -------- SHADING --------- */
+#ifdef V3D_LIGHTING_FLAT
+ vec3 shaded_color = diffuse_color.rgb;
+
+#elif defined(V3D_LIGHTING_MATCAP)
bool flipped = world_data.matcap_orientation != 0;
vec2 matcap_uv = matcap_uv_compute(I_vs, nor, flipped);
- diffuse_light = texture(matcapImage, matcap_uv).rgb;
-#endif
+ vec3 matcap = textureLod(matcapImage, matcap_uv, 0.0).rgb;
+ vec3 shaded_color = matcap * diffuse_color.rgb;
-#ifdef V3D_SHADING_SPECULAR_HIGHLIGHT
- vec3 specular_color = get_world_specular_lights(world_data, vec4(materialSpecularColor.rgb, materialRoughness), nor, I_vs);
-#else
- vec3 specular_color = vec3(0.0);
+#elif defined(V3D_LIGHTING_STUDIO)
+ vec3 shaded_color = get_world_lighting(world_data,
+ diffuse_color.rgb, materialSpecularColor.rgb, materialRoughness,
+ nor, I_vs);
#endif
-#ifdef V3D_LIGHTING_STUDIO
-# ifdef STUDIOLIGHT_ORIENTATION_CAMERA
- diffuse_light = get_camera_diffuse_light(world_data, nor);
-# endif
-# ifdef STUDIOLIGHT_ORIENTATION_WORLD
- vec3 normal_world = normalWorldMatrix * nor;
- diffuse_light = get_world_diffuse_light(world_data, normal_world);
-# endif
-#endif
-
- vec3 shaded_color = diffuse_light * diffuse_color.rgb + specular_color;
-
/* Based on :
* McGuire and Bavoil, Weighted Blended Order-Independent Transparency, Journal of
* Computer Graphics Techniques (JCGT), vol. 2, no. 2, 122–141, 2013