Differential D13910 Diff 47467 source/blender/draw/engines/workbench/shaders/workbench_shadow_caps_geom.glsl
Changeset View
Changeset View
Standalone View
Standalone View
source/blender/draw/engines/workbench/shaders/workbench_shadow_caps_geom.glsl
| #ifdef GPU_ARB_gpu_shader5 | #ifdef GPU_ARB_gpu_shader5 | ||||
| # define USE_INVOC_EXT | # define USE_INVOC_EXT | ||||
| #endif | #endif | ||||
| #ifdef DOUBLE_MANIFOLD | |||||
| # ifdef USE_INVOC_EXT | |||||
| # define invoc_len 2 | |||||
| # else | |||||
| # define vert_len 6 | |||||
| # endif | |||||
| #else | |||||
| # ifdef USE_INVOC_EXT | |||||
| # define invoc_len 2 | |||||
| # else | |||||
| # define vert_len 6 | |||||
| # endif | |||||
| #endif | |||||
| #ifdef USE_INVOC_EXT | |||||
| layout(triangles, invocations = invoc_len) in; | |||||
| layout(triangle_strip, max_vertices = 3) out; | |||||
| #else | |||||
| layout(triangles) in; | |||||
| layout(triangle_strip, max_vertices = vert_len) out; | |||||
| #endif | |||||
| uniform vec3 lightDirection = vec3(0.57, 0.57, -0.57); | |||||
| in VertexData | |||||
| { | |||||
| vec3 pos; /* local position */ | |||||
| vec4 frontPosition; /* final ndc position */ | |||||
| vec4 backPosition; | |||||
| } | |||||
| vData[]; | |||||
| vec4 get_pos(int v, bool backface) | vec4 get_pos(int v, bool backface) | ||||
| { | { | ||||
| return (backface) ? vData[v].backPosition : vData[v].frontPosition; | return (backface) ? vData[v].backPosition : vData[v].frontPosition; | ||||
| } | } | ||||
| void emit_cap(const bool front, bool reversed) | void emit_cap(const bool front, bool reversed) | ||||
| { | { | ||||
| if (front) { | if (front) { | ||||
| Show All 24 Lines | void main() | ||||
| float facing = dot(n, lightDirection); | float facing = dot(n, lightDirection); | ||||
| bool backface = facing > 0.0; | bool backface = facing > 0.0; | ||||
| #ifdef DOUBLE_MANIFOLD | #ifdef DOUBLE_MANIFOLD | ||||
| /* In case of non manifold geom, we only increase/decrease | /* In case of non manifold geom, we only increase/decrease | ||||
| * the stencil buffer by one but do every faces as they were facing the light. */ | * the stencil buffer by one but do every faces as they were facing the light. */ | ||||
| bool invert = backface; | bool invert = backface; | ||||
| const bool is_manifold = false; | |||||
| #else | #else | ||||
| const bool invert = false; | const bool invert = false; | ||||
| if (!backface) { | const bool is_manifold = true; | ||||
| #endif | #endif | ||||
| if (!is_manifold || !backface) { | |||||
| #ifdef USE_INVOC_EXT | #ifdef USE_INVOC_EXT | ||||
| bool do_front = (gl_InvocationID & 1) == 0; | bool do_front = (gl_InvocationID & 1) == 0; | ||||
| emit_cap(do_front, invert); | emit_cap(do_front, invert); | ||||
| #else | #else | ||||
| emit_cap(true, invert); | emit_cap(true, invert); | ||||
| emit_cap(false, invert); | emit_cap(false, invert); | ||||
| #endif | #endif | ||||
| #ifndef DOUBLE_MANIFOLD | |||||
| } | } | ||||
| #endif | |||||
| } | } | ||||