Jason McKesson avatar Jason McKesson committed 7a19715

Tut13: renamed some impostor files.

Comments (0)

Files changed (5)

Tut 13 Imposters/BasicImposter.cpp

 
 const char *g_impShaderNames[IMP_NUM_IMPOSTORS * 2] =
 {
-	"BasicImposter.vert", "BasicImposter.frag",
+	"BasicImpostor.vert", "BasicImpostor.frag",
  	"PerspImpostor.vert", "PerspImpostor.frag",
  	"DepthImpostor.vert", "DepthImpostor.frag",
 };

Tut 13 Imposters/data/BasicImposter.frag

-#version 330
-
-in vec2 mapping;
-
-out vec4 outputColor;
-
-uniform float sphereRadius;
-uniform vec3 cameraSpherePos;
-
-layout(std140) uniform;
-
-uniform Material
-{
-	vec4 diffuseColor;
-	vec4 specularColor;
-	float specularShininess;
-} Mtl;
-
-struct PerLight
-{
-	vec4 cameraSpaceLightPos;
-	vec4 lightIntensity;
-};
-
-const int numberOfLights = 2;
-
-uniform Light
-{
-	vec4 ambientIntensity;
-	float lightAttenuation;
-	PerLight lights[numberOfLights];
-} Lgt;
-
-
-float CalcAttenuation(in vec3 cameraSpacePosition,
-	in vec3 cameraSpaceLightPos,
-	out vec3 lightDirection)
-{
-	vec3 lightDifference =  cameraSpaceLightPos - cameraSpacePosition;
-	float lightDistanceSqr = dot(lightDifference, lightDifference);
-	lightDirection = lightDifference * inversesqrt(lightDistanceSqr);
-	
-	return (1 / ( 1.0 + Lgt.lightAttenuation * lightDistanceSqr));
-}
-
-uniform Projection
-{
-	mat4 cameraToClipMatrix;
-};
-
-vec4 ComputeLighting(in PerLight lightData, in vec3 cameraSpacePosition,
-	in vec3 cameraSpaceNormal)
-{
-	vec3 lightDir;
-	vec4 lightIntensity;
-	if(lightData.cameraSpaceLightPos.w == 0.0)
-	{
-		lightDir = vec3(lightData.cameraSpaceLightPos);
-		lightIntensity = lightData.lightIntensity;
-	}
-	else
-	{
-		float atten = CalcAttenuation(cameraSpacePosition,
-			lightData.cameraSpaceLightPos.xyz, lightDir);
-		lightIntensity = atten * lightData.lightIntensity;
-	}
-	
-	vec3 surfaceNormal = normalize(cameraSpaceNormal);
-	float cosAngIncidence = dot(surfaceNormal, lightDir);
-	cosAngIncidence = cosAngIncidence < 0.0001 ? 0.0 : cosAngIncidence;
-	
-	vec3 viewDirection = normalize(-cameraSpacePosition);
-	
-	vec3 halfAngle = normalize(lightDir + viewDirection);
-	float angleNormalHalf = acos(dot(halfAngle, surfaceNormal));
-	float exponent = angleNormalHalf / Mtl.specularShininess;
-	exponent = -(exponent * exponent);
-	float gaussianTerm = exp(exponent);
-
-	gaussianTerm = cosAngIncidence != 0.0 ? gaussianTerm : 0.0;
-	
-	vec4 lighting = Mtl.diffuseColor * lightIntensity * cosAngIncidence;
-	lighting += Mtl.specularColor * lightIntensity * gaussianTerm;
-	
-	return lighting;
-}
-
-void Impostor(out vec3 cameraPos, out vec3 cameraNormal)
-{
-	float lensqr = dot(mapping, mapping);
-	if(lensqr > 1.0)
-		discard;
-		
-	cameraNormal = vec3(mapping, sqrt(1.0 - lensqr));
-	cameraPos = (cameraNormal * sphereRadius) + cameraSpherePos;
-}
-
-void main()
-{
-	vec3 cameraPos;
-	vec3 cameraNormal;
-	
-	Impostor(cameraPos, cameraNormal);
-	
-	vec4 accumLighting = Mtl.diffuseColor * Lgt.ambientIntensity;
-	for(int light = 0; light < numberOfLights; light++)
-	{
-		accumLighting += ComputeLighting(Lgt.lights[light],
-			cameraPos, cameraNormal);
-	}
-	
-	outputColor = sqrt(accumLighting); //2.0 gamma correction
-}

Tut 13 Imposters/data/BasicImposter.vert

-#version 330
-
-layout(std140) uniform;
-
-out vec2 mapping;
-
-uniform Projection
-{
-	mat4 cameraToClipMatrix;
-};
-
-uniform float sphereRadius;
-uniform vec3 cameraSpherePos;
-
-void main()
-{
-	vec2 offset;
-	switch(gl_VertexID)
-	{
-	case 0:
-		//Bottom-left
-		mapping = vec2(-1.0, -1.0);
-		offset = vec2(-sphereRadius, -sphereRadius);
-		break;
-	case 1:
-		//Top-left
-		mapping = vec2(-1.0, 1.0);
-		offset = vec2(-sphereRadius, sphereRadius);
-		break;
-	case 2:
-		//Bottom-right
-		mapping = vec2(1.0, -1.0);
-		offset = vec2(sphereRadius, -sphereRadius);
-		break;
-	case 3:
-		//Top-right
-		mapping = vec2(1.0, 1.0);
-		offset = vec2(sphereRadius, sphereRadius);
-		break;
-	}
-
-	vec4 cameraCornerPos = vec4(cameraSpherePos, 1.0);
-	cameraCornerPos.xy += offset;
-
-	gl_Position = cameraToClipMatrix * cameraCornerPos;
-}

