summaryrefslogtreecommitdiff
path: root/src/renderergl2/glsl/dlight_vp.glsl
diff options
context:
space:
mode:
authorSmileTheory <SmileTheory@gmail.com>2013-12-12 21:38:01 -0800
committerTim Angus <tim@ngus.net>2014-06-17 17:43:37 +0100
commit1efa9bd0b4748ab2a8bc7b962fc7f0dce03daa8c (patch)
tree85710f4b43808b3cda5e8f1dfe44ba8f223601e1 /src/renderergl2/glsl/dlight_vp.glsl
parent22a29956b832cd1d74726b166c37c340df1a7213 (diff)
OpenGL2: Small glsl shader optimizations, fixes, and cleanup.
Diffstat (limited to 'src/renderergl2/glsl/dlight_vp.glsl')
-rw-r--r--src/renderergl2/glsl/dlight_vp.glsl16
1 files changed, 8 insertions, 8 deletions
diff --git a/src/renderergl2/glsl/dlight_vp.glsl b/src/renderergl2/glsl/dlight_vp.glsl
index 61531ad6..9566a04c 100644
--- a/src/renderergl2/glsl/dlight_vp.glsl
+++ b/src/renderergl2/glsl/dlight_vp.glsl
@@ -1,4 +1,4 @@
-attribute vec4 attr_Position;
+attribute vec3 attr_Position;
attribute vec4 attr_TexCoord0;
attribute vec3 attr_Normal;
@@ -48,7 +48,7 @@ vec3 DeformPosition(const vec3 pos, const vec3 normal, const vec2 st)
}
else if (u_DeformGen == DGEN_WAVE_SQUARE)
{
- func = sign(sin(value * 2.0 * M_PI));
+ func = sign(0.5 - fract(value));
}
else if (u_DeformGen == DGEN_WAVE_TRIANGLE)
{
@@ -62,7 +62,7 @@ vec3 DeformPosition(const vec3 pos, const vec3 normal, const vec2 st)
{
func = (1.0 - fract(value));
}
- else if (u_DeformGen == DGEN_BULGE)
+ else // if (u_DeformGen == DGEN_BULGE)
{
func = sin(value);
}
@@ -73,16 +73,16 @@ vec3 DeformPosition(const vec3 pos, const vec3 normal, const vec2 st)
void main()
{
- vec4 position = attr_Position;
- vec3 normal = attr_Normal;
+ vec3 position = attr_Position;
+ vec3 normal = attr_Normal * 2.0 - vec3(1.0);
#if defined(USE_DEFORM_VERTEXES)
- position.xyz = DeformPosition(position.xyz, normal, attr_TexCoord0.st);
+ position = DeformPosition(position, normal, attr_TexCoord0.st);
#endif
- gl_Position = u_ModelViewProjectionMatrix * position;
+ gl_Position = u_ModelViewProjectionMatrix * vec4(position, 1.0);
- vec3 dist = u_DlightInfo.xyz - position.xyz;
+ vec3 dist = u_DlightInfo.xyz - position;
var_Tex1 = dist.xy * u_DlightInfo.a + vec2(0.5);
float dlightmod = step(0.0, dot(dist, normal));