mirror of
https://github.com/luanti-org/luanti.git
synced 2025-10-20 11:35:21 +02:00
Port shadow shaders to work with OpenGL3
Co-authored-by: sfan5 <sfan5@live.de>
This commit is contained in:
@@ -1,9 +1,15 @@
|
||||
uniform sampler2D ColorMapSampler;
|
||||
varying vec4 tPos;
|
||||
|
||||
#ifdef GL_ES
|
||||
varying mediump vec2 varTexCoord;
|
||||
#else
|
||||
centroid varying vec2 varTexCoord;
|
||||
#endif
|
||||
|
||||
void main()
|
||||
{
|
||||
vec4 col = texture2D(ColorMapSampler, gl_TexCoord[0].st);
|
||||
vec4 col = texture2D(ColorMapSampler, varTexCoord);
|
||||
|
||||
if (col.a < 0.70)
|
||||
discard;
|
@@ -6,6 +6,12 @@ uniform float xyPerspectiveBias0;
|
||||
uniform float xyPerspectiveBias1;
|
||||
uniform float zPerspectiveBias;
|
||||
|
||||
#ifdef GL_ES
|
||||
varying mediump vec2 varTexCoord;
|
||||
#else
|
||||
centroid varying vec2 varTexCoord;
|
||||
#endif
|
||||
|
||||
vec4 getRelativePosition(in vec4 position)
|
||||
{
|
||||
vec2 l = position.xy - CameraPos.xy;
|
||||
@@ -34,10 +40,10 @@ vec4 applyPerspectiveDistortion(in vec4 position)
|
||||
|
||||
void main()
|
||||
{
|
||||
vec4 pos = LightMVP * gl_Vertex;
|
||||
vec4 pos = LightMVP * inVertexPosition;
|
||||
|
||||
tPos = applyPerspectiveDistortion(pos);
|
||||
|
||||
gl_Position = vec4(tPos.xyz, 1.0);
|
||||
gl_TexCoord[0] = gl_TextureMatrix[0] * gl_MultiTexCoord0;
|
||||
varTexCoord = (mTexture * vec4(inTexCoord0.xy, 0.0, 1.0)).xy;
|
||||
}
|
@@ -1,6 +1,12 @@
|
||||
uniform sampler2D ColorMapSampler;
|
||||
varying vec4 tPos;
|
||||
|
||||
#ifdef GL_ES
|
||||
varying mediump vec2 varTexCoord;
|
||||
#else
|
||||
centroid varying vec2 varTexCoord;
|
||||
#endif
|
||||
|
||||
#ifdef COLORED_SHADOWS
|
||||
varying vec3 varColor;
|
||||
|
||||
@@ -20,7 +26,7 @@ const vec3 black = vec3(0.0);
|
||||
|
||||
void main()
|
||||
{
|
||||
vec4 col = texture2D(ColorMapSampler, gl_TexCoord[0].st);
|
||||
vec4 col = texture2D(ColorMapSampler, varTexCoord);
|
||||
#ifndef COLORED_SHADOWS
|
||||
if (col.a < 0.5)
|
||||
discard;
|
@@ -9,6 +9,12 @@ uniform float xyPerspectiveBias0;
|
||||
uniform float xyPerspectiveBias1;
|
||||
uniform float zPerspectiveBias;
|
||||
|
||||
#ifdef GL_ES
|
||||
varying mediump vec2 varTexCoord;
|
||||
#else
|
||||
centroid varying vec2 varTexCoord;
|
||||
#endif
|
||||
|
||||
vec4 getRelativePosition(in vec4 position)
|
||||
{
|
||||
vec2 l = position.xy - CameraPos.xy;
|
||||
@@ -37,14 +43,14 @@ vec4 applyPerspectiveDistortion(in vec4 position)
|
||||
|
||||
void main()
|
||||
{
|
||||
vec4 pos = LightMVP * gl_Vertex;
|
||||
vec4 pos = LightMVP * inVertexPosition;
|
||||
|
||||
tPos = applyPerspectiveDistortion(LightMVP * gl_Vertex);
|
||||
tPos = applyPerspectiveDistortion(pos);
|
||||
|
||||
gl_Position = vec4(tPos.xyz, 1.0);
|
||||
gl_TexCoord[0].st = gl_MultiTexCoord0.st;
|
||||
varTexCoord = inTexCoord0.xy;
|
||||
|
||||
#ifdef COLORED_SHADOWS
|
||||
varColor = gl_Color.rgb;
|
||||
varColor = inVertexColor.rgb;
|
||||
#endif
|
||||
}
|
@@ -4,20 +4,25 @@ uniform sampler2D ShadowMapClientMapTraslucent;
|
||||
#endif
|
||||
uniform sampler2D ShadowMapSamplerdynamic;
|
||||
|
||||
void main() {
|
||||
#ifdef GL_ES
|
||||
varying mediump vec2 varTexCoord;
|
||||
#else
|
||||
centroid varying vec2 varTexCoord;
|
||||
#endif
|
||||
|
||||
void main()
|
||||
{
|
||||
#ifdef COLORED_SHADOWS
|
||||
vec2 first_depth = texture2D(ShadowMapClientMap, gl_TexCoord[0].st).rg;
|
||||
vec2 depth_splitdynamics = vec2(texture2D(ShadowMapSamplerdynamic, gl_TexCoord[2].st).r, 0.0);
|
||||
vec2 first_depth = texture2D(ShadowMapClientMap, varTexCoord).rg;
|
||||
vec2 depth_splitdynamics = vec2(texture2D(ShadowMapSamplerdynamic, varTexCoord).r, 0.0);
|
||||
if (first_depth.r > depth_splitdynamics.r)
|
||||
first_depth = depth_splitdynamics;
|
||||
vec2 depth_color = texture2D(ShadowMapClientMapTraslucent, gl_TexCoord[1].st).rg;
|
||||
vec2 depth_color = texture2D(ShadowMapClientMapTraslucent, varTexCoord).rg;
|
||||
gl_FragColor = vec4(first_depth.r, first_depth.g, depth_color.r, depth_color.g);
|
||||
#else
|
||||
float first_depth = texture2D(ShadowMapClientMap, gl_TexCoord[0].st).r;
|
||||
float depth_splitdynamics = texture2D(ShadowMapSamplerdynamic, gl_TexCoord[2].st).r;
|
||||
float first_depth = texture2D(ShadowMapClientMap, varTexCoord).r;
|
||||
float depth_splitdynamics = texture2D(ShadowMapSamplerdynamic, varTexCoord).r;
|
||||
first_depth = min(first_depth, depth_splitdynamics);
|
||||
gl_FragColor = vec4(first_depth, 0.0, 0.0, 1.0);
|
||||
#endif
|
||||
|
||||
}
|
12
client/shaders/shadow/pass2/opengl_vertex.glsl
Normal file
12
client/shaders/shadow/pass2/opengl_vertex.glsl
Normal file
@@ -0,0 +1,12 @@
|
||||
#ifdef GL_ES
|
||||
varying mediump vec2 varTexCoord;
|
||||
#else
|
||||
centroid varying vec2 varTexCoord;
|
||||
#endif
|
||||
|
||||
void main()
|
||||
{
|
||||
vec4 uv = vec4(inVertexPosition.xyz, 1.0) * 0.5 + 0.5;
|
||||
varTexCoord = uv.st;
|
||||
gl_Position = vec4(inVertexPosition.xyz, 1.0);
|
||||
}
|
@@ -1,9 +0,0 @@
|
||||
|
||||
void main()
|
||||
{
|
||||
vec4 uv = vec4(gl_Vertex.xyz, 1.0) * 0.5 + 0.5;
|
||||
gl_TexCoord[0] = uv;
|
||||
gl_TexCoord[1] = uv;
|
||||
gl_TexCoord[2] = uv;
|
||||
gl_Position = vec4(gl_Vertex.xyz, 1.0);
|
||||
}
|
Reference in New Issue
Block a user