Commits

Jason McKesson  committed 6354392

Tut12: Lighting properly established.

  • Participants
  • Parent commits 2aa4061

Comments (0)

Files changed (4)

File Tut 12 Dynamic Range/Lights.cpp

 }
 
 LightManager::LightManager()
-	: m_sunTimer(Framework::Timer::TT_LOOP, 5.0f)
+	: m_sunTimer(Framework::Timer::TT_LOOP, 30.0f)
 	, m_ambientInterpolator()
 {
 	m_lightTimers.reserve(NUMBER_OF_POINT_LIGHTS);
 {
 	return m_backgroundInterpolator.Interpolate(m_sunTimer.GetAlpha());
 }
+
+float LightManager::GetSunTime() const
+{
+	return m_sunTimer.GetAlpha();
+}

File Tut 12 Dynamic Range/Lights.h

 
 	void CreateTimer(const std::string &timerName, Framework::Timer::Type eType, float fDuration);
 	float GetTimerValue(const std::string &timerName) const;
+	float GetSunTime() const;
 
 private:
 	typedef Framework::ConstVelLinearInterpolator<glm::vec3> LightInterpolator;

File Tut 12 Dynamic Range/Scene Lighting.cpp

 	materials[0].specularShininess = 0.6f;
 
 	//Tetrahedron
-	materials[1].diffuseColor = glm::vec4(1.0f);
+	materials[1].diffuseColor = glm::vec4(0.5f);
 	materials[1].specularColor = glm::vec4(0.5f, 0.5f, 0.5f, 1.0f);
 	materials[1].specularShininess = 0.05f;
 
 	//Monolith
-	materials[2].diffuseColor = glm::vec4(1.0f);
-	materials[2].specularColor = glm::vec4(0.5f, 0.5f, 0.5f, 1.0f);
-	materials[2].specularShininess = 0.6f;
+	materials[2].diffuseColor = glm::vec4(0.05f);
+	materials[2].specularColor = glm::vec4(0.95f, 0.95f, 0.95f, 1.0f);
+	materials[2].specularShininess = 0.4f;
 
 	//Cube
-	materials[3].diffuseColor = glm::vec4(1.0f);
-	materials[3].specularColor = glm::vec4(0.5f, 0.5f, 0.5f, 1.0f);
-	materials[3].specularShininess = 0.6f;
+	materials[3].diffuseColor = glm::vec4(0.5f);
+	materials[3].specularColor = glm::vec4(0.3f, 0.3f, 0.3f, 1.0f);
+	materials[3].specularShininess = 0.1f;
 
 	//Cylinder
-	materials[4].diffuseColor = glm::vec4(1.0f);
-	materials[4].specularColor = glm::vec4(0.5f, 0.5f, 0.5f, 1.0f);
+	materials[4].diffuseColor = glm::vec4(0.5f);
+	materials[4].specularColor = glm::vec4(0.0f, 0.0f, 0.0f, 1.0f);
 	materials[4].specularShininess = 0.6f;
 
-	//Sphere
-	materials[5].diffuseColor = glm::vec4(1.0f);
-	materials[5].specularColor = glm::vec4(0.5f, 0.5f, 0.5f, 1.0f);
-	materials[5].specularShininess = 0.6f;
+	//Sphere 85/80/02
+	materials[5].diffuseColor = glm::vec4(0.63f, 0.60f, 0.02f, 1.0f);
+	materials[5].specularColor = glm::vec4(0.22f, 0.20f, 0.0f, 1.0f);
+	materials[5].specularShininess = 0.3f;
 }
 
 GLuint g_lightUniformBuffer;
 	glBufferData(GL_UNIFORM_BUFFER, sizeMaterialUniformBuffer, bufferPtr, GL_STATIC_DRAW);
 }
 
