stk-code_catmod/data/shaders/grass.frag
samuncle 14432a8689 Now the grass shader can be used with the new pipeline.
git-svn-id: svn+ssh://svn.code.sf.net/p/supertuxkart/code/main/trunk@14695 178a84e3-b1eb-0310-8ba1-8eac791a3b58
2013-12-10 01:58:22 +00:00

41 lines
1.0 KiB
GLSL
Raw Blame History

This file contains invisible Unicode characters

This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

/*--- GENERIC HEADER -----------------------------------------------------------------------------*/
varying vec3 nor;
uniform float far;
uniform float objectid;
const float near = 1.0;
vec4 encdepth(float v) {
vec4 enc = vec4(1.0, 255.0, 65025.0, 16581375.0) * v;
enc = fract(enc);
enc -= enc.yzww * vec4(1.0/255.0, 1.0/255.0, 1.0/255.0, 0.0);
return enc;
}
/*--- END OF GENERIC HEADER ----------------------------------------------------------------------*/
uniform sampler2D tex;
void main()
{
vec4 color = texture2D(tex, gl_TexCoord[0].st);
/*--- GENERIC FOOTER -----------------------------------------------------------------------------*/
float linear_z = (2.0 * near) / (far + near - gl_FragCoord.z * (far - near));
// Tune for better inside range without losing outdoors
linear_z *= 2.0;
gl_FragData[0] = color;
gl_FragData[1] = vec4(nor, linear_z);
gl_FragData[2] = vec4(encdepth(gl_FragCoord.z).xyz, objectid);
/*--- END OF GENERIC FOOTER ----------------------------------------------------------------------*/
}