This commit is contained in:
XsedoX 2023-02-12 22:27:34 +01:00
commit 79f13b93e5
29 changed files with 118 additions and 85 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.

View File

@ -2,7 +2,7 @@
<Project> <Project>
<ProjectOutputs> <ProjectOutputs>
<ProjectOutput> <ProjectOutput>
<FullPath>C:\Users\jedrz\Desktop\g\GRK_Project\Release\grk-cw9.exe</FullPath> <FullPath>C:\Users\jedrz\Desktop\gr\GRK_Project\Release\grk-cw9.exe</FullPath>
</ProjectOutput> </ProjectOutput>
</ProjectOutputs> </ProjectOutputs>
<ContentFiles /> <ContentFiles />

Binary file not shown.

Binary file not shown.

View File

@ -1,96 +1,86 @@
 main.cpp  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:\Program Files (x86)\Windows Kits\10\Include\10.0.19041.0\shared\minwindef.h(130,1): warning C4005: "APIENTRY": ponowna definicja makra
C:\Users\jedrz\Desktop\g\GRK_Project\dependencies\glfw-3.3.8.bin.WIN32\include\GLFW\glfw3.h(123): message : zobacz poprzednią definicję „APIENTRY” C:\Users\jedrz\Desktop\gr\GRK_Project\dependencies\glfw-3.3.8.bin.WIN32\include\GLFW\glfw3.h(123): message : zobacz poprzednią definicję „APIENTRY”
C:\Users\jedrz\Desktop\g\GRK_Project\cw 9\src\Collision_System.cpp(87,16): warning C4244: "inicjowanie": konwersja z "float" do "int", możliwa utrata danych C:\Users\jedrz\Desktop\gr\GRK_Project\cw 9\src\Collision_System.cpp(87,16): warning C4244: "inicjowanie": konwersja z "float" do "int", możliwa utrata danych
C:\Users\jedrz\Desktop\g\GRK_Project\cw 9\src\Collision_System.cpp(88,14): warning C4244: "inicjowanie": konwersja z "float" do "int", możliwa utrata danych C:\Users\jedrz\Desktop\gr\GRK_Project\cw 9\src\Collision_System.cpp(88,14): warning C4244: "inicjowanie": konwersja z "float" do "int", możliwa utrata danych
C:\Users\jedrz\Desktop\g\GRK_Project\cw 9\src\Collision_System.cpp(90,17): warning C4244: "inicjowanie": konwersja z "float" do "int", możliwa utrata danych C:\Users\jedrz\Desktop\gr\GRK_Project\cw 9\src\Collision_System.cpp(90,17): warning C4244: "inicjowanie": konwersja z "float" do "int", możliwa utrata danych
C:\Users\jedrz\Desktop\g\GRK_Project\cw 9\src\Collision_System.cpp(91,15): warning C4244: "inicjowanie": konwersja z "float" do "int", możliwa utrata danych C:\Users\jedrz\Desktop\gr\GRK_Project\cw 9\src\Collision_System.cpp(91,15): warning C4244: "inicjowanie": konwersja z "float" do "int", możliwa utrata danych
C:\Users\jedrz\Desktop\g\GRK_Project\cw 9\src\Collision_System.cpp(100,9): warning C4244: "inicjowanie": konwersja z "float" do "int", możliwa utrata danych C:\Users\jedrz\Desktop\gr\GRK_Project\cw 9\src\Collision_System.cpp(100,9): warning C4244: "inicjowanie": konwersja z "float" do "int", możliwa utrata danych
C:\Users\jedrz\Desktop\g\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\gr\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\g\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\gr\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\g\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\gr\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\g\GRK_Project\cw 9\src\ex_9_1.hpp(337,30): warning C4305: "inicjowanie": obcięcie z "double" do "float" C:\Users\jedrz\Desktop\gr\GRK_Project\cw 9\src\ex_9_1.hpp(342,30): warning C4305: "inicjowanie": obcięcie z "double" do "float"
C:\Users\jedrz\Desktop\g\GRK_Project\cw 9\src\ex_9_1.hpp(375,17): warning C4101: "data": lokalna zmienna, do której nie istnieje odwołanie C:\Users\jedrz\Desktop\gr\GRK_Project\cw 9\src\ex_9_1.hpp(370,17): warning C4101: "data": lokalna zmienna, do której nie istnieje odwołanie
C:\Users\jedrz\Desktop\g\GRK_Project\cw 9\src\ex_9_1.hpp(400,38): warning C4305: "=": obcięcie z "double" do "float" C:\Users\jedrz\Desktop\gr\GRK_Project\cw 9\src\ex_9_1.hpp(395,38): warning C4305: "=": obcięcie z "double" do "float"
C:\Users\jedrz\Desktop\g\GRK_Project\cw 9\src\ex_9_1.hpp(429,16): warning C4305: "inicjowanie": obcięcie z "double" do "float" C:\Users\jedrz\Desktop\gr\GRK_Project\cw 9\src\ex_9_1.hpp(424,16): warning C4305: "inicjowanie": obcięcie z "double" do "float"
C:\Users\jedrz\Desktop\g\GRK_Project\cw 9\src\ex_9_1.hpp(642,13): warning C4244: "inicjowanie": konwersja z "double" do "float", możliwa utrata danych C:\Users\jedrz\Desktop\gr\GRK_Project\cw 9\src\ex_9_1.hpp(641,13): warning C4244: "inicjowanie": konwersja z "double" do "float", możliwa utrata danych
C:\Users\jedrz\Desktop\g\GRK_Project\cw 9\src\ex_9_1.hpp(650,73): warning C4244: "argument": konwersja z "int" do "GLfloat", możliwa utrata danych C:\Users\jedrz\Desktop\gr\GRK_Project\cw 9\src\ex_9_1.hpp(649,73): warning C4244: "argument": konwersja z "int" do "GLfloat", możliwa utrata danych
C:\Users\jedrz\Desktop\g\GRK_Project\cw 9\src\ex_9_1.hpp(650,66): warning C4244: "argument": konwersja z "int" do "GLfloat", możliwa utrata danych C:\Users\jedrz\Desktop\gr\GRK_Project\cw 9\src\ex_9_1.hpp(649,66): warning C4244: "argument": konwersja z "int" do "GLfloat", możliwa utrata danych
C:\Users\jedrz\Desktop\g\GRK_Project\cw 9\src\ex_9_1.hpp(665,13): warning C4244: "inicjowanie": konwersja z "double" do "float", możliwa utrata danych C:\Users\jedrz\Desktop\gr\GRK_Project\cw 9\src\ex_9_1.hpp(664,13): warning C4244: "inicjowanie": konwersja z "double" do "float", możliwa utrata danych
C:\Users\jedrz\Desktop\g\GRK_Project\cw 9\src\ex_9_1.hpp(683,98): warning C4305: "argument": obcięcie z "double" do "T" C:\Users\jedrz\Desktop\gr\GRK_Project\cw 9\src\ex_9_1.hpp(682,98): warning C4305: "argument": obcięcie z "double" do "T"
with with
[ [
T=float T=float
] ]
C:\Users\jedrz\Desktop\g\GRK_Project\cw 9\src\ex_9_1.hpp(686,68): warning C4305: "argument": obcięcie z "double" do "T" C:\Users\jedrz\Desktop\gr\GRK_Project\cw 9\src\ex_9_1.hpp(685,68): warning C4305: "argument": obcięcie z "double" do "T"
with with
[ [
T=float T=float
] ]
C:\Users\jedrz\Desktop\g\GRK_Project\cw 9\src\ex_9_1.hpp(731,13): warning C4244: "inicjowanie": konwersja z "double" do "float", możliwa utrata danych C:\Users\jedrz\Desktop\gr\GRK_Project\cw 9\src\ex_9_1.hpp(730,13): warning C4244: "inicjowanie": konwersja z "double" do "float", możliwa utrata danych
C:\Users\jedrz\Desktop\g\GRK_Project\cw 9\src\ex_9_1.hpp(745,99): warning C4305: "argument": obcięcie z "double" do "T" C:\Users\jedrz\Desktop\gr\GRK_Project\cw 9\src\ex_9_1.hpp(744,99): warning C4305: "argument": obcięcie z "double" do "T"
with with
[ [
T=float T=float
] ]
C:\Users\jedrz\Desktop\g\GRK_Project\cw 9\src\ex_9_1.hpp(748,69): warning C4305: "argument": obcięcie z "double" do "T" C:\Users\jedrz\Desktop\gr\GRK_Project\cw 9\src\ex_9_1.hpp(747,69): warning C4305: "argument": obcięcie z "double" do "T"
with with
[ [
T=float T=float
] ]
C:\Users\jedrz\Desktop\g\GRK_Project\cw 9\src\ex_9_1.hpp(793,13): warning C4244: "inicjowanie": konwersja z "double" do "float", możliwa utrata danych C:\Users\jedrz\Desktop\gr\GRK_Project\cw 9\src\ex_9_1.hpp(792,13): warning C4244: "inicjowanie": konwersja z "double" do "float", możliwa utrata danych
C:\Users\jedrz\Desktop\g\GRK_Project\cw 9\src\ex_9_1.hpp(807,99): warning C4305: "argument": obcięcie z "double" do "T" C:\Users\jedrz\Desktop\gr\GRK_Project\cw 9\src\ex_9_1.hpp(806,99): warning C4305: "argument": obcięcie z "double" do "T"
with with
[ [
T=float T=float
] ]
C:\Users\jedrz\Desktop\g\GRK_Project\cw 9\src\ex_9_1.hpp(810,69): warning C4305: "argument": obcięcie z "double" do "T" C:\Users\jedrz\Desktop\gr\GRK_Project\cw 9\src\ex_9_1.hpp(809,69): warning C4305: "argument": obcięcie z "double" do "T"
with with
[ [
T=float T=float
] ]
C:\Users\jedrz\Desktop\g\GRK_Project\cw 9\src\ex_9_1.hpp(934,8): warning C4244: "inicjowanie": konwersja z "float" do "int", możliwa utrata danych C:\Users\jedrz\Desktop\gr\GRK_Project\cw 9\src\ex_9_1.hpp(933,8): warning C4244: "inicjowanie": konwersja z "float" do "int", możliwa utrata danych
C:\Users\jedrz\Desktop\g\GRK_Project\cw 9\src\ex_9_1.hpp(935,8): warning C4244: "inicjowanie": konwersja z "float" do "int", możliwa utrata danych C:\Users\jedrz\Desktop\gr\GRK_Project\cw 9\src\ex_9_1.hpp(934,8): warning C4244: "inicjowanie": konwersja z "float" do "int", możliwa utrata danych
C:\Users\jedrz\Desktop\g\GRK_Project\cw 9\src\ex_9_1.hpp(936,8): warning C4244: "inicjowanie": konwersja z "float" do "int", możliwa utrata danych C:\Users\jedrz\Desktop\gr\GRK_Project\cw 9\src\ex_9_1.hpp(935,8): warning C4244: "inicjowanie": konwersja z "float" do "int", możliwa utrata danych
C:\Users\jedrz\Desktop\g\GRK_Project\cw 9\src\ex_9_1.hpp(939,31): warning C4305: "inicjowanie": obcięcie z "double" do "float" C:\Users\jedrz\Desktop\gr\GRK_Project\cw 9\src\ex_9_1.hpp(938,31): warning C4305: "inicjowanie": obcięcie z "double" do "float"
C:\Users\jedrz\Desktop\g\GRK_Project\cw 9\src\ex_9_1.hpp(940,25): warning C4305: "inicjowanie": obcięcie z "double" do "float" C:\Users\jedrz\Desktop\gr\GRK_Project\cw 9\src\ex_9_1.hpp(939,25): warning C4305: "inicjowanie": obcięcie z "double" do "float"
C:\Users\jedrz\Desktop\g\GRK_Project\cw 9\src\ex_9_1.hpp(996,8): warning C4244: "inicjowanie": konwersja z "float" do "int", możliwa utrata danych C:\Users\jedrz\Desktop\gr\GRK_Project\cw 9\src\ex_9_1.hpp(993,8): warning C4244: "inicjowanie": konwersja z "float" do "int", możliwa utrata danych
C:\Users\jedrz\Desktop\g\GRK_Project\cw 9\src\ex_9_1.hpp(997,8): warning C4244: "inicjowanie": konwersja z "float" do "int", możliwa utrata danych C:\Users\jedrz\Desktop\gr\GRK_Project\cw 9\src\ex_9_1.hpp(994,8): warning C4244: "inicjowanie": konwersja z "float" do "int", możliwa utrata danych
C:\Users\jedrz\Desktop\g\GRK_Project\cw 9\src\ex_9_1.hpp(998,8): warning C4244: "inicjowanie": konwersja z "float" do "int", możliwa utrata danych C:\Users\jedrz\Desktop\gr\GRK_Project\cw 9\src\ex_9_1.hpp(995,8): warning C4244: "inicjowanie": konwersja z "float" do "int", możliwa utrata danych
C:\Users\jedrz\Desktop\g\GRK_Project\cw 9\src\ex_9_1.hpp(1001,31): warning C4305: "inicjowanie": obcięcie z "double" do "float" C:\Users\jedrz\Desktop\gr\GRK_Project\cw 9\src\ex_9_1.hpp(998,31): warning C4305: "inicjowanie": obcięcie z "double" do "float"
C:\Users\jedrz\Desktop\g\GRK_Project\cw 9\src\ex_9_1.hpp(1002,25): warning C4305: "inicjowanie": obcięcie z "double" do "float" C:\Users\jedrz\Desktop\gr\GRK_Project\cw 9\src\ex_9_1.hpp(999,23): warning C4305: "inicjowanie": obcięcie z "double" do "float"
C:\Users\jedrz\Desktop\g\GRK_Project\cw 9\src\ex_9_1.hpp(1108,13): warning C4244: "inicjowanie": konwersja z "double" do "float", możliwa utrata danych C:\Users\jedrz\Desktop\gr\GRK_Project\cw 9\src\ex_9_1.hpp(1101,13): warning C4244: "inicjowanie": konwersja z "double" do "float", możliwa utrata danych
C:\Users\jedrz\Desktop\g\GRK_Project\cw 9\src\ex_9_1.hpp(1122,108): warning C4305: "argument": obcięcie z "double" do "T" C:\Users\jedrz\Desktop\gr\GRK_Project\cw 9\src\ex_9_1.hpp(1115,108): warning C4305: "argument": obcięcie z "double" do "T"
with with
[ [
T=float T=float
] ]
C:\Users\jedrz\Desktop\g\GRK_Project\cw 9\src\ex_9_1.hpp(1131,87): warning C4305: "argument": obcięcie z "double" do "T" C:\Users\jedrz\Desktop\gr\GRK_Project\cw 9\src\ex_9_1.hpp(1128,85): warning C4305: "argument": obcięcie z "double" do "float"
C:\Users\jedrz\Desktop\gr\GRK_Project\cw 9\src\ex_9_1.hpp(1154,73): warning C4305: "argument": obcięcie z "double" do "float"
C:\Users\jedrz\Desktop\gr\GRK_Project\cw 9\src\ex_9_1.hpp(1158,81): warning C4305: "argument": obcięcie z "double" do "float"
C:\Users\jedrz\Desktop\gr\GRK_Project\cw 9\src\ex_9_1.hpp(1159,93): warning C4305: "argument": obcięcie z "double" do "float"
C:\Users\jedrz\Desktop\gr\GRK_Project\cw 9\src\ex_9_1.hpp(1160,83): warning C4305: "argument": obcięcie z "double" do "float"
C:\Users\jedrz\Desktop\gr\GRK_Project\cw 9\src\ex_9_1.hpp(1161,83): warning C4305: "argument": obcięcie z "double" do "float"
C:\Users\jedrz\Desktop\gr\GRK_Project\cw 9\src\ex_9_1.hpp(1257,108): warning C4305: "argument": obcięcie z "double" do "T"
with with
[ [
T=float T=float
] ]
C:\Users\jedrz\Desktop\g\GRK_Project\cw 9\src\ex_9_1.hpp(1131,223): warning C4305: "argument": obcięcie z "double" do "float" C:\Users\jedrz\Desktop\gr\GRK_Project\cw 9\src\ex_9_1.hpp(1597,21): warning C4305: "-=": obcięcie z "double" do "float"
C:\Users\jedrz\Desktop\g\GRK_Project\cw 9\src\ex_9_1.hpp(1160,73): warning C4305: "argument": obcięcie z "double" do "float" C:\Users\jedrz\Desktop\gr\GRK_Project\cw 9\src\ex_9_1.hpp(1599,21): warning C4305: "+=": obcięcie z "double" do "float"
C:\Users\jedrz\Desktop\g\GRK_Project\cw 9\src\ex_9_1.hpp(1164,81): warning C4305: "argument": obcięcie z "double" do "float"
C:\Users\jedrz\Desktop\g\GRK_Project\cw 9\src\ex_9_1.hpp(1165,93): warning C4305: "argument": obcięcie z "double" do "float"
C:\Users\jedrz\Desktop\g\GRK_Project\cw 9\src\ex_9_1.hpp(1166,83): warning C4305: "argument": obcięcie z "double" do "float"
C:\Users\jedrz\Desktop\g\GRK_Project\cw 9\src\ex_9_1.hpp(1167,83): warning C4305: "argument": obcięcie z "double" do "float"
C:\Users\jedrz\Desktop\g\GRK_Project\cw 9\src\ex_9_1.hpp(1263,108): warning C4305: "argument": obcięcie z "double" do "T"
with
[
T=float
]
C:\Users\jedrz\Desktop\g\GRK_Project\cw 9\src\ex_9_1.hpp(1592,66): warning C4244: "=": konwersja z "double" do "T", możliwa utrata danych
with
[
T=float
]
C:\Users\jedrz\Desktop\g\GRK_Project\cw 9\src\ex_9_1.hpp(1609,21): warning C4305: "-=": obcięcie z "double" do "float"
C:\Users\jedrz\Desktop\g\GRK_Project\cw 9\src\ex_9_1.hpp(1611,21): warning C4305: "+=": obcięcie z "double" do "float"
Trwa generowanie kodu Trwa generowanie kodu
1 of 723 functions ( 0.1%) were compiled, the rest were copied from previous compilation. 102 of 727 functions (14.0%) were compiled, the rest were copied from previous compilation.
0 functions were new in current compilation 1 functions were new in current compilation
9 functions had inline decision re-evaluated but remain unchanged 11 functions had inline decision re-evaluated but remain unchanged
Zakończono generowanie kodu Zakończono generowanie kodu
grk-cw9.vcxproj -> C:\Users\jedrz\Desktop\g\GRK_Project\Release\grk-cw9.exe grk-cw9.vcxproj -> C:\Users\jedrz\Desktop\gr\GRK_Project\Release\grk-cw9.exe

