diff options
| author | Simon Robertshaw <simon@hardwired.org.uk> | 2011-10-22 18:24:32 (GMT) |
|---|---|---|
| committer | Simon Robertshaw <simon@hardwired.org.uk> | 2011-10-22 18:24:32 (GMT) |
| commit | 014c1fbad669b0cf1abd881e696f0c7e432b3707 (patch) | |
| tree | 049005945e5e63aad3a5d856e24058f5152fa9a9 /includes | |
| parent | ba59ba8b7c9fc12ba9ff349c1d35d73fbfc54624 (diff) | |
| download | powder-014c1fbad669b0cf1abd881e696f0c7e432b3707.zip powder-014c1fbad669b0cf1abd881e696f0c7e432b3707.tar.gz | |
Embed shaders
Diffstat (limited to 'includes')
| -rw-r--r-- | includes/graphics.h | 44 |
1 files changed, 42 insertions, 2 deletions
diff --git a/includes/graphics.h b/includes/graphics.h index a570396..962a04e 100644 --- a/includes/graphics.h +++ b/includes/graphics.h @@ -193,14 +193,54 @@ void ogl_blit(int x, int y, int w, int h, pixel *src, int pitch, int scale); #endif #ifdef INCLUDE_SHADERS -const char * fragment = "uniform sampler2D fireAlpha;\ +const char * fireFragment = "uniform sampler2D fireAlpha;\ void main () {\ vec4 texColor = texture2D(fireAlpha, gl_PointCoord);\ gl_FragColor = vec4(gl_Color.rgb, texColor.a*gl_Color.a);\ }"; -const char * vertex = "void main(void)\ +const char * fireVertex = "void main(void)\ {\ gl_Position = ftransform();;\ gl_FrontColor = gl_Color;\ }"; +const char * lensFragment = "uniform sampler2D pTex;\ +uniform sampler2D tfX;\ +uniform sampler2D tfY;\ +uniform float xres = 612.0;\ +uniform float yres = 384.0;\ +void main () {\ + vec4 transformX = texture2D(tfX, vec2(gl_TexCoord[0].s, -gl_TexCoord[0].t));\ + vec4 transformY = -texture2D(tfY, vec2(gl_TexCoord[0].s, -gl_TexCoord[0].t));\ + transformX.r /= xres;\ + transformY.g /= yres;\ + vec4 texColor = vec4(\ + texture2D(pTex, gl_TexCoord[0].st-vec2(transformX.r*0.75, transformY.g*0.75)).r,\ + texture2D(pTex, gl_TexCoord[0].st-vec2(transformX.r*0.875, transformY.g*0.875)).g,\ + texture2D(pTex, gl_TexCoord[0].st-vec2(transformX.r, transformY.g)).b,\ + 1.0\ + );\ + gl_FragColor = texColor;\ +}"; +const char * lensVertex = "void main(void)\ +{\ + gl_TexCoord[0] = gl_MultiTexCoord0;\ + gl_Position = ftransform();;\ + gl_FrontColor = gl_Color;\ +}"; +const char * airFragment = "uniform sampler2D airX;\ +uniform sampler2D airY;\ +uniform sampler2D airP;\ +void main () {\ + vec4 texX = texture2D(airX, gl_TexCoord[0].st);\ + vec4 texY = texture2D(airY, gl_TexCoord[0].st);\ + vec4 texP = texture2D(airP, gl_TexCoord[0].st);\ + gl_FragColor = vec4(abs(texX.r)/2.0, texP.b/2.0, abs(texY.g)/2.0, 1.0);\ +}"; +const char * airVertex = "void main(void)\ +{\ + gl_TexCoord[0] = gl_MultiTexCoord0;\ + gl_Position = ftransform();;\ + gl_FrontColor = gl_Color;\ +}"; + #endif |
