Apply deferred shading to walls
This commit is contained in:
@@ -1,9 +1,10 @@
|
|||||||
#version 430 core
|
#version 430 core
|
||||||
|
layout (location=0) out vec4 fCol;
|
||||||
|
layout (location=1) out vec4 fPos;
|
||||||
in vec4 gColor;
|
in vec4 gColor;
|
||||||
|
in vec4 gPos;
|
||||||
out vec4 fColor;
|
|
||||||
|
|
||||||
void main()
|
void main()
|
||||||
{
|
{
|
||||||
fColor = gColor;
|
fCol = gColor;
|
||||||
|
fPos = gPos;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -4,6 +4,7 @@ layout (triangle_strip, max_vertices = 4) out;
|
|||||||
layout (std140, binding = 0) uniform TheMat { mat4 theMat; } ;
|
layout (std140, binding = 0) uniform TheMat { mat4 theMat; } ;
|
||||||
in vec4 vColor [];
|
in vec4 vColor [];
|
||||||
out vec4 gColor;
|
out vec4 gColor;
|
||||||
|
out vec4 gPos;
|
||||||
// consider using isLHS to check if the wall is facing the center
|
// consider using isLHS to check if the wall is facing the center
|
||||||
// this needs the view from point
|
// this needs the view from point
|
||||||
float isLHS (vec2 startV, vec2 testV)
|
float isLHS (vec2 startV, vec2 testV)
|
||||||
@@ -14,10 +15,8 @@ float isLHS (vec2 startV, vec2 testV)
|
|||||||
void main()
|
void main()
|
||||||
{
|
{
|
||||||
gColor = vColor[0];
|
gColor = vColor[0];
|
||||||
|
|
||||||
vec4 p1 = vec4 (gl_in[0].gl_Position.xy,0,1);
|
vec4 p1 = vec4 (gl_in[0].gl_Position.xy,0,1);
|
||||||
vec4 p2 = vec4 (gl_in[0].gl_Position.zw,0,1);
|
vec4 p2 = vec4 (gl_in[0].gl_Position.zw,0,1);
|
||||||
|
|
||||||
vec4 a1 = theMat * p1;
|
vec4 a1 = theMat * p1;
|
||||||
vec4 a2 = theMat * p2;
|
vec4 a2 = theMat * p2;
|
||||||
// if (0 > isLHS (a1.xy - a2.xy, a1.xy - "viewFromPoint")) {
|
// if (0 > isLHS (a1.xy - a2.xy, a1.xy - "viewFromPoint")) {
|
||||||
@@ -25,11 +24,10 @@ void main()
|
|||||||
vec4 p4 = vec4 (p2.xy,100,1);
|
vec4 p4 = vec4 (p2.xy,100,1);
|
||||||
vec4 a3 = theMat * p3;
|
vec4 a3 = theMat * p3;
|
||||||
vec4 a4 = theMat * p4;
|
vec4 a4 = theMat * p4;
|
||||||
|
gPos = p1;gl_Position = a1; EmitVertex();
|
||||||
gl_Position = a1; EmitVertex();
|
gPos = p3;gl_Position = a3; EmitVertex();
|
||||||
gl_Position = a3; EmitVertex();
|
gPos = p2;gl_Position = a2; EmitVertex();
|
||||||
gl_Position = a2; EmitVertex();
|
gPos = p4;gl_Position = a4; EmitVertex();
|
||||||
gl_Position = a4; EmitVertex();
|
|
||||||
EndPrimitive();
|
EndPrimitive();
|
||||||
// }
|
// }
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,9 +1,12 @@
|
|||||||
#version 430 core
|
#version 430 core
|
||||||
|
layout (location=0) out vec4 fCol;
|
||||||
|
layout (location=1) out vec4 fPos;
|
||||||
in vec2 tPos;
|
in vec2 tPos;
|
||||||
|
in vec4 gPos;
|
||||||
in vec4 gColor;
|
in vec4 gColor;
|
||||||
uniform sampler2D tex;
|
uniform sampler2D tex;
|
||||||
out vec4 fColor;
|
|
||||||
void main()
|
void main()
|
||||||
{
|
{
|
||||||
fColor = gColor * texture(tex,tPos);
|
fCol = gColor * texture(tex,tPos);
|
||||||
|
fPos = gPos;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -5,6 +5,7 @@ layout (std140, binding = 0) uniform TheMat { mat4 theMat; } ;
|
|||||||
in vec4 vColor [];
|
in vec4 vColor [];
|
||||||
out vec4 gColor;
|
out vec4 gColor;
|
||||||
out vec2 tPos;
|
out vec2 tPos;
|
||||||
|
out vec4 gPos;
|
||||||
// consider using isLHS to check if the wall is facing the center
|
// consider using isLHS to check if the wall is facing the center
|
||||||
float isLHS (vec2 startV, vec2 testV)
|
float isLHS (vec2 startV, vec2 testV)
|
||||||
{ return sign( -startV.x * testV.y + startV.y * testV.x); }
|
{ return sign( -startV.x * testV.y + startV.y * testV.x); }
|
||||||
@@ -18,9 +19,9 @@ void main()
|
|||||||
vec4 a2 = theMat * p2;
|
vec4 a2 = theMat * p2;
|
||||||
vec4 a3 = theMat * p3;
|
vec4 a3 = theMat * p3;
|
||||||
vec4 a4 = theMat * p4;
|
vec4 a4 = theMat * p4;
|
||||||
tPos = vec2 ( 1,-1) ; gl_Position = a1; EmitVertex();
|
gPos = p1; tPos = vec2 ( 1,-1) ; gl_Position = a1; EmitVertex();
|
||||||
tPos = vec2 ( 1, 1) ; gl_Position = a3; EmitVertex();
|
gPos = p3; tPos = vec2 ( 1, 1) ; gl_Position = a3; EmitVertex();
|
||||||
tPos = vec2 (-1,-1) ; gl_Position = a2; EmitVertex();
|
gPos = p2; tPos = vec2 (-1,-1) ; gl_Position = a2; EmitVertex();
|
||||||
tPos = vec2 (-1, 1) ; gl_Position = a4; EmitVertex();
|
gPos = p4; tPos = vec2 (-1, 1) ; gl_Position = a4; EmitVertex();
|
||||||
EndPrimitive();
|
EndPrimitive();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -577,8 +577,8 @@ flamer = defaultAutoGun
|
|||||||
, _itUseModifiers =
|
, _itUseModifiers =
|
||||||
[ ammoUseCheckI
|
[ ammoUseCheckI
|
||||||
, withSidePushI 5
|
, withSidePushI 5
|
||||||
, withTempLight 1 100 (V3 1 0 0)
|
--, withTempLight 1 100 (V3 1 0 0)
|
||||||
--, withSidePushAfterI 20
|
, withSidePushAfterI 20
|
||||||
]
|
]
|
||||||
, _wpSpread = 0
|
, _wpSpread = 0
|
||||||
, _wpRange = 8
|
, _wpRange = 8
|
||||||
|
|||||||
Reference in New Issue
Block a user