Commits

Jason McKesson  committed f3814ca

Tut12 remains broken.

  • Participants
  • Parent commits dc6446f

Comments (0)

Files changed (6)

File Tut 12 Dynamic Range/Scene Lighting.cpp

 
 enum LightingModel
 {
-	LM_PHONG_SPECULAR = 0,
-	LM_PHONG_ONLY,
-	LM_BLINN_SPECULAR,
-	LM_BLINN_ONLY,
-	LM_GAUSSIAN_SPECULAR,
+	LM_GAUSSIAN_SPECULAR = 0,
 	LM_GAUSSIAN_ONLY,
 
 	LM_MAX_LIGHTING_MODEL,
 {
 	{"PN.vert", "PCN.vert", "GaussianLighting.frag"},
 	{"PN.vert", "PCN.vert", "GaussianOnly.frag"},
-	{"PN.vert", "PCN.vert", "GaussianLighting.frag"},
-	{"PN.vert", "PCN.vert", "GaussianOnly.frag"},
-	{"PN.vert", "PCN.vert", "GaussianLighting.frag"},
-	{"PN.vert", "PCN.vert", "GaussianOnly.frag"},
 };
 
 UnlitProgData g_Unlit;
 	{
 		switch(g_eLightModel)
 		{
-		case LM_PHONG_SPECULAR:
-		case LM_PHONG_ONLY:
-			return m_fPhongExponent;
-		case LM_BLINN_SPECULAR:
-		case LM_BLINN_ONLY:
-			return m_fBlinnExponent;
 		case LM_GAUSSIAN_SPECULAR:
 		case LM_GAUSSIAN_ONLY:
 			return m_fGaussianRoughness;
 	{
 		switch(g_eLightModel)
 		{
-		case LM_PHONG_SPECULAR:
-		case LM_PHONG_ONLY:
-			return m_fPhongExponent;
-		case LM_BLINN_SPECULAR:
-		case LM_BLINN_ONLY:
-			return m_fBlinnExponent;
 		case LM_GAUSSIAN_SPECULAR:
 		case LM_GAUSSIAN_ONLY:
 			return m_fGaussianRoughness;
 
 static const char *strLightModelNames[] =
 {
-	"Phong Specular.",
-	"Phong Only",
-	"Blinn Specular.",
-	"Blinn Only",
 	"Gaussian Specular.",
 	"Gaussian Only",
 };
 	case 'b': g_bRotateLight = !g_bRotateLight; break;
 	case 'g': g_bDrawDark = !g_bDrawDark; break;
 	case 'h':
-		g_eLightModel += 2;
-		g_eLightModel %= LM_MAX_LIGHTING_MODEL;
-		bChangedLightModel = true;
-		break;
-	case 'H':
 		if(g_eLightModel % 2)
 			g_eLightModel -= 1;
 		else

File Tut 12 Dynamic Range/data/GaussianLighting.frag

 uniform float shininessFactor;
 
 
-float CalcAttenuation(in vec3 cameraSpacePosition, out vec3 lightDirection)
-{
-	vec3 lightDifference =  cameraSpaceLightPos - cameraSpacePosition;
-	float lightDistanceSqr = dot(lightDifference, lightDifference);
-	lightDirection = lightDifference * inversesqrt(lightDistanceSqr);
-	
-	return (1 / ( 1.0 + lightAttenuation * sqrt(lightDistanceSqr)));
-}
-
 void main()
 {
-	vec3 lightDir = vec3(0.0);
-	float atten = CalcAttenuation(cameraSpacePosition, lightDir);
-	vec4 attenIntensity = atten * lightIntensity;
-	
+	vec3 lightDir = normalize(cameraSpaceLightPos - cameraSpacePosition);
 	vec3 surfaceNormal = normalize(vertexNormal);
-	float cosAngIncidence = dot(surfaceNormal, lightDir);
-	cosAngIncidence = clamp(cosAngIncidence, 0, 1);
-	
-	vec3 viewDirection = normalize(-cameraSpacePosition);
-	
-	vec3 halfAngle = normalize(lightDir + viewDirection);
-	float angleNormalHalf = acos(dot(halfAngle, surfaceNormal));
-	float exponent = angleNormalHalf / shininessFactor;
-	exponent = -(exponent * exponent);
-	float gaussianTerm = exp(exponent);
-
-	gaussianTerm = cosAngIncidence != 0.0 ? gaussianTerm : 0.0;
-
 	outputColor = vec4(dot(surfaceNormal, lightDir));
-//	outputColor = (diffuseColor * attenIntensity *  cosAngIncidence) +
-//		(specularColor * attenIntensity * gaussianTerm) +
-//		(diffuseColor * ambientIntensity);
 }

File Tut 12 Dynamic Range/data/GaussianOnly.frag

 uniform float shininessFactor;
 
 
-float CalcAttenuation(in vec3 cameraSpacePosition, out vec3 lightDirection)
-{
-	vec3 lightDifference =  cameraSpaceLightPos - cameraSpacePosition;
-	float lightDistanceSqr = dot(lightDifference, lightDifference);
-	lightDirection = lightDifference * inversesqrt(lightDistanceSqr);
-	
-	return (1 / ( 1.0 + lightAttenuation * sqrt(lightDistanceSqr)));
-}
-
 void main()
 {
-	vec3 lightDir = vec3(0.0);
-	float atten = CalcAttenuation(cameraSpacePosition, lightDir);
-	vec4 attenIntensity = atten * lightIntensity;
-	
-	vec3 surfaceNormal = normalize(vertexNormal);
-	
-	vec3 viewDirection = normalize(-cameraSpacePosition);
-	
-	vec3 halfAngle = normalize(lightDir + viewDirection);
-	float angleNormalHalf = acos(dot(halfAngle, surfaceNormal));
-	float exponent = angleNormalHalf / shininessFactor;
-	exponent = -(exponent * exponent);
-	float gaussianTerm = exp(exponent);
-
-	gaussianTerm = dot(surfaceNormal, lightDir) >= 0.0 ? gaussianTerm : 0.0;
-
-	outputColor = vec4(normalize(vertexNormal), 1.0);
-//	outputColor = (specularColor * attenIntensity * gaussianTerm) + 
-//		(diffuseColor * ambientIntensity)
-//		vec4(0.0, 0.0, surfaceNormal.y, 1.0f);
+	outputColor = vec4(normalize(modelSpaceNormal), 1.0);
 }

File Tut 12 Dynamic Range/data/PN.vert

 	vec4 tempCamPosition = (modelToCameraMatrix * vec4(position, 1.0));
 	gl_Position = cameraToClipMatrix * tempCamPosition;
 
-	vertexNormal = normalModelToCameraMatrix * normal;
+	vertexNormal = normalize(normalModelToCameraMatrix * normal);
 	modelSpaceNormal = normalize(normal);
 	diffuseColor = baseDiffuseColor;
 	cameraSpacePosition = vec3(tempCamPosition);

File Tut 12 Dynamic Range/data/PosTransform.vert

+#version 330
+
+layout(location = 0) in vec3 position;
+
+uniform mat4 cameraToClipMatrix;
+uniform mat4 modelToCameraMatrix;
+
+void main()
+{
+	gl_Position = cameraToClipMatrix * (modelToCameraMatrix * vec4(position, 1.0));
+}

File Tut 12 Dynamic Range/data/UniformColor.frag

+#version 330
+
+uniform vec4 objectColor;
+
+out vec4 outputColor;
+
+void main()
+{
+	outputColor = objectColor;
+}