-void SetupLighting()
+bool g_daytimeLighting = false;
+
+const glm::vec4 g_skyDaylightColor = glm::vec4(0.65f, 0.65f, 1.0f, 1.0f);
+
+void SetupDaytimeLighting()
 {
+	g_daytimeLighting = true;
+
+	SunlightValue values[] =
+	{
+		{ 0.0f/24.0f, glm::vec4(0.2f, 0.2f, 0.2f, 1.0f), glm::vec4(0.6f, 0.6f, 0.6f, 1.0f), g_skyDaylightColor},
+		{ 4.5f/24.0f, glm::vec4(0.2f, 0.2f, 0.2f, 1.0f), glm::vec4(0.6f, 0.6f, 0.6f, 1.0f), g_skyDaylightColor},
+		{ 6.5f/24.0f, glm::vec4(0.15f, 0.05f, 0.05f, 1.0f), glm::vec4(0.3f, 0.1f, 0.10f, 1.0f), glm::vec4(0.5f, 0.1f, 0.1f, 1.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)},
+		{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)},
+		{19.5f/24.0f, glm::vec4(0.15f, 0.05f, 0.05f, 1.0f), glm::vec4(0.3f, 0.1f, 0.1f, 1.0f), glm::vec4(0.5f, 0.1f, 0.1f, 1.0f)},
+		{20.5f/24.0f, glm::vec4(0.2f, 0.2f, 0.2f, 1.0f), glm::vec4(0.6f, 0.6f, 0.6f, 1.0f), g_skyDaylightColor},
+	};
+
+	g_lights.SetSunlightValues(values, 7);
+
+	g_lights.SetPointLightIntensity(0, glm::vec4(0.05f, 0.05f, 0.05f, 1.0f));
+	g_lights.SetPointLightIntensity(1, glm::vec4(0.0f, 0.0f, 0.1f, 1.0f));
+	g_lights.SetPointLightIntensity(2, glm::vec4(0.1f, 0.0f, 0.0f, 1.0f));
+}
+
+void SetupNighttimeLighting()
+{
+	g_daytimeLighting = false;
+
 	SunlightValue values[] =
 	{
 		{0.0f, glm::vec4(0.2f, 0.2f, 0.2f, 1.0f), glm::vec4(0.4f, 0.4f, 0.4f, 1.0f), glm::vec4(0.9f, 0.9f, 1.0f, 1.0f)},
 		throw;
 	}
 
-	SetupLighting();
+	SetupDaytimeLighting();
 
 	g_lights.CreateTimer("tetra", Framework::Timer::TT_LOOP, 2.5f);
 
 		
 	case 'b': g_lights.TogglePause(); break;
 	case 'B': g_lights.ToggleSunPause(); break;
-	case 'g': g_lights.RewindTime(1.0f); break;
-	case 'G': g_lights.FastForwardTime(1.0f); break;
+	case '-': g_lights.RewindTime(1.0f); break;
+	case '=': g_lights.FastForwardTime(1.0f); break;
 	case 't': g_bDrawCameraPos = !g_bDrawCameraPos; break;
 
+	case 'l':
+		if(g_daytimeLighting)
+			SetupNighttimeLighting();
+		else
+			SetupDaytimeLighting();
+		break;
+
 	case 32:
-		printf("%f\n", 360.0f * g_lights.GetTimerValue("tetra"));
+		printf("%f\n", g_lights.GetSunTime());
 		break;
 	}
 

File Tut 12 Dynamic Range/data/DiffuseSpecularMtl.frag

 	exponent = -(exponent * exponent);
 	float gaussianTerm = exp(exponent);
 
-	gaussianTerm = cosAngIncidence != 0.0001 ? gaussianTerm : 0.0;
+	gaussianTerm = cosAngIncidence != 0.0 ? gaussianTerm : 0.0;
 	
 	vec4 lighting = Mtl.diffuseColor * lightIntensity * cosAngIncidence;
 	lighting += Mtl.specularColor * lightIntensity * gaussianTerm;