diff options
author | Zou Nan hai <[email protected]> | 2007-06-21 10:22:28 +0800 |
---|---|---|
committer | Zou Nan hai <[email protected]> | 2007-06-21 10:22:28 +0800 |
commit | d19d0596daf004b56d80f78fa1a329b43c2ebf94 (patch) | |
tree | 24a911efdfe23a8e4cbec85d519875d78eb64be6 /progs | |
parent | 58eac1bbf320b4104c3158aaeca4726f1a59daf9 (diff) |
support branch and loop in pixel shader
most of the sample working with some small modification
Diffstat (limited to 'progs')
-rw-r--r-- | progs/glsl/CH06-brick.frag.txt | 6 | ||||
-rw-r--r-- | progs/glsl/CH11-bumpmap.frag.txt | 2 | ||||
-rw-r--r-- | progs/glsl/CH11-bumpmap.vert.txt | 9 | ||||
-rw-r--r-- | progs/glsl/CH11-toyball.frag.txt | 7 | ||||
-rw-r--r-- | progs/glsl/CH11-toyball.vert.txt | 7 |
5 files changed, 19 insertions, 12 deletions
diff --git a/progs/glsl/CH06-brick.frag.txt b/progs/glsl/CH06-brick.frag.txt index 06ef04e3afb..388c5f9e660 100644 --- a/progs/glsl/CH06-brick.frag.txt +++ b/progs/glsl/CH06-brick.frag.txt @@ -23,7 +23,11 @@ void main() position = MCposition / BrickSize; - if (fract(position.y * 0.5) > 0.5) +// if (fract(position.y * 0.5) > 0.5) +// position.x += 0.5; + float tmp; + tmp = fract(position.y * 0.5); + if (tmp > 0.5) position.x += 0.5; position = fract(position); diff --git a/progs/glsl/CH11-bumpmap.frag.txt b/progs/glsl/CH11-bumpmap.frag.txt index 063576f5a3c..1467f767ec4 100644 --- a/progs/glsl/CH11-bumpmap.frag.txt +++ b/progs/glsl/CH11-bumpmap.frag.txt @@ -33,7 +33,7 @@ void main() litColor = SurfaceColor * max(dot(normDelta, LightDir), 0.0); vec3 reflectDir = reflect(LightDir, normDelta); - float spec = max(dot(EyeDir, reflectDir), 0.0); + float spec = max(dot(normalize(EyeDir), reflectDir), 0.0); spec *= SpecularFactor; litColor = min(litColor + spec, vec3(1.0)); diff --git a/progs/glsl/CH11-bumpmap.vert.txt b/progs/glsl/CH11-bumpmap.vert.txt index d3d19f62ac3..55cf43ba7dd 100644 --- a/progs/glsl/CH11-bumpmap.vert.txt +++ b/progs/glsl/CH11-bumpmap.vert.txt @@ -31,8 +31,9 @@ void main() v.z = dot(LightPosition, n); LightDir = normalize(v); - v.x = dot(EyeDir, t); - v.y = dot(EyeDir, b); - v.z = dot(EyeDir, n); - EyeDir = normalize(v); +/* v.x = dot(EyeDir, t); + v.y = dot(EyeDir, b); + v.z = dot(EyeDir, n); + EyeDir = normalize(EyeDir); +*/ } diff --git a/progs/glsl/CH11-toyball.frag.txt b/progs/glsl/CH11-toyball.frag.txt index 90ec1c27fc1..f3cac62fb3e 100644 --- a/progs/glsl/CH11-toyball.frag.txt +++ b/progs/glsl/CH11-toyball.frag.txt @@ -49,14 +49,15 @@ void main() inorout += dot(distance, vec4(1.0)); distance.x = dot(p, HalfSpace4); - distance.y = StripeWidth - abs(p.z); +// distance.y = StripeWidth - abs(p.z); + distance.y = StripeWidth - abs(p.y); distance = smoothstep(-FWidth, FWidth, distance); inorout += distance.x; inorout = clamp(inorout, 0.0, 1.0); - surfColor = mix(Yellow, Red, inorout); - surfColor = mix(surfColor, Blue, distance.y); + surfColor = mix(Yellow, Blue, distance.y); + surfColor = mix(surfColor, Red, inorout); // normal = point on surface for sphere at (0,0,0) normal = p; diff --git a/progs/glsl/CH11-toyball.vert.txt b/progs/glsl/CH11-toyball.vert.txt index b7da3ac839e..a3ee1b03776 100644 --- a/progs/glsl/CH11-toyball.vert.txt +++ b/progs/glsl/CH11-toyball.vert.txt @@ -14,10 +14,11 @@ uniform vec4 BallCenter; // ball center in modelling coordinates void main() { -//orig: ECposition = gl_ModelViewMatrix * gl_Vertex; + ECposition = gl_ModelViewMatrix * gl_Vertex; - ECposition = gl_TextureMatrix[0] * gl_Vertex; - ECposition = gl_ModelViewMatrix * ECposition; +// ECposition = gl_TextureMatrix[0] * gl_Vertex; +// ECposition = gl_MultiTexCoord0 * gl_Vertex; +// ECposition = gl_ModelViewMatrix * ECposition; ECballCenter = gl_ModelViewMatrix * BallCenter; gl_Position = ftransform(); |