Compare commits
1 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 4494e7592d |
+5
-5
@@ -69,7 +69,7 @@ void GameWorld::Initialize()
|
||||
auto transform = AddComponent<Components::Transform>(chassis, "Transform");
|
||||
transform->Position = glm::vec3(0, -0.6577f, 0);
|
||||
auto model = AddComponent<Components::Model>(chassis, "Model");
|
||||
model->ModelFile = "Models/JeepV2/Chassi/chassi.OBJ";
|
||||
model->ModelFile = "Models/Jeep/Chassi/chassi.OBJ";
|
||||
|
||||
}
|
||||
|
||||
@@ -79,7 +79,7 @@ void GameWorld::Initialize()
|
||||
transform->Position = glm::vec3(1.4f, 0.5546f - 0.6577f - 0.2, -0.9242f);
|
||||
transform->Scale = glm::vec3(1.0f);
|
||||
auto model = AddComponent<Components::Model>(wheel, "Model");
|
||||
model->ModelFile = "Models/JeepV2/WheelFront/wheelFront.obj";
|
||||
model->ModelFile = "Models/Jeep/WheelFront/wheelFront.obj";
|
||||
auto Wheel = AddComponent<Components::Wheel>(wheel, "Wheel");
|
||||
Wheel->Hardpoint = transform->Position + glm::vec3(0.f, 1.f, 0.f);
|
||||
Wheel->AxleID = 0;
|
||||
@@ -99,7 +99,7 @@ void GameWorld::Initialize()
|
||||
transform->Scale = glm::vec3(1.0f);
|
||||
transform->Orientation = glm::angleAxis(glm::pi<float>(), glm::vec3(0, 0, 1));
|
||||
auto model = AddComponent<Components::Model>(wheel, "Model");
|
||||
model->ModelFile = "Models/JeepV2/WheelFront/wheelFront.obj";
|
||||
model->ModelFile = "Models/Jeep/WheelFront/wheelFront.obj";
|
||||
auto Wheel = AddComponent<Components::Wheel>(wheel, "Wheel");
|
||||
Wheel->Hardpoint = transform->Position + glm::vec3(0.f, 1.f, 0.f);
|
||||
Wheel->AxleID = 0;
|
||||
@@ -117,7 +117,7 @@ void GameWorld::Initialize()
|
||||
auto transform = AddComponent<Components::Transform>(wheel, "Transform");
|
||||
transform->Position = glm::vec3(0.2726f, 0.2805f - 0.6577f, 1.9307f);
|
||||
auto model = AddComponent<Components::Model>(wheel, "Model");
|
||||
model->ModelFile = "Models/JeepV2/WheelBack/wheelBack.obj";
|
||||
model->ModelFile = "Models/Jeep/WheelBack/wheelBack.obj";
|
||||
auto Wheel = AddComponent<Components::Wheel>(wheel, "Wheel");
|
||||
Wheel->Hardpoint = transform->Position + glm::vec3(0.f, 1.f, 0.f);
|
||||
Wheel->AxleID = 1;
|
||||
@@ -135,7 +135,7 @@ void GameWorld::Initialize()
|
||||
transform->Position = glm::vec3(-0.2726f, 0.2805f - 0.6577f, 1.9307f);
|
||||
transform->Orientation = glm::angleAxis(glm::pi<float>(), glm::vec3(0, 0, 1));
|
||||
auto model = AddComponent<Components::Model>(wheel, "Model");
|
||||
model->ModelFile = "Models/JeepV2/WheelBack/wheelBack.obj";
|
||||
model->ModelFile = "Models/Jeep/WheelBack/wheelBack.obj";
|
||||
auto Wheel = AddComponent<Components::Wheel>(wheel, "Wheel");
|
||||
Wheel->Hardpoint = transform->Position + glm::vec3(0.f, 1.f, 0.f);
|
||||
Wheel->AxleID = 1;
|
||||
|
||||
+3
-1
@@ -20,8 +20,10 @@ Model::Model(OBJ &obj, ResourceManager* rm)
|
||||
|
||||
// Load texture
|
||||
auto texture = std::shared_ptr<Texture>(rm->Load<Texture>("Texture", currentMaterial->DiffuseTexture.FileName));
|
||||
// TODO: Load normal map
|
||||
// Load normal map
|
||||
std::shared_ptr<Texture> normalMap = nullptr;
|
||||
if (!currentMaterial->NormalMap.FileName.empty())
|
||||
normalMap = std::shared_ptr<Texture>(rm->Load<Texture>("Texture", currentMaterial->NormalMap.FileName));
|
||||
// Load specular map
|
||||
std::shared_ptr<Texture> specularMap = nullptr;
|
||||
if (!currentMaterial->SpecularMap.FileName.empty())
|
||||
|
||||
+32
-4
@@ -118,6 +118,14 @@ void Renderer::LoadContent()
|
||||
glBindFragDataLocation(m_FirstPassProgram.GetHandle(), 2, "frag_Normal");
|
||||
m_FirstPassProgram.Link();
|
||||
|
||||
m_FirstPassNormalProgram.AddShader(std::shared_ptr<Shader>(new VertexShader("Shaders/Vertex.glsl")));
|
||||
m_FirstPassNormalProgram.AddShader(std::shared_ptr<Shader>(new FragmentShader("Shaders/Fragment-Normal.glsl")));
|
||||
m_FirstPassNormalProgram.Compile();
|
||||
glBindFragDataLocation(m_FirstPassNormalProgram.GetHandle(), 0, "frag_Diffuse");
|
||||
glBindFragDataLocation(m_FirstPassNormalProgram.GetHandle(), 1, "frag_Position");
|
||||
glBindFragDataLocation(m_FirstPassNormalProgram.GetHandle(), 2, "frag_Normal");
|
||||
m_FirstPassNormalProgram.Link();
|
||||
|
||||
m_SecondPassProgram.AddShader(std::shared_ptr<Shader>(new VertexShader("Shaders/Vertex2.glsl")));
|
||||
m_SecondPassProgram.AddShader(std::shared_ptr<Shader>(new FragmentShader("Shaders/Fragment2.glsl")));
|
||||
m_SecondPassProgram.Compile();
|
||||
@@ -694,7 +702,6 @@ void Renderer::DrawFBO()
|
||||
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);
|
||||
|
||||
@@ -823,15 +830,36 @@ void Renderer::DrawFBOScene()
|
||||
continue;
|
||||
|
||||
MVP = cameraMatrix * modelMatrix;
|
||||
glBindVertexArray(model->VAO);
|
||||
for (auto texGroup : model->TextureGroups)
|
||||
{
|
||||
if (texGroup.NormalMap)
|
||||
{
|
||||
m_FirstPassNormalProgram.Bind();
|
||||
|
||||
glUniformMatrix4fv(glGetUniformLocation(m_FirstPassNormalProgram.GetHandle(), "MVP"), 1, GL_FALSE, glm::value_ptr(MVP));
|
||||
glUniformMatrix4fv(glGetUniformLocation(m_FirstPassNormalProgram.GetHandle(), "M"), 1, GL_FALSE, glm::value_ptr(modelMatrix));
|
||||
glUniformMatrix4fv(glGetUniformLocation(m_FirstPassNormalProgram.GetHandle(), "V"), 1, GL_FALSE, glm::value_ptr(m_Camera->ViewMatrix()));
|
||||
glUniformMatrix4fv(glGetUniformLocation(m_FirstPassNormalProgram.GetHandle(), "P"), 1, GL_FALSE, glm::value_ptr(m_Camera->ProjectionMatrix()));
|
||||
}
|
||||
else
|
||||
{
|
||||
m_FirstPassProgram.Bind();
|
||||
|
||||
glUniformMatrix4fv(glGetUniformLocation(m_FirstPassProgram.GetHandle(), "MVP"), 1, GL_FALSE, glm::value_ptr(MVP));
|
||||
glUniformMatrix4fv(glGetUniformLocation(m_FirstPassProgram.GetHandle(), "M"), 1, GL_FALSE, glm::value_ptr(modelMatrix));
|
||||
glUniformMatrix4fv(glGetUniformLocation(m_FirstPassProgram.GetHandle(), "V"), 1, GL_FALSE, glm::value_ptr(m_Camera->ViewMatrix()));
|
||||
glUniformMatrix4fv(glGetUniformLocation(m_FirstPassProgram.GetHandle(), "P"), 1, GL_FALSE, glm::value_ptr(m_Camera->ProjectionMatrix()));
|
||||
glBindVertexArray(model->VAO);
|
||||
for (auto texGroup : model->TextureGroups)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
glActiveTexture(GL_TEXTURE0);
|
||||
glBindTexture(GL_TEXTURE_2D, *texGroup.Texture);
|
||||
if (texGroup.NormalMap)
|
||||
{
|
||||
glActiveTexture(GL_TEXTURE1);
|
||||
glBindTexture(GL_TEXTURE_2D, *texGroup.NormalMap);
|
||||
}
|
||||
glDrawArrays(GL_TRIANGLES, texGroup.StartIndex, texGroup.EndIndex - texGroup.StartIndex + 1);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -111,6 +111,7 @@ private:
|
||||
|
||||
ShaderProgram m_ShaderProgram;
|
||||
ShaderProgram m_FirstPassProgram;
|
||||
ShaderProgram m_FirstPassNormalProgram;
|
||||
ShaderProgram m_SecondPassProgram;
|
||||
ShaderProgram m_SecondPassProgram_Debug;
|
||||
ShaderProgram m_FinalPassProgram;
|
||||
|
||||
@@ -0,0 +1,32 @@
|
||||
#version 430
|
||||
|
||||
uniform mat4 MVP;
|
||||
uniform mat4 M;
|
||||
uniform mat4 V;
|
||||
uniform mat4 P;
|
||||
|
||||
layout (binding=0) uniform sampler2D DiffuseTexture;
|
||||
layout (binding=1) uniform sampler2D NormalMap;
|
||||
|
||||
in VertexData
|
||||
{
|
||||
vec3 Position;
|
||||
vec3 Normal;
|
||||
vec2 TextureCoord;
|
||||
} Input;
|
||||
|
||||
out vec4 frag_Diffuse;
|
||||
out vec4 frag_Position;
|
||||
out vec4 frag_Normal;
|
||||
|
||||
void main()
|
||||
{
|
||||
// Diffuse Texture
|
||||
frag_Diffuse = texture2D(DiffuseTexture, Input.TextureCoord);
|
||||
|
||||
// G-buffer Position
|
||||
frag_Position = vec4(Input.Position.xyz, 0.0);
|
||||
|
||||
// G-buffer Normal
|
||||
frag_Normal = vec4(normalize(vec3(Input.Normal * (texture2D(NormalMap, Input.TextureCoord)).xyz)), 0.0);
|
||||
}
|
||||
@@ -1,5 +1,10 @@
|
||||
#version 430
|
||||
|
||||
uniform mat4 MVP;
|
||||
uniform mat4 M;
|
||||
uniform mat4 V;
|
||||
uniform mat4 P;
|
||||
|
||||
layout (binding=0) uniform sampler2D DiffuseTexture;
|
||||
|
||||
in VertexData
|
||||
|
||||
@@ -169,6 +169,7 @@
|
||||
<None Include="..\..\src\Shaders\AABB.frag.glsl" />
|
||||
<None Include="..\..\src\Shaders\FinalPass.frag.glsl" />
|
||||
<None Include="..\..\src\Shaders\FinalPass.vert.glsl" />
|
||||
<None Include="..\..\src\Shaders\Fragment-Normal.glsl" />
|
||||
<None Include="..\..\src\Shaders\Fragment.glsl" />
|
||||
<None Include="..\..\src\Shaders\Fragment2-Debug.glsl" />
|
||||
<None Include="..\..\src\Shaders\Fragment2.glsl" />
|
||||
|
||||
@@ -277,5 +277,8 @@
|
||||
<None Include="..\..\src\Shaders\FinalPass.frag.glsl">
|
||||
<Filter>Shaders</Filter>
|
||||
</None>
|
||||
<None Include="..\..\src\Shaders\Fragment-Normal.glsl">
|
||||
<Filter>Shaders</Filter>
|
||||
</None>
|
||||
</ItemGroup>
|
||||
</Project>
|
||||
Reference in New Issue
Block a user