Specular maps working.
This commit is contained in:
+2
-4
@@ -49,14 +49,14 @@ void GameWorld::Initialize()
|
||||
|
||||
AddComponent<Components::Input>(jeep, "Input");
|
||||
|
||||
for(int i = 0; i < 5; i++)
|
||||
for(int i = 0; i < 1; i++)
|
||||
{
|
||||
auto Light = CreateEntity(jeep);
|
||||
auto transform = AddComponent<Components::Transform>(Light, "Transform");
|
||||
transform->Position = glm::vec3((5+(i/2.f))*cos(i/5.0f), 0.3f, 0 + (5+(i/5.f))*sin(i/2.0f));
|
||||
auto light = AddComponent<Components::PointLight>(Light, "PointLight");
|
||||
light->Specular = glm::vec3(1.0f, 1.0f, 1.0f);
|
||||
light->Diffuse = glm::vec3((float)(rand()%255)/255.f, (float)(rand()%255)/255.f, (float)(rand()%255)/255.f);
|
||||
light->Diffuse = glm::vec3(1.0f, 1.0f, 1.0f);
|
||||
auto model = AddComponent<Components::Model>(Light, "Model");
|
||||
model->ModelFile = "Models/Placeholders/PhysicsTest/PointLight.obj";
|
||||
}
|
||||
@@ -236,8 +236,6 @@ void GameWorld::Initialize()
|
||||
}
|
||||
*/
|
||||
|
||||
|
||||
|
||||
for(int i = 0; i < 10; i++)
|
||||
{
|
||||
auto cube = CreateEntity();
|
||||
|
||||
+16
-9
@@ -536,7 +536,7 @@ void Renderer::FrameBufferTextures()
|
||||
//Generate and bind position texture
|
||||
glGenTextures(1, &m_fPositionTexture);
|
||||
glBindTexture(GL_TEXTURE_2D, m_fPositionTexture);
|
||||
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA32F, WIDTH, HEIGHT, 0, GL_RGBA, GL_UNSIGNED_BYTE, NULL);
|
||||
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGB16F, WIDTH, HEIGHT, 0, GL_RGB, GL_UNSIGNED_BYTE, NULL);
|
||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
|
||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
|
||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT);
|
||||
@@ -545,7 +545,7 @@ void Renderer::FrameBufferTextures()
|
||||
//Generate and bind normal texture
|
||||
glGenTextures(1, &m_fNormalsTexture);
|
||||
glBindTexture(GL_TEXTURE_2D, m_fNormalsTexture);
|
||||
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGB10_A2, WIDTH, HEIGHT, 0, GL_RGBA, GL_UNSIGNED_BYTE, NULL);
|
||||
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGB, WIDTH, HEIGHT, 0, GL_RGB, GL_UNSIGNED_BYTE, NULL);
|
||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
|
||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
|
||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT);
|
||||
@@ -554,7 +554,7 @@ void Renderer::FrameBufferTextures()
|
||||
//Generate and bind normal texture
|
||||
glGenTextures(1, &m_fSpecularTexture);
|
||||
glBindTexture(GL_TEXTURE_2D, m_fSpecularTexture);
|
||||
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGB10_A2, WIDTH, HEIGHT, 0, GL_RGBA, GL_UNSIGNED_BYTE, NULL);
|
||||
glTexImage2D(GL_TEXTURE_2D, 0, GL_R8, WIDTH, HEIGHT, 0, GL_RED, GL_UNSIGNED_BYTE, NULL);
|
||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
|
||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
|
||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT);
|
||||
@@ -621,15 +621,15 @@ void Renderer::DrawFBO()
|
||||
glBindFramebuffer(GL_DRAW_FRAMEBUFFER, m_fbBasePass);
|
||||
|
||||
// Clear G-buffer
|
||||
GLenum windowBuffClear[] = { GL_COLOR_ATTACHMENT0, GL_COLOR_ATTACHMENT1, GL_COLOR_ATTACHMENT2 };
|
||||
glDrawBuffers(3, windowBuffClear);
|
||||
glClearColor(0.f, 0.f, 0.f, 0.f);
|
||||
GLenum windowBuffClear[] = { GL_COLOR_ATTACHMENT0, GL_COLOR_ATTACHMENT1, GL_COLOR_ATTACHMENT2, GL_COLOR_ATTACHMENT3 };
|
||||
glDrawBuffers(4, windowBuffClear);
|
||||
glClearColor(0.5f, 0.f, 0.f, 0.f);
|
||||
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
|
||||
|
||||
// Execute the first render stage which will fill out the internal buffers with data(??)
|
||||
m_FirstPassProgram.Bind();
|
||||
GLenum windowBuffOpaque[] = { GL_COLOR_ATTACHMENT0, GL_COLOR_ATTACHMENT1, GL_COLOR_ATTACHMENT2 };
|
||||
glDrawBuffers(3, windowBuffOpaque);
|
||||
GLenum windowBuffOpaque[] = { GL_COLOR_ATTACHMENT0, GL_COLOR_ATTACHMENT1, GL_COLOR_ATTACHMENT2, GL_COLOR_ATTACHMENT3 };
|
||||
glDrawBuffers(4, windowBuffOpaque);
|
||||
|
||||
glCullFace(GL_BACK);
|
||||
|
||||
@@ -651,6 +651,8 @@ void Renderer::DrawFBO()
|
||||
glBindTexture(GL_TEXTURE_2D, m_fPositionTexture);
|
||||
glActiveTexture(GL_TEXTURE1);
|
||||
glBindTexture(GL_TEXTURE_2D, m_fNormalsTexture);
|
||||
glActiveTexture(GL_TEXTURE2);
|
||||
glBindTexture(GL_TEXTURE_2D, m_fSpecularTexture);
|
||||
|
||||
glCullFace(GL_FRONT);
|
||||
DrawLightScene();
|
||||
@@ -664,7 +666,7 @@ void Renderer::DrawFBO()
|
||||
m_FinalPassProgram.Bind();
|
||||
|
||||
// Ambient light
|
||||
glUniform3fv(glGetUniformLocation(m_FinalPassProgram.GetHandle(), "La"), 1, glm::value_ptr(glm::vec3(0.1f, 0.1f, 0.1f)));
|
||||
glUniform3fv(glGetUniformLocation(m_FinalPassProgram.GetHandle(), "La"), 1, glm::value_ptr(glm::vec3(0.4f, 0.4f, 0.4f)));
|
||||
glUniform1f(glGetUniformLocation(m_FinalPassProgram.GetHandle(), "Gamma"), Gamma);
|
||||
|
||||
glActiveTexture(GL_TEXTURE0);
|
||||
@@ -728,6 +730,11 @@ void Renderer::DrawFBOScene()
|
||||
glActiveTexture(GL_TEXTURE2);
|
||||
glBindTexture(GL_TEXTURE_2D, *texGroup.NormalMap);
|
||||
}
|
||||
if (texGroup.SpecularMap)
|
||||
{
|
||||
glActiveTexture(GL_TEXTURE3);
|
||||
glBindTexture(GL_TEXTURE_2D, *texGroup.SpecularMap);
|
||||
}
|
||||
glDrawArrays(GL_TRIANGLES, texGroup.StartIndex, texGroup.EndIndex - texGroup.StartIndex + 1);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -22,8 +22,10 @@ void main()
|
||||
vec4 ShadowTexel = texture(ShadowTexture, Input.TextureCoord);
|
||||
|
||||
|
||||
vec4 _FragmentColor = DiffuseTexel * vec4(La, 1.0) + LightingTexel;
|
||||
FragmentColor = vec4(pow(_FragmentColor.rgb, vec3(1.0 / Gamma)), _FragmentColor.a);
|
||||
FragmentColor = DiffuseTexel * (LightingTexel + vec4(La, 0.0));
|
||||
//FragmentColor = vec4(pow(_FragmentColor.rgb, vec3(1.0 / Gamma)), _FragmentColor.a);
|
||||
|
||||
//FragmentColor = DiffuseTexel;
|
||||
//FragmentColor = DiffuseTexel;
|
||||
|
||||
}
|
||||
@@ -19,7 +19,7 @@ in VertexData
|
||||
out vec4 frag_Diffuse;
|
||||
out vec4 frag_Position;
|
||||
out vec4 frag_Normal;
|
||||
out vec4 frag_specular;
|
||||
out vec4 frag_Specular;
|
||||
|
||||
float Shadow(vec4 ShadowCoord)
|
||||
{
|
||||
@@ -51,5 +51,5 @@ void main()
|
||||
//frag_Normal = vec4(Input.Normal, 0.0);
|
||||
|
||||
//G-buffer Specular
|
||||
frag_specular = texture(SpecularMapTexture, Input.TextureCoord);
|
||||
frag_Specular = texture(SpecularMapTexture, Input.TextureCoord);
|
||||
}
|
||||
@@ -2,6 +2,7 @@
|
||||
|
||||
layout (binding=0) uniform sampler2D PositionTexture;
|
||||
layout (binding=1) uniform sampler2D NormalsTexture;
|
||||
layout (binding=2) uniform sampler2D SpecularTexture;
|
||||
|
||||
uniform vec2 ViewportSize;
|
||||
uniform mat4 MVP;
|
||||
@@ -22,6 +23,7 @@ const vec3 ks = vec3(1.0, 1.0, 1.0);
|
||||
const vec3 kd = vec3(1.0, 1.0, 1.0);
|
||||
const vec3 ka = vec3(1.0, 1.0, 1.0);
|
||||
const float kshine = 1.0;
|
||||
const float LRadius = 5.0;
|
||||
|
||||
in VertexData
|
||||
{
|
||||
@@ -31,7 +33,7 @@ in VertexData
|
||||
|
||||
out vec4 FragColor;
|
||||
|
||||
vec4 phong(vec3 position, vec3 normal)
|
||||
vec4 phong(vec3 position, vec3 normal, vec3 specular)
|
||||
{
|
||||
// Diffuse
|
||||
vec3 lightPos = vec3(V * vec4(lp, 1.0));
|
||||
@@ -47,13 +49,15 @@ vec4 phong(vec3 position, vec3 normal)
|
||||
vec3 halfWay = normalize(surfaceToViewer + directionToLight);
|
||||
float dotSpecular = max(dot(halfWay, normal), 0.0);
|
||||
float specularFactor = pow(dotSpecular, specularExponent * 2.0);
|
||||
vec3 Is = ks * ls * specularFactor;
|
||||
vec3 Is = specular.r * ls * specularFactor;
|
||||
|
||||
//Attenuation
|
||||
float dist = distance(lightPos, position);
|
||||
//float attenuation = -log(min(1.0, dist / LightRadius));
|
||||
|
||||
float attenuation = 1.0 / (ConstantAttenuation + (LinearAttenuation * dist) + (QuadraticAttenuation * dist * dist));
|
||||
//float attenuation = 1.0 / (ConstantAttenuation + (LinearAttenuation * dist) + (QuadraticAttenuation * dist * dist));
|
||||
|
||||
float attenuation = pow(max(0.0f, 1.0 - (dist / LRadius)), 2);
|
||||
|
||||
//float attenuation = 1.0 / (1.0 - 0.0001 * pow(dist, 2));
|
||||
|
||||
@@ -79,7 +83,8 @@ void main()
|
||||
vec2 TextureCoord = gl_FragCoord.xy / ViewportSize;
|
||||
vec4 PositionTexel = texture(PositionTexture, TextureCoord);
|
||||
vec4 NormalTexel = texture(NormalsTexture, TextureCoord);
|
||||
vec4 SpecularTexel = texture(SpecularTexture, TextureCoord);
|
||||
|
||||
FragColor = phong(vec3(PositionTexel), vec3(NormalTexel));
|
||||
FragColor = phong(vec3(PositionTexel), vec3(NormalTexel), vec3(SpecularTexel));
|
||||
//FragColor = NormalTexel;
|
||||
}
|
||||
@@ -39,4 +39,7 @@ Global
|
||||
GlobalSection(SolutionProperties) = preSolution
|
||||
HideSolutionNode = FALSE
|
||||
EndGlobalSection
|
||||
GlobalSection(Performance) = preSolution
|
||||
HasPerformanceSessions = true
|
||||
EndGlobalSection
|
||||
EndGlobal
|
||||
|
||||
@@ -0,0 +1,89 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<VSPerformanceSession Version="1.00">
|
||||
<Options>
|
||||
<Solution>Returngeance.sln</Solution>
|
||||
<CollectionMethod>Sampling</CollectionMethod>
|
||||
<AllocationMethod>None</AllocationMethod>
|
||||
<AddReport>true</AddReport>
|
||||
<ResourceBasedAnalysisSelected>true</ResourceBasedAnalysisSelected>
|
||||
<UniqueReport>Timestamp</UniqueReport>
|
||||
<SamplingMethod>Cycles</SamplingMethod>
|
||||
<CycleCount>10000000</CycleCount>
|
||||
<PageFaultCount>10</PageFaultCount>
|
||||
<SysCallCount>10</SysCallCount>
|
||||
<SamplingCounter Name="" ReloadValue="00000000000f4240" DisplayName="" />
|
||||
<RelocateBinaries>false</RelocateBinaries>
|
||||
<HardwareCounters EnableHWCounters="false" />
|
||||
<EtwSettings />
|
||||
<PdhSettings>
|
||||
<PdhCountersEnabled>false</PdhCountersEnabled>
|
||||
<PdhCountersRate>500</PdhCountersRate>
|
||||
<PdhCounters>
|
||||
<PdhCounter>\Memory\Pages/sec</PdhCounter>
|
||||
<PdhCounter>\PhysicalDisk(_Total)\Avg. Disk Queue Length</PdhCounter>
|
||||
<PdhCounter>\Processor(_Total)\% Processor Time</PdhCounter>
|
||||
</PdhCounters>
|
||||
</PdhSettings>
|
||||
</Options>
|
||||
<ExcludeSmallFuncs>true</ExcludeSmallFuncs>
|
||||
<InteractionProfilingEnabled>false</InteractionProfilingEnabled>
|
||||
<JScriptProfilingEnabled>false</JScriptProfilingEnabled>
|
||||
<PreinstrumentEvent>
|
||||
<InstrEventExclude>false</InstrEventExclude>
|
||||
</PreinstrumentEvent>
|
||||
<PostinstrumentEvent>
|
||||
<InstrEventExclude>false</InstrEventExclude>
|
||||
</PostinstrumentEvent>
|
||||
<Binaries>
|
||||
<ProjBinary>
|
||||
<Path>bin\Debug\Returngeance.exe</Path>
|
||||
<ArgumentTimestamp>01/01/0001 00:00:00</ArgumentTimestamp>
|
||||
<Instrument>true</Instrument>
|
||||
<Sample>true</Sample>
|
||||
<ExternalWebsite>false</ExternalWebsite>
|
||||
<InteractionProfilingEnabled>false</InteractionProfilingEnabled>
|
||||
<IsLocalJavascript>false</IsLocalJavascript>
|
||||
<IsWindowsStoreApp>false</IsWindowsStoreApp>
|
||||
<IsWWA>false</IsWWA>
|
||||
<LaunchProject>true</LaunchProject>
|
||||
<OverrideProjectSettings>false</OverrideProjectSettings>
|
||||
<LaunchMethod>Executable</LaunchMethod>
|
||||
<ExecutablePath>bin\Debug\Returngeance.exe</ExecutablePath>
|
||||
<StartupDirectory>..\bin\Debug</StartupDirectory>
|
||||
<Arguments>
|
||||
</Arguments>
|
||||
<NetAppHost>IIS</NetAppHost>
|
||||
<NetBrowser>InternetExplorer</NetBrowser>
|
||||
<ExcludeSmallFuncs>true</ExcludeSmallFuncs>
|
||||
<JScriptProfilingEnabled>false</JScriptProfilingEnabled>
|
||||
<PreinstrumentEvent>
|
||||
<InstrEventExclude>false</InstrEventExclude>
|
||||
</PreinstrumentEvent>
|
||||
<PostinstrumentEvent>
|
||||
<InstrEventExclude>false</InstrEventExclude>
|
||||
</PostinstrumentEvent>
|
||||
<ProjRef>{E8B4A2A2-882B-402A-98A7-8B4F7233C8B3}|Returngeance\Returngeance.vcxproj</ProjRef>
|
||||
<ProjPath>Returngeance\Returngeance.vcxproj</ProjPath>
|
||||
<ProjName>Returngeance</ProjName>
|
||||
</ProjBinary>
|
||||
</Binaries>
|
||||
<Reports>
|
||||
<Report>
|
||||
<Path>Returngeance140519.vsp</Path>
|
||||
</Report>
|
||||
<Report>
|
||||
<Path>Returngeance140519(1).vsp</Path>
|
||||
</Report>
|
||||
<Report>
|
||||
<Path>Returngeance140519(2).vsp</Path>
|
||||
</Report>
|
||||
<Report>
|
||||
<Path>Returngeance140519(3).vsp</Path>
|
||||
</Report>
|
||||
</Reports>
|
||||
<Launches>
|
||||
<ProjBinary>
|
||||
<Path>:PB:{E8B4A2A2-882B-402A-98A7-8B4F7233C8B3}|Returngeance\Returngeance.vcxproj</Path>
|
||||
</ProjBinary>
|
||||
</Launches>
|
||||
</VSPerformanceSession>
|
||||
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Reference in New Issue
Block a user