From: <sv...@ww...> - 2006-12-09 07:26:32
|
Author: mkrose Date: 2006-12-08 23:26:24 -0800 (Fri, 08 Dec 2006) New Revision: 2025 Added: trunk/csp/data/shaders/clod.fragment trunk/csp/data/shaders/clod.vertex Log: Add chunklod vertex and fragment shaders. Not sure exactly what state these files and the chunklod shader loader are in; some changes may be needed to get them to work. Browse at: https://www.zerobar.net/viewcvs/viewcvs.cgi?view=rev&rev=2025 Added: trunk/csp/data/shaders/clod.fragment =================================================================== --- trunk/csp/data/shaders/clod.fragment 2006-12-01 12:03:43 UTC (rev 2024) +++ trunk/csp/data/shaders/clod.fragment 2006-12-09 07:26:24 UTC (rev 2025) @@ -0,0 +1,20 @@ +// clod fragment shader +// +// Copyright 2003-2006 Mark Rose <mk...@us...> +// + +uniform sampler2D tex0; +varying vec4 normal; +varying vec4 light; +varying vec4 eye; + +const vec4 fog_color = vec4(0.2, 0.2, 0.4, 1.0); + +void main() { + const vec4 color = texture2D(tex0, gl_TexCoord[0].st); + vec3 r = reflect(normalize(light.xyz), normalize(normal.xyz)); + float spot = dot(r, normalize(eye.xyz)); + spot = pow(spot, 20.0); + float specular = spot * color.b / dot(color, color); + gl_FragColor = mix(color + vec4(1.0, 1.0, 1.0, 1.0) * clamp(specular, 0.0, 1.0), fog_color, gl_FogFragCoord); +} Added: trunk/csp/data/shaders/clod.vertex =================================================================== --- trunk/csp/data/shaders/clod.vertex 2006-12-01 12:03:43 UTC (rev 2024) +++ trunk/csp/data/shaders/clod.vertex 2006-12-09 07:26:24 UTC (rev 2025) @@ -0,0 +1,34 @@ +// clod vertex morpher +// +// Copyright 2003-2006 Mark Rose <mk...@us...> +// +// + +uniform vec3 vertex_scale; +uniform vec3 vertex_offset; + +varying vec4 normal; +varying vec4 light; +varying vec4 eye; + +void main() { + vec4 morph = vec4(0.0, 0.0, 0.0, 1.0); + morph.xz = vertex_offset.xz + gl_Vertex.xz * vertex_scale.xz; + vec4 vxy_eye = gl_ModelViewMatrix * morph; + vec4 range = length(vxy_eye); + morph.y = (gl_Vertex.y + gl_Vertex.w * vertex_offset.y) * vertex_scale.y - range * range / 12740000.0; + gl_Position = gl_ModelViewProjectionMatrix * morph; + + vec4 t0 = vec4(0.0, 0.0, 1.0, 1.0); + t0.s = dot(morph, gl_ObjectPlaneS[0]); + t0.t = dot(morph, gl_ObjectPlaneT[0]); + gl_TexCoord[0] = gl_TextureMatrix[0] * t0; + + normal = gl_ModelViewMatrix * vec4(0.0, 1.0, 0.0, 0.0); + eye = gl_ModelViewMatrix * morph; + light = -gl_LightSource[0].position; + + gl_FrontColor = vec4(1.0, 1.0, 1.0, 1.0); + gl_FogFragCoord = 1.0 - exp(-length(eye) * 0.000002); +} + |