added 2nd shadow map and some new objects

This commit is contained in:
s464921 2023-02-11 12:55:02 +01:00
parent fad0a79c5c
commit 1467ac2e30
50 changed files with 291 additions and 74 deletions

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

View File

@ -9,50 +9,61 @@ C:\Users\jedrz\Desktop\graf\GRK_Project\cw 9\src\Collision_System.cpp(100,9): wa
C:\Users\jedrz\Desktop\graf\GRK_Project\cw 9\src\Collision_System.cpp(101,9): warning C4244: "inicjowanie": konwersja z "float" do "int", możliwa utrata danych C:\Users\jedrz\Desktop\graf\GRK_Project\cw 9\src\Collision_System.cpp(101,9): warning C4244: "inicjowanie": konwersja z "float" do "int", możliwa utrata danych
C:\Users\jedrz\Desktop\graf\GRK_Project\cw 9\src\Collision_System.cpp(111,29): warning C4244: "return": konwersja z "int" do "float", możliwa utrata danych C:\Users\jedrz\Desktop\graf\GRK_Project\cw 9\src\Collision_System.cpp(111,29): warning C4244: "return": konwersja z "int" do "float", możliwa utrata danych
C:\Users\jedrz\Desktop\graf\GRK_Project\cw 9\src\Collision_System.cpp(115,29): warning C4244: "return": konwersja z "int" do "float", możliwa utrata danych C:\Users\jedrz\Desktop\graf\GRK_Project\cw 9\src\Collision_System.cpp(115,29): warning C4244: "return": konwersja z "int" do "float", możliwa utrata danych
C:\Users\jedrz\Desktop\graf\GRK_Project\cw 9\src\ex_9_1.hpp(234,30): warning C4305: "inicjowanie": obcięcie z "double" do "float" C:\Users\jedrz\Desktop\graf\GRK_Project\cw 9\src\ex_9_1.hpp(270,30): warning C4305: "inicjowanie": obcięcie z "double" do "float"
C:\Users\jedrz\Desktop\graf\GRK_Project\cw 9\src\ex_9_1.hpp(248,17): warning C4101: "data": lokalna zmienna, do której nie istnieje odwołanie C:\Users\jedrz\Desktop\graf\GRK_Project\cw 9\src\ex_9_1.hpp(284,17): warning C4101: "data": lokalna zmienna, do której nie istnieje odwołanie
C:\Users\jedrz\Desktop\graf\GRK_Project\cw 9\src\ex_9_1.hpp(273,38): warning C4305: "=": obcięcie z "double" do "float" C:\Users\jedrz\Desktop\graf\GRK_Project\cw 9\src\ex_9_1.hpp(309,38): warning C4305: "=": obcięcie z "double" do "float"
C:\Users\jedrz\Desktop\graf\GRK_Project\cw 9\src\ex_9_1.hpp(302,16): warning C4305: "inicjowanie": obcięcie z "double" do "float" C:\Users\jedrz\Desktop\graf\GRK_Project\cw 9\src\ex_9_1.hpp(338,16): warning C4305: "inicjowanie": obcięcie z "double" do "float"
C:\Users\jedrz\Desktop\graf\GRK_Project\cw 9\src\ex_9_1.hpp(479,13): warning C4244: "inicjowanie": konwersja z "double" do "float", możliwa utrata danych C:\Users\jedrz\Desktop\graf\GRK_Project\cw 9\src\ex_9_1.hpp(527,13): warning C4244: "inicjowanie": konwersja z "double" do "float", możliwa utrata danych
C:\Users\jedrz\Desktop\graf\GRK_Project\cw 9\src\ex_9_1.hpp(495,98): warning C4305: "argument": obcięcie z "double" do "T" C:\Users\jedrz\Desktop\graf\GRK_Project\cw 9\src\ex_9_1.hpp(541,98): warning C4305: "argument": obcięcie z "double" do "T"
with with
[ [
T=float T=float
] ]
C:\Users\jedrz\Desktop\graf\GRK_Project\cw 9\src\ex_9_1.hpp(498,68): warning C4305: "argument": obcięcie z "double" do "T" C:\Users\jedrz\Desktop\graf\GRK_Project\cw 9\src\ex_9_1.hpp(544,68): warning C4305: "argument": obcięcie z "double" do "T"
with with
[ [
T=float T=float
] ]
C:\Users\jedrz\Desktop\graf\GRK_Project\cw 9\src\ex_9_1.hpp(591,13): warning C4244: "inicjowanie": konwersja z "double" do "float", możliwa utrata danych C:\Users\jedrz\Desktop\graf\GRK_Project\cw 9\src\ex_9_1.hpp(576,13): warning C4244: "inicjowanie": konwersja z "double" do "float", możliwa utrata danych
C:\Users\jedrz\Desktop\graf\GRK_Project\cw 9\src\ex_9_1.hpp(599,108): warning C4305: "argument": obcięcie z "double" do "T" C:\Users\jedrz\Desktop\graf\GRK_Project\cw 9\src\ex_9_1.hpp(590,99): warning C4305: "argument": obcięcie z "double" do "T"
with with
[ [
T=float T=float
] ]
C:\Users\jedrz\Desktop\graf\GRK_Project\cw 9\src\ex_9_1.hpp(607,87): warning C4305: "argument": obcięcie z "double" do "T" C:\Users\jedrz\Desktop\graf\GRK_Project\cw 9\src\ex_9_1.hpp(593,69): warning C4305: "argument": obcięcie z "double" do "T"
with with
[ [
T=float T=float
] ]
C:\Users\jedrz\Desktop\graf\GRK_Project\cw 9\src\ex_9_1.hpp(607,223): warning C4305: "argument": obcięcie z "double" do "float" C:\Users\jedrz\Desktop\graf\GRK_Project\cw 9\src\ex_9_1.hpp(685,13): warning C4244: "inicjowanie": konwersja z "double" do "float", możliwa utrata danych
C:\Users\jedrz\Desktop\graf\GRK_Project\cw 9\src\ex_9_1.hpp(610,59): warning C4305: "argument": obcięcie z "double" do "T" C:\Users\jedrz\Desktop\graf\GRK_Project\cw 9\src\ex_9_1.hpp(694,108): warning C4305: "argument": obcięcie z "double" do "T"
with with
[ [
T=float T=float
] ]
C:\Users\jedrz\Desktop\graf\GRK_Project\cw 9\src\ex_9_1.hpp(611,37): warning C4305: "argument": obcięcie z "double" do "float" C:\Users\jedrz\Desktop\graf\GRK_Project\cw 9\src\ex_9_1.hpp(702,87): warning C4305: "argument": obcięcie z "double" do "T"
C:\Users\jedrz\Desktop\graf\GRK_Project\cw 9\src\ex_9_1.hpp(643,2): warning C4305: "argument": obcięcie z "double" do "float"
C:\Users\jedrz\Desktop\graf\GRK_Project\cw 9\src\ex_9_1.hpp(738,108): warning C4305: "argument": obcięcie z "double" do "T"
with with
[ [
T=float T=float
] ]
C:\Users\jedrz\Desktop\graf\GRK_Project\cw 9\src\ex_9_1.hpp(961,21): warning C4305: "-=": obcięcie z "double" do "float" C:\Users\jedrz\Desktop\graf\GRK_Project\cw 9\src\ex_9_1.hpp(702,223): warning C4305: "argument": obcięcie z "double" do "float"
C:\Users\jedrz\Desktop\graf\GRK_Project\cw 9\src\ex_9_1.hpp(963,21): warning C4305: "+=": obcięcie z "double" do "float" C:\Users\jedrz\Desktop\graf\GRK_Project\cw 9\src\ex_9_1.hpp(705,59): warning C4305: "argument": obcięcie z "double" do "T"
with
[
T=float
]
C:\Users\jedrz\Desktop\graf\GRK_Project\cw 9\src\ex_9_1.hpp(706,37): warning C4305: "argument": obcięcie z "double" do "float"
C:\Users\jedrz\Desktop\graf\GRK_Project\cw 9\src\ex_9_1.hpp(726,2): warning C4305: "argument": obcięcie z "double" do "float"
C:\Users\jedrz\Desktop\graf\GRK_Project\cw 9\src\ex_9_1.hpp(825,108): warning C4305: "argument": obcięcie z "double" do "T"
with
[
T=float
]
C:\Users\jedrz\Desktop\graf\GRK_Project\cw 9\src\ex_9_1.hpp(1088,21): warning C4305: "-=": obcięcie z "double" do "float"
C:\Users\jedrz\Desktop\graf\GRK_Project\cw 9\src\ex_9_1.hpp(1090,21): warning C4305: "+=": obcięcie z "double" do "float"
Trwa generowanie kodu Trwa generowanie kodu
1 of 676 functions ( 0.1%) were compiled, the rest were copied from previous compilation. 2 of 687 functions ( 0.3%) were compiled, the rest were copied from previous compilation.
0 functions were new in current compilation 0 functions were new in current compilation
7 functions had inline decision re-evaluated but remain unchanged 10 functions had inline decision re-evaluated but remain unchanged
Zakończono generowanie kodu Zakończono generowanie kodu
grk-cw9.vcxproj -> C:\Users\jedrz\Desktop\graf\GRK_Project\Release\grk-cw9.exe grk-cw9.vcxproj -> C:\Users\jedrz\Desktop\graf\GRK_Project\Release\grk-cw9.exe

