Jason McKesson avatar Jason McKesson committed 6a5a1d2

Tut12: Gamma-correct lighting environment.

Comments (0)

Files changed (1)

Tut 12 Dynamic Range/Gamma Correction.cpp

 	g_lights.SetPointLightIntensity(2, glm::vec4(0.7f, 0.0f, 0.0f, 1.0f));
 }
 
+void SetupGammaLighting()
+{
+	glm::vec4 sunlight(6.5f, 6.5f, 6.5f, 1.0f);
+	glm::vec4 brightAmbient(0.4f, 0.4f, 0.4f, 1.0f);
+
+	SunlightValueHDR values[] =
+	{
+		{ 0.0f/24.0f, brightAmbient, sunlight, glm::vec4(0.65f, 0.65f, 1.0f, 1.0f), 10.0f},
+		{ 4.5f/24.0f, brightAmbient, sunlight, g_skyDaylightColor, 10.0f},
+		{ 6.5f/24.0f, glm::vec4(0.01f, 0.025f, 0.025f, 1.0f), glm::vec4(2.5f, 0.2f, 0.2f, 1.0f), glm::vec4(0.5f, 0.1f, 0.1f, 1.0f), 5.0f},
+		{ 8.0f/24.0f, glm::vec4(0.0f, 0.0f, 0.0f, 1.0f), glm::vec4(0.0f, 0.0f, 0.0f, 1.0f), glm::vec4(0.0f, 0.0f, 0.0f, 1.0f), 3.0f},
+		{18.0f/24.0f, glm::vec4(0.0f, 0.0f, 0.0f, 1.0f), glm::vec4(0.0f, 0.0f, 0.0f, 1.0f), glm::vec4(0.0f, 0.0f, 0.0f, 1.0f), 3.0f},
+		{19.5f/24.0f, glm::vec4(0.01f, 0.025f, 0.025f, 1.0f), glm::vec4(2.5f, 0.2f, 0.2f, 1.0f), glm::vec4(0.5f, 0.1f, 0.1f, 1.0f), 5.0f},
+		{20.5f/24.0f, brightAmbient, sunlight, g_skyDaylightColor, 10.0f},
+	};
+
+	g_lights.SetSunlightValues(values, 7);
+
+	g_lights.SetPointLightIntensity(0, glm::vec4(0.6f, 0.6f, 0.6f, 1.0f));
+	g_lights.SetPointLightIntensity(1, glm::vec4(0.0f, 0.0f, 0.7f, 1.0f));
+	g_lights.SetPointLightIntensity(2, glm::vec4(0.7f, 0.0f, 0.0f, 1.0f));
+}
+
 Scene *g_pScene = NULL;
 
 //Called after the window and OpenGL are initialized. Called exactly once, before the main loop.
 	case '2': g_eTimerMode = TIMER_SUN; printf("Sun\n"); break;
 	case '3': g_eTimerMode = TIMER_LIGHTS; printf("Lights\n"); break;
 
-	case 'l':
+	case 'l': SetupHDRLighting(); break;
+	case 'L': SetupGammaLighting(); break;
+
+	case 'k':
 		g_isGammaCorrect = !g_isGammaCorrect;
 		if(g_isGammaCorrect)
 			printf("Gamma on!\n");
 			printf("Gamma off!\n");
 		break;
 
+	case 'y':
+		g_gammaValue += 0.1f;
+		printf("Gamma: %f\n", g_gammaValue);
+		break;
+	case 'h':
+		g_gammaValue -= 0.1f;
+		if(g_gammaValue < 1.0f)
+			g_gammaValue = 1.0f;
+		printf("Gamma: %f\n", g_gammaValue);
+		break;
+
 	case 32:
 		{
 			float sunAlpha = g_lights.GetSunTime();
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.