Tut 13 Imposters/data/BasicImpostor.frag

+#version 330
+
+in vec2 mapping;
+
+out vec4 outputColor;
+
+uniform float sphereRadius;
+uniform vec3 cameraSpherePos;
+
+layout(std140) uniform;
+
+uniform Material
+{
+	vec4 diffuseColor;
+	vec4 specularColor;
+	float specularShininess;
+} Mtl;
+
+struct PerLight
+{
+	vec4 cameraSpaceLightPos;
+	vec4 lightIntensity;
+};
+
+const int numberOfLights = 2;
+
+uniform Light
+{
+	vec4 ambientIntensity;
+	float lightAttenuation;
+	PerLight lights[numberOfLights];
+} Lgt;
+
+
+float CalcAttenuation(in vec3 cameraSpacePosition,
+	in vec3 cameraSpaceLightPos,
+	out vec3 lightDirection)
+{
+	vec3 lightDifference =  cameraSpaceLightPos - cameraSpacePosition;
+	float lightDistanceSqr = dot(lightDifference, lightDifference);
+	lightDirection = lightDifference * inversesqrt(lightDistanceSqr);
+	
+	return (1 / ( 1.0 + Lgt.lightAttenuation * lightDistanceSqr));
+}
+
+uniform Projection
+{
+	mat4 cameraToClipMatrix;
+};
+
+vec4 ComputeLighting(in PerLight lightData, in vec3 cameraSpacePosition,
+	in vec3 cameraSpaceNormal)
+{
+	vec3 lightDir;
+	vec4 lightIntensity;
+	if(lightData.cameraSpaceLightPos.w == 0.0)
+	{
+		lightDir = vec3(lightData.cameraSpaceLightPos);
+		lightIntensity = lightData.lightIntensity;
+	}
+	else
+	{
+		float atten = CalcAttenuation(cameraSpacePosition,
+			lightData.cameraSpaceLightPos.xyz, lightDir);
+		lightIntensity = atten * lightData.lightIntensity;
+	}
+	
+	vec3 surfaceNormal = normalize(cameraSpaceNormal);
+	float cosAngIncidence = dot(surfaceNormal, lightDir);
+	cosAngIncidence = cosAngIncidence < 0.0001 ? 0.0 : cosAngIncidence;
+	
+	vec3 viewDirection = normalize(-cameraSpacePosition);
+	
+	vec3 halfAngle = normalize(lightDir + viewDirection);
+	float angleNormalHalf = acos(dot(halfAngle, surfaceNormal));
+	float exponent = angleNormalHalf / Mtl.specularShininess;
+	exponent = -(exponent * exponent);
+	float gaussianTerm = exp(exponent);
+
+	gaussianTerm = cosAngIncidence != 0.0 ? gaussianTerm : 0.0;
+	
+	vec4 lighting = Mtl.diffuseColor * lightIntensity * cosAngIncidence;
+	lighting += Mtl.specularColor * lightIntensity * gaussianTerm;
+	
+	return lighting;
+}
+
+void Impostor(out vec3 cameraPos, out vec3 cameraNormal)
+{
+	float lensqr = dot(mapping, mapping);
+	if(lensqr > 1.0)
+		discard;
+		
+	cameraNormal = vec3(mapping, sqrt(1.0 - lensqr));
+	cameraPos = (cameraNormal * sphereRadius) + cameraSpherePos;
+}
+
+void main()
+{
+	vec3 cameraPos;
+	vec3 cameraNormal;
+	
+	Impostor(cameraPos, cameraNormal);
+	
+	vec4 accumLighting = Mtl.diffuseColor * Lgt.ambientIntensity;
+	for(int light = 0; light < numberOfLights; light++)
+	{
+		accumLighting += ComputeLighting(Lgt.lights[light],
+			cameraPos, cameraNormal);
+	}
+	
+	outputColor = sqrt(accumLighting); //2.0 gamma correction
+}

Tut 13 Imposters/data/BasicImpostor.vert

+#version 330
+
+layout(std140) uniform;
+
+out vec2 mapping;
+
+uniform Projection
+{
+	mat4 cameraToClipMatrix;
+};
+
+uniform float sphereRadius;
+uniform vec3 cameraSpherePos;
+
+void main()
+{
+	vec2 offset;
+	switch(gl_VertexID)
+	{
+	case 0:
+		//Bottom-left
+		mapping = vec2(-1.0, -1.0);
+		offset = vec2(-sphereRadius, -sphereRadius);
+		break;
+	case 1:
+		//Top-left
+		mapping = vec2(-1.0, 1.0);
+		offset = vec2(-sphereRadius, sphereRadius);
+		break;
+	case 2:
+		//Bottom-right
+		mapping = vec2(1.0, -1.0);
+		offset = vec2(sphereRadius, -sphereRadius);
+		break;
+	case 3:
+		//Top-right
+		mapping = vec2(1.0, 1.0);
+		offset = vec2(sphereRadius, sphereRadius);
+		break;
+	}
+
+	vec4 cameraCornerPos = vec4(cameraSpherePos, 1.0);
+	cameraCornerPos.xy += offset;
+
+	gl_Position = cameraToClipMatrix * cameraCornerPos;
+}
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.