-
Notifications
You must be signed in to change notification settings - Fork 113
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
21 changed files
with
799 additions
and
832 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
47 changes: 47 additions & 0 deletions
47
cont/base/springcontent/shaders/GLSL/ShadowGenVertMapProg.glsl
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
#if (GL_FRAGMENT_PRECISION_HIGH == 1) | ||
// ancient GL3 ATI drivers confuse GLSL for GLSL-ES and require this | ||
precision highp float; | ||
#else | ||
precision mediump float; | ||
#endif | ||
|
||
in vec3 vertexPos; | ||
|
||
uniform sampler2D heightMapTex; | ||
uniform float borderMinHeight; | ||
uniform ivec2 texSquare; | ||
uniform vec4 mapSize; // mapSize, 1.0/mapSize | ||
|
||
const float SMF_TEXSQR_SIZE = 1024.0; | ||
|
||
float HeightAtWorldPos(vec2 wxz){ | ||
// Some texel magic to make the heightmap tex perfectly align: | ||
const vec2 HM_TEXEL = vec2(8.0, 8.0); | ||
wxz += -HM_TEXEL * (wxz * mapSize.zw) + 0.5 * HM_TEXEL; | ||
|
||
vec2 uvhm = clamp(wxz, HM_TEXEL, mapSize.xy - HM_TEXEL); | ||
uvhm *= mapSize.zw; | ||
|
||
return textureLod(heightMapTex, uvhm, 0.0).x; | ||
} | ||
|
||
void main() { | ||
vec4 vertexWorldPos = vec4(vertexPos, 1.0); | ||
vertexWorldPos.xz += vec2(texSquare) * SMF_TEXSQR_SIZE; | ||
vertexWorldPos.y = mix(borderMinHeight, HeightAtWorldPos(vertexWorldPos.xz), float(vertexWorldPos.y == 0.0)); | ||
/* | ||
if (vertexWorldPos.y == 0.0) | ||
vertexWorldPos.y = HeightAtWorldPos(vertexWorldPos.xz); | ||
else | ||
vertexWorldPos.y = borderMinHeight; | ||
*/ | ||
vec4 lightVertexPos = gl_ModelViewMatrix * vertexWorldPos; | ||
|
||
lightVertexPos.xy += vec2(0.5); | ||
//lightVertexPos.z -= 2e-3; // glEnable(GL_POLYGON_OFFSET_FILL); is in use | ||
|
||
gl_Position = gl_ProjectionMatrix * lightVertexPos; | ||
|
||
gl_ClipVertex = vertexWorldPos; | ||
gl_TexCoord[0] = gl_MultiTexCoord0; | ||
} |
Oops, something went wrong.