CVS: data/Shaders reflect.frag, 1.3, 1.4 reflect.vert, 1.3, 1.4

Vivian Meazza <[email protected]> Fri, 2 Apr 2010 09:12:10 -0500
Newsgroups gmane.games.flightgear.cvc
Message-ID <[email protected]>
Update of /var/cvs/FlightGear-0.9/data/Shaders
In directory baron.flightgear.org:/tmp/cvs-serv26665

Modified Files:
	reflect.frag reflect.vert 
Log Message:
Add mapping and noise

Index: reflect.frag
===================================================================
RCS file: /var/cvs/FlightGear-0.9/data/Shaders/reflect.frag,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -r1.3 -r1.4
--- reflect.frag	31 Mar 2010 09:11:44 -0000	1.3
+++ reflect.frag	2 Apr 2010 14:06:46 -0000	1.4
@@ -4,6 +4,7 @@
 
 #version 120
 
+varying vec4  rawpos;
 varying vec4  ecPosition;
 varying vec3  VNormal;
 varying vec3  Normal;
@@ -19,12 +20,15 @@
 uniform sampler2D Rainbow;
 uniform sampler2D BaseTex;
 uniform sampler2D Fresnel;
+uniform sampler2D Map;
+uniform sampler3D Noise;
 
 uniform float refl_correction;
 uniform float rainbowiness;
 uniform float fresneliness;
+uniform float noisiness;
 uniform float ambient_correction;
-
+uniform float reflect_map;
 
 void main (void)
 {
@@ -75,21 +79,37 @@
     // map the refection of the environment
     vec4 reflection = textureCube(Environment, reflVec);
 
-    // set the reflectivity proportional to shininess with user 
-    // input ambient
+    // set the user shininess offse
     float transparency_offset = clamp(refl_correction, -1.0, 1.0);
-    float reflFactor = (gl_FrontMaterial.shininess / 128) + transparency_offset;
+    float reflFactor = 0.0;
+
+    if(reflect_map > 0){
+        // map the shininess of the object with user input 
+        vec4 map = texture2D(Map, gl_TexCoord[0].st);
+        //float pam = (map.a * -2) + 1; //reverse map
+        reflFactor = map.a + transparency_offset;
+    } else {
+        // set the reflectivity proportional to shininess with user 
+        // input 
+        reflFactor = (gl_FrontMaterial.shininess / 128) + transparency_offset;
+    }
+
     reflFactor = clamp(reflFactor, 0.0, 1.0);
 
-    // set adjust ambient ambient
+    // set adjust ambient 
     float ambient_offset = clamp(ambient_correction, -1.0, 1.0);
-    vec4 ambient_Correction = mix(gl_LightSource[0].ambient, vec4(1.0, 1.0, 0.9, 1.0), 0.5) 
+    vec4 ambient_Correction = mix(gl_LightSource[0].ambient, vec4(1.0, 1.0, 0.6, 1.0), 0.5) 
         * ambient_offset;
 
+    // map noise vectore
+    vec4 noisevec = texture3D(Noise, rawpos.xyz);
+
     // add fringing fresnel and rainbow effects and modulate by reflection
     vec4 reflcolor = mix(reflection, rainbow, rainbowiness * v);
     vec4 reflfrescolor = mix(reflcolor, fresnel, fresneliness * v);
-    vec4 raincolor = vec4(reflfrescolor.rgb, 1.0) * reflFactor;
+    vec4 noisecolor = mix(reflfrescolor, noisevec, noisiness);
+    vec4 raincolor = vec4(noisecolor.rgb, 1.0) * reflFactor;
+
     vec4 mixedcolor = mix(texel, raincolor, reflFactor);
 
     // the final reflection

Index: reflect.vert
===================================================================
RCS file: /var/cvs/FlightGear-0.9/data/Shaders/reflect.vert,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -r1.3 -r1.4
--- reflect.vert	31 Mar 2010 09:11:44 -0000	1.3
+++ reflect.vert	2 Apr 2010 14:10:38 -0000	1.4
@@ -1,7 +1,8 @@
 // -*- mode: C; -*-
 // Licence: GPL v2
-// Author: Vivian Meazza. 
+// Author: Vivian Meazza.
 
+varying vec4  rawpos;
 varying vec4  ecPosition;
 varying vec3  VNormal;
 varying vec3  Normal;
@@ -19,6 +20,7 @@
 
 void main(void)
 {
+    rawpos     = gl_Vertex;
     ecPosition = gl_ModelViewMatrix * gl_Vertex;
     vec3 ecPosition3 = vec3(gl_ModelViewMatrix * gl_Vertex) / ecPosition.w;
 


------------------------------------------------------------------------------
Download Intel&#174; Parallel Studio Eval
Try the new software tools for yourself. Speed compiling, find bugs
proactively, and fine-tune applications for parallel performance.
See why Intel Parallel Studio got high marks during beta.
http://p.sf.net/sfu/intel-sw-dev