We have a limited number of interpolants, and 2 were used for spotlights, but this is a fairly uncommon case, so we move the calculation to the fragment shader. A side effect of this is that we are not limited to two spot-light anymore from the shader's point of view. This essentially adds a vector transform per fragment, but on the other hand, it removes communication between the vertex and fragment shader, as well as interpolation of the position.
31 lines
1.0 KiB
GLSL
31 lines
1.0 KiB
GLSL
//------------------------------------------------------------------------------
|
|
// Attributes and uniforms
|
|
//------------------------------------------------------------------------------
|
|
|
|
LAYOUT_LOCATION(4) in highp vec3 vertex_worldPosition;
|
|
|
|
#if defined(HAS_ATTRIBUTE_TANGENTS)
|
|
LAYOUT_LOCATION(5) SHADING_INTERPOLATION in mediump vec3 vertex_worldNormal;
|
|
#if defined(MATERIAL_NEEDS_TBN)
|
|
LAYOUT_LOCATION(6) SHADING_INTERPOLATION in mediump vec4 vertex_worldTangent;
|
|
#endif
|
|
#endif
|
|
|
|
LAYOUT_LOCATION(7) in highp vec4 vertex_position;
|
|
|
|
#if defined(HAS_ATTRIBUTE_COLOR)
|
|
LAYOUT_LOCATION(9) in mediump vec4 vertex_color;
|
|
#endif
|
|
|
|
#if defined(HAS_ATTRIBUTE_UV0) && !defined(HAS_ATTRIBUTE_UV1)
|
|
LAYOUT_LOCATION(10) in highp vec2 vertex_uv01;
|
|
#elif defined(HAS_ATTRIBUTE_UV1)
|
|
LAYOUT_LOCATION(10) in highp vec4 vertex_uv01;
|
|
#endif
|
|
|
|
#if defined(HAS_SHADOWING) && defined(HAS_DIRECTIONAL_LIGHTING)
|
|
LAYOUT_LOCATION(11) in highp vec4 vertex_lightSpacePosition;
|
|
#endif
|
|
|
|
// Note that fragColor is an output and is not declared here; see main.fs and depth_main.fs
|