My favorites | Sign in
Project Logo
                
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
#extension GL_EXT_gpu_shader4 : enable

uniform sampler2D _input;
uniform sampler2D dir;
uniform float dt; //change in time
uniform int key;
uniform vec3 camPos;
const float EPSILON = 2.4414e-4;
const float STOPRANGE = 6.0; //stop

uvec4 whiteNoise(in uvec4 _input, in unsigned int key);

vec4 convertToR0_R1(in uvec4 _input);

void main()
{


//update position using old euler's method
vec2 tc = gl_TexCoord[0].st;
//tc.t = 1.0 - tc.t;
vec4 pos = texture2D(_input,tc);
vec4 dir = texture2D(dir,tc);

uvec4 coord;
unsigned int uintkey = unsigned int(key);
coord.x = uint(gl_TexCoord[0].x*20000.0);
coord.y = uint(gl_TexCoord[0].y*20000.0);
coord.z = uintkey;
coord.w = uintkey;

uvec4 noise = whiteNoise(coord,uintkey);
vec4 rand = convertToR0_R1(noise);
//rand.x = rand.x*0.03; //speed
rand.x = rand.x*0.5;
vec3 camPosG = camPos;
camPosG.y = 0.0;
vec3 vecToPlayer = camPosG - pos.xyz;
float dis = length(vecToPlayer);
if(dis > STOPRANGE)
{
dis = STOPRANGE/dis;
dis = max(dis,EPSILON); //for now, we need to limit the zombie range later.
}
else
dis = 1.0;
pos.xz = pos.xz + dt*rand.x*dir.xy;
//pos.xz = pos.xz + dt*rand.x*(1.0 - dis)*dir.xy; //old euler's method
//pos.xz = pos.xz + dt*rand.x*vecToPlayer.xz;
gl_FragColor = pos;
}
Show details Hide details

Change log

r57 by llwijk on Aug 01, 2009   Diff
added preliminar networking.
Go to: 
Project members, sign in to write a code review

Older revisions

r56 by llwijk on Apr 11, 2009   Diff
Fixed a crash because OGL 3
input/ouput are reserved keywords, so
I had to change them in GLSL, but
forgot to reflect this when setting
input material in Ping-Pong shader.
...
r51 by llwijk on Oct 14, 2008   Diff
More work. Imposter renderer is more
complete than last time... :P. Started
working on some shader effects
(lighting etc) for imposters. Right
now the shader code is sort of messy,
...
r49 by llwijk on Oct 09, 2008   Diff
It's ALIVE! Finished the very first
version of Zombie wandering. They
move!
All revisions of this file

File info

Size: 1269 bytes, 51 lines
Hosted by Google Code