Binary file not shown.

View File

@ -4,12 +4,14 @@ float AMBIENT = 0.03;
float PI = 3.14; float PI = 3.14;
uniform sampler2D depthMap; uniform sampler2D depthMap;
uniform sampler2D depthMap2;
uniform vec3 cameraPos; uniform vec3 cameraPos;
uniform vec3 color; uniform vec3 color;
uniform vec3 sunDir; uniform vec3 sunDir;
uniform vec3 sunDir2;
uniform vec3 sunColor; uniform vec3 sunColor;
uniform vec3 lightPos; uniform vec3 lightPos;
@ -38,6 +40,7 @@ in vec3 sunDirTS;
in vec3 test; in vec3 test;
in vec4 sunSpacePos; in vec4 sunSpacePos;
in vec4 sunSpacePos2;
float DistributionGGX(vec3 normal, vec3 H, float roughness){ float DistributionGGX(vec3 normal, vec3 H, float roughness){
float a = roughness*roughness; float a = roughness*roughness;
@ -112,6 +115,16 @@ float calculateShadow() {
} }
} }
float calculateShadow2() {
vec4 sunSpacePosNormalized = (0.5 * sunSpacePos2 / (sunSpacePos2.w)) + 0.5;
float closestDepth = texture2D(depthMap2, sunSpacePosNormalized.xy).x;
float diff = (0.001+closestDepth) - sunSpacePosNormalized.z;
return (0.5*(diff)/abs(diff))+0.5;
}
void main() void main()
{ {
@ -142,6 +155,8 @@ void main()
//sun //sun
ilumination=ilumination+PBRLight(sunDir, sunColor * calculateShadow(), normal, viewDir); ilumination=ilumination+PBRLight(sunDir, sunColor * calculateShadow(), normal, viewDir);
//sun2
ilumination=ilumination+PBRLight(sunDir2, sunColor * calculateShadow2(), normal, viewDir);
outColor = vec4(vec3(1.0) - exp(-ilumination*exposition),1); outColor = vec4(vec3(1.0) - exp(-ilumination*exposition),1);
//outColor = vec4(roughness,metallic,0,1); //outColor = vec4(roughness,metallic,0,1);

View File

@ -9,6 +9,7 @@ layout(location = 4) in vec3 vertexBitangent;
uniform mat4 transformation; uniform mat4 transformation;
uniform mat4 modelMatrix; uniform mat4 modelMatrix;
uniform mat4 LightVP; uniform mat4 LightVP;
uniform mat4 LightVP2;
out vec3 vecNormal; out vec3 vecNormal;
out vec3 worldPos; out vec3 worldPos;
@ -23,6 +24,7 @@ out vec3 lightDirTS;
out vec3 spotlightDirTS; out vec3 spotlightDirTS;
out vec3 sunDirTS; out vec3 sunDirTS;
out vec4 sunSpacePos; out vec4 sunSpacePos;
out vec4 sunSpacePos2;
void main() void main()
{ {
@ -42,4 +44,5 @@ void main()
spotlightDirTS = TBN*SL; spotlightDirTS = TBN*SL;
sunDirTS = TBN*sunDir; sunDirTS = TBN*sunDir;
sunSpacePos=LightVP*modelMatrix*vec4(vertexPosition,1); sunSpacePos=LightVP*modelMatrix*vec4(vertexPosition,1);
sunSpacePos2=LightVP2*modelMatrix*vec4(vertexPosition,1);
} }

View File

@ -4,12 +4,14 @@ float AMBIENT = 0.03;
float PI = 3.14; float PI = 3.14;
uniform sampler2D depthMap; uniform sampler2D depthMap;
uniform sampler2D depthMap2;
uniform vec3 cameraPos; uniform vec3 cameraPos;
uniform sampler2D colorTexture; uniform sampler2D colorTexture;
uniform vec3 sunDir; uniform vec3 sunDir;
uniform vec3 sunDir2;
uniform vec3 sunColor; uniform vec3 sunColor;
uniform vec3 lightPos; uniform vec3 lightPos;
@ -39,6 +41,7 @@ in vec3 spotlightDirTS;
in vec3 sunDirTS; in vec3 sunDirTS;
in vec4 sunSpacePos; in vec4 sunSpacePos;
in vec4 sunSpacePos2;
vec3 color; vec3 color;
@ -114,6 +117,16 @@ float calculateShadow() {
return (0.5*(diff)/abs(diff))+0.5; return (0.5*(diff)/abs(diff))+0.5;
} }
float calculateShadow2() {
vec4 sunSpacePosNormalized = (0.5 * sunSpacePos2 / (sunSpacePos2.w)) + 0.5;
float closestDepth = texture2D(depthMap2, sunSpacePosNormalized.xy).x;
float diff = (0.001+closestDepth) - sunSpacePosNormalized.z;
return (0.5*(diff)/abs(diff))+0.5;
}
void main() void main()
{ {
@ -148,6 +161,8 @@ void main()
//ilumination=ilumination+PBRLight(sunDir,sunColor,normal,viewDir); //ilumination=ilumination+PBRLight(sunDir,sunColor,normal,viewDir);
ilumination=ilumination+PBRLight(sunDir, sunColor * calculateShadow(), normal, viewDir); ilumination=ilumination+PBRLight(sunDir, sunColor * calculateShadow(), normal, viewDir);
//sun2
ilumination=ilumination+PBRLight(sunDir2, sunColor * calculateShadow2(), normal, viewDir);
outColor = vec4(vec3(1.0) - exp(-ilumination*exposition),1); outColor = vec4(vec3(1.0) - exp(-ilumination*exposition),1);
} }

View File

@ -9,6 +9,7 @@ layout(location = 4) in vec3 vertexBitangent;
uniform mat4 transformation; uniform mat4 transformation;
uniform mat4 modelMatrix; uniform mat4 modelMatrix;
uniform mat4 LightVP; uniform mat4 LightVP;
uniform mat4 LightVP2;
out vec3 vecNormal; out vec3 vecNormal;
out vec3 worldPos; out vec3 worldPos;
@ -24,6 +25,8 @@ out vec3 spotlightDirTS;
out vec3 sunDirTS; out vec3 sunDirTS;
out vec2 vecTex; out vec2 vecTex;
out vec4 sunSpacePos; out vec4 sunSpacePos;
out vec4 sunSpacePos2;
void main() void main()
{ {
@ -46,5 +49,6 @@ void main()
spotlightDirTS = TBN*SL; spotlightDirTS = TBN*SL;
sunDirTS = TBN*sunDir; sunDirTS = TBN*sunDir;
sunSpacePos=LightVP*modelMatrix*vec4(vertexPosition,1); sunSpacePos=LightVP*modelMatrix*vec4(vertexPosition,1);
sunSpacePos2=LightVP2*modelMatrix*vec4(vertexPosition,1);
} }

View File

@ -8,6 +8,7 @@ float PI = 3.14;
uniform vec3 cameraPos; uniform vec3 cameraPos;
uniform sampler2D depthMap; uniform sampler2D depthMap;
uniform sampler2D depthMap2;
uniform sampler2D colorTexture; uniform sampler2D colorTexture;
uniform sampler2D metallicTexture; uniform sampler2D metallicTexture;
uniform sampler2D roughnessTexture; uniform sampler2D roughnessTexture;
@ -15,6 +16,7 @@ uniform sampler2D aoTexture;
uniform sampler2D normalSampler; uniform sampler2D normalSampler;
uniform vec3 sunDir; uniform vec3 sunDir;
uniform vec3 sunDir2;
uniform vec3 sunColor; uniform vec3 sunColor;
uniform vec3 lightPos; uniform vec3 lightPos;
@ -46,6 +48,7 @@ float metallic;
float roughness; float roughness;
in vec4 sunSpacePos; in vec4 sunSpacePos;
in vec4 sunSpacePos2;
float DistributionGGX(vec3 normal, vec3 H, float roughness){ float DistributionGGX(vec3 normal, vec3 H, float roughness){
@ -119,6 +122,17 @@ float calculateShadow() {
return (0.5*(diff)/abs(diff))+0.5; return (0.5*(diff)/abs(diff))+0.5;
} }
float calculateShadow2() {
vec4 sunSpacePosNormalized = (0.5 * sunSpacePos2 / (sunSpacePos2.w)) + 0.5;
float closestDepth = texture2D(depthMap2, sunSpacePosNormalized.xy).x;
float diff = (0.001+closestDepth) - sunSpacePosNormalized.z;
return (0.5*(diff)/abs(diff))+0.5;
}
void main() void main()
{ {
@ -157,6 +171,9 @@ void main()
//sun //sun
//ilumination=ilumination+PBRLight(sunDir,sunColor,normal,viewDir); //ilumination=ilumination+PBRLight(sunDir,sunColor,normal,viewDir);
ilumination=ilumination+PBRLight(sunDir, sunColor * calculateShadow(), normal, viewDir); ilumination=ilumination+PBRLight(sunDir, sunColor * calculateShadow(), normal, viewDir);
//outColor = vec4(vec3(1.0) - exp(-ilumination*exposition),1);
//sun2
ilumination=ilumination+PBRLight(sunDir2, sunColor * calculateShadow2(), normal, viewDir);
outColor = vec4(vec3(1.0) - exp(-ilumination*exposition),1); outColor = vec4(vec3(1.0) - exp(-ilumination*exposition),1);
} }

View File

@ -9,6 +9,7 @@ layout(location = 4) in vec3 vertexBitangent;
uniform mat4 transformation; uniform mat4 transformation;
uniform mat4 modelMatrix; uniform mat4 modelMatrix;
uniform mat4 LightVP; uniform mat4 LightVP;
uniform mat4 LightVP2;
out vec3 vecNormal; out vec3 vecNormal;
out vec3 worldPos; out vec3 worldPos;
@ -24,6 +25,8 @@ out vec3 spotlightDirTS;
out vec3 sunDirTS; out vec3 sunDirTS;
out vec2 vecTex; out vec2 vecTex;
out vec4 sunSpacePos; out vec4 sunSpacePos;
out vec4 sunSpacePos2;
void main() void main()
{ {
@ -45,5 +48,6 @@ void main()
spotlightDirTS = TBN*SL; spotlightDirTS = TBN*SL;
sunDirTS = TBN*sunDir; sunDirTS = TBN*sunDir;
sunSpacePos=LightVP*modelMatrix*vec4(vertexPosition,1); sunSpacePos=LightVP*modelMatrix*vec4(vertexPosition,1);
sunSpacePos2=LightVP2*modelMatrix*vec4(vertexPosition,1);
} }

View File

@ -8,11 +8,13 @@ float PI = 3.14;
uniform vec3 cameraPos; uniform vec3 cameraPos;
uniform sampler2D depthMap; uniform sampler2D depthMap;
uniform sampler2D depthMap2;
uniform sampler2D colorTexture; uniform sampler2D colorTexture;
uniform sampler2D armTexture; uniform sampler2D armTexture;
uniform sampler2D normalSampler; uniform sampler2D normalSampler;
uniform vec3 sunDir; uniform vec3 sunDir;
uniform vec3 sunDir2;
uniform vec3 sunColor; uniform vec3 sunColor;
uniform vec3 lightPos; uniform vec3 lightPos;
@ -44,6 +46,7 @@ float metallic;
float roughness; float roughness;
in vec4 sunSpacePos; in vec4 sunSpacePos;
in vec4 sunSpacePos2;
float DistributionGGX(vec3 normal, vec3 H, float roughness){ float DistributionGGX(vec3 normal, vec3 H, float roughness){
@ -118,6 +121,17 @@ float calculateShadow() {
} }
float calculateShadow2() {
vec4 sunSpacePosNormalized = (0.5 * sunSpacePos2 / (sunSpacePos2.w)) + 0.5;
float closestDepth = texture2D(depthMap2, sunSpacePosNormalized.xy).x;
float diff = (0.001+closestDepth) - sunSpacePosNormalized.z;
return (0.5*(diff)/abs(diff))+0.5;
}
void main() void main()
{ {
color = texture2D(colorTexture, vecTex).xyz; color = texture2D(colorTexture, vecTex).xyz;
@ -155,6 +169,9 @@ void main()
//sun //sun
//ilumination=ilumination+PBRLight(sunDir,sunColor,normal,viewDir); //ilumination=ilumination+PBRLight(sunDir,sunColor,normal,viewDir);
ilumination=ilumination+PBRLight(sunDir, sunColor * calculateShadow(), normal, viewDir); ilumination=ilumination+PBRLight(sunDir, sunColor * calculateShadow(), normal, viewDir);
//sun2
ilumination=ilumination+PBRLight(sunDir2, sunColor * calculateShadow2(), normal, viewDir);
outColor = vec4(vec3(1.0) - exp(-ilumination*exposition),1); outColor = vec4(vec3(1.0) - exp(-ilumination*exposition),1);
} }

View File

@ -9,6 +9,7 @@ layout(location = 4) in vec3 vertexBitangent;
uniform mat4 transformation; uniform mat4 transformation;
uniform mat4 modelMatrix; uniform mat4 modelMatrix;
uniform mat4 LightVP; uniform mat4 LightVP;
uniform mat4 LightVP2;
out vec3 vecNormal; out vec3 vecNormal;
out vec3 worldPos; out vec3 worldPos;
@ -24,6 +25,7 @@ out vec3 spotlightDirTS;
out vec3 sunDirTS; out vec3 sunDirTS;
out vec2 vecTex; out vec2 vecTex;
out vec4 sunSpacePos; out vec4 sunSpacePos;
out vec4 sunSpacePos2;
void main() void main()
{ {
@ -45,5 +47,6 @@ void main()
spotlightDirTS = TBN*SL; spotlightDirTS = TBN*SL;
sunDirTS = TBN*sunDir; sunDirTS = TBN*sunDir;
sunSpacePos=LightVP*modelMatrix*vec4(vertexPosition,1); sunSpacePos=LightVP*modelMatrix*vec4(vertexPosition,1);
sunSpacePos2=LightVP2*modelMatrix*vec4(vertexPosition,1);
} }

BIN
cw 9/sound/ocean.wav Normal file

Binary file not shown.

View File

@ -20,7 +20,7 @@
const unsigned int SHADOW_WIDTH = 1024, SHADOW_HEIGHT = 1024; const unsigned int SHADOW_WIDTH = 1024, SHADOW_HEIGHT = 1024;
int WIDTH = 500, HEIGHT = 500; int WIDTH = 1000, HEIGHT = 1000;
CollisionSystem collisionSystem; CollisionSystem collisionSystem;
@ -73,6 +73,11 @@ namespace models {
Core::RenderContext laptopContext; Core::RenderContext laptopContext;
Core::RenderContext screenContext; Core::RenderContext screenContext;
Core::RenderContext mugContext;
Core::RenderContext carContext;
Core::RenderContext books1Context;
Core::RenderContext books2Context;
Core::RenderContext cactusContext;
} }
std::vector<std::string> faces = { std::vector<std::string> faces = {
@ -186,10 +191,36 @@ namespace texture {
GLuint laptop_ao; GLuint laptop_ao;
GLuint laptop_normal; GLuint laptop_normal;
GLuint mug_albedo;
GLuint mug_metallic;
GLuint mug_roughness;
GLuint mug_ao;
GLuint mug_normal;
GLuint car_albedo;
GLuint car_metallic;
GLuint car_roughness;
GLuint car_ao;
GLuint car_normal;
GLuint books_albedo;
GLuint books_metallic;
GLuint books_roughness;
GLuint books_ao;
GLuint books_normal;
GLuint cactus_albedo;
GLuint cactus_metallic;
GLuint cactus_roughness;
GLuint cactus_ao;
GLuint cactus_normal;
} }
GLuint depthMapFBO; GLuint depthMapFBO;
GLuint depthMap; GLuint depthMap;
GLuint depthMapFBO2;
GLuint depthMap2;
GLuint program; GLuint program;
GLuint programSun; GLuint programSun;
@ -211,13 +242,15 @@ TriangleSoup water;
glm::vec3 sunPos = glm::vec3(-4.740971f, 2.149999f, -0.069280f); glm::vec3 sunPos = glm::vec3(-4.740971f, 2.149999f, -0.069280f);
glm::vec3 sunDir = glm::vec3(-0.93633f, 0.351106, 0.003226f); glm::vec3 sunDir = glm::vec3(-0.93633f, 0.351106, 0.003226f);
glm::vec3 sunPos2 = glm::vec3(4.040971f, 2.149999f, -0.739280f);
glm::vec3 sunDir2 = glm::vec3(0.93633f, 0.351106, -0.003226f);
glm::vec3 sunColor = glm::vec3(0.9f, 0.9f, 0.7f) * 5; 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);
glm::vec3 spaceshipPos = glm::vec3(0.065808f, 1.250000f, -2.189549f); glm::vec3 spaceshipPos = glm::vec3(0.065808f, 1.250000f, -1.189549f);
glm::vec3 spaceshipDir = glm::vec3(-0.490263f, 0.000000f, 0.871578f); glm::vec3 spaceshipDir = glm::vec3(-0.490263f, 0.000000f, 0.871578f);
GLuint VAO, VBO; GLuint VAO, VBO;
@ -225,6 +258,9 @@ float aspectRatio = 1.f;
float exposition = 1.f; float exposition = 1.f;
glm::mat4 lightVP = glm::ortho(-3.f, 2.3f, -1.3f, 3.f, -1.0f, 40.0f) * glm::lookAt(sunPos, sunPos - sunDir, glm::vec3(0, 1, 0));
glm::mat4 lightVP2 = glm::ortho(-3.f, 2.3f, -1.3f, 3.f, -1.0f, 40.0f) * glm::lookAt(sunPos2, sunPos2 - sunDir2, glm::vec3(0, 1, 0));
glm::vec3 pointlightPos = glm::vec3(0, 2, 0); glm::vec3 pointlightPos = glm::vec3(0, 2, 0);
glm::vec3 pointlightColor = glm::vec3(0.9, 0.6, 0.6); glm::vec3 pointlightColor = glm::vec3(0.9, 0.6, 0.6);
@ -333,6 +369,7 @@ 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"), sunDir.x, sunDir.y, sunDir.z);
glUniform3f(glGetUniformLocation(program, "sunDir2"), sunDir2.x, sunDir2.y, sunDir2.z);
glUniform3f(glGetUniformLocation(program, "sunColor"), sunColor.x, sunColor.y, sunColor.z); glUniform3f(glGetUniformLocation(program, "sunColor"), sunColor.x, sunColor.y, sunColor.z);
glUniform3f(glGetUniformLocation(program, "lightPos"), pointlightPos.x, pointlightPos.y, pointlightPos.z); glUniform3f(glGetUniformLocation(program, "lightPos"), pointlightPos.x, pointlightPos.y, pointlightPos.z);
@ -343,9 +380,11 @@ void drawObjectPBR(Core::RenderContext& context, glm::mat4 modelMatrix, glm::vec
glUniform3f(glGetUniformLocation(program, "spotlightColor"), spotlightColor.x, spotlightColor.y, spotlightColor.z); glUniform3f(glGetUniformLocation(program, "spotlightColor"), spotlightColor.x, spotlightColor.y, spotlightColor.z);
glUniform1f(glGetUniformLocation(program, "spotlightPhi"), spotlightPhi); glUniform1f(glGetUniformLocation(program, "spotlightPhi"), spotlightPhi);
glm::mat4 lightVP = glm::ortho(-3.f, 2.3f, -1.3f, 3.f, -1.0f, 40.0f) * glm::lookAt(sunPos, sunPos - sunDir, glm::vec3(0, 1, 0));
glUniformMatrix4fv(glGetUniformLocation(program, "LightVP"), 1, GL_FALSE, (float*)&lightVP); glUniformMatrix4fv(glGetUniformLocation(program, "LightVP"), 1, GL_FALSE, (float*)&lightVP);
Core::SetActiveTexture(depthMap, "depthMap", program, 0); Core::SetActiveTexture(depthMap, "depthMap", program, 0);
glUniformMatrix4fv(glGetUniformLocation(program, "LightVP2"), 1, GL_FALSE, (float*)&lightVP2);
Core::SetActiveTexture(depthMap2, "depthMap2", program, 1);
Core::DrawContext(context); Core::DrawContext(context);
} }
@ -367,6 +406,7 @@ void drawObjectTex(Core::RenderContext& context, glm::mat4 modelMatrix, float ro
glUniform3f(glGetUniformLocation(programTex, "cameraPos"), cameraPos.x, cameraPos.y, cameraPos.z); glUniform3f(glGetUniformLocation(programTex, "cameraPos"), cameraPos.x, cameraPos.y, cameraPos.z);
glUniform3f(glGetUniformLocation(programTex, "sunDir"), sunDir.x, sunDir.y, sunDir.z); glUniform3f(glGetUniformLocation(programTex, "sunDir"), sunDir.x, sunDir.y, sunDir.z);
glUniform3f(glGetUniformLocation(programTex, "sunDir2"), sunDir2.x, sunDir2.y, sunDir2.z);
glUniform3f(glGetUniformLocation(programTex, "sunColor"), sunColor.x, sunColor.y, sunColor.z); glUniform3f(glGetUniformLocation(programTex, "sunColor"), sunColor.x, sunColor.y, sunColor.z);
glUniform3f(glGetUniformLocation(programTex, "lightPos"), pointlightPos.x, pointlightPos.y, pointlightPos.z); glUniform3f(glGetUniformLocation(programTex, "lightPos"), pointlightPos.x, pointlightPos.y, pointlightPos.z);
@ -380,9 +420,11 @@ void drawObjectTex(Core::RenderContext& context, glm::mat4 modelMatrix, float ro
//Core::DrawContext(context); //Core::DrawContext(context);
glm::mat4 lightVP = glm::ortho(-3.f, 2.3f, -1.3f, 3.f, -1.0f, 40.0f) * glm::lookAt(sunPos, sunPos - sunDir, glm::vec3(0, 1, 0));
glUniformMatrix4fv(glGetUniformLocation(programTex, "LightVP"), 1, GL_FALSE, (float*)&lightVP); glUniformMatrix4fv(glGetUniformLocation(programTex, "LightVP"), 1, GL_FALSE, (float*)&lightVP);
Core::SetActiveTexture(depthMap, "depthMap", programTex, 1); Core::SetActiveTexture(depthMap, "depthMap", programTex, 1);
glUniformMatrix4fv(glGetUniformLocation(programTex, "LightVP2"), 1, GL_FALSE, (float*)&lightVP2);
Core::SetActiveTexture(depthMap2, "depthMap2", programTex, 2);
Core::DrawContext(context); Core::DrawContext(context);
} }
@ -404,6 +446,7 @@ void drawObjectTexPBR(Core::RenderContext& context, glm::mat4 modelMatrix, GLuin
glUniform3f(glGetUniformLocation(programTexPBR, "cameraPos"), cameraPos.x, cameraPos.y, cameraPos.z); glUniform3f(glGetUniformLocation(programTexPBR, "cameraPos"), cameraPos.x, cameraPos.y, cameraPos.z);
glUniform3f(glGetUniformLocation(programTexPBR, "sunDir"), sunDir.x, sunDir.y, sunDir.z); glUniform3f(glGetUniformLocation(programTexPBR, "sunDir"), sunDir.x, sunDir.y, sunDir.z);
glUniform3f(glGetUniformLocation(programTexPBR, "sunDir2"), sunDir2.x, sunDir2.y, sunDir2.z);
glUniform3f(glGetUniformLocation(programTexPBR, "sunColor"), sunColor.x, sunColor.y, sunColor.z); glUniform3f(glGetUniformLocation(programTexPBR, "sunColor"), sunColor.x, sunColor.y, sunColor.z);
glUniform3f(glGetUniformLocation(programTexPBR, "lightPos"), pointlightPos.x, pointlightPos.y, pointlightPos.z); glUniform3f(glGetUniformLocation(programTexPBR, "lightPos"), pointlightPos.x, pointlightPos.y, pointlightPos.z);
@ -421,9 +464,11 @@ void drawObjectTexPBR(Core::RenderContext& context, glm::mat4 modelMatrix, GLuin
//Core::DrawContext(context); //Core::DrawContext(context);
glm::mat4 lightVP = glm::ortho(-3.f, 2.3f, -1.3f, 3.f, -1.0f, 40.0f) * glm::lookAt(sunPos, sunPos - sunDir, glm::vec3(0, 1, 0));
glUniformMatrix4fv(glGetUniformLocation(programTexPBR, "LightVP"), 1, GL_FALSE, (float*)&lightVP); glUniformMatrix4fv(glGetUniformLocation(programTexPBR, "LightVP"), 1, GL_FALSE, (float*)&lightVP);
Core::SetActiveTexture(depthMap, "depthMap", programTexPBR, 0); Core::SetActiveTexture(depthMap, "depthMap", programTexPBR, 0);
glUniformMatrix4fv(glGetUniformLocation(programTexPBR, "LightVP2"), 1, GL_FALSE, (float*)&lightVP2);
Core::SetActiveTexture(depthMap2, "depthMap2", programTexPBR, 6);
Core::DrawContext(context); Core::DrawContext(context);
} }
@ -445,6 +490,7 @@ void drawObjectTexPBR_ARM(Core::RenderContext& context, glm::mat4 modelMatrix, G
glUniform3f(glGetUniformLocation(programTexPBR_ARM, "cameraPos"), cameraPos.x, cameraPos.y, cameraPos.z); glUniform3f(glGetUniformLocation(programTexPBR_ARM, "cameraPos"), cameraPos.x, cameraPos.y, cameraPos.z);
glUniform3f(glGetUniformLocation(programTexPBR_ARM, "sunDir"), sunDir.x, sunDir.y, sunDir.z); glUniform3f(glGetUniformLocation(programTexPBR_ARM, "sunDir"), sunDir.x, sunDir.y, sunDir.z);
glUniform3f(glGetUniformLocation(programTexPBR_ARM, "sunDir2"), sunDir2.x, sunDir2.y, sunDir2.z);
glUniform3f(glGetUniformLocation(programTexPBR_ARM, "sunColor"), sunColor.x, sunColor.y, sunColor.z); glUniform3f(glGetUniformLocation(programTexPBR_ARM, "sunColor"), sunColor.x, sunColor.y, sunColor.z);
glUniform3f(glGetUniformLocation(programTexPBR_ARM, "lightPos"), pointlightPos.x, pointlightPos.y, pointlightPos.z); glUniform3f(glGetUniformLocation(programTexPBR_ARM, "lightPos"), pointlightPos.x, pointlightPos.y, pointlightPos.z);
@ -460,9 +506,11 @@ void drawObjectTexPBR_ARM(Core::RenderContext& context, glm::mat4 modelMatrix, G
//Core::DrawContext(context); //Core::DrawContext(context);
glm::mat4 lightVP = glm::ortho(-3.f, 2.3f, -1.3f, 3.f, -1.0f, 40.0f) * glm::lookAt(sunPos, sunPos - sunDir, glm::vec3(0, 1, 0));
glUniformMatrix4fv(glGetUniformLocation(programTexPBR_ARM, "LightVP"), 1, GL_FALSE, (float*)&lightVP); glUniformMatrix4fv(glGetUniformLocation(programTexPBR_ARM, "LightVP"), 1, GL_FALSE, (float*)&lightVP);
Core::SetActiveTexture(depthMap, "depthMap", programTexPBR_ARM, 0); Core::SetActiveTexture(depthMap, "depthMap", programTexPBR_ARM, 0);
glUniformMatrix4fv(glGetUniformLocation(programTexPBR_ARM, "LightVP2"), 1, GL_FALSE, (float*)&lightVP2);
Core::SetActiveTexture(depthMap2, "depthMap2", programTexPBR_ARM, 4);
Core::DrawContext(context); Core::DrawContext(context);
} }
@ -490,35 +538,11 @@ void renderShadowapSun() {
//ustawianie programu //ustawianie programu
glUseProgram(programDepth); glUseProgram(programDepth);
glm::mat4 lightVP = glm::ortho(-3.f, 2.3f, -1.3f, 3.f, -1.0f, 40.0f) * glm::lookAt(sunPos, sunPos - sunDir, glm::vec3(0, 1, 0));
drawObjectDepth(sphereContext, lightVP, 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, lightVP, 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, drawObjectDepth(sphereContext,
lightVP, 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))); lightVP, 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)));
/*
drawObjectTexPBR(models::bedContext, glm::mat4(), texture::wood_roughness, texture::wood_metallic, texture::wood_albedo, texture::wood_normal, texture::wood_ao);
drawObjectTexPBR(models::mattressContext, glm::mat4(), texture::sheets_roughness, texture::sheets_metallic, texture::sheets_albedo, texture::sheets_normal, texture::sheets_ao);
drawObjectTexPBR(models::bed_pillowContext, glm::mat4(), texture::sheets_roughness, texture::sheets_metallic, texture::sheets_albedo, texture::sheets_normal, texture::sheets_ao);
drawObjectTexPBR(models::floorContext, glm::mat4(), texture::floor_roughness, texture::floor_metallic, texture::floor_albedo, texture::floor_normal, texture::floor_ao);
drawObjectTexPBR(models::desk_topContext, glm::mat4(), texture::wood_roughness, texture::wood_metallic, texture::wood_albedo, texture::wood_normal, texture::wood_ao);
drawObjectTexPBR(models::desk_bottomContext, glm::mat4(), texture::black_metal_roughness, texture::black_metal_metallic, texture::black_metal_albedo, texture::black_metal_normal, texture::black_metal_ao);
drawObjectTexPBR(models::framesContext, glm::mat4(), texture::wood_roughness, texture::wood_metallic, texture::wood_albedo, texture::wood_normal, texture::wood_ao);
drawObjectTexPBR(models::wallContext, glm::mat4(), texture::white_paint_roughness, texture::white_paint_metallic, texture::white_paint_albedo, texture::white_paint_normal, texture::white_paint_ao);
drawObjectTexPBR(models::foldingContext, glm::mat4(), texture::bamboo_roughness, texture::bamboo_metallic, texture::bamboo_albedo, texture::bamboo_normal, texture::bamboo_ao);
drawObjectTexPBR(models::couchContext, glm::mat4(), texture::couch_roughness, texture::couch_metallic, texture::couch_albedo, texture::couch_normal, texture::couch_ao);
drawObjectTexPBR(models::doorContext, glm::mat4(), texture::wood_roughness, texture::wood_metallic, texture::wood_albedo, texture::wood_normal, texture::wood_ao);
drawObjectTexPBR(models::chairContext, glm::mat4(), texture::wood_roughness, texture::wood_metallic, texture::wood_albedo, texture::wood_normal, texture::wood_ao);
drawObjectTexPBR_ARM(models::roofContext, glm::mat4(), texture::wall_albedo, texture::wall_normal, texture::wall_arm);
drawObjectTexPBR_ARM(models::blanketContext, glm::mat4(), texture::blanket_albedo, texture::blanket_normal, texture::blanket_arm);
drawObjectTexPBR_ARM(models::drawerContext, glm::mat4(), texture::drawer_albedo, texture::drawer_normal, texture::drawer_arm);
drawObjectTexPBR_ARM(models::clockContext, glm::mat4(), texture::clock_albedo, texture::clock_normal, texture::clock_arm);
drawObjectTexPBR_ARM(models::plantContext, glm::mat4(), texture::plant_albedo, texture::clock_normal, texture::plant_arm);
drawObjectTexPBR_ARM(models::c_tableContext, glm::mat4(), texture::c_table_albedo, texture::c_table_normal, texture::c_table_arm);
drawObjectTexPBR_ARM(models::vaseContext, glm::mat4(), texture::vase_albedo, texture::vase_normal, texture::vase_arm);
*/
drawObjectDepth(models::bedContext, lightVP, glm::mat4()); drawObjectDepth(models::bedContext, lightVP, glm::mat4());
drawObjectDepth(models::mattressContext, lightVP, glm::mat4()); drawObjectDepth(models::mattressContext, lightVP, glm::mat4());
drawObjectDepth(models::bed_pillowContext, lightVP, glm::mat4()); drawObjectDepth(models::bed_pillowContext, lightVP, glm::mat4());
@ -539,10 +563,60 @@ void renderShadowapSun() {
drawObjectDepth(models::plantContext, lightVP, glm::mat4()); drawObjectDepth(models::plantContext, lightVP, glm::mat4());
drawObjectDepth(models::c_tableContext, lightVP, glm::mat4()); drawObjectDepth(models::c_tableContext, lightVP, glm::mat4());
drawObjectDepth(models::foldingContext, lightVP, glm::mat4()); drawObjectDepth(models::foldingContext, lightVP, glm::mat4());
drawObjectDepth(models::mugContext, lightVP, glm::mat4());
drawObjectDepth(models::carContext, lightVP, glm::mat4());
drawObjectDepth(models::books1Context, lightVP, glm::mat4());
drawObjectDepth(models::books2Context, lightVP, glm::mat4());
drawObjectDepth(models::cactusContext, lightVP, glm::mat4());
glBindFramebuffer(GL_FRAMEBUFFER, 0);
glViewport(0, 0, WIDTH, HEIGHT);
}
void renderShadowapSun2() {
float time = glfwGetTime();
glViewport(0, 0, SHADOW_WIDTH, SHADOW_HEIGHT);
//uzupelnij o renderowanie glebokosci do tekstury
glUseProgram(programDepth);
//ustawianie przestrzeni rysowania
glViewport(0, 0, SHADOW_WIDTH, SHADOW_HEIGHT);
//bindowanie FBO
glBindFramebuffer(GL_FRAMEBUFFER, depthMapFBO2);
//czyszczenie mapy głębokości
glClear(GL_DEPTH_BUFFER_BIT);
//ustawianie programu
glUseProgram(programDepth);
drawObjectDepth(sphereContext, lightVP2, 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,
lightVP2, 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::bedContext, lightVP2, glm::mat4());
drawObjectDepth(models::mattressContext, lightVP2, glm::mat4());
drawObjectDepth(models::bed_pillowContext, lightVP2, glm::mat4());
drawObjectDepth(models::floorContext, lightVP2, glm::mat4());
drawObjectDepth(models::desk_topContext, lightVP2, glm::mat4());
drawObjectDepth(models::desk_bottomContext, lightVP2, glm::mat4());
drawObjectDepth(models::framesContext, lightVP2, glm::mat4());
drawObjectDepth(models::wallContext, lightVP2, glm::mat4());
drawObjectDepth(models::foldingContext, lightVP2, glm::mat4());
drawObjectDepth(models::couchContext, lightVP2, glm::mat4());
drawObjectDepth(models::laptopContext, lightVP2, glm::mat4());
drawObjectDepth(models::doorContext, lightVP2, glm::mat4());
drawObjectDepth(models::chairContext, lightVP2, glm::mat4());
drawObjectDepth(models::roofContext, lightVP2, glm::mat4());
drawObjectDepth(models::blanketContext, lightVP2, glm::mat4());
drawObjectDepth(models::drawerContext, lightVP2, glm::mat4());
drawObjectDepth(models::clockContext, lightVP2, glm::mat4());
drawObjectDepth(models::plantContext, lightVP2, glm::mat4());
drawObjectDepth(models::c_tableContext, lightVP2, glm::mat4());
drawObjectDepth(models::foldingContext, lightVP2, glm::mat4());
drawObjectDepth(models::mugContext, lightVP2, glm::mat4());
drawObjectDepth(models::carContext, lightVP2, glm::mat4());
drawObjectDepth(models::books1Context, lightVP2, glm::mat4());
drawObjectDepth(models::books2Context, lightVP2, glm::mat4());
drawObjectDepth(models::cactusContext, lightVP2, glm::mat4());
glBindFramebuffer(GL_FRAMEBUFFER, 0); glBindFramebuffer(GL_FRAMEBUFFER, 0);
glViewport(0, 0, WIDTH, HEIGHT); glViewport(0, 0, WIDTH, HEIGHT);
} }
@ -567,6 +641,26 @@ void initDepthMap()
glBindFramebuffer(GL_FRAMEBUFFER, 0); glBindFramebuffer(GL_FRAMEBUFFER, 0);
} }
void initDepthMap2()
{
glGenFramebuffers(1, &depthMapFBO2);
glGenTextures(1, &depthMap2);
glBindTexture(GL_TEXTURE_2D, depthMap2);
glTexImage2D(GL_TEXTURE_2D, 0, GL_DEPTH_COMPONENT,
SHADOW_WIDTH, SHADOW_HEIGHT, 0, GL_DEPTH_COMPONENT, GL_FLOAT, NULL);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT);
glBindFramebuffer(GL_FRAMEBUFFER, depthMapFBO2);
glFramebufferTexture2D(GL_FRAMEBUFFER, GL_DEPTH_ATTACHMENT, GL_TEXTURE_2D, depthMap2, 0);
glDrawBuffer(GL_NONE);
glReadBuffer(GL_NONE);
glBindFramebuffer(GL_FRAMEBUFFER, 0);
}
void drawObjectColorWater(Core::RenderContext& context, glm::mat4 modelMatrix, glm::vec3 color, float time, GLuint textureID) { void drawObjectColorWater(Core::RenderContext& context, glm::mat4 modelMatrix, glm::vec3 color, float time, GLuint textureID) {
glm::mat4 viewProjectionMatrix = createPerspectiveMatrix() * glm::mat4(glm::mat3(createCameraMatrix())); glm::mat4 viewProjectionMatrix = createPerspectiveMatrix() * glm::mat4(glm::mat3(createCameraMatrix()));
@ -592,6 +686,7 @@ void renderScene(GLFWwindow* window)
updateDeltaTime(time); updateDeltaTime(time);
renderShadowapSun(); renderShadowapSun();
renderShadowapSun2();
//space lamp //space lamp
glUseProgram(programSun); glUseProgram(programSun);
@ -610,18 +705,6 @@ void renderScene(GLFWwindow* window)
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)), 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)),
glm::vec3(0.5, 0.5, 0.5), 0.7, 0.0); glm::vec3(0.5, 0.5, 0.5), 0.7, 0.0);
//drawObjectPBR(models::bedContext, glm::mat4(), glm::vec3(0.03f, 0.03f, 0.03f), 0.2f, 0.0f);
//drawObjectPBR(models::chairContext, glm::mat4(), glm::vec3(0.195239f, 0.37728f, 0.8f), 0.4f, 0.0f);
//drawObjectPBR(models::deskContext, glm::mat4(), glm::vec3(0.428691f, 0.08022f, 0.036889f), 0.2f, 0.0f);
//drawObjectPBR(models::doorContext, glm::mat4(), glm::vec3(0.402978f, 0.120509f, 0.057729f), 0.2f, 0.0f);
//drawObjectPBR(models::drawerContext, glm::mat4(), glm::vec3(0.428691f, 0.08022f, 0.036889f), 0.2f, 0.0f);
//drawObjectPBR(models::marbleBustContext, glm::mat4(), glm::vec3(1.f, 1.f, 1.f), 0.5f, 1.0f);
//drawObjectPBR(models::materaceContext, glm::mat4(), glm::vec3(0.9f, 0.9f, 0.9f), 0.8f, 0.0f);
//drawObjectPBR(models::pencilsContext, glm::mat4(), glm::vec3(0.10039f, 0.018356f, 0.001935f), 0.1f, 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(0.9f, 0.9f, 0.9f), 0.8f, 0.0f);
//drawObjectPBR(models::windowContext, glm::mat4(), 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 spaceshipSide = glm::normalize(glm::cross(spaceshipDir, glm::vec3(0.f, 1.f, 0.f)));
glm::vec3 spaceshipUp = glm::normalize(glm::cross(spaceshipSide, spaceshipDir)); glm::vec3 spaceshipUp = glm::normalize(glm::cross(spaceshipSide, spaceshipDir));
glm::mat4 specshipCameraRotrationMatrix = glm::mat4({ glm::mat4 specshipCameraRotrationMatrix = glm::mat4({
@ -667,7 +750,11 @@ void renderScene(GLFWwindow* window)
drawObjectTexPBR(models::doorContext, glm::mat4(), texture::wood_roughness, texture::wood_metallic, texture::wood_albedo, texture::wood_normal, texture::wood_ao); drawObjectTexPBR(models::doorContext, glm::mat4(), texture::wood_roughness, texture::wood_metallic, texture::wood_albedo, texture::wood_normal, texture::wood_ao);
drawObjectTexPBR(models::chairContext, glm::mat4(), texture::wood_roughness, texture::wood_metallic, texture::wood_albedo, texture::wood_normal, texture::wood_ao); drawObjectTexPBR(models::chairContext, glm::mat4(), texture::wood_roughness, texture::wood_metallic, texture::wood_albedo, texture::wood_normal, texture::wood_ao);
drawObjectTexPBR(models::laptopContext, glm::mat4(), texture::laptop_roughness, texture::laptop_metallic, texture::laptop_albedo, texture::laptop_normal, texture::laptop_ao); drawObjectTexPBR(models::laptopContext, glm::mat4(), texture::laptop_roughness, texture::laptop_metallic, texture::laptop_albedo, texture::laptop_normal, texture::laptop_ao);
drawObjectTexPBR(models::mugContext, glm::mat4(), texture::mug_roughness, texture::mug_metallic, texture::mug_albedo, texture::mug_normal, texture::mug_ao);
drawObjectTexPBR(models::carContext, glm::mat4(), texture::car_roughness, texture::car_metallic, texture::car_albedo, texture::car_normal, texture::car_ao);
drawObjectTexPBR(models::cactusContext, glm::mat4(), texture::cactus_roughness, texture::cactus_metallic, texture::cactus_albedo, texture::cactus_normal, texture::cactus_ao);
drawObjectTexPBR(models::books1Context, glm::mat4(), texture::books_roughness, texture::books_metallic, texture::books_albedo, texture::books_normal, texture::books_ao);
drawObjectTexPBR(models::books2Context, glm::mat4(), texture::books_roughness, texture::books_metallic, texture::books_albedo, texture::books_normal, texture::books_ao);
@ -738,6 +825,8 @@ void init(GLFWwindow* window)
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));
glfwSetFramebufferSizeCallback(window, framebuffer_size_callback); glfwSetFramebufferSizeCallback(window, framebuffer_size_callback);
initDepthMap(); initDepthMap();
initDepthMap2();
PlaySound(TEXT("sound/ocean.wav"), NULL, SND_ASYNC|SND_LOOP);
glEnable(GL_DEPTH_TEST); glEnable(GL_DEPTH_TEST);
program = shaderLoader.CreateProgram("shaders/shader_9_1.vert", "shaders/shader_9_1.frag"); program = shaderLoader.CreateProgram("shaders/shader_9_1.vert", "shaders/shader_9_1.frag");
programTest = shaderLoader.CreateProgram("shaders/test.vert", "shaders/test.frag"); programTest = shaderLoader.CreateProgram("shaders/test.vert", "shaders/test.frag");
@ -855,6 +944,30 @@ void init(GLFWwindow* window)
texture::laptop_normal = Core::LoadTexture("textures/laptop/normal.png"); texture::laptop_normal = Core::LoadTexture("textures/laptop/normal.png");
texture::screen = Core::LoadTexture("textures/visual.png"); texture::screen = Core::LoadTexture("textures/visual.png");
texture::mug_albedo = Core::LoadTexture("textures/mug/albedo.png");
texture::mug_metallic = Core::LoadTexture("textures/mug/metallic.png");
texture::mug_roughness = Core::LoadTexture("textures/mug/roughness.png");
texture::mug_ao = Core::LoadTexture("textures/mug/ao.png");
texture::mug_normal = Core::LoadTexture("textures/mug/normal.png");
texture::car_albedo = Core::LoadTexture("textures/car/albedo.jpg");
texture::car_metallic = Core::LoadTexture("textures/car/metallic.jpg");
texture::car_roughness = Core::LoadTexture("textures/car/roughness.jpg");
texture::car_ao = Core::LoadTexture("textures/car/ao.jpg");
texture::car_normal = Core::LoadTexture("textures/car/normal.jpg");
texture::books_albedo = Core::LoadTexture("textures/books/albedo.png");
texture::books_metallic = Core::LoadTexture("textures/books/metallic.png");
texture::books_roughness = Core::LoadTexture("textures/books/roughness.png");
texture::books_ao = Core::LoadTexture("textures/books/ao.png");
texture::books_normal = Core::LoadTexture("textures/books/normal.png");
texture::cactus_albedo = Core::LoadTexture("textures/cactus/albedo.png");
texture::cactus_metallic = Core::LoadTexture("textures/cactus/metallic.png");
texture::cactus_roughness = Core::LoadTexture("textures/cactus/roughness.png");
texture::cactus_ao = Core::LoadTexture("textures/cactus/ao.png");
texture::cactus_normal = Core::LoadTexture("textures/cactus/normal.png");
loadModelToContext("./models/sphere.obj", sphereContext, false); loadModelToContext("./models/sphere.obj", sphereContext, false);
loadModelToContext("./models/spaceship.obj", shipContext, false); loadModelToContext("./models/spaceship.obj", shipContext, false);
//loadModelToContext("./models/bed.obj", models::bedContext, true); //loadModelToContext("./models/bed.obj", models::bedContext, true);
@ -881,25 +994,31 @@ void init(GLFWwindow* window)
loadModelToContext("./models/bed_frame.obj", models::bedContext, true); loadModelToContext("./models/bed_frame.obj", models::bedContext, true);
loadModelToContext("./models/bed_mattress.obj", models::mattressContext, true); loadModelToContext("./models/bed_mattress.obj", models::mattressContext, true);
loadModelToContext("./models/bed_pillow.obj", models::bed_pillowContext, false); loadModelToContext("./models/bed_pillow.obj", models::bed_pillowContext, false);
loadModelToContext("./models/paplan.obj", models::blanketContext, true); loadModelToContext("./models/paplan.obj", models::blanketContext, false);
loadModelToContext("./models/PC_desk_bake_003.obj", models::desk_topContext, true); loadModelToContext("./models/PC_desk_bake_003.obj", models::desk_topContext, true);
loadModelToContext("./models/PC_desk_bake_004.obj", models::desk_bottomContext, true); loadModelToContext("./models/PC_desk_bake_004.obj", models::desk_bottomContext, false);
loadModelToContext("./models/Cube_002.obj", models::paper_stack2Context, false); loadModelToContext("./models/Cube_002.obj", models::paper_stack2Context, false);
loadModelToContext("./models/Cube_009.obj", models::paper_stack3Context, false); loadModelToContext("./models/Cube_009.obj", models::paper_stack3Context, false);
loadModelToContext("./models/windows_v.obj", models::framesContext, false); loadModelToContext("./models/windows_v.obj", models::framesContext, false);
loadModelToContext("./models/Cylinder.obj", models::trashcanContext, true); loadModelToContext("./models/Cylinder.obj", models::trashcanContext, false);
loadModelToContext("./models/drawer_cabinet.obj", models::drawerContext, true); loadModelToContext("./models/drawer_cabinet.obj", models::drawerContext, true);
loadModelToContext("./models/alarm_clock_01.obj", models::clockContext, true); loadModelToContext("./models/alarm_clock_01.obj", models::clockContext, false);
loadModelToContext("./models/potted_plant_04.obj", models::plantContext, true); loadModelToContext("./models/potted_plant_04.obj", models::plantContext, false);
loadModelToContext("./models/modern_coffee_table_01.obj", models::c_tableContext, true); loadModelToContext("./models/modern_coffee_table_01.obj", models::c_tableContext, false);
loadModelToContext("./models/20848_Folding_Screen_v3.obj", models::foldingContext, true); loadModelToContext("./models/20848_Folding_Screen_v3.obj", models::foldingContext, true);
loadModelToContext("./models/Foot_Rest_001.obj", models::couchContext, false); loadModelToContext("./models/Foot_Rest_001.obj", models::couchContext, false);
loadModelToContext("./models/dor.obj", models::doorContext, true); loadModelToContext("./models/dor.obj", models::doorContext, false);
loadModelToContext("./models/uploads_files_1938755_KAUSTBY.obj", models::chairContext, false); loadModelToContext("./models/uploads_files_1938755_KAUSTBY.obj", models::chairContext, false);
loadModelToContext("./models/ceramic_vase_01.obj", models::vaseContext, true); loadModelToContext("./models/ceramic_vase_01.obj", models::vaseContext, false);
loadModelToContext("./models/laptop.obj", models::laptopContext, false); loadModelToContext("./models/laptop.obj", models::laptopContext, false);
loadModelToContext("./models/screen.obj", models::screenContext, false); loadModelToContext("./models/screen.obj", models::screenContext, false);
loadModelToContext("./models/mug.obj", models::mugContext, false);
loadModelToContext("./models/car.obj", models::carContext, false);
loadModelToContext("./models/cactus.obj", models::cactusContext, false);
loadModelToContext("./models/books1.obj", models::books1Context, false);
loadModelToContext("./models/books2.obj", models::books2Context, false);
collisionSystem.calculateSceneBounding(); collisionSystem.calculateSceneBounding();
skyboxTexture = loadSkybox(faces); skyboxTexture = loadSkybox(faces);
@ -946,8 +1065,16 @@ void processInput(GLFWwindow* window)
PlaySound(TEXT("sound/main.wav"), NULL, SND_ASYNC); PlaySound(TEXT("sound/main.wav"), NULL, SND_ASYNC);
} }
if (glfwGetKey(window, GLFW_KEY_J) == GLFW_PRESS) { if (glfwGetKey(window, GLFW_KEY_J) == GLFW_PRESS) {
texture::screen = Core::LoadTexture("textures/heroes.jpg");
PlaySound(TEXT("sound/grass.wav"), NULL, SND_ASYNC);
}
if (glfwGetKey(window, GLFW_KEY_K) == GLFW_PRESS) {
texture::screen = Core::LoadTexture("textures/necro.png");
PlaySound(TEXT("sound/necro.wav"), NULL, SND_ASYNC);
}
if (glfwGetKey(window, GLFW_KEY_L) == GLFW_PRESS) {
texture::screen = Core::LoadTexture("textures/visual.png"); texture::screen = Core::LoadTexture("textures/visual.png");
PlaySound(nullptr, nullptr, 0); PlaySound(TEXT("sound/ocean.wav"), NULL, SND_ASYNC|SND_LOOP);
} }
cameraDir = spaceshipDir; cameraDir = spaceshipDir;

