Differential D6206 Diff 19465 source/blender/draw/engines/eevee/shaders/renderpass_postprocess_frag.glsl
Changeset View
Changeset View
Standalone View
Standalone View
source/blender/draw/engines/eevee/shaders/renderpass_postprocess_frag.glsl
- This file was added.
| #define SCE_PASS_Z (1 << 1) | |||||
| #define SCE_PASS_AO (1 << 6) | |||||
jbakker: remove line, is an unused define | |||||
| #define SCE_PASS_NORMAL (1 << 8) | |||||
| #define SCE_PASS_MIST (1 << 14) | |||||
| #define SCE_PASS_SUBSURFACE_DIRECT (1 << 28) | |||||
| #define SCE_PASS_SUBSURFACE_COLOR (1 << 30) | |||||
| #define ACCUMULATED_COLOR_PASSES (SCE_PASS_SUBSURFACE_DIRECT | SCE_PASS_SUBSURFACE_COLOR) | |||||
| #define ACCUMULATED_VALUE_PASSES (SCE_PASS_MIST) | |||||
| uniform int renderpassType; | |||||
| uniform int currentSample; | |||||
| uniform sampler2D inputBuffer; | |||||
| out vec4 fragColor; | |||||
| bool view_is_persp_get() | |||||
| { | |||||
| return ProjectionMatrix[3][3] == 0.0; | |||||
| } | |||||
| void main() | |||||
| { | |||||
| ivec2 texel = ivec2(gl_FragCoord.xy); | |||||
| if (renderpassType == SCE_PASS_Z) { | |||||
| float depth = texelFetch(depthBuffer, texel, 0).r; | |||||
| if (depth == 1.0f) { | |||||
| depth = 1e10; | |||||
| } | |||||
| else { | |||||
| if (view_is_persp_get()) { | |||||
fclemUnsubmitted Done Inline Actionswe have a function in bsdf_common.lib for converting to view depth fclem: we have a function in bsdf_common.lib for converting to view depth | |||||
| depth = ProjectionMatrix[3][2] / ((depth * 2.0 - 1.0) + ProjectionMatrix[2][2]); | |||||
| } | |||||
| else { | |||||
| depth = -viewVecs[0][2] + depth * viewVecs[1][2]; | |||||
| } | |||||
| } | |||||
| fragColor.r = depth; | |||||
| } | |||||
| else if (renderpassType == SCE_PASS_AO) { | |||||
Done Inline Actionsany(notEqual()) jbakker: any(notEqual()) | |||||
| float ao_accum = texelFetch(inputBuffer, texel, 0).r; | |||||
| fragColor = vec4(vec3(min(1.0, ao_accum / currentSample)), 1.0); | |||||
| } | |||||
| else if (renderpassType == SCE_PASS_NORMAL) { | |||||
| vec2 encoded_normal = texelFetch(inputBuffer, texel, 0).rg; | |||||
| /* decode the normals only when they are valid. otherwise the result buffer will be filled with | |||||
| * NaN's */ | |||||
| if (encoded_normal != vec2(0.0)) { | |||||
| vec3 decoded_normal = normal_decode(texelFetch(inputBuffer, texel, 0).rg, vec3(0.0)); | |||||
| vec3 world_normal = mat3(ViewMatrixInverse) * decoded_normal; | |||||
| fragColor = vec4(world_normal, 0.0); | |||||
| } | |||||
| else { | |||||
| fragColor = vec4(0.0); | |||||
| } | |||||
| } | |||||
| else if ((renderpassType & ACCUMULATED_VALUE_PASSES) != 0) { | |||||
| float accumulated_value = texelFetch(inputBuffer, texel, 0).r; | |||||
| fragColor.r = accumulated_value / currentSample; | |||||
| } | |||||
| else if ((renderpassType & ACCUMULATED_COLOR_PASSES) != 0) { | |||||
| vec3 accumulated_color = texelFetch(inputBuffer, texel, 0).rgb; | |||||
| fragColor.rgb = accumulated_color / currentSample; | |||||
| } | |||||
| else { | |||||
| fragColor = vec4(1.0, 0.0, 1.0, 1.0); | |||||
| } | |||||
| } | |||||
| No newline at end of file | |||||
remove line, is an unused define