diff options
author | Clément Foucault <foucault.clem@gmail.com> | 2018-05-14 14:34:54 +0300 |
---|---|---|
committer | Clément Foucault <foucault.clem@gmail.com> | 2018-05-16 17:58:32 +0300 |
commit | f1a5fd90bad851ccb9eef7bc59c3a8ebe39fe8b8 (patch) | |
tree | 0da7498d7479e534d08a60a0de68ffc552efc587 /source/blender/gpu | |
parent | e862bcd6c8cb218c2213ac4a05a11dd13dbdecbf (diff) |
Shader Node Editor: Add Closure to RGB convertion node.
Patch D3205 by Kanzaki Wataru
Only implemented in Eevee for now. Collapse a closure to RGBA so we can
do NPR stuff on the resulting color.
Use an emission shader to convert the color back to a closure.
Doing this will break PBR and will kill any SSR and SSS effects the shader
the shader rely on. That said screen space refraction and ambient occlusion
are supported due to the way they are implemented.
Diffstat (limited to 'source/blender/gpu')
-rw-r--r-- | source/blender/gpu/shaders/gpu_shader_material.glsl | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/source/blender/gpu/shaders/gpu_shader_material.glsl b/source/blender/gpu/shaders/gpu_shader_material.glsl index 45701f090fa..236eddbb63f 100644 --- a/source/blender/gpu/shaders/gpu_shader_material.glsl +++ b/source/blender/gpu/shaders/gpu_shader_material.glsl @@ -2544,4 +2544,28 @@ void node_eevee_specular( result.ssr_id = int(ssr_id); } +void node_shadertorgb(Closure cl, out vec4 outcol, out float outalpha) +{ + vec4 spec_accum = vec4(0.0); + if (ssrToggle && cl.ssr_id == outputSsrId) { + vec3 V = cameraVec; + vec3 vN = normal_decode(cl.ssr_normal, viewCameraVec); + vec3 N = transform_direction(ViewMatrixInverse, vN); + float roughness = cl.ssr_data.a; + float roughnessSquared = max(1e-3, roughness * roughness); + fallback_cubemap(N, V, worldPosition, viewPosition, roughness, roughnessSquared, spec_accum); + } + + outalpha = cl.opacity; + outcol = vec4((spec_accum.rgb * cl.ssr_data.rgb) + cl.radiance, 1.0); + +# ifdef USE_SSS +# ifdef USE_SSS_ALBEDO + outcol += (cl.sss_data * cl.sss_albedo); +# else + outcol += cl.sss_data; +# endif +# endif +} + #endif /* VOLUMETRICS */ |