View File

@ -24,7 +24,7 @@ int main(int argc, char** argv)
#endif #endif
// tworzenie okna za pomoca glfw // tworzenie okna za pomoca glfw
GLFWwindow* window = glfwCreateWindow(500, 500, "FirstWindow", NULL, NULL); GLFWwindow* window = glfwCreateWindow(1000, 1000, "FirstWindow", NULL, NULL);
if (window == NULL) if (window == NULL)
{ {
std::cout << "Failed to create GLFW window" << std::endl; std::cout << "Failed to create GLFW window" << std::endl;
@ -35,7 +35,7 @@ int main(int argc, char** argv)
// ladowanie OpenGL za pomoca glew // ladowanie OpenGL za pomoca glew
glewInit(); glewInit();
glViewport(0, 0, 500, 500); glViewport(0, 0, 1000, 1000);
init(window); init(window);

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.5 MiB

BIN
cw 9/textures/books/ao.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.7 MiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 9.7 MiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 620 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.7 MiB

BIN
cw 9/textures/cactus/ao.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.2 MiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 492 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.9 MiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.2 MiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.4 MiB

BIN
cw 9/textures/car/ao.jpg Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.2 MiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 257 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.1 MiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 295 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 291 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.4 MiB

BIN
cw 9/textures/floor3/ao.jpg Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.0 MiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.7 MiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 853 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.5 MiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 10 MiB

BIN
cw 9/textures/floor4/ao.jpg Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 744 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.2 MiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.6 MiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.5 MiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 790 KiB

BIN
cw 9/textures/mug/ao.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 268 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 202 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.8 MiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 515 KiB

1
models.txt Normal file
View File

@ -0,0 +1 @@
https://drive.google.com/drive/folders/1H9mCPv32GYCW7wTFX0St0C-mWTQPUpZ-?usp=sharing