source: trunk/tests/planet_test/planet.frag @ 324

Last change on this file since 324 was 324, checked in by epyon, 11 years ago
  • planet test added (will be expanded later)
File size: 15.7 KB
RevLine 
[324]1#version 120
2
3//uniform sampler2D nv_t_diffuse;
4uniform vec4 light_diffuse;
5uniform vec4 light_specular;
6
7//varying vec2 v_texcoord;
8//varying vec3 v_normal;
9//varying vec3 v_light_vector;
10//varying vec3 v_view_vector;
11varying vec3 v_world_pos;
12varying vec3 v_camera_loc;
13varying vec3 v_light_loc;
14uniform vec3 center;
15uniform float radius;
16uniform mat4 nv_m_mvp;
17
18vec3 mod289(vec3 x) {
19  return x - floor(x * (1.0 / 289.0)) * 289.0;
20}
21
22vec4 mod289(vec4 x) {
23  return x - floor(x * (1.0 / 289.0)) * 289.0;
24}
25
26vec4 permute(vec4 x) {
27     return mod289(((x*34.0)+1.0)*x);
28}
29
30vec4 taylorInvSqrt(vec4 r)
31{
32  return 1.79284291400159 - 0.85373472095314 * r;
33}
34
35#define jitter 1.0 // smaller jitter gives more regular pattern
36
37float snoise(vec3 v)
38  {
39  const vec2  C = vec2(1.0/6.0, 1.0/3.0) ;
40  const vec4  D = vec4(0.0, 0.5, 1.0, 2.0);
41
42// First corner
43  vec3 i  = floor(v + dot(v, C.yyy) );
44  vec3 x0 =   v - i + dot(i, C.xxx) ;
45
46// Other corners
47  vec3 g = step(x0.yzx, x0.xyz);
48  vec3 l = 1.0 - g;
49  vec3 i1 = min( g.xyz, l.zxy );
50  vec3 i2 = max( g.xyz, l.zxy );
51
52  //   x0 = x0 - 0.0 + 0.0 * C.xxx;
53  //   x1 = x0 - i1  + 1.0 * C.xxx;
54  //   x2 = x0 - i2  + 2.0 * C.xxx;
55  //   x3 = x0 - 1.0 + 3.0 * C.xxx;
56  vec3 x1 = x0 - i1 + C.xxx;
57  vec3 x2 = x0 - i2 + C.yyy; // 2.0*C.x = 1/3 = C.y
58  vec3 x3 = x0 - D.yyy;      // -1.0+3.0*C.x = -0.5 = -D.y
59
60// Permutations
61  i = mod289(i);
62  vec4 p = permute( permute( permute(
63             i.z + vec4(0.0, i1.z, i2.z, 1.0 ))
64           + i.y + vec4(0.0, i1.y, i2.y, 1.0 ))
65           + i.x + vec4(0.0, i1.x, i2.x, 1.0 ));
66
67// Gradients: 7x7 points over a square, mapped onto an octahedron.
68// The ring size 17*17 = 289 is close to a multiple of 49 (49*6 = 294)
69  float n_ = 0.142857142857; // 1.0/7.0
70  vec3  ns = n_ * D.wyz - D.xzx;
71
72  vec4 j = p - 49.0 * floor(p * ns.z * ns.z);  //  mod(p,7*7)
73
74  vec4 x_ = floor(j * ns.z);
75  vec4 y_ = floor(j - 7.0 * x_ );    // mod(j,N)
76
77  vec4 x = x_ *ns.x + ns.yyyy;
78  vec4 y = y_ *ns.x + ns.yyyy;
79  vec4 h = 1.0 - abs(x) - abs(y);
80
81  vec4 b0 = vec4( x.xy, y.xy );
82  vec4 b1 = vec4( x.zw, y.zw );
83
84  //vec4 s0 = vec4(lessThan(b0,0.0))*2.0 - 1.0;
85  //vec4 s1 = vec4(lessThan(b1,0.0))*2.0 - 1.0;
86  vec4 s0 = floor(b0)*2.0 + 1.0;
87  vec4 s1 = floor(b1)*2.0 + 1.0;
88  vec4 sh = -step(h, vec4(0.0));
89
90  vec4 a0 = b0.xzyw + s0.xzyw*sh.xxyy ;
91  vec4 a1 = b1.xzyw + s1.xzyw*sh.zzww ;
92
93  vec3 p0 = vec3(a0.xy,h.x);
94  vec3 p1 = vec3(a0.zw,h.y);
95  vec3 p2 = vec3(a1.xy,h.z);
96  vec3 p3 = vec3(a1.zw,h.w);
97
98//Normalise gradients
99  vec4 norm = taylorInvSqrt(vec4(dot(p0,p0), dot(p1,p1), dot(p2, p2), dot(p3,p3)));
100  p0 *= norm.x;
101  p1 *= norm.y;
102  p2 *= norm.z;
103  p3 *= norm.w;
104
105// Mix final noise value
106  vec4 m = max(0.6 - vec4(dot(x0,x0), dot(x1,x1), dot(x2,x2), dot(x3,x3)), 0.0);
107  m = m * m;
108  return 42.0 * dot( m*m, vec4( dot(p0,x0), dot(p1,x1),
109                                dot(p2,x2), dot(p3,x3) ) );
110}
111
112// Permutation polynomial: (34x^2 + x) mod 289
113vec3 permute(vec3 x) {
114  return mod((34.0 * x + 1.0) * x, 289.0);
115}
116
117#define jitter2x2x2 0.8 // smaller jitter gives less errors in F2
118
119vec2 cellular(vec3 P) {
120#define K 0.142857142857 // 1/7
121#define Ko 0.428571428571 // 1/2-K/2
122#define K2 0.020408163265306 // 1/(7*7)
123#define Kz 0.166666666667 // 1/6
124#define Kzo 0.416666666667 // 1/2-1/6*2
125
126        vec3 Pi = mod(floor(P), 289.0);
127        vec3 Pf = fract(P) - 0.5;
128
129        vec3 Pfx = Pf.x + vec3(1.0, 0.0, -1.0);
130        vec3 Pfy = Pf.y + vec3(1.0, 0.0, -1.0);
131        vec3 Pfz = Pf.z + vec3(1.0, 0.0, -1.0);
132
133        vec3 p = permute(Pi.x + vec3(-1.0, 0.0, 1.0));
134        vec3 p1 = permute(p + Pi.y - 1.0);
135        vec3 p2 = permute(p + Pi.y);
136        vec3 p3 = permute(p + Pi.y + 1.0);
137
138        vec3 p11 = permute(p1 + Pi.z - 1.0);
139        vec3 p12 = permute(p1 + Pi.z);
140        vec3 p13 = permute(p1 + Pi.z + 1.0);
141
142        vec3 p21 = permute(p2 + Pi.z - 1.0);
143        vec3 p22 = permute(p2 + Pi.z);
144        vec3 p23 = permute(p2 + Pi.z + 1.0);
145
146        vec3 p31 = permute(p3 + Pi.z - 1.0);
147        vec3 p32 = permute(p3 + Pi.z);
148        vec3 p33 = permute(p3 + Pi.z + 1.0);
149
150        vec3 ox11 = fract(p11*K) - Ko;
151        vec3 oy11 = mod(floor(p11*K), 7.0)*K - Ko;
152        vec3 oz11 = floor(p11*K2)*Kz - Kzo; // p11 < 289 guaranteed
153
154        vec3 ox12 = fract(p12*K) - Ko;
155        vec3 oy12 = mod(floor(p12*K), 7.0)*K - Ko;
156        vec3 oz12 = floor(p12*K2)*Kz - Kzo;
157
158        vec3 ox13 = fract(p13*K) - Ko;
159        vec3 oy13 = mod(floor(p13*K), 7.0)*K - Ko;
160        vec3 oz13 = floor(p13*K2)*Kz - Kzo;
161
162        vec3 ox21 = fract(p21*K) - Ko;
163        vec3 oy21 = mod(floor(p21*K), 7.0)*K - Ko;
164        vec3 oz21 = floor(p21*K2)*Kz - Kzo;
165
166        vec3 ox22 = fract(p22*K) - Ko;
167        vec3 oy22 = mod(floor(p22*K), 7.0)*K - Ko;
168        vec3 oz22 = floor(p22*K2)*Kz - Kzo;
169
170        vec3 ox23 = fract(p23*K) - Ko;
171        vec3 oy23 = mod(floor(p23*K), 7.0)*K - Ko;
172        vec3 oz23 = floor(p23*K2)*Kz - Kzo;
173
174        vec3 ox31 = fract(p31*K) - Ko;
175        vec3 oy31 = mod(floor(p31*K), 7.0)*K - Ko;
176        vec3 oz31 = floor(p31*K2)*Kz - Kzo;
177
178        vec3 ox32 = fract(p32*K) - Ko;
179        vec3 oy32 = mod(floor(p32*K), 7.0)*K - Ko;
180        vec3 oz32 = floor(p32*K2)*Kz - Kzo;
181
182        vec3 ox33 = fract(p33*K) - Ko;
183        vec3 oy33 = mod(floor(p33*K), 7.0)*K - Ko;
184        vec3 oz33 = floor(p33*K2)*Kz - Kzo;
185
186        vec3 dx11 = Pfx + jitter2x2x2*ox11;
187        vec3 dy11 = Pfy.x + jitter2x2x2*oy11;
188        vec3 dz11 = Pfz.x + jitter2x2x2*oz11;
189
190        vec3 dx12 = Pfx + jitter2x2x2*ox12;
191        vec3 dy12 = Pfy.x + jitter2x2x2*oy12;
192        vec3 dz12 = Pfz.y + jitter2x2x2*oz12;
193
194        vec3 dx13 = Pfx + jitter2x2x2*ox13;
195        vec3 dy13 = Pfy.x + jitter2x2x2*oy13;
196        vec3 dz13 = Pfz.z + jitter2x2x2*oz13;
197
198        vec3 dx21 = Pfx + jitter2x2x2*ox21;
199        vec3 dy21 = Pfy.y + jitter2x2x2*oy21;
200        vec3 dz21 = Pfz.x + jitter2x2x2*oz21;
201
202        vec3 dx22 = Pfx + jitter2x2x2*ox22;
203        vec3 dy22 = Pfy.y + jitter2x2x2*oy22;
204        vec3 dz22 = Pfz.y + jitter2x2x2*oz22;
205
206        vec3 dx23 = Pfx + jitter2x2x2*ox23;
207        vec3 dy23 = Pfy.y + jitter2x2x2*oy23;
208        vec3 dz23 = Pfz.z + jitter2x2x2*oz23;
209
210        vec3 dx31 = Pfx + jitter2x2x2*ox31;
211        vec3 dy31 = Pfy.z + jitter2x2x2*oy31;
212        vec3 dz31 = Pfz.x + jitter2x2x2*oz31;
213
214        vec3 dx32 = Pfx + jitter2x2x2*ox32;
215        vec3 dy32 = Pfy.z + jitter2x2x2*oy32;
216        vec3 dz32 = Pfz.y + jitter2x2x2*oz32;
217
218        vec3 dx33 = Pfx + jitter2x2x2*ox33;
219        vec3 dy33 = Pfy.z + jitter2x2x2*oy33;
220        vec3 dz33 = Pfz.z + jitter2x2x2*oz33;
221
222        vec3 d11 = dx11 * dx11 + dy11 * dy11 + dz11 * dz11;
223        vec3 d12 = dx12 * dx12 + dy12 * dy12 + dz12 * dz12;
224        vec3 d13 = dx13 * dx13 + dy13 * dy13 + dz13 * dz13;
225        vec3 d21 = dx21 * dx21 + dy21 * dy21 + dz21 * dz21;
226        vec3 d22 = dx22 * dx22 + dy22 * dy22 + dz22 * dz22;
227        vec3 d23 = dx23 * dx23 + dy23 * dy23 + dz23 * dz23;
228        vec3 d31 = dx31 * dx31 + dy31 * dy31 + dz31 * dz31;
229        vec3 d32 = dx32 * dx32 + dy32 * dy32 + dz32 * dz32;
230        vec3 d33 = dx33 * dx33 + dy33 * dy33 + dz33 * dz33;
231
232        // Sort out the two smallest distances (F1, F2)
233#if 0
234        // Cheat and sort out only F1
235        vec3 d1 = min(min(d11,d12), d13);
236        vec3 d2 = min(min(d21,d22), d23);
237        vec3 d3 = min(min(d31,d32), d33);
238        vec3 d = min(min(d1,d2), d3);
239        d.x = min(min(d.x,d.y),d.z);
240        return sqrt(d.xx); // F1 duplicated, no F2 computed
241#else
242        // Do it right and sort out both F1 and F2
243        vec3 d1a = min(d11, d12);
244        d12 = max(d11, d12);
245        d11 = min(d1a, d13); // Smallest now not in d12 or d13
246        d13 = max(d1a, d13);
247        d12 = min(d12, d13); // 2nd smallest now not in d13
248        vec3 d2a = min(d21, d22);
249        d22 = max(d21, d22);
250        d21 = min(d2a, d23); // Smallest now not in d22 or d23
251        d23 = max(d2a, d23);
252        d22 = min(d22, d23); // 2nd smallest now not in d23
253        vec3 d3a = min(d31, d32);
254        d32 = max(d31, d32);
255        d31 = min(d3a, d33); // Smallest now not in d32 or d33
256        d33 = max(d3a, d33);
257        d32 = min(d32, d33); // 2nd smallest now not in d33
258        vec3 da = min(d11, d21);
259        d21 = max(d11, d21);
260        d11 = min(da, d31); // Smallest now in d11
261        d31 = max(da, d31); // 2nd smallest now not in d31
262        d11.xy = (d11.x < d11.y) ? d11.xy : d11.yx;
263        d11.xz = (d11.x < d11.z) ? d11.xz : d11.zx; // d11.x now smallest
264        d12 = min(d12, d21); // 2nd smallest now not in d21
265        d12 = min(d12, d22); // nor in d22
266        d12 = min(d12, d31); // nor in d31
267        d12 = min(d12, d32); // nor in d32
268        d11.yz = min(d11.yz,d12.xy); // nor in d12.yz
269        d11.y = min(d11.y,d12.z); // Only two more to go
270        d11.y = min(d11.y,d11.z); // Done! (Phew!)
271        return sqrt(d11.xy); // F1, F2
272#endif
273}
274
275// Permutation polynomial: (34x^2 + x) mod 289
276vec4 permute4(vec4 x) {
277  return mod((34.0 * x + 1.0) * x, 289.0);
278}
279
280// Cellular noise, returning F1 and F2 in a vec2.
281// Speeded up by using 2x2x2 search window instead of 3x3x3,
282// at the expense of some pattern artifacts.
283// F2 is often wrong and has sharp discontinuities.
284// If you need a good F2, use the slower 3x3x3 version.
285vec2 cellular2x2x2(vec3 P) {
286#define K 0.142857142857 // 1/7
287#define Ko 0.428571428571 // 1/2-K/2
288#define K2 0.020408163265306 // 1/(7*7)
289#define Kz 0.166666666667 // 1/6
290#define Kzo 0.416666666667 // 1/2-1/6*2
291        vec3 Pi = mod(floor(P), 289.0);
292        vec3 Pf = fract(P);
293        vec4 Pfx = Pf.x + vec4(0.0, -1.0, 0.0, -1.0);
294        vec4 Pfy = Pf.y + vec4(0.0, 0.0, -1.0, -1.0);
295        vec4 p = permute4(Pi.x + vec4(0.0, 1.0, 0.0, 1.0));
296        p = permute4(p + Pi.y + vec4(0.0, 0.0, 1.0, 1.0));
297        vec4 p1 = permute4(p + Pi.z); // z+0
298        vec4 p2 = permute4(p + Pi.z + vec4(1.0)); // z+1
299        vec4 ox1 = fract(p1*K) - Ko;
300        vec4 oy1 = mod(floor(p1*K), 7.0)*K - Ko;
301        vec4 oz1 = floor(p1*K2)*Kz - Kzo; // p1 < 289 guaranteed
302        vec4 ox2 = fract(p2*K) - Ko;
303        vec4 oy2 = mod(floor(p2*K), 7.0)*K - Ko;
304        vec4 oz2 = floor(p2*K2)*Kz - Kzo;
305        vec4 dx1 = Pfx + jitter*ox1;
306        vec4 dy1 = Pfy + jitter*oy1;
307        vec4 dz1 = Pf.z + jitter*oz1;
308        vec4 dx2 = Pfx + jitter*ox2;
309        vec4 dy2 = Pfy + jitter*oy2;
310        vec4 dz2 = Pf.z - 1.0 + jitter*oz2;
311        vec4 d1 = dx1 * dx1 + dy1 * dy1 + dz1 * dz1; // z+0
312        vec4 d2 = dx2 * dx2 + dy2 * dy2 + dz2 * dz2; // z+1
313
314        // Sort out the two smallest distances (F1, F2)
315#if 0
316        // Cheat and sort out only F1
317        d1 = min(d1, d2);
318        d1.xy = min(d1.xy, d1.wz);
319        d1.x = min(d1.x, d1.y);
320        return sqrt(d1.xx);
321#else
322        // Do it right and sort out both F1 and F2
323        vec4 d = min(d1,d2); // F1 is now in d
324        d2 = max(d1,d2); // Make sure we keep all candidates for F2
325        d.xy = (d.x < d.y) ? d.xy : d.yx; // Swap smallest to d.x
326        d.xz = (d.x < d.z) ? d.xz : d.zx;
327        d.xw = (d.x < d.w) ? d.xw : d.wx; // F1 is now in d.x
328        d.yzw = min(d.yzw, d2.yzw); // F2 now not in d2.yzw
329        d.y = min(d.y, d.z); // nor in d.z
330        d.y = min(d.y, d.w); // nor in d.w
331        d.y = min(d.y, d2.x); // F2 is now in d.y
332        return sqrt(d.xy); // F1 and F2
333#endif
334}
335
336float fbm_map( vec3 position )
337{
338//      float frequency  = 1.0;
339//      float lacunarity = 2.0;
340//      float gain       = 0.5;
341        float fbm=snoise(1.0*position)
342                + 0.5*snoise(2.0*position)
343                + 0.25*snoise(4.0*position)
344                + 0.125*snoise(8.0*position)
345                + 0.0625*snoise(16.0*position)
346                ;
347        return fbm;
348}
349
350float crater_map( vec3 position, float cutoff, float inset )
351{
352        vec2 value = cellular2x2x2( position ); // 0..1
353        float factor = smoothstep( 0.0, cutoff, value.x );
354        float rmaxabs = 1.0 / max( 1.0 - inset, inset );
355        return 1.0 - smoothstep( -0.05, 1.0, abs( factor - inset ) * rmaxabs );
356}
357
358float height_map( vec3 position )
359{
360        float crater1 = crater_map( 3*position, 0.5, 0.5 );
361        float crater2 = crater_map( 1.7*position, 0.5, 0.8 );
362        float crater  = 0.7 * crater2 + 0.3 * crater1;
363        float fbm     = ( fbm_map( 6*position ) + 1.0 ) / 2.0;
364        //fbm = 1.0;
365        return 1.5*crater*(0.15*fbm+0.85) + fbm * 0.2;
366}
367
368vec3 color_map( vec3 position, float h )
369{
370        float fbm = ( fbm_map( 2*position ) + 1.0 ) / 2.0;
371        //fbm = 1.0;
372        return (fbm*0.5 + 0.5)*vec3(0.9,0.9,1.0);
373}
374
375vec3 self_ilum_map( vec3 position, float h )
376{
377//      float test     = fbm_map( 8*position );
378//      float test = crater_map( 1.7*position, 0.5, 0.8 );
379//      if ( test < -1.0 )
380//              return vec3(1.0,0.0,0.0);
381//      if ( test > 1.2 )
382//              return vec3(0.0,1.0,0.0);
383        return vec3(0.0,0.0,0.0);
384}
385
386float specular_map( vec3 position, float h )
387{
388        return 0.2*h;
389}
390
391vec3 normal_map( vec3 position, vec3 normal, vec3 tangent, vec3 bitangent )
392{
393        float step  = 0.001;
394        float ystep = 0.1;
395        vec3 n = ystep * normal;
396        vec3 t = step * tangent;
397        vec3 b = step * bitangent;
398        vec3 prev_x = position - t;
399        vec3 prev_z = position - b;
400        vec3 next_x = position + t;
401        vec3 next_z = position + b;
402        float px = height_map( prev_x );
403        float nx = height_map( next_x );
404        float pz = height_map( prev_z );
405        float nz = height_map( next_z );
406        prev_x += px * n;
407        prev_z += pz * n;
408        next_x += nx * n;
409        next_z += nz * n;
410        vec3 nt = next_x - prev_x;
411        vec3 nb = next_z - prev_z;
412        return normalize( cross( nt, nb ) );
413}
414
415
416float world_depth( vec3 world_pos )
417{
418        vec4 v = nv_m_mvp * vec4( world_pos, 1.0 );
419        v.z /= v.w;
420        v.z = ( v.z + 1.0 ) * 0.5;
421        return v.z;
422}
423
424vec4 sphere_isect( vec3 origin, vec3 ray, vec3 center, float r2 )
425{
426        vec3 sd = center - origin;
427        float b = dot( ray, sd );
428        float disc = b*b + r2 - dot(sd,sd);
429        if ( disc > 0.0 )
430        {
431                float tnow = b - sqrt(disc);
432                return vec4( origin + tnow * ray, tnow );
433        }
434        return vec4(0,0,0,0);
435}
436
437// Minnaert limb darkening diffuse term
438float minnaert( vec3 L, vec3 Nf, float k) {
439        float ndotl = max( 0.0, dot(L, Nf));
440        return pow( ndotl, k);
441}
442
443// Ward isotropic specular term
444float wardiso( vec3 Nf, vec3 Ln, vec3 Hn, float roughness, float ndotv ) {
445        float ndoth = dot( Nf, Hn);
446        float ndotl = dot( Nf, Ln);
447        float tandelta = tan( acos(ndoth));
448        return exp( -( pow( tandelta, 2.0) / pow( roughness, 2.0)))
449                * (1.0 / sqrt( ndotl * ndotv ))
450                * (1.0 / (4.0 * pow( roughness, 2.0)));
451        }
452       
453float schlick( vec3 Nf, vec3 Vf, float ior, float ndotv ) {
454        float kr = (ior-1.0)/(ior+1.0);
455        kr *= kr;
456        return kr + (1.0-kr)*pow( 1.0 - ndotv, 5.0);
457}
458
459void main(void) {
460        vec3 view_vector  = normalize( v_world_pos - v_camera_loc );
461        vec4 inter = sphere_isect( v_camera_loc, view_vector, center, radius*radius );
462        //float height = height_map( inter.xyz );
463        //vec3 position = inter.xyz + height*0.1*inter.xyz;
464        vec3 position = inter.xyz;
465        float height = height_map( position );
466        vec3 light_vector = normalize( position - v_light_loc );
467        view_vector       = normalize( position - v_camera_loc );
468        vec3 normal       = normalize( position - center );
469        vec3 tangent      = normalize( cross( normal, vec3(0.0,1.0,0.0) ) );
470        vec3 bitangent    = cross( normal, tangent );
471
472        normal       = normal_map( position, normal, tangent, bitangent );
473        tangent      = normalize( cross( normal, vec3(0.0,1.0,0.0) ) );
474        bitangent    = cross( normal, tangent );
475
476        //vec3 diff_texel      = vec3( texture2D( nv_t_diffuse, v_texcoord ) );
477        vec3 diff_texel       = color_map( position, height );
478        float specular_amount = specular_map( position, height );
479        vec3 self_ilum_color  = self_ilum_map( position, height );
480        vec3 ambient_color    = vec3 (0.1, 0.1, 0.1);
481        float diffuse_amount  = 1.0 - specular_amount;
482
483        vec3 reflect_vector     = reflect( light_vector, normal );
484        float dot_prod_specular = dot( reflect_vector, -view_vector );
485        float dot_prod_diffuse  = dot( -light_vector, normal );
486
487        float diffuse_factor  = max( dot_prod_diffuse, 0.0 );
488        float specular_factor = pow( max( dot_prod_specular, 0.0 ), 16.0 ); // 100.0
489
490        float final_diffuse  = diffuse_amount * diffuse_factor;
491        float final_specular = specular_amount * specular_factor;
492
493
494        vec3 N = normalize(normal);
495        vec3 V = normalize(view_vector);
496        vec3 L = normalize(-light_vector);
497        vec3 Vf = -V;
498        float ndotv = dot(N, Vf);
499        vec3 H = normalize(L+Vf);
500
501        final_diffuse  = minnaert( L, N, 1.5) * diffuse_factor;
502        //float fresnel  = schlick( N, V, 0.1, ndotv);
503        //final_specular = wardiso( N, L, H, 0.1, ndotv) * fresnel;
504
505        vec3 diffuse_color   = light_diffuse.xyz  * final_diffuse * diff_texel;
506        vec3 specular_color  = light_specular.xyz * final_specular * diff_texel;
507
508        if ( inter.w < 0.0 || inter.w > 0.0 )
509                gl_FragColor = vec4( max( self_ilum_color, diffuse_color + specular_color + ambient_color ), 1.0 );
510        else
511                discard;
512        gl_FragDepth = world_depth( inter.xyz );
513        //gl_FragColor = vec4( 0.0, 1.0, 0.5, 0.8 );
514
515}
Note: See TracBrowser for help on using the repository browser.