CVS: data/Shaders landmass-g.vert, NONE, 1.1 landmass.geom, NONE, 1.1

Frederic Bouvier <[email protected]>
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-serv18954/Shaders

Added Files:
	landmass-g.vert landmass.geom 
Log Message:
Use geometry shader to give more relief to landmass

--- NEW FILE "landmass-g.vert" ---
varying vec4 rawposIn;
varying vec3 NormalIn;
varying vec3 VTangentIn;
varying vec3 VBinormalIn;

attribute vec3 tangent;
attribute vec3 binormal;

void main(void)
{
	rawposIn = gl_Vertex;
	NormalIn = normalize(gl_Normal);
	VTangentIn = gl_NormalMatrix * tangent;
	VBinormalIn = gl_NormalMatrix * binormal;

	gl_FrontColor = gl_Color;
	gl_Position = ftransform();
	gl_TexCoord[0] = gl_TextureMatrix[0] * gl_MultiTexCoord0;
}

--- NEW FILE "landmass.geom" ---
#version 120
#extension GL_EXT_geometry_shader4 : enable

varying in vec4 rawposIn[];
varying in vec3 NormalIn[];
varying in vec3 VTangentIn[];
varying in vec3 VBinormalIn[];

varying out vec4 rawpos;
varying out vec4 ecPosition;
varying out vec3 VNormal;
varying out vec3 VTangent;
varying out vec3 VBinormal;
varying out vec3 Normal;
varying out vec4 constantColor;

uniform float canopy_height;

void createVertex(int i, int j, float offset, float s)
{
	rawpos = rawposIn[i] + offset * vec4(NormalIn[i], 0.0);
	ecPosition = gl_ModelViewMatrix * rawpos;
	if ( s == 0.0 )
	{
		vec4 v;
		if (j < i)
		{
			v = rawposIn[j] - rawposIn[i];
			Normal = normalize(cross( NormalIn[i], v.xyz ));
		}
		else
		{
			v = rawposIn[i] - rawposIn[j];
			Normal = normalize(cross( NormalIn[j], v.xyz ));
		}
	}
	else
	{
		Normal = NormalIn[i];
	}
	VNormal = normalize(gl_NormalMatrix * Normal);
	VTangent  = VTangentIn[i];
	VBinormal = VBinormalIn[i];

	gl_FrontColor = gl_FrontColorIn[i];
	constantColor = gl_FrontMaterial.emission
		+ gl_FrontColorIn[i] * (gl_LightModel.ambient + gl_LightSource[0].ambient);  
	gl_Position = gl_ProjectionMatrix * ecPosition;
	gl_TexCoord[0] = gl_TexCoordIn[i][0];
	EmitVertex();
}

void main(void)
{
	createVertex(0, 1, canopy_height, 0.0);
	createVertex(0, 1, 0.0, 0.0);
	createVertex(1, 0, canopy_height, 0.0);
	createVertex(1, 0, 0.0, 0.0);
	EndPrimitive();
	createVertex(1, 2, canopy_height, 0.0);
	createVertex(1, 2, 0.0, 0.0);
	createVertex(2, 1, canopy_height, 0.0);
	createVertex(2, 1, 0.0, 0.0);
	EndPrimitive();
	createVertex(2, 0, canopy_height, 0.0);
	createVertex(2, 0, 0.0, 0.0);
	createVertex(0, 2, canopy_height, 0.0);
	createVertex(0, 2, 0.0, 0.0);
	EndPrimitive();

	createVertex(0, 1, canopy_height, 1.0);
	createVertex(1, 2, canopy_height, 1.0);
	createVertex(2, 0, canopy_height, 1.0);
	EndPrimitive();
}


------------------------------------------------------------------------------
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
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.