CVS: data/Shaders landmass-g.vert, 1.2, 1.3 landmass.geom, 1.4, 1.5

Tim Moore <[email protected]> Fri, 30 Apr 2010 10:20:40 -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-serv13945/Shaders

Modified Files:
	landmass-g.vert landmass.geom 
Log Message:
Another go at the landmass geometry shader, using fewer varying parameters


Author: Tim Moore <[email protected]>


Index: landmass-g.vert
===================================================================
RCS file: /var/cvs/FlightGear-0.9/data/Shaders/landmass-g.vert,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- landmass-g.vert	22 Apr 2010 14:56:35 -0000	1.2
+++ landmass-g.vert	30 Apr 2010 15:20:36 -0000	1.3
@@ -15,18 +15,14 @@
 
 // model position of original terrain poly; the bottom of the forest.
 varying vec4 rawposIn;
-// model forest top
-varying vec4 rawTopIn;
 // model normal
 varying vec3 NormalIn;
 varying vec4 ecPosIn;
-varying vec4 ecTopIn;
 varying vec3 ecNormalIn;
 // eye spacce tangent and binormal
 varying vec3 VTangentIn;
 varying vec3 VBinormalIn;
 // screen-space position of top
-varying vec4 positionTopIn;
 // constant color component
 varying vec4 constantColorIn;
 
@@ -40,15 +36,15 @@
         rawposIn = gl_Vertex;
 	ecPosIn = gl_ModelViewMatrix * gl_Vertex;
 	NormalIn = normalize(gl_Normal);
-        rawTopIn = rawposIn + vec4(0.0, 0.0, canopy_height, 0.0);
-        ecTopIn = gl_ModelViewMatrix * rawTopIn;
+        //rawTopIn = rawposIn + vec4(0.0, 0.0, canopy_height, 0.0);
+        //ecTopIn = gl_ModelViewMatrix * rawTopIn;
         ecNormalIn = gl_NormalMatrix * NormalIn;
 	VTangentIn = gl_NormalMatrix * tangent;
 	VBinormalIn = gl_NormalMatrix * binormal;
 
 	gl_FrontColor = gl_Color;
 	gl_Position = ftransform();
-        positionTopIn = gl_ModelViewProjectionMatrix * rawTopIn;
+        //positionTopIn = gl_ModelViewProjectionMatrix * rawTopIn;
 	gl_TexCoord[0] = gl_TextureMatrix[0] * gl_MultiTexCoord0;
         constantColorIn = gl_FrontMaterial.emission
 		+ gl_Color * (gl_LightModel.ambient + gl_LightSource[0].ambient);  

Index: landmass.geom
===================================================================
RCS file: /var/cvs/FlightGear-0.9/data/Shaders/landmass.geom,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -r1.4 -r1.5
--- landmass.geom	22 Apr 2010 14:56:35 -0000	1.4
+++ landmass.geom	30 Apr 2010 15:20:36 -0000	1.5
@@ -9,13 +9,10 @@
 // See landmass-g.vert for a description of the inputs.
 varying in vec4 rawposIn[];
 varying in vec3 NormalIn[];
-varying in vec4 rawTopIn[];
 varying in vec4 ecPosIn[];
-varying in vec4 ecTopIn[];
 varying in vec3 ecNormalIn[];
 varying in vec3 VTangentIn[];
 varying in vec3 VBinormalIn[];
-varying in vec4 positionTopIn[];
 varying in vec4 constantColorIn[];
 
 uniform float canopy_height;
@@ -67,14 +64,25 @@
 
 void main(void)
 {
+        vec4 rawTopDisp = vec4(0.0, 0.0, canopy_height, 0.0);
+        vec4 ecTopDisp = gl_ModelViewMatrix * rawTopDisp;
+        vec4 mvpTopDisp = gl_ModelViewProjectionMatrix * rawTopDisp;
+        // model forest top        
+        vec4 rawTopIn[3];
+        vec4 ecTopIn[3];
+        vec4 positionTopIn[3];
         rawSideNormal[0] = normalize(cross((rawposIn[1] - rawposIn[0]).xyz,
                                            NormalIn[0]));
         rawSideNormal[1] = normalize(cross((rawposIn[2] - rawposIn[1]).xyz,
                                            NormalIn[1]));
         rawSideNormal[2] = normalize(cross((rawposIn[0] - rawposIn[2]).xyz, 
                                            NormalIn[2]));
-        for (int i = 0; i < 3; ++i)
+        for (int i = 0; i < 3; ++i) {
                 sideNormal[i] = gl_NormalMatrix * rawSideNormal[i];
+                rawTopIn[i] = rawposIn[i] + rawTopDisp;
+                ecTopIn[i] = ecPosIn[i] + ecTopDisp;
+                positionTopIn[i] = gl_PositionIn[i] + mvpTopDisp;
+        }
         if (canopy_height > 0.01) {
                 // Sides
                 doSideVertex(0, 0, rawTopIn[0], ecTopIn[0], positionTopIn[0]);


------------------------------------------------------------------------------