source: java/client_3D/static/shared/res/shaders/old_fur.glsl @ 65

Last change on this file since 65 was 65, checked in by Maciej Komosinski, 13 years ago

added sources of the 3D client for the Framsticks server

File size: 999 bytes
Line 
1//name fur
2//vert
3uniform float scale;
4varying vec3 ecPos;
5varying vec3 ecNormal;                 
6void main()
7{       
8        vec4 vert = gl_Vertex + vec4(gl_Normal.x*scale, gl_Normal.y*scale, gl_Normal.z*scale, 0);
9        gl_Position = gl_ProjectionMatrix * gl_ModelViewMatrix * vert;
10        gl_TexCoord[0].st = gl_MultiTexCoord0.ts;
11        gl_TexCoord[0].st *= 0.25;
12        ecNormal = gl_NormalMatrix * gl_Normal;
13        vec4 ecPos4 = gl_ModelViewMatrix * gl_Vertex;
14        ecPos = ecPos4.xyz/ecPos4.w;
15}
16
17//frag
18uniform sampler2D diffuseMap;
19uniform sampler2D furMap;
20varying vec3 ecPos;
21varying vec3 ecNormal;
22vec3 ecEye;
23vec3 ecLight;
24
25float diffuse(int lightId)
26{
27        ecLight = gl_LightSource[lightId].position.xyz - ecPos;
28        return max(0.2, dot(normalize(ecNormal), normalize(ecLight)));
29}
30
31void main()
32{                                       
33        ecEye = normalize(-ecPos);     
34        vec3 alpha = texture2D(furMap, vec2(gl_TexCoord[0].s * 2.0, gl_TexCoord[0].t * 2.0)).xyz;
35        if (alpha.r + alpha.g + alpha.b < 1.5) discard;                 
36        gl_FragColor = diffuse(0) * texture2D(diffuseMap, gl_TexCoord[0].st);;
37}
38
Note: See TracBrowser for help on using the repository browser.