added missing shaders

This commit is contained in:
Dave Griffiths 2009-09-28 10:30:09 +01:00
parent 07438ae5c1
commit 0104dd8ada
6 changed files with 130 additions and 2 deletions

View file

@ -17,7 +17,7 @@
(define (ornament-colour) (vector 0.7 0.7 0.7)) (define (ornament-colour) (vector 0.7 0.7 0.7))
(define (pickup-colour) (vector 1 1 1)) (define (pickup-colour) (vector 1 1 1))
(define (earth-colour) (vector 0.1 0.1 0.1)) (define (earth-colour) (vector 0.2 0.15 0.1))
(define (dust-colour) (vmul (vector 0.05 0.05 0.05) (* 2 (rndf)))) (define (dust-colour) (vmul (vector 0.05 0.05 0.05) (* 2 (rndf))))
(define (stones-colour) (vmul (vector 0.5 0.5 0.5) (* (crndf) 0.5))) (define (stones-colour) (vmul (vector 0.5 0.5 0.5) (* (crndf) 0.5)))
(define (alive-colour) (vmul (vector 1 1 1) (+ 0.5 (* (rndf) 0.5)))) (define (alive-colour) (vmul (vector 1 1 1) (+ 0.5 (* (rndf) 0.5))))
@ -34,7 +34,7 @@
(define fin-grow-prob 200) (define fin-grow-prob 200)
(define max-fins-per-twig 5) (define max-fins-per-twig 5)
(define above-fog-col (vector 1 1 1)) (define above-fog-col (vector 0.9 1 0.95))
(define above-fog-strength 0.01) (define above-fog-strength 0.01)
(define ground-change-duration 4) (define ground-change-duration 4)

View file

View file

@ -0,0 +1,58 @@
varying vec3 N;
varying vec3 L;
varying vec3 V;
varying vec2 T;
uniform sampler2D Maps[3];
uniform sampler2D NormalMap;
uniform float Time;
void main()
{
vec3 bump = normalize(texture2D(NormalMap,T).xyz*2.0-1.0)-vec3(0,0,1);
vec3 n = normalize(N);
vec3 bn = normalize(N);//+bump*2.0);
vec3 l = normalize(L);
vec3 v = normalize(V);
float HighlightSize=0.1;
float ShadowSize=0.2;
float OutlineWidth=0.2;
vec4 MidColour=gl_FrontMaterial.diffuse;
vec4 HighlightColour=MidColour*1.3;
vec4 ShadowColour=MidColour*0.6;
MidColour.a=1.0;
HighlightColour.a=1.0;
ShadowColour.a=1.0;
vec4 texture;
float t = fract(Time*0.1)*3.0;
if (t<1.0) // mix bet 0 and 1
{
texture = mix(texture2D(Maps[0], T*10),texture2D(Maps[1], T*10),t);
}
else if (t<2.0 && t>1.0) // mix bet 1 and 2
{
texture = mix(texture2D(Maps[1], T*10),texture2D(Maps[2], T*10),t-1.0);
}
else // mix bet 2 and 0
{
texture = mix(texture2D(Maps[2], T*10),texture2D(Maps[0], T*10),t-2.0);
}
float lambert = dot(l,bn);
vec4 colour = MidColour;
if (lambert > 1.0-HighlightSize) colour = HighlightColour;
if (lambert < ShadowSize) colour = ShadowColour;
if (dot(n,v) < OutlineWidth) colour = vec4(0,0,0,1);
if (dot(n,v) < 0.0) colour = MidColour*texture*0.5;
// add linear fog
//float fog_factor = clamp((gl_Fog.end - gl_FogFragCoord) * gl_Fog.scale, 0.0, 1.0);
//gl_FragColor = mix(gl_Fog.color, colour, fog_factor);
gl_FragColor = colour;
}

View file

@ -0,0 +1,36 @@
varying vec3 N;
varying vec3 L;
varying vec3 V;
varying vec2 T;
uniform sampler2D BaseMap;
uniform sampler2D AltMap;
uniform sampler2D NormalMap;
void main()
{
vec3 bump = normalize(texture2D(NormalMap,T).xyz*2.0-1.0)-vec3(0,0,1);
vec3 n = normalize(N)//+bump*5.0);
vec3 l = normalize(L);
vec3 v = normalize(V);
float HighlightSize=0.1;
float ShadowSize=0.2;
float OutlineWidth=0.2;
vec4 MidColour=gl_FrontMaterial.diffuse;
vec4 HighlightColour=MidColour*2.0;
vec4 ShadowColour=MidColour*0.5;
HighlightColour.a=1.0;
ShadowColour.a=1.0;
float lambert = dot(l,n);
vec4 colour = vec4(MidColour.xyz*lambert,1);
if (lambert > 1.0-HighlightSize) colour = HighlightColour;
if (lambert < ShadowSize) colour = ShadowColour;
if (dot(n,v) < OutlineWidth) colour = vec4(0,0,0,1);
if (dot(n,v) < 0.0) colour = MidColour;//*texture2D(BaseMap, T);
colour = mix(colour+texture2D(AltMap, T*10.0),colour,smoothstep(4.0,8.0,length(V)));
colour.a *= smoothstep(2.0,6.0,length(V));
gl_FragColor = colour;
}

View file

@ -0,0 +1,18 @@
// Copyright (C) 2007 Dave Griffiths
// Licence: GPLv2 (see COPYING)
varying vec3 N;
varying vec3 P;
varying vec3 V;
varying vec3 L;
varying vec2 T;
void main()
{
N = normalize(gl_NormalMatrix*gl_Normal);
P = gl_Vertex.xyz;
V = -vec3(gl_ModelViewMatrix*gl_Vertex);
vec4 LightPos = gl_LightSource[1].position;
L = vec3((LightPos-gl_Vertex));
T = gl_MultiTexCoord0.xy;
gl_Position = ftransform();
}

View file

@ -0,0 +1,16 @@
varying vec3 N;
varying vec3 P;
varying vec3 V;
varying vec3 L;
varying vec2 T;
void main()
{
N = normalize(gl_NormalMatrix*gl_Normal);
P = gl_Vertex.xyz;
V = -vec3(gl_ModelViewMatrix*gl_Vertex);
vec4 LightPos = gl_LightSource[1].position;
L = vec3(gl_ModelViewMatrix*(LightPos-gl_Vertex));
T = gl_MultiTexCoord0.xy;
gl_Position = ftransform();
}