View File

@ -1,2 +1,2 @@
PlatformToolSet=v143:VCToolArchitecture=Native32Bit:VCToolsVersion=14.33.31629:TargetPlatformVersion=10.0.19041.0: PlatformToolSet=v143:VCToolArchitecture=Native32Bit:VCToolsVersion=14.33.31629:TargetPlatformVersion=10.0.19041.0:
Release|Win32|C:\Users\jedrz\Desktop\g\GRK_Project\| Release|Win32|C:\Users\jedrz\Desktop\gr\GRK_Project\|

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

View File

@ -9,6 +9,7 @@ uniform vec3 cameraPos;
uniform sampler2D depthMap; uniform sampler2D depthMap;
uniform sampler2D depthMap2; uniform sampler2D depthMap2;
uniform sampler2D depthMap3;
uniform sampler2D colorTexture; uniform sampler2D colorTexture;
uniform sampler2D metallicTexture; uniform sampler2D metallicTexture;
uniform sampler2D roughnessTexture; uniform sampler2D roughnessTexture;
@ -17,6 +18,7 @@ uniform sampler2D normalSampler;
uniform vec3 sunDir; uniform vec3 sunDir;
uniform vec3 sunDir2; uniform vec3 sunDir2;
uniform vec3 lampDir;
uniform vec3 sunColor; uniform vec3 sunColor;
uniform vec3 lightPos; uniform vec3 lightPos;
@ -49,6 +51,7 @@ float roughness;
in vec4 sunSpacePos; in vec4 sunSpacePos;
in vec4 sunSpacePos2; in vec4 sunSpacePos2;
in vec4 lampSpacePos;
float DistributionGGX(vec3 normal, vec3 H, float roughness){ float DistributionGGX(vec3 normal, vec3 H, float roughness){
@ -133,6 +136,19 @@ float calculateShadow2() {
return (0.5*(diff)/abs(diff))+0.5; return (0.5*(diff)/abs(diff))+0.5;
} }
float calculateShadow3() {
vec4 sunSpacePosNormalized = (0.5 * sunSpacePos / (sunSpacePos.w)) + 0.5;
float closestDepth = texture2D(depthMap3, sunSpacePosNormalized.xy).r;
if(closestDepth + 0.01 > sunSpacePosNormalized.z){
return 1.0;
} else {
return 0.0;
}
}
void main() void main()
{ {
@ -175,5 +191,8 @@ void main()
//sun2 //sun2
ilumination=ilumination+PBRLight(sunDir2, sunColor * calculateShadow2(), normal, viewDir); ilumination=ilumination+PBRLight(sunDir2, sunColor * calculateShadow2(), normal, viewDir);
ilumination=ilumination+PBRLight(lampDir, sunColor * calculateShadow3(), normal, viewDir);
outColor = vec4(vec3(1.0) - exp(-ilumination*exposition),1); outColor = vec4(vec3(1.0) - exp(-ilumination*exposition),1);
} }

View File

@ -10,6 +10,7 @@ uniform mat4 transformation;
uniform mat4 modelMatrix; uniform mat4 modelMatrix;
uniform mat4 LightVP; uniform mat4 LightVP;
uniform mat4 LightVP2; uniform mat4 LightVP2;
uniform mat4 LightVP3;
out vec3 vecNormal; out vec3 vecNormal;
out vec3 worldPos; out vec3 worldPos;
@ -26,6 +27,7 @@ out vec3 sunDirTS;
out vec2 vecTex; out vec2 vecTex;
out vec4 sunSpacePos; out vec4 sunSpacePos;
out vec4 sunSpacePos2; out vec4 sunSpacePos2;
out vec4 lampSpacePos;
void main() void main()
@ -49,5 +51,5 @@ void main()
sunDirTS = TBN*sunDir; sunDirTS = TBN*sunDir;
sunSpacePos=LightVP*modelMatrix*vec4(vertexPosition,1); sunSpacePos=LightVP*modelMatrix*vec4(vertexPosition,1);
sunSpacePos2=LightVP2*modelMatrix*vec4(vertexPosition,1); sunSpacePos2=LightVP2*modelMatrix*vec4(vertexPosition,1);
lampSpacePos=LightVP3*modelMatrix*vec4(vertexPosition,1);
} }

View File

@ -9,12 +9,14 @@ uniform vec3 cameraPos;
uniform sampler2D depthMap; uniform sampler2D depthMap;
uniform sampler2D depthMap2; uniform sampler2D depthMap2;
uniform sampler2D depthMap3;
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 sunDir2;
uniform vec3 lampDir;
uniform vec3 sunColor; uniform vec3 sunColor;
uniform vec3 lightPos; uniform vec3 lightPos;
@ -47,7 +49,7 @@ float roughness;
in vec4 sunSpacePos; in vec4 sunSpacePos;
in vec4 sunSpacePos2; in vec4 sunSpacePos2;
in vec4 lampSpacePos;
float DistributionGGX(vec3 normal, vec3 H, float roughness){ float DistributionGGX(vec3 normal, vec3 H, float roughness){
float a = roughness*roughness; float a = roughness*roughness;
@ -132,6 +134,19 @@ float calculateShadow2() {
return (0.5*(diff)/abs(diff))+0.5; return (0.5*(diff)/abs(diff))+0.5;
} }
float calculateShadow3() {
vec4 sunSpacePosNormalized = (0.5 * sunSpacePos / (sunSpacePos.w)) + 0.5;
float closestDepth = texture2D(depthMap3, sunSpacePosNormalized.xy).r;
if(closestDepth + 0.01 > sunSpacePosNormalized.z){
return 1.0;
} else {
return 0.0;
}
}
void main() void main()
{ {
color = texture2D(colorTexture, vecTex).xyz; color = texture2D(colorTexture, vecTex).xyz;
@ -159,12 +174,12 @@ void main()
//flashlight //flashlight
//vec3 spotlightDir= normalize(spotlightDirTS); //vec3 spotlightDir= normalize(spotlightDirTS);
vec3 spotlightDir= normalize(spotlightPos-worldPos); //vec3 spotlightDir= normalize(spotlightPos-worldPos);
float angle_atenuation = clamp((dot(-normalize(spotlightPos-worldPos),spotlightConeDir)-0.5)*3,0,1); //float angle_atenuation = clamp((dot(-normalize(spotlightPos-worldPos),spotlightConeDir)-0.5)*3,0,1);
attenuatedlightColor = angle_atenuation*spotlightColor/pow(length(spotlightPos-worldPos),2); //attenuatedlightColor = angle_atenuation*spotlightColor/pow(length(spotlightPos-worldPos),2);
ilumination=ilumination+PBRLight(spotlightDir,attenuatedlightColor,normal,viewDir); //ilumination=ilumination+PBRLight(spotlightDir,attenuatedlightColor,normal,viewDir);
//sun //sun
//ilumination=ilumination+PBRLight(sunDir,sunColor,normal,viewDir); //ilumination=ilumination+PBRLight(sunDir,sunColor,normal,viewDir);
@ -172,6 +187,9 @@ void main()
//sun2 //sun2
ilumination=ilumination+PBRLight(sunDir2, sunColor * calculateShadow2(), normal, viewDir); ilumination=ilumination+PBRLight(sunDir2, sunColor * calculateShadow2(), normal, viewDir);
//lamp
ilumination=ilumination+PBRLight(lampDir, sunColor * calculateShadow3(), normal, viewDir);
outColor = vec4(vec3(1.0) - exp(-ilumination*exposition),1); outColor = vec4(vec3(1.0) - exp(-ilumination*exposition),1);
} }

View File

@ -10,6 +10,7 @@ uniform mat4 transformation;
uniform mat4 modelMatrix; uniform mat4 modelMatrix;
uniform mat4 LightVP; uniform mat4 LightVP;
uniform mat4 LightVP2; uniform mat4 LightVP2;
uniform mat4 LightVP3;
out vec3 vecNormal; out vec3 vecNormal;
out vec3 worldPos; out vec3 worldPos;
@ -26,6 +27,7 @@ out vec3 sunDirTS;
out vec2 vecTex; out vec2 vecTex;
out vec4 sunSpacePos; out vec4 sunSpacePos;
out vec4 sunSpacePos2; out vec4 sunSpacePos2;
out vec4 lampSpacePos;
void main() void main()
{ {
@ -48,5 +50,5 @@ void main()
sunDirTS = TBN*sunDir; sunDirTS = TBN*sunDir;
sunSpacePos=LightVP*modelMatrix*vec4(vertexPosition,1); sunSpacePos=LightVP*modelMatrix*vec4(vertexPosition,1);
sunSpacePos2=LightVP2*modelMatrix*vec4(vertexPosition,1); sunSpacePos2=LightVP2*modelMatrix*vec4(vertexPosition,1);
lampSpacePos=LightVP3*modelMatrix*vec4(vertexPosition,1);
} }

View File

@ -37,6 +37,7 @@ namespace models {
Core::RenderContext roomContext; Core::RenderContext roomContext;
Core::RenderContext spaceshipContext; Core::RenderContext spaceshipContext;
Core::RenderContext sphereContext; Core::RenderContext sphereContext;
Core::RenderContext sphereBubbleContext;
//Core::RenderContext windowContext; //Core::RenderContext windowContext;
Core::RenderContext testContext; Core::RenderContext testContext;
Core::RenderContext cubeContext; Core::RenderContext cubeContext;
@ -93,8 +94,10 @@ namespace models {
Core::RenderContext mug2Context; Core::RenderContext mug2Context;
Core::RenderContext bookContext; Core::RenderContext bookContext;
Core::RenderContext lampContext; Core::RenderContext lampContext;
Core::RenderContext cableContext;
} }
std::vector<std::string> faces = { std::vector<std::string> faces = {
"textures/skybox_2/right.jpg", "textures/skybox_2/right.jpg",
"textures/skybox_2/left.jpg", "textures/skybox_2/left.jpg",
@ -321,6 +324,8 @@ 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 sunPos2 = glm::vec3(4.040971f, 2.149999f, -0.739280f);
glm::vec3 sunDir2 = glm::vec3(0.93633f, 0.351106, -0.003226f); glm::vec3 sunDir2 = glm::vec3(0.93633f, 0.351106, -0.003226f);
glm::vec3 lampPos = glm::vec3(1.5, 1.15, -1.1);
glm::vec3 lampDir = glm::vec3(-0.2, -1.0, 0.3);
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);
@ -337,26 +342,16 @@ float exposition = 1.f;
float spotlightPhi = 3.14 / 4; float spotlightPhi = 3.14 / 4;
glm::vec3 spotlightPos = glm::vec3(1.5, 1.15, -1.1); glm::vec3 spotlightPos = glm::vec3(1.5, 1.15, -1.1);
glm::vec3 spotlightConeDir = glm::vec3(0, -1, 0); glm::vec3 spotlightConeDir = glm::vec3(-0.2, -1.0, 0.3);
glm::vec3 spotlightColor = glm::vec3(0.4, 0.4, 0.9) * 3; glm::vec3 spotlightColor = glm::vec3(0.4, 0.4, 0.9) * 3;
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 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::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::mat4 lightVP3 = glm::ortho(-3.f, 2.3f, -1.3f, 3.f, -1.0f, 40.0f) * glm::lookAt(spotlightPos, spotlightPos - spotlightConeDir, glm::vec3(0, 1, 0)); glm::mat4 lightVP3 = glm::ortho(-3.f, 2.3f, -1.3f, 3.f, -1.0f, 40.0f) * glm::lookAt(spotlightPos, spotlightPos - spotlightConeDir, glm::vec3(0, 1, 0));
//glm::mat4 lightVP3 = glm::ortho(-10.0f,10.0f,-10.0f,10.0f,0.1f,10.f) * glm::lookAt(spotlightPos, -spotlightConeDir,glm::vec3(0.0,1.0,0.0));
glm::mat4 ort = glm::ortho(-3.0f, 3.0f, -3.0f, 3.0f, 0.1f, 3.0f);
glm::mat4 lightView = glm::lookAt(spotlightPos, spotlightPos+spotlightConeDir, glm::vec3(0.0, 1.0, 0.0));
//glm::mat4 lightVP3 = glm::perspective(glm::radians(180.0f), 1.0f, 0.05f, 25.0f) * glm::lookAt(spotlightPos, spotlightPos - spotlightConeDir, glm::vec3(0, 1, 0));
//glm::mat4 lightVP3 = ort * lightView;
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);
//glm::vec3 spotlightPos = glm::vec3(0, 0, 0);
//glm::vec3 spotlightConeDir = glm::vec3(0, 0, 0);
//glm::vec3 spotlightColor = glm::vec3(0.4, 0.4, 0.9) * 3;
glm::vec3 lightPos = glm::vec3(-8, 4, 2); glm::vec3 lightPos = glm::vec3(-8, 4, 2);
float lastTime = -1.f; float lastTime = -1.f;
@ -461,6 +456,7 @@ void drawObjectPBR(Core::RenderContext& context, glm::mat4 modelMatrix, glm::vec
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, "sunDir2"), sunDir2.x, sunDir2.y, sunDir2.z);
glUniform3f(glGetUniformLocation(program, "lampDir"), lampDir.x, lampDir.y, lampDir.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);
@ -500,6 +496,7 @@ void drawObjectTex(Core::RenderContext& context, glm::mat4 modelMatrix, float ro
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, "sunDir2"), sunDir2.x, sunDir2.y, sunDir2.z);
glUniform3f(glGetUniformLocation(program, "lampDir"), lampDir.x, lampDir.y, lampDir.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);
@ -542,6 +539,7 @@ void drawObjectTexPBR(Core::RenderContext& context, glm::mat4 modelMatrix, GLuin
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, "sunDir2"), sunDir2.x, sunDir2.y, sunDir2.z);
glUniform3f(glGetUniformLocation(program, "lampDir"), lampDir.x, lampDir.y, lampDir.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);
@ -588,6 +586,7 @@ void drawObjectTexPBR_ARM(Core::RenderContext& context, glm::mat4 modelMatrix, G
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, "sunDir2"), sunDir2.x, sunDir2.y, sunDir2.z);
glUniform3f(glGetUniformLocation(program, "lampDir"), lampDir.x, lampDir.y, lampDir.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);
@ -654,7 +653,7 @@ void drawBubble(glm::mat4 transformSphere) {
glBindTexture(GL_TEXTURE_CUBE_MAP, bubbleTexture0); glBindTexture(GL_TEXTURE_CUBE_MAP, bubbleTexture0);
Core::SetActiveTexture(bubbleTexture1, "iChannel1", programBubble, 0); Core::SetActiveTexture(bubbleTexture1, "iChannel1", programBubble, 0);
glBindTexture(GL_TEXTURE_2D, bubbleTexture1); glBindTexture(GL_TEXTURE_2D, bubbleTexture1);
Core::DrawContext(sphereContext); Core::DrawContext(models::sphereBubbleContext);
} }
@ -1119,10 +1118,11 @@ void renderScene(GLFWwindow* window)
glUseProgram(program); glUseProgram(program);
glm::mat4 transform(1.0f); glm::mat4 transform(1.0f);
//transform = glm::rotate(glm::mat4(), angle, glm::vec3(1.0f, 0.0f, 0.0f)); //transform = glm::rotate(glm::mat4(), angle, glm::vec3(1.0f, 0.0f, 0.0f));
drawObjectPBR(sphereContext, 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)), glm::vec3(0.2, 0.7, 0.3), 0.3, 0.0); //drawObjectPBR(sphereContext, 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)), glm::vec3(0.2, 0.7, 0.3), 0.3, 0.0);
//drawObjectPBR(models::fanContext, glm::mat4(), glm::vec3(0.01, 0.01, 0.01), 0.1, 0.2); //drawObjectPBR(models::fanContext, glm::mat4(), glm::vec3(0.01, 0.01, 0.01), 0.1, 0.2);
//drawObjectPBR(models::fanTopContext, glm::mat4()*rotate, glm::vec3(0.01, 0.01, 0.01), 0.1, 0.2); //drawObjectPBR(models::fanTopContext, glm::mat4()*rotate, glm::vec3(0.01, 0.01, 0.01), 0.1, 0.2);
drawObjectPBR(models::ceilingContext, glm::mat4(), glm::vec3(1,1,1), 0.5, 0); drawObjectPBR(models::ceilingContext, glm::mat4(), glm::vec3(1,1,1), 0.5, 0);
drawObjectPBR(models::cableContext, glm::mat4(), glm::vec3(0.1, 0.1, 0.1), 0.3, 0.3);
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));
@ -1434,10 +1434,11 @@ void init(GLFWwindow* window)
texture::metal = Core::LoadTexture("textures/metal.png"); texture::metal = Core::LoadTexture("textures/metal.png");
loadModelToContext("models/bubble.obj", bubbleContext, false); loadModelToContext("models/bubble.obj", bubbleContext, false);
loadModelToContext("./models/sphere.obj", sphereContext, false); loadModelToContext("./models/sphere.obj", sphereContext, false);
loadModelToContext("./models/sphere_bubble.obj", models::sphereBubbleContext, false);
loadModelToContext("./models/spray.obj", shipContext, false); loadModelToContext("./models/spray.obj", shipContext, false);
//loadModelToContext("./models/bed.obj", models::bedContext, true); //loadModelToContext("./models/bed.obj", models::bedContext, true);
//loadModelToContext("./models/chair.obj", models::chairContext, true); //loadModelToContext("./models/chair.obj", models::chairContext, true);
loadModelToContext("./models/desk.obj", models::deskContext, true); loadModelToContext("./models/desk.obj", models::deskContext, false);
//loadModelToContext("./models/door.obj", models::doorContext, false); //loadModelToContext("./models/door.obj", models::doorContext, false);
//loadModelToContext("./models/drawer.obj", models::drawerContext, false); //loadModelToContext("./models/drawer.obj", models::drawerContext, false);
loadModelToContext("./models/marbleBust.obj", models::marbleBustContext, false); loadModelToContext("./models/marbleBust.obj", models::marbleBustContext, false);
@ -1461,7 +1462,7 @@ void init(GLFWwindow* window)
loadModelToContext("./models/bed_pillow.obj", models::bed_pillowContext, false); loadModelToContext("./models/bed_pillow.obj", models::bed_pillowContext, false);
loadModelToContext("./models/paplan.obj", models::blanketContext, false); loadModelToContext("./models/paplan.obj", models::blanketContext, false);
loadModelToContext("./models/PC_desk_bake_003.obj", models::desk_topContext, false); loadModelToContext("./models/PC_desk_bake_003.obj", models::desk_topContext, true);
loadModelToContext("./models/PC_desk_bake_004.obj", models::desk_bottomContext, false); 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);
@ -1474,7 +1475,7 @@ void init(GLFWwindow* window)
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, true); loadModelToContext("./models/Foot_Rest_001.obj", models::couchContext, true);
loadModelToContext("./models/dor.obj", models::doorContext, false); 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, true);
loadModelToContext("./models/ceramic_vase_01.obj", models::vaseContext, false); 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);
@ -1498,6 +1499,7 @@ void init(GLFWwindow* window)
loadModelToContext("./models/mug2.obj", models::mug2Context, false); loadModelToContext("./models/mug2.obj", models::mug2Context, false);
loadModelToContext("./models/book.obj", models::bookContext, false); loadModelToContext("./models/book.obj", models::bookContext, false);
loadModelToContext("./models/lamp.obj", models::lampContext, false); loadModelToContext("./models/lamp.obj", models::lampContext, false);
loadModelToContext("./models/cable.obj", models::cableContext, false);
collisionSystem.calculateSceneBounding(); collisionSystem.calculateSceneBounding();