diff options
author | Clément Foucault <foucault.clem@gmail.com> | 2017-11-13 23:56:49 +0300 |
---|---|---|
committer | Clément Foucault <foucault.clem@gmail.com> | 2017-11-14 00:09:12 +0300 |
commit | ab013224adf5bb07c1467637592cd8c7bb5cb2fe (patch) | |
tree | 42a5c4e396b795f3e196e0fd67103f15c01d7aa1 /source/blender/gpu | |
parent | f4beb64020dec7729b298bd6660e19a02b89e948 (diff) |
GPUMaterial : Add sss_data to Closure struct.
Diffstat (limited to 'source/blender/gpu')
-rw-r--r-- | source/blender/gpu/shaders/gpu_shader_material.glsl | 65 |
1 files changed, 54 insertions, 11 deletions
diff --git a/source/blender/gpu/shaders/gpu_shader_material.glsl b/source/blender/gpu/shaders/gpu_shader_material.glsl index 2cf66c78db1..e829c4a0c0e 100644 --- a/source/blender/gpu/shaders/gpu_shader_material.glsl +++ b/source/blender/gpu/shaders/gpu_shader_material.glsl @@ -2672,7 +2672,11 @@ void node_bsdf_diffuse(vec4 color, float roughness, vec3 N, out Closure result) #ifdef EEVEE_ENGINE vec3 L = eevee_surface_diffuse_lit(N, vec3(1.0), 1.0); vec3 vN = normalize(mat3(ViewMatrix) * N); - result = Closure(L * color.rgb, 1.0, vec4(0.0), normal_encode(vN, viewCameraVec), -1); + result.radiance = L * color.rgb; + result.opacity = 1.0; + result.ssr_data = vec4(0.0); + result.ssr_normal = normal_encode(vN, viewCameraVec); + result.ssr_id = -1; #else /* ambient light */ vec3 L = vec3(0.2); @@ -2697,7 +2701,11 @@ void node_bsdf_glossy(vec4 color, float roughness, vec3 N, float ssr_id, out Clo roughness = sqrt(roughness); vec3 L = eevee_surface_glossy_lit(N, vec3(1.0), roughness, 1.0, int(ssr_id), ssr_spec); vec3 vN = normalize(mat3(ViewMatrix) * N); - result = Closure(L * color.rgb, 1.0, vec4(ssr_spec * color.rgb, roughness), normal_encode(vN, viewCameraVec), int(ssr_id)); + result.radiance = L * color.rgb; + result.opacity = 1.0; + result.ssr_data = vec4(ssr_spec * color.rgb, roughness); + result.ssr_normal = normal_encode(vN, viewCameraVec); + result.ssr_id = int(ssr_id); #else /* ambient light */ vec3 L = vec3(0.2); @@ -2735,7 +2743,11 @@ void node_bsdf_glass(vec4 color, float roughness, float ior, vec3 N, float ssr_i roughness = sqrt(roughness); vec3 L = eevee_surface_glass(N, (refractionDepth > 0.0) ? color.rgb : vec3(1.0), roughness, ior, int(ssr_id), ssr_spec); vec3 vN = normalize(mat3(ViewMatrix) * N); - result = Closure(L * color.rgb, 1.0, vec4(ssr_spec * color.rgb, roughness), normal_encode(vN, viewCameraVec), int(ssr_id)); + result.radiance = L * color.rgb; + result.opacity = 1.0; + result.ssr_data = vec4(ssr_spec * color.rgb, roughness); + result.ssr_normal = normal_encode(vN, viewCameraVec); + result.ssr_id = int(ssr_id); #else node_bsdf_diffuse(color, 0.0, N, result); #endif @@ -2856,7 +2868,11 @@ void node_bsdf_principled_simple(vec4 base_color, float subsurface, vec3 subsurf vec3 L = eevee_surface_lit(N, diffuse, f0, roughness, 1.0, int(ssr_id), ssr_spec); vec3 vN = normalize(mat3(ViewMatrix) * N); - result = Closure(L, 1.0, vec4(ssr_spec, roughness), normal_encode(vN, viewCameraVec), int(ssr_id)); + result.radiance = L; + result.opacity = 1.0; + result.ssr_data = vec4(ssr_spec, roughness); + result.ssr_normal = normal_encode(vN, viewCameraVec); + result.ssr_id = int(ssr_id); #else node_bsdf_principled(base_color, subsurface, subsurface_radius, subsurface_color, metallic, specular, specular_tint, roughness, anisotropic, anisotropic_rotation, sheen, sheen_tint, clearcoat, @@ -2909,7 +2925,11 @@ void node_bsdf_principled_clearcoat(vec4 base_color, float subsurface, vec3 subs vec3 L = eevee_surface_clearcoat_lit(N, diffuse, f0, roughness, CN, clearcoat, clearcoat_roughness, 1.0, int(ssr_id), ssr_spec); L = mix(L, L_trans, transmission); vec3 vN = normalize(mat3(ViewMatrix) * N); - result = Closure(L, 1.0, vec4(ssr_spec, roughness), normal_encode(vN, viewCameraVec), int(ssr_id)); + result.radiance = L; + result.opacity = 1.0; + result.ssr_data = vec4(ssr_spec, roughness); + result.ssr_normal = normal_encode(vN, viewCameraVec); + result.ssr_id = int(ssr_id); #endif #else @@ -2940,10 +2960,21 @@ void node_bsdf_velvet(vec4 color, float sigma, vec3 N, out Closure result) } void node_subsurface_scattering( - vec4 color, float scale, vec3 radius, float sharpen, float texture_blur, vec3 N, + vec4 color, float scale, vec3 radius, float sharpen, float texture_blur, vec3 N, float sss_id, out Closure result) { +#if defined(EEVEE_ENGINE) && defined(USE_SSS) + vec3 vN = normalize(mat3(ViewMatrix) * N); + result.radiance = vec3(0.0); + result.opacity = 1.0; + result.ssr_data = vec4(0.0); + result.ssr_normal = normal_encode(vN, viewCameraVec); + result.ssr_id = -1; + result.sss_data.rgb = eevee_surface_diffuse_lit(N, vec3(1.0), 1.0) * color.rgb; + result.sss_data.a = scale; +#else node_bsdf_diffuse(color, 0.0, N, result); +#endif } void node_bsdf_refraction(vec4 color, float roughness, float ior, vec3 N, out Closure result) @@ -2952,7 +2983,9 @@ void node_bsdf_refraction(vec4 color, float roughness, float ior, vec3 N, out Cl color.rgb *= (refractionDepth > 0.0) ? color.rgb : vec3(1.0); /* Simulate 2 absorption event. */ roughness = sqrt(roughness); vec3 L = eevee_surface_refraction(N, vec3(1.0), roughness, ior); - result = Closure(L * color.rgb, 1.0, vec4(0.0), vec2(0.0), REFRACT_CLOSURE_FLAG); + result.radiance = L * color.rgb; + result.opacity = 1.0; + result.ssr_id = REFRACT_CLOSURE_FLAG; #else node_bsdf_diffuse(color, 0.0, N, result); #endif /* EEVEE_ENGINE */ @@ -2980,7 +3013,11 @@ void node_emission(vec4 color, float strength, vec3 N, out Closure result) #ifndef VOLUMETRICS color *= strength; #ifdef EEVEE_ENGINE - result = Closure(color.rgb, color.a, vec4(0.0), normal_encode(N, viewCameraVec), -1); + result.radiance = color.rgb; + result.opacity = color.a; + result.ssr_data = vec4(0.0); + result.ssr_normal = normal_encode(N, viewCameraVec); + result.ssr_id = -1; #else result = Closure(color.rgb, color.a); #endif @@ -3009,7 +3046,8 @@ void node_background(vec4 color, float strength, out Closure result) #ifndef VOLUMETRICS color *= strength; #ifdef EEVEE_ENGINE - result = Closure(color.rgb, color.a, vec4(0.0), vec2(0.0), -1); + result.radiance = color.rgb; + result.opacity = color.a; #else result = Closure(color.rgb, color.a); #endif @@ -4115,7 +4153,8 @@ void node_output_world(Closure surface, Closure volume, out Closure result) { #ifndef VOLUMETRICS #ifdef EEVEE_ENGINE - result = Closure(surface.radiance, backgroundAlpha, vec4(0.0), vec2(0.0), -1); + result.radiance = surface.radiance; + result.opacity = backgroundAlpha; #else result = Closure(surface.radiance, backgroundAlpha); #endif @@ -4142,7 +4181,11 @@ void node_eevee_specular( vec3 L = eevee_surface_lit(normal, diffuse.rgb, specular.rgb, roughness, occlusion, int(ssr_id), ssr_spec); vec3 vN = normalize(mat3(ViewMatrix) * normal); - result = Closure(L + emissive.rgb, 1.0 - transp, vec4(ssr_spec, roughness), normal_encode(vN, viewCameraVec), int(ssr_id)); + result.radiance = L + emissive.rgb; + result.opacity = 1.0 - transp; + result.ssr_data = vec4(ssr_spec, roughness); + result.ssr_normal = normal_encode(vN, viewCameraVec); + result.ssr_id = int(ssr_id); } #endif /* EEVEE_ENGINE */ |