Merge pull request 'fixed lamp and turning off/on lights;' (#14) from textures into master

Reviewed-on: #14
This commit is contained in:
Angelika Iskra 2023-02-11 16:39:49 +01:00
commit ee11b8fa93
33 changed files with 310 additions and 90 deletions

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

View File

@ -1,35 +1,35 @@
 main.cpp
C:\Program Files (x86)\Windows Kits\10\Include\10.0.19041.0\shared\minwindef.h(130,1): warning C4005: "APIENTRY": ponowna definicja makra
C:\Users\annas\Desktop\graf\dependencies\glfw-3.3.8.bin.WIN32\include\GLFW\glfw3.h(123): message : zobacz poprzednią definicję „APIENTRY”
C:\Users\annas\Desktop\graf\cw 9\src\room.hpp(118,30): warning C4305: "inicjowanie": obcięcie z "double" do "float"
C:\Users\annas\Desktop\graf\cw 9\src\room.hpp(136,38): warning C4305: "=": obcięcie z "double" do "float"
C:\Users\annas\Desktop\graf\cw 9\src\room.hpp(159,16): warning C4305: "inicjowanie": obcięcie z "double" do "float"
C:\Users\annas\Desktop\graf\cw 9\src\room.hpp(178,16): warning C4305: "inicjowanie": obcięcie z "double" do "float"
C:\Users\annas\Desktop\graf\cw 9\src\room.hpp(196,15): warning C4101: "textureID": lokalna zmienna, do której nie istnieje odwołanie
C:\Users\annas\Desktop\graf\cw 9\src\room.hpp(288,13): warning C4244: "inicjowanie": konwersja z "double" do "float", możliwa utrata danych
C:\Users\annas\Desktop\graf\cw 9\src\room.hpp(294,96): warning C4305: "argument": obcięcie z "double" do "T"
D:\UAM\Grafika komputerowa\projekt\GRK_Room\dependencies\glfw-3.3.8.bin.WIN32\include\GLFW\glfw3.h(123): message : zobacz poprzednią definicję „APIENTRY”
D:\UAM\Grafika komputerowa\projekt\GRK_Room\cw 9\src\room.hpp(120,30): warning C4305: "inicjowanie": obcięcie z "double" do "float"
D:\UAM\Grafika komputerowa\projekt\GRK_Room\cw 9\src\room.hpp(138,38): warning C4305: "=": obcięcie z "double" do "float"
D:\UAM\Grafika komputerowa\projekt\GRK_Room\cw 9\src\room.hpp(161,16): warning C4305: "inicjowanie": obcięcie z "double" do "float"
D:\UAM\Grafika komputerowa\projekt\GRK_Room\cw 9\src\room.hpp(180,16): warning C4305: "inicjowanie": obcięcie z "double" do "float"
D:\UAM\Grafika komputerowa\projekt\GRK_Room\cw 9\src\room.hpp(198,15): warning C4101: "textureID": lokalna zmienna, do której nie istnieje odwołanie
D:\UAM\Grafika komputerowa\projekt\GRK_Room\cw 9\src\room.hpp(338,13): warning C4244: "inicjowanie": konwersja z "double" do "float", możliwa utrata danych
D:\UAM\Grafika komputerowa\projekt\GRK_Room\cw 9\src\room.hpp(344,96): warning C4305: "argument": obcięcie z "double" do "T"
with
[
T=float
]
C:\Users\annas\Desktop\graf\cw 9\src\room.hpp(298,59): warning C4305: "argument": obcięcie z "double" do "T"
D:\UAM\Grafika komputerowa\projekt\GRK_Room\cw 9\src\room.hpp(347,59): warning C4305: "argument": obcięcie z "double" do "T"
with
[
T=float
]
C:\Users\annas\Desktop\graf\cw 9\src\room.hpp(462,29): warning C4018: "<": niezgodność typu ze znakiem/bez znaku
C:\Users\annas\Desktop\graf\cw 9\src\room.hpp(487,13): warning C4244: "inicjowanie": konwersja z "double" do "float", możliwa utrata danych
C:\Users\annas\Desktop\graf\cw 9\src\room.hpp(504,109): warning C4305: "argument": obcięcie z "double" do "T"
D:\UAM\Grafika komputerowa\projekt\GRK_Room\cw 9\src\room.hpp(495,29): warning C4018: "<": niezgodność typu ze znakiem/bez znaku
D:\UAM\Grafika komputerowa\projekt\GRK_Room\cw 9\src\room.hpp(520,13): warning C4244: "inicjowanie": konwersja z "double" do "float", możliwa utrata danych
D:\UAM\Grafika komputerowa\projekt\GRK_Room\cw 9\src\room.hpp(534,109): warning C4305: "argument": obcięcie z "double" do "T"
with
[
T=float
]
C:\Users\annas\Desktop\graf\cw 9\src\room.hpp(560,2): warning C4305: "argument": obcięcie z "double" do "float"
C:\Users\annas\Desktop\graf\cw 9\src\room.hpp(699,21): warning C4305: "-=": obcięcie z "double" do "float"
C:\Users\annas\Desktop\graf\cw 9\src\room.hpp(701,21): warning C4305: "+=": obcięcie z "double" do "float"
D:\UAM\Grafika komputerowa\projekt\GRK_Room\cw 9\src\room.hpp(587,2): warning C4305: "argument": obcięcie z "double" do "float"
D:\UAM\Grafika komputerowa\projekt\GRK_Room\cw 9\src\room.hpp(727,21): warning C4305: "-=": obcięcie z "double" do "float"
D:\UAM\Grafika komputerowa\projekt\GRK_Room\cw 9\src\room.hpp(729,21): warning C4305: "+=": obcięcie z "double" do "float"
Trwa generowanie kodu
54 of 607 functions ( 8.9%) were compiled, the rest were copied from previous compilation.
47 of 607 functions ( 7.7%) were compiled, the rest were copied from previous compilation.
0 functions were new in current compilation
18 functions had inline decision re-evaluated but remain unchanged
9 functions had inline decision re-evaluated but remain unchanged
Zakończono generowanie kodu
grk-cw9.vcxproj -> C:\Users\annas\Desktop\graf\Release\room.exe
grk-cw9.vcxproj -> D:\UAM\Grafika komputerowa\projekt\GRK_Room\Release\room.exe

Binary file not shown.

Binary file not shown.

Binary file not shown.

View File

@ -2,7 +2,7 @@
<Project>
<ProjectOutputs>
<ProjectOutput>
<FullPath>C:\Users\annas\Desktop\graf\Release\room.exe</FullPath>
<FullPath>D:\UAM\Grafika komputerowa\projekt\GRK_Room\Release\room.exe</FullPath>
</ProjectOutput>
</ProjectOutputs>
<ContentFiles />

Binary file not shown.

Binary file not shown.

View File

@ -1,2 +1,2 @@
PlatformToolSet=v142:VCToolArchitecture=Native32Bit:VCToolsVersion=14.29.30133:TargetPlatformVersion=10.0.19041.0:
Release|Win32|C:\Users\annas\Desktop\graf\|
Release|Win32|D:\UAM\Grafika komputerowa\projekt\GRK_Room\|

Binary file not shown.

Binary file not shown.

View File

@ -1,4 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="Current" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup />
<PropertyGroup>
<ShowAllFiles>true</ShowAllFiles>
</PropertyGroup>
</Project>

View File

@ -1,18 +0,0 @@
#version 430 core
float AMBIENT = 0.1;
uniform vec3 color;
uniform vec3 lightPos;
in vec3 vecNormal;
in vec3 worldPos;
out vec4 outColor;
void main()
{
vec3 lightDir = normalize(lightPos-worldPos);
vec3 normal = normalize(vecNormal);
float diffuse=max(0,dot(normal,lightDir));
outColor = vec4(color*min(1,AMBIENT+diffuse), 1.0);
}

View File

@ -1,18 +0,0 @@
#version 430 core
layout(location = 0) in vec3 vertexPosition;
layout(location = 1) in vec3 vertexNormal;
layout(location = 2) in vec2 vertexTexCoord;
uniform mat4 transformation;
uniform mat4 modelMatrix;
out vec3 vecNormal;
out vec3 worldPos;
void main()
{
worldPos = (modelMatrix* vec4(vertexPosition,1)).xyz;
vecNormal = (modelMatrix* vec4(vertexNormal,0)).xyz;
gl_Position = transformation * vec4(vertexPosition, 1.0);
}

View File

@ -0,0 +1,150 @@
#version 430 core
float AMBIENT = 0.03;
float PI = 3.14;
uniform sampler2D depthMapSun;
uniform vec3 cameraPos;
uniform vec3 color;
uniform vec3 sunDir;
uniform vec3 sunColor;
uniform vec3 lightPos;
uniform vec3 lightColor;
uniform sampler2D colorTexture;
in vec2 vecTex;
uniform vec3 spotlightPos;
uniform vec3 spotlightColor;
uniform vec3 spotlightConeDir;
uniform vec3 spotlightPhi;
uniform float metallic;
uniform float roughness;
uniform float exposition;
in vec3 vecNormal;
in vec3 worldPos;
out vec4 outColor;
in vec3 viewDirTS;
in vec3 lightDirTS;
in vec3 spotlightDirTS;
in vec3 sunDirTS;
in vec4 sunSpacePos;
in vec3 test;
uniform float time;
float DistributionGGX(vec3 normal, vec3 H, float roughness){
float a = roughness*roughness;
float a2 = a*a;
float NdotH = max(dot(normal, H), 0.0);
float NdotH2 = NdotH*NdotH;
float num = a2;
float denom = (NdotH2 * (a2 - 1.0) + 1.0);
denom = PI * denom * denom;
return num / denom;
}
float GeometrySchlickGGX(float NdotV, float roughness){
float r = (roughness + 1.0);
float k = (r*r) / 8.0;
float num = NdotV;
float denom = NdotV * (1.0 - k) + k;
return num / denom;
}
float GeometrySmith(vec3 normal, vec3 V, vec3 lightDir, float roughness){
float NdotV = max(dot(normal, V), 0.0);
float NdotL = max(dot(normal, lightDir), 0.0);
float ggx2 = GeometrySchlickGGX(NdotV, roughness);
float ggx1 = GeometrySchlickGGX(NdotL, roughness);
return ggx1 * ggx2;
}
vec3 fresnelSchlick(float cosTheta, vec3 F0){
return F0 + (1.0 - F0) * pow(clamp(1.0 - cosTheta, 0.0, 1.0), 5.0);
}
vec3 PBRLight(vec3 lightDir, vec3 radiance, vec3 normal, vec3 V){
float diffuse=max(0,dot(normal,lightDir));
//vec3 V = normalize(cameraPos-worldPos);
vec3 F0 = vec3(0.04);
F0 = mix(F0, color, metallic);
vec3 H = normalize(V + lightDir);
// cook-torrance brdf
float NDF = DistributionGGX(normal, H, roughness);
float G = GeometrySmith(normal, V, lightDir, roughness);
vec3 F = fresnelSchlick(max(dot(H, V), 0.0), F0);
vec3 kS = F;
vec3 kD = vec3(1.0) - kS;
kD *= 1.0 - metallic;
vec3 numerator = NDF * G * F;
float denominator = 4.0 * max(dot(normal, V), 0.0) * max(dot(normal, lightDir), 0.0) + 0.0001;
vec3 specular = numerator / denominator;
// add to outgoing radiance Lo
float NdotL = max(dot(normal, lightDir), 0.0);
return (kD * color / PI + specular) * radiance * NdotL;
}
float calculateShadow() {
vec4 sunSpacePosNormalized = (0.5 * sunSpacePos / (sunSpacePos.w)) + 0.5;
float closestDepth = texture2D(depthMapSun, sunSpacePosNormalized.xy).x;//r?
float diff = (0.001+closestDepth) - sunSpacePosNormalized.z;//sunSpacePosNormalized.z;
return (0.5*(diff)/abs(diff))+0.5;
}
void main()
{
vec3 lightDir = normalize(lightPos-worldPos);
vec3 normal = normalize(vecNormal);
vec3 textureColor = texture2D(colorTexture, vecTex).xyz;
float diffuse=max(0,dot(normal,lightDir));
vec3 viewDir = normalize(cameraPos-worldPos);
vec3 ambient = AMBIENT*color;
vec3 attenuatedlightColor = lightColor/pow(length(lightPos-worldPos),2);
vec3 ilumination;
ilumination = ambient+PBRLight(lightDir,attenuatedlightColor,normal,viewDir);
//flashlight
//vec3 spotlightDir= normalize(spotlightDirTS);
vec3 spotlightDir= normalize(spotlightPos-worldPos);
float angle_atenuation = clamp((dot(-normalize(spotlightPos-worldPos),spotlightConeDir)-0.5)*3,0,1);
attenuatedlightColor = angle_atenuation*spotlightColor/pow(length(spotlightPos-worldPos),2);
ilumination=ilumination+PBRLight(spotlightDir,attenuatedlightColor,normal,viewDir);
//sun
ilumination=ilumination+PBRLight(sunDir, sunColor * calculateShadow(), normal, viewDir);
//outColor = vec4(textureColor*min(1,AMBIENT+diffuse), 1.0);
//outColor = vec4(vec3(1.0) - exp(-ilumination*exposition),1);
outColor = vec4(textureColor*min(1,AMBIENT+diffuse) - 1*exp(-ilumination*exposition),1);
}

View File

@ -0,0 +1,72 @@
#version 430 core
//layout(location = 0) in vec3 vertexPosition;
//layout(location = 1) in vec3 vertexNormal;
//layout(location = 2) in vec2 vertexTexCoord;
//
//uniform mat4 transformation;
//uniform mat4 modelMatrix;
//
//out vec3 vecNormal;
//out vec3 worldPos;
//out vec2 vecTex;
//
//void main()
//{
// worldPos = (modelMatrix * vec4(vertexPosition, 1)).xyz;
// vecNormal = (modelMatrix * vec4(vertexNormal, 0)).xyz;
// vecTex = vertexTexCoord;
// vecTex.y = 1.0 - vecTex.y;
// gl_Position = transformation * vec4(vertexPosition, 1.0);
//}
layout(location = 0) in vec3 vertexPosition;
layout(location = 1) in vec3 vertexNormal;
layout(location = 2) in vec2 vertexTexCoord;
layout(location = 3) in vec3 vertexTangent;
layout(location = 4) in vec3 vertexBitangent;
uniform mat4 transformation;
uniform mat4 modelMatrix;
uniform mat4 LightVPSun;
out vec3 vecNormal;
out vec3 worldPos;
out vec2 vecTex;
uniform vec3 lightPos;
uniform vec3 spotlightPos;
uniform vec3 cameraPos;
uniform vec3 sunDir;
out vec3 viewDirTS;
out vec3 lightDirTS;
out vec3 spotlightDirTS;
out vec3 sunDirTS;
out vec4 sunSpacePos;
void main()
{
worldPos = (modelMatrix* vec4(vertexPosition,1)).xyz;
vecNormal = (modelMatrix* vec4(vertexNormal,0)).xyz;
vecTex = vertexTexCoord;
vecTex.y = 1.0 - vecTex.y;
gl_Position = transformation * vec4(vertexPosition, 1.0);
vec3 w_tangent = normalize(mat3(modelMatrix)*vertexTangent);
vec3 w_bitangent = normalize(mat3(modelMatrix)*vertexBitangent);
mat3 TBN = transpose(mat3(w_tangent, w_bitangent, vecNormal));
vec3 V = normalize(cameraPos-worldPos);
viewDirTS = TBN*V;
vec3 L = normalize(lightPos-worldPos);
lightDirTS = TBN*L;
vec3 SL = normalize(spotlightPos-worldPos);
spotlightDirTS = TBN*SL;
sunDirTS = TBN*sunDir;
sunSpacePos=LightVPSun*modelMatrix*vec4(vertexPosition,1);
}

View File

@ -56,6 +56,8 @@ namespace texture {
GLuint earth;
GLuint earthNormal;
GLuint floor;
}
Core::RenderContext cubeContext;
@ -107,7 +109,7 @@ unsigned int pingpongBuffer[2];
GLuint VAO,VBO;
float aspectRatio = 1.f;
float exposition = 1.f;
float exposition = 3.0f;
glm::vec3 pointlightPos = glm::vec3(0, 2, 0);
glm::vec3 pointlightColor = glm::vec3(0.9, 0.6, 0.6); //cienie z latarki
@ -123,7 +125,7 @@ glm::mat4 lightShipVP;
float lastTime = -1.f;
float deltaTime = 0.f;
bool lightOn = true;
float lightOn = 1.0f;
glm::vec3 carPosTranform = glm::vec3(0, 0, 0);
void updateDeltaTime(float time) {
@ -231,7 +233,7 @@ void drawSkyBox(Core::RenderContext& context, glm::mat4 modelMatrix) {
glUniformMatrix4fv(glGetUniformLocation(programSkybox, "transformation"), 1, GL_FALSE, (float*)&transformation);
glUniform1i(glGetUniformLocation(programSkybox, "skybox"), 0);
glUniform1f(glGetUniformLocation(programSkybox, "exposition"), exposition);
if (lightOn)
if (lightOn > 0.0f)
glUniform3f(glGetUniformLocation(program, "lightPos"), pointlightPos.x, pointlightPos.y, pointlightPos.z);
else
glUniform3f(glGetUniformLocation(program, "lightPos"), 1000.f, 1000.f, 1000.f);
@ -269,7 +271,7 @@ void drawObjectPBR(Core::RenderContext& context, glm::mat4 modelMatrix, glm::vec
glUniform3f(glGetUniformLocation(program, "sunDir"), sunDir.x, sunDir.y, sunDir.z);
glUniform3f(glGetUniformLocation(program, "sunColor"), sunColor.x, sunColor.y, sunColor.z);
if (lightOn)
if (lightOn > 0.0f)
glUniform3f(glGetUniformLocation(program, "lightPos"), pointlightPos.x, pointlightPos.y, pointlightPos.z);
else
glUniform3f(glGetUniformLocation(program, "lightPos"), 1000.f, 1000.f, 1000.f);
@ -284,6 +286,54 @@ void drawObjectPBR(Core::RenderContext& context, glm::mat4 modelMatrix, glm::vec
Core::DrawContext(context);
}
void drawObjectTexture(Core::RenderContext& context, glm::mat4 modelMatrix, GLuint textureID, glm::vec3 color, float roughness, float metallic) {
glUseProgram(programTex);
glm::mat4 viewProjectionMatrix = createPerspectiveMatrix() * createCameraMatrix();
glm::mat4 transformation = viewProjectionMatrix * modelMatrix;
glUniformMatrix4fv(glGetUniformLocation(programTex, "transformation"), 1, GL_FALSE, (float*)&transformation);
glUniformMatrix4fv(glGetUniformLocation(programTex, "modelMatrix"), 1, GL_FALSE, (float*)&modelMatrix);
glUniform1f(glGetUniformLocation(programTex, "exposition"), exposition);
glUniform1f(glGetUniformLocation(programTex, "roughness"), roughness);
glUniform1f(glGetUniformLocation(programTex, "metallic"), metallic);
glUniform3f(glGetUniformLocation(programTex, "color"), color.x, color.y, color.z);
glUniform3f(glGetUniformLocation(programTex, "cameraPos"), cameraPos.x, cameraPos.y, cameraPos.z);
glUniform3f(glGetUniformLocation(programTex, "sunDir"), sunDir.x, sunDir.y, sunDir.z);
glUniform3f(glGetUniformLocation(programTex, "sunColor"), sunColor.x, sunColor.y, sunColor.z);
if (lightOn > 0.0f)
glUniform3f(glGetUniformLocation(programTex, "lightPos"), pointlightPos.x, pointlightPos.y, pointlightPos.z);
else
glUniform3f(glGetUniformLocation(programTex, "lightPos"), 1000.f, 1000.f, 1000.f);
glUniform3f(glGetUniformLocation(programTex, "lightColor"), pointlightColor.x, pointlightColor.y, pointlightColor.z);
glUniform3f(glGetUniformLocation(programTex, "spotlightConeDir"), spotlightConeDir.x, spotlightConeDir.y, spotlightConeDir.z);
glUniform3f(glGetUniformLocation(programTex, "spotlightPos"), spotlightPos.x, spotlightPos.y, spotlightPos.z);
glUniform3f(glGetUniformLocation(programTex, "spotlightColor"), spotlightColor.x, spotlightColor.y, spotlightColor.z);
glUniform1f(glGetUniformLocation(program, "spotlightPhi"), spotlightPhi);
glActiveTexture(GL_TEXTURE0);
glUniform1i(glGetUniformLocation(programTex, "depthMapSun"), 0);
glBindTexture(GL_TEXTURE_2D, depthMap);
glUniformMatrix4fv(glGetUniformLocation(programTex, "LightVPSun"), 1, GL_FALSE, (float*)&lightVP);
glActiveTexture(GL_TEXTURE1);
glUniform1i(glGetUniformLocation(programTex, "depthMapShip"), 1);
glBindTexture(GL_TEXTURE_2D, depthMapShip);
glUniformMatrix4fv(glGetUniformLocation(programTex, "lightShipVP"), 1, GL_FALSE, (float*)&lightShipVP);
Core::SetActiveTexture(textureID, "colorTexture", programTex, 0);
Core::DrawContext(context);
glUseProgram(0);
}
void renderShadowapSun(GLuint depthFBO, glm::mat4 light) {
float time = glfwGetTime();
glViewport(0, 0, SHADOW_WIDTH, SHADOW_HEIGHT);
@ -292,38 +342,22 @@ void renderShadowapSun(GLuint depthFBO, glm::mat4 light) {
glUseProgram(programDepth);
drawObjectDepth(sphereContext, light, glm::translate(pointlightPos) * glm::scale(glm::vec3(0.1)) * glm::eulerAngleY(time / 3) * glm::translate(glm::vec3(4.f, 0, 0)) * glm::scale(glm::vec3(0.3f)));
drawObjectDepth(sphereContext,
light,
glm::translate(pointlightPos) * glm::scale(glm::vec3(0.1)) * glm::eulerAngleY(time / 3) * glm::translate(glm::vec3(4.f, 0, 0)) * glm::eulerAngleY(time) * glm::translate(glm::vec3(1.f, 0, 0)) * glm::scale(glm::vec3(0.1f)));
drawObjectDepth(models::couchContext, light, glm::scale(glm::vec3(0.5f)) * glm::translate(glm::vec3(8.4f, 0, -0.4f)) * glm::eulerAngleY(3.15f));
drawObjectDepth(models::coffeeTableContext, light, glm::translate(glm::vec3(2.8f, 0, 0.5f)));
drawObjectDepth(models::doorContext, light, glm::mat4());
drawObjectDepth(models::planeContext, light, glm::mat4());
drawObjectDepth(models::roomContext, light, glm::mat4());
// draw windows
drawObjectDepth(models::windowContext, light, glm::scale(glm::vec3(1.0f, 1.0f, 2.3f)) * glm::translate(glm::vec3(-2.9f, 0, -0.2f)));
drawObjectDepth(models::windowContext, light, glm::eulerAngleY(3.14f) * glm::scale(glm::vec3(1.0f, 1.0f, 2.3f)) * glm::translate(glm::vec3(-2.9f, 0, -0.3f)));
drawObjectDepth(models::windowContext, light, glm::eulerAngleY(1.57f) * glm::scale(glm::vec3(1.0f, 1.0f, 2.45f)) * glm::translate(glm::vec3(-0.6f, 0, -0.25f)));
drawObjectDepth(models::deskContext, light, glm::eulerAngleY(3.14f) * glm::translate(glm::vec3(2.8f, 0.0f, 1.9f)));
drawObjectDepth(models::displayScreenContext, light, glm::scale(glm::vec3(0.1, 0.1, 0.1)) * glm::translate(glm::vec3(-28.5f, 9.0f, -20.0f)));
drawObjectDepth(models::chairContext, light, glm::scale(glm::vec3(1.0f, 1.2f, 1.0f)) * glm::eulerAngleY(3.14f) * glm::translate(glm::vec3(2.8f, 0.0f, 1.5f)));
drawObjectDepth(models::ps5Context, light, glm::mat4());
drawObjectDepth(models::tvStandContext, light, glm::mat4());
@ -431,7 +465,6 @@ void initBloom()
void initPingPong()
{
glGenFramebuffers(2, pingpongFBO);
glGenTextures(2, pingpongBuffer);
for (unsigned int i = 0; i < 2; i++)
@ -487,7 +520,6 @@ void renderScene(GLFWwindow* window)
float time = glfwGetTime();
updateDeltaTime(time);
renderShadowapSun(depthMapFBO, lightVP);
renderShadowapSun(depthMapShipFBO, lightShipVP);
glBindFramebuffer(GL_FRAMEBUFFER, bloomTextureFBO);
@ -496,9 +528,7 @@ void renderScene(GLFWwindow* window)
drawSkyBox(cubeContext, glm::translate(cameraPos));
if (lightOn) {
if (lightOn > 0.0f) {
glUseProgram(programSun);
glm::mat4 viewProjectionMatrix = createPerspectiveMatrix() * createCameraMatrix();
glm::mat4 transformation = viewProjectionMatrix * glm::translate(pointlightPos) * glm::scale(glm::vec3(0.1));
@ -508,16 +538,12 @@ void renderScene(GLFWwindow* window)
Core::DrawContext(sphereContext);
}
//pingPongBluring(time);
glUseProgram(program);
drawObjectPBR(models::couchContext, glm::scale(glm::vec3(0.5f)) * glm::translate(glm::vec3(8.4f, 0, -0.4f)) * glm::eulerAngleY(3.15f), glm::vec3(0.03f, 0.03f, 0.03f), 0.2f, 0.0f);
drawObjectPBR(models::coffeeTableContext, glm::translate(glm::vec3(2.8f, 0, 0.5f)), glm::vec3(1.f, 1.f, 1.f), 0.4f, 0.0f);
drawObjectPBR(models::doorContext, glm::mat4(), glm::vec3(0.402978f, 0.120509f, 0.057729f), 0.2f, 0.0f);
drawObjectPBR(models::planeContext, glm::mat4(), glm::vec3(0.402978f, 0.120509f, 0.057729f), 0.2f, 0.0f);
drawObjectPBR(models::roomContext, glm::mat4(), glm::vec3(1.0f, 1.0f, 1.0f), 0.8f, 0.0f);
drawObjectPBR(models::deskContext, glm::eulerAngleY(3.14f) * glm::translate(glm::vec3(2.8f, 0.0f, 1.9f)), glm::vec3(1.0f, 1.0f, 1.0f), 0.0f, 0.0f);
drawObjectPBR(models::displayScreenContext, glm::scale(glm::vec3(0.1, 0.1, 0.1)) * glm::translate(glm::vec3(-28.5f, 9.0f, -20.0f)), glm::vec3(0.0f, 0.0f, 0.0f), 0.0f, 0.3f);
@ -529,17 +555,19 @@ void renderScene(GLFWwindow* window)
drawObjectPBR(models::carpetContext, glm::mat4(), glm::vec3(0.6745098039215686f, 0.6352941176470588f, 0.6235294117647059f), 0.0f, 0.2f);
drawObjectPBR(models::cabinet1Context, glm::mat4(), glm::vec3(1.0f, 1.0f, 1.0f), 0.0f, 0.2f);
drawObjectPBR(models::cabinet2Context, glm::mat4(), glm::vec3(1.0f, 1.0f, 1.0f), 0.0f, 0.2f);
drawObjectPBR(models::lampContext, glm::translate(glm::vec3(0.023f, 0.15f, 0.0f)), glm::vec3(1.0f, 1.0f, 1.0f), 0.0f, 0.2f);
drawObjectPBR(models::lampContext, glm::translate(glm::vec3(0.022f, 0.15f, 0.04f)), glm::vec3(1.0f, 1.0f, 1.0f), 0.0f, 0.2f);
drawObjectPBR(models::bookshelfContext, glm::mat4(), glm::vec3(1.0f, 1.0f, 1.0f), 0.0f, 0.2f);
drawObjectPBR(models::lightSwitchContext, glm::mat4(), glm::vec3(1.0f, 1.0f, 1.0f), 0.0f, 0.2f);
drawObjectPBR(models::easelContext, glm::mat4(), glm::vec3(0.6745098039215686f, 0.6352941176470588f, 0.6235294117647059f), 0.0f, 0.2f);
drawObjectPBR(models::carContext, glm::translate(carPosTranform), glm::vec3(1.0f, 0.0f, 0.0f), 0.0f, 0.2f);
drawObjectPBR(models::vaseContext, glm::translate(glm::vec3(1.1f, 1.41f, -2.2f)), glm::vec3(244.0f / 255.0f, 245.0f / 255.0f, 220.0f / 255.0f), 0.0f, 0.2f);
// draw windows
drawObjectPBR(models::windowContext, glm::scale(glm::vec3(1.0f, 1.0f, 2.3f)) * glm::translate(glm::vec3(-2.9f, 0, -0.2f)), glm::vec3(0.402978f, 0.120509f, 0.057729f), 0.2f, 0.0f);
drawObjectPBR(models::windowContext, glm::eulerAngleY(3.14f) * glm::scale(glm::vec3(1.0f, 1.0f, 2.3f)) * glm::translate(glm::vec3(-2.9f, 0, -0.3f)), glm::vec3(0.402978f, 0.120509f, 0.057729f), 0.2f, 0.0f);
drawObjectPBR(models::windowContext, glm::eulerAngleY(1.57f) * glm::scale(glm::vec3(1.0f, 1.0f, 2.45f)) * glm::translate(glm::vec3(-0.6f, 0, -0.25f)), glm::vec3(0.402978f, 0.120509f, 0.057729f), 0.2f, 0.0f);
//drawObjectTexture(models::planeContext, glm::mat4(), texture::floor, glm::vec3(0.402978f, 0.120509f, 0.057729f), 0.2f, 0.0f);
glm::vec3 spaceshipSide = glm::normalize(glm::cross(spaceshipDir, glm::vec3(0.f, 1.f, 0.f)));
glm::vec3 spaceshipUp = glm::normalize(glm::cross(spaceshipSide, spaceshipDir));
@ -551,7 +579,6 @@ void renderScene(GLFWwindow* window)
});
//drawObjectPBR(shipContext,
drawObjectPBR(models::spaceshipContext,
glm::translate(spaceshipPos) * specshipCameraRotrationMatrix * glm::eulerAngleY(glm::pi<float>()) * glm::scale(glm::vec3(0.03f)),
@ -615,8 +642,10 @@ void init(GLFWwindow* window)
loadCubemap(faces);
initDepthMap();
programTex = shaderLoader.CreateProgram("shaders/shader_tex.vert", "shaders/shader_tex.frag");
texture::earth = Core::LoadTexture("textures/room/earth.png");
texture::earthNormal = Core::LoadTexture("textures/room/earth_normalmap.png");
texture::floor = Core::LoadTexture("textures/floor/floor_wood.jpg");
loadModelToContext("./models/sphere.obj", sphereContext);
loadModelToContext("./models/cube.obj", cubeContext);
@ -653,7 +682,6 @@ void init(GLFWwindow* window)
initBloom();
initPingPong();
}
void shutdown(GLFWwindow* window)
@ -703,9 +731,13 @@ void processInput(GLFWwindow* window)
if (glfwGetKey(window, GLFW_KEY_3) == GLFW_PRESS) {
printf("spaceshipPos = glm::vec3(%ff, %ff, %ff);\n", spaceshipPos.x, spaceshipPos.y, spaceshipPos.z);
printf("spaceshipDir = glm::vec3(%ff, %ff, %ff);\n", spaceshipDir.x, spaceshipDir.y, spaceshipDir.z);
printf("exposition = %ff);\n", exposition);
}
if (glfwGetKey(window, GLFW_KEY_L) == GLFW_PRESS)
lightOn = !lightOn;
lightOn -= 1.0f;
if (glfwGetKey(window, GLFW_KEY_K) == GLFW_PRESS)
lightOn += 1.0f;
// if (glfwGetKey(window, GLFW_KEY_LEFT) == GLFW_PRESS)
if (glfwGetKey(window, GLFW_KEY_UP) == GLFW_PRESS)

Binary file not shown.

After

Width:  |  Height:  |  Size: 36 MiB