seperate class for sun variables
This commit is contained in:
parent
321f321cb0
commit
4bdf8d5e8b
11
grk/project/Sun.h
Normal file
11
grk/project/Sun.h
Normal file
@ -0,0 +1,11 @@
|
|||||||
|
#include "glm.hpp"
|
||||||
|
#include "ext.hpp"
|
||||||
|
|
||||||
|
#pragma once
|
||||||
|
class Sun
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
glm::vec3 sunPos = glm::vec3(-4.740971f, 2.149999f, 0.369280f);
|
||||||
|
glm::vec3 sunDir = glm::vec3(-0.93633f, 0.351106, 0.003226f);
|
||||||
|
glm::vec3 sunColor = glm::vec3(0.9f, 0.9f, 0.7f) * 5;
|
||||||
|
};
|
@ -35,6 +35,7 @@
|
|||||||
<ClInclude Include="src\SOIL\stbi_DDS_aug_c.h" />
|
<ClInclude Include="src\SOIL\stbi_DDS_aug_c.h" />
|
||||||
<ClInclude Include="src\SOIL\stb_image_aug.h" />
|
<ClInclude Include="src\SOIL\stb_image_aug.h" />
|
||||||
<ClInclude Include="src\Texture.h" />
|
<ClInclude Include="src\Texture.h" />
|
||||||
|
<ClInclude Include="Sun.h" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<None Include="shaders\shader_9_1.frag" />
|
<None Include="shaders\shader_9_1.frag" />
|
||||||
|
@ -89,6 +89,9 @@
|
|||||||
<ClInclude Include="src\ex_9_1.hpp">
|
<ClInclude Include="src\ex_9_1.hpp">
|
||||||
<Filter>Source Files</Filter>
|
<Filter>Source Files</Filter>
|
||||||
</ClInclude>
|
</ClInclude>
|
||||||
|
<ClInclude Include="Sun.h">
|
||||||
|
<Filter>Header Files</Filter>
|
||||||
|
</ClInclude>
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<None Include="shaders\shader_8_sun.vert">
|
<None Include="shaders\shader_8_sun.vert">
|
||||||
|
@ -14,6 +14,7 @@
|
|||||||
#include <assimp/scene.h>
|
#include <assimp/scene.h>
|
||||||
#include <assimp/postprocess.h>
|
#include <assimp/postprocess.h>
|
||||||
#include <string>
|
#include <string>
|
||||||
|
#include "../Sun.h"
|
||||||
|
|
||||||
const unsigned int SHADOW_WIDTH = 1024, SHADOW_HEIGHT = 1024;
|
const unsigned int SHADOW_WIDTH = 1024, SHADOW_HEIGHT = 1024;
|
||||||
|
|
||||||
@ -49,9 +50,7 @@ Core::Shader_Loader shaderLoader;
|
|||||||
Core::RenderContext shipContext;
|
Core::RenderContext shipContext;
|
||||||
Core::RenderContext sphereContext;
|
Core::RenderContext sphereContext;
|
||||||
|
|
||||||
glm::vec3 sunPos = glm::vec3(-4.740971f, 2.149999f, 0.369280f);
|
Sun sun;
|
||||||
glm::vec3 sunDir = glm::vec3(-0.93633f, 0.351106, 0.003226f);
|
|
||||||
glm::vec3 sunColor = glm::vec3(0.9f, 0.9f, 0.7f)*5;
|
|
||||||
|
|
||||||
glm::vec3 cameraPos = glm::vec3(0.479490f, 1.250000f, -2.124680f);
|
glm::vec3 cameraPos = glm::vec3(0.479490f, 1.250000f, -2.124680f);
|
||||||
glm::vec3 cameraDir = glm::vec3(-0.354510f, 0.000000f, 0.935054f);
|
glm::vec3 cameraDir = glm::vec3(-0.354510f, 0.000000f, 0.935054f);
|
||||||
@ -141,8 +140,8 @@ void drawObjectPBR(Core::RenderContext& context, glm::mat4 modelMatrix, glm::vec
|
|||||||
|
|
||||||
glUniform3f(glGetUniformLocation(program, "cameraPos"), cameraPos.x, cameraPos.y, cameraPos.z);
|
glUniform3f(glGetUniformLocation(program, "cameraPos"), cameraPos.x, cameraPos.y, cameraPos.z);
|
||||||
|
|
||||||
glUniform3f(glGetUniformLocation(program, "sunDir"), sunDir.x, sunDir.y, sunDir.z);
|
glUniform3f(glGetUniformLocation(program, "sunDir"), sun.sunDir.x, sun.sunDir.y, sun.sunDir.z);
|
||||||
glUniform3f(glGetUniformLocation(program, "sunColor"), sunColor.x, sunColor.y, sunColor.z);
|
glUniform3f(glGetUniformLocation(program, "sunColor"), sun.sunColor.x, sun.sunColor.y, sun.sunColor.z);
|
||||||
|
|
||||||
glUniform3f(glGetUniformLocation(program, "lightPos"), pointlightPos.x, pointlightPos.y, pointlightPos.z);
|
glUniform3f(glGetUniformLocation(program, "lightPos"), pointlightPos.x, pointlightPos.y, pointlightPos.z);
|
||||||
glUniform3f(glGetUniformLocation(program, "lightColor"), pointlightColor.x, pointlightColor.y, pointlightColor.z);
|
glUniform3f(glGetUniformLocation(program, "lightColor"), pointlightColor.x, pointlightColor.y, pointlightColor.z);
|
||||||
@ -182,7 +181,7 @@ void renderScene(GLFWwindow* window)
|
|||||||
glm::mat4 viewProjectionMatrix = createPerspectiveMatrix() * createCameraMatrix();
|
glm::mat4 viewProjectionMatrix = createPerspectiveMatrix() * createCameraMatrix();
|
||||||
glm::mat4 transformation = viewProjectionMatrix * glm::translate(pointlightPos) * glm::scale(glm::vec3(0.1));
|
glm::mat4 transformation = viewProjectionMatrix * glm::translate(pointlightPos) * glm::scale(glm::vec3(0.1));
|
||||||
glUniformMatrix4fv(glGetUniformLocation(programSun, "transformation"), 1, GL_FALSE, (float*)&transformation);
|
glUniformMatrix4fv(glGetUniformLocation(programSun, "transformation"), 1, GL_FALSE, (float*)&transformation);
|
||||||
glUniform3f(glGetUniformLocation(programSun, "color"), sunColor.x / 2, sunColor.y / 2, sunColor.z / 2);
|
glUniform3f(glGetUniformLocation(programSun, "color"), sun.sunColor.x / 2, sun.sunColor.y / 2, sun.sunColor.z / 2);
|
||||||
glUniform1f(glGetUniformLocation(programSun, "exposition"), exposition);
|
glUniform1f(glGetUniformLocation(programSun, "exposition"), exposition);
|
||||||
Core::DrawContext(sphereContext);
|
Core::DrawContext(sphereContext);
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user