added point light shadow generation shaders
This commit is contained in:
parent
1cca1287ee
commit
44efb383a9
@ -5,11 +5,23 @@ in vec2 varTexCoord;
|
||||
|
||||
out float fragmentdepth;
|
||||
|
||||
#ifdef POINT_LIGHT
|
||||
in vec4 FragPos;
|
||||
|
||||
uniform vec3 pointLight;
|
||||
uniform float far_plane;
|
||||
#endif
|
||||
|
||||
void main()
|
||||
{
|
||||
#ifdef ALPHA_MASK
|
||||
if(texture(alphaMask, varTexCoord).r < 0.5)
|
||||
discard;
|
||||
#endif
|
||||
|
||||
#ifdef POINT_LIGHT
|
||||
fragmentdepth = length(FragPos.xyz - pointLight)/far_plane;
|
||||
#else
|
||||
fragmentdepth = gl_FragCoord.z;
|
||||
#endif
|
||||
}
|
||||
|
@ -1,16 +1,14 @@
|
||||
layout(triangles) in;
|
||||
|
||||
#ifdef POINT_LIGHT
|
||||
|
||||
// inspired from
|
||||
// http://learnopengl.com/#!Advanced-Lighting/Shadows/Point-Shadows
|
||||
|
||||
layout(triangles) in;
|
||||
layout(triangle_strip, max_vertices = 18) out;
|
||||
|
||||
#ifdef POINT_LIGHT
|
||||
uniform mat4 MVP[6];
|
||||
#elif defined CASCADED
|
||||
uniform mat4 frontShadowMVP;
|
||||
uniform mat4 midShadowMVP;
|
||||
uniform mat4 backShadowMVP;
|
||||
#endif
|
||||
uniform mat4 projectionMatrix;
|
||||
uniform mat4 viewMatrices[6];
|
||||
|
||||
out vec4 FragPos;
|
||||
|
||||
@ -19,13 +17,28 @@ flat out int fcolor_idx;
|
||||
|
||||
void main(void){
|
||||
for (int layerId = 0; layerId < 6; ++layerId){
|
||||
mat4 MVP = projectionMatrix * viewMatrices[layerId];
|
||||
for (int i = 0; i < gl_in.length(); ++i){
|
||||
gl_Layer = layerId;
|
||||
fcolor_idx = layerId;
|
||||
FragPos = gl_in[i].gl_Position;
|
||||
gl_Position = MVP[layerId] * FragPos;
|
||||
gl_Position = MVP * FragPos;
|
||||
EmitVertex();
|
||||
}
|
||||
EndPrimitive();
|
||||
}
|
||||
}
|
||||
|
||||
#elif defined CASCADED
|
||||
|
||||
layout(triangle_strip, max_vertices = 9) out;
|
||||
|
||||
uniform mat4 frontShadowMVP;
|
||||
uniform mat4 midShadowMVP;
|
||||
uniform mat4 backShadowMVP;
|
||||
|
||||
// TODO
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user