PBR textures #1

Closed
s464921 wants to merge 3 commits from pbr into master
105 changed files with 68035 additions and 72 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.

BIN
cw 9/Debug/TriangleSoup.obj Normal file

Binary file not shown.

View File

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

View File

@ -1,47 +1,49 @@
 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\jedrz\Desktop\grk\dependencies\glfw-3.3.8.bin.WIN32\include\GLFW\glfw3.h(123): message : zobacz poprzednią definicję „APIENTRY”
C:\Users\jedrz\Desktop\grk\cw 9\src\ex_9_1.hpp(100,30): warning C4305: "inicjowanie": obcięcie z "double" do "float"
C:\Users\jedrz\Desktop\grk\cw 9\src\ex_9_1.hpp(114,17): warning C4101: "data": lokalna zmienna, do której nie istnieje odwołanie
C:\Users\jedrz\Desktop\grk\cw 9\src\ex_9_1.hpp(139,38): warning C4305: "=": obcięcie z "double" do "float"
C:\Users\jedrz\Desktop\grk\cw 9\src\ex_9_1.hpp(168,16): warning C4305: "inicjowanie": obcięcie z "double" do "float"
C:\Users\jedrz\Desktop\grk\cw 9\src\ex_9_1.hpp(228,13): warning C4244: "inicjowanie": konwersja z "double" do "float", możliwa utrata danych
C:\Users\jedrz\Desktop\grk\cw 9\src\ex_9_1.hpp(244,98): warning C4305: "argument": obcięcie z "double" do "T"
C:\Users\jedrz\Desktop\GRK_Project\dependencies\glfw-3.3.8.bin.WIN32\include\GLFW\glfw3.h(123): message : zobacz poprzednią definicję „APIENTRY”
C:\Users\jedrz\Desktop\GRK_Project\cw 9\src\ex_9_1.hpp(104,30): warning C4305: "inicjowanie": obcięcie z "double" do "float"
C:\Users\jedrz\Desktop\GRK_Project\cw 9\src\ex_9_1.hpp(118,17): warning C4101: "data": lokalna zmienna, do której nie istnieje odwołanie
C:\Users\jedrz\Desktop\GRK_Project\cw 9\src\ex_9_1.hpp(143,38): warning C4305: "=": obcięcie z "double" do "float"
C:\Users\jedrz\Desktop\GRK_Project\cw 9\src\ex_9_1.hpp(172,16): warning C4305: "inicjowanie": obcięcie z "double" do "float"
C:\Users\jedrz\Desktop\GRK_Project\cw 9\src\ex_9_1.hpp(308,13): warning C4244: "inicjowanie": konwersja z "double" do "float", możliwa utrata danych
C:\Users\jedrz\Desktop\GRK_Project\cw 9\src\ex_9_1.hpp(324,98): warning C4305: "argument": obcięcie z "double" do "T"
with
[
T=float
]
C:\Users\jedrz\Desktop\grk\cw 9\src\ex_9_1.hpp(247,68): warning C4305: "argument": obcięcie z "double" do "T"
C:\Users\jedrz\Desktop\GRK_Project\cw 9\src\ex_9_1.hpp(327,68): warning C4305: "argument": obcięcie z "double" do "T"
with
[
T=float
]
C:\Users\jedrz\Desktop\grk\cw 9\src\ex_9_1.hpp(290,13): warning C4244: "inicjowanie": konwersja z "double" do "float", możliwa utrata danych
C:\Users\jedrz\Desktop\grk\cw 9\src\ex_9_1.hpp(298,108): warning C4305: "argument": obcięcie z "double" do "T"
C:\Users\jedrz\Desktop\GRK_Project\cw 9\src\ex_9_1.hpp(388,13): warning C4244: "inicjowanie": konwersja z "double" do "float", możliwa utrata danych
C:\Users\jedrz\Desktop\GRK_Project\cw 9\src\ex_9_1.hpp(396,108): warning C4305: "argument": obcięcie z "double" do "T"
with
[
T=float
]
C:\Users\jedrz\Desktop\grk\cw 9\src\ex_9_1.hpp(307,87): warning C4305: "argument": obcięcie z "double" do "T"
C:\Users\jedrz\Desktop\GRK_Project\cw 9\src\ex_9_1.hpp(404,87): warning C4305: "argument": obcięcie z "double" do "T"
with
[
T=float
]
C:\Users\jedrz\Desktop\grk\cw 9\src\ex_9_1.hpp(307,223): warning C4305: "argument": obcięcie z "double" do "float"
C:\Users\jedrz\Desktop\grk\cw 9\src\ex_9_1.hpp(310,59): warning C4305: "argument": obcięcie z "double" do "T"
C:\Users\jedrz\Desktop\GRK_Project\cw 9\src\ex_9_1.hpp(404,223): warning C4305: "argument": obcięcie z "double" do "float"
C:\Users\jedrz\Desktop\GRK_Project\cw 9\src\ex_9_1.hpp(407,59): warning C4305: "argument": obcięcie z "double" do "T"
with
[
T=float
]
C:\Users\jedrz\Desktop\grk\cw 9\src\ex_9_1.hpp(311,37): warning C4305: "argument": obcięcie z "double" do "float"
C:\Users\jedrz\Desktop\grk\cw 9\src\ex_9_1.hpp(343,2): warning C4305: "argument": obcięcie z "double" do "float"
C:\Users\jedrz\Desktop\grk\cw 9\src\ex_9_1.hpp(387,108): warning C4305: "argument": obcięcie z "double" do "T"
C:\Users\jedrz\Desktop\GRK_Project\cw 9\src\ex_9_1.hpp(408,37): warning C4305: "argument": obcięcie z "double" do "float"
C:\Users\jedrz\Desktop\GRK_Project\cw 9\src\ex_9_1.hpp(441,2): warning C4305: "argument": obcięcie z "double" do "float"
C:\Users\jedrz\Desktop\GRK_Project\cw 9\src\ex_9_1.hpp(447,116): warning C4305: "argument": obcięcie z "double" do "float"
C:\Users\jedrz\Desktop\GRK_Project\cw 9\src\ex_9_1.hpp(448,113): warning C4305: "argument": obcięcie z "double" do "float"
C:\Users\jedrz\Desktop\GRK_Project\cw 9\src\ex_9_1.hpp(496,108): warning C4305: "argument": obcięcie z "double" do "T"
with
[
T=float
]
C:\Users\jedrz\Desktop\grk\cw 9\src\ex_9_1.hpp(460,21): warning C4305: "-=": obcięcie z "double" do "float"
C:\Users\jedrz\Desktop\grk\cw 9\src\ex_9_1.hpp(462,21): warning C4305: "+=": obcięcie z "double" do "float"
C:\Users\jedrz\Desktop\GRK_Project\cw 9\src\ex_9_1.hpp(581,21): warning C4305: "-=": obcięcie z "double" do "float"
C:\Users\jedrz\Desktop\GRK_Project\cw 9\src\ex_9_1.hpp(583,21): warning C4305: "+=": obcięcie z "double" do "float"
Box.obj : warning LNK4075: zignorowano opcję „/EDITANDCONTINUE” z powodu określenia opcji „/INCREMENTAL:NO”
LINK : warning LNK4098: domyślna biblioteka „MSVCRT” powoduje konflikt z innymi bibliotekami; użyj opcji /NODEFAULTLIB:biblioteka
grk-cw9.vcxproj -> C:\Users\jedrz\Desktop\grk\Debug\grk-cw9.exe
grk-cw9.vcxproj -> C:\Users\jedrz\Desktop\GRK_Project\Debug\grk-cw9.exe

View File

@ -1,2 +1,2 @@
PlatformToolSet=v142:VCToolArchitecture=Native32Bit:VCToolsVersion=14.29.30133:TargetPlatformVersion=10.0.19041.0:
Debug|Win32|C:\Users\jedrz\Desktop\grk\|
PlatformToolSet=v143:VCToolArchitecture=Native32Bit:VCToolsVersion=14.33.31629:TargetPlatformVersion=10.0.19041.0:
Debug|Win32|C:\Users\jedrz\Desktop\GRK_Project\|

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

BIN
cw 9/Debug/vc143.idb Normal file

Binary file not shown.

BIN
cw 9/Debug/vc143.pdb Normal file

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>
<ProjectOutputs>
<ProjectOutput>
<FullPath>C:\Users\jedrz\Desktop\grk\Release\grk-cw9.exe</FullPath>
<FullPath>C:\Users\jedrz\Desktop\GRK_Project\Release\grk-cw9.exe</FullPath>
</ProjectOutput>
</ProjectOutputs>
<ContentFiles />

Binary file not shown.

Binary file not shown.

View File

@ -1,50 +1,52 @@
 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\jedrz\Desktop\grk\dependencies\glfw-3.3.8.bin.WIN32\include\GLFW\glfw3.h(123): message : zobacz poprzednią definicję „APIENTRY”
C:\Users\jedrz\Desktop\grk\cw 9\src\ex_9_1.hpp(96,30): warning C4305: "inicjowanie": obcięcie z "double" do "float"
C:\Users\jedrz\Desktop\grk\cw 9\src\ex_9_1.hpp(110,17): warning C4101: "data": lokalna zmienna, do której nie istnieje odwołanie
C:\Users\jedrz\Desktop\grk\cw 9\src\ex_9_1.hpp(135,38): warning C4305: "=": obcięcie z "double" do "float"
C:\Users\jedrz\Desktop\grk\cw 9\src\ex_9_1.hpp(164,16): warning C4305: "inicjowanie": obcięcie z "double" do "float"
C:\Users\jedrz\Desktop\grk\cw 9\src\ex_9_1.hpp(224,13): warning C4244: "inicjowanie": konwersja z "double" do "float", możliwa utrata danych
C:\Users\jedrz\Desktop\grk\cw 9\src\ex_9_1.hpp(240,98): warning C4305: "argument": obcięcie z "double" do "T"
C:\Users\jedrz\Desktop\GRK_Project\dependencies\glfw-3.3.8.bin.WIN32\include\GLFW\glfw3.h(123): message : zobacz poprzednią definicję „APIENTRY”
C:\Users\jedrz\Desktop\GRK_Project\cw 9\src\ex_9_1.hpp(122,30): warning C4305: "inicjowanie": obcięcie z "double" do "float"
C:\Users\jedrz\Desktop\GRK_Project\cw 9\src\ex_9_1.hpp(136,17): warning C4101: "data": lokalna zmienna, do której nie istnieje odwołanie
C:\Users\jedrz\Desktop\GRK_Project\cw 9\src\ex_9_1.hpp(161,38): warning C4305: "=": obcięcie z "double" do "float"
C:\Users\jedrz\Desktop\GRK_Project\cw 9\src\ex_9_1.hpp(190,16): warning C4305: "inicjowanie": obcięcie z "double" do "float"
C:\Users\jedrz\Desktop\GRK_Project\cw 9\src\ex_9_1.hpp(328,13): warning C4244: "inicjowanie": konwersja z "double" do "float", możliwa utrata danych
C:\Users\jedrz\Desktop\GRK_Project\cw 9\src\ex_9_1.hpp(344,98): warning C4305: "argument": obcięcie z "double" do "T"
with
[
T=float
]
C:\Users\jedrz\Desktop\grk\cw 9\src\ex_9_1.hpp(243,68): warning C4305: "argument": obcięcie z "double" do "T"
C:\Users\jedrz\Desktop\GRK_Project\cw 9\src\ex_9_1.hpp(347,68): warning C4305: "argument": obcięcie z "double" do "T"
with
[
T=float
]
C:\Users\jedrz\Desktop\grk\cw 9\src\ex_9_1.hpp(303,13): warning C4244: "inicjowanie": konwersja z "double" do "float", możliwa utrata danych
C:\Users\jedrz\Desktop\grk\cw 9\src\ex_9_1.hpp(311,108): warning C4305: "argument": obcięcie z "double" do "T"
C:\Users\jedrz\Desktop\GRK_Project\cw 9\src\ex_9_1.hpp(408,13): warning C4244: "inicjowanie": konwersja z "double" do "float", możliwa utrata danych
C:\Users\jedrz\Desktop\GRK_Project\cw 9\src\ex_9_1.hpp(416,108): warning C4305: "argument": obcięcie z "double" do "T"
with
[
T=float
]
C:\Users\jedrz\Desktop\grk\cw 9\src\ex_9_1.hpp(319,87): warning C4305: "argument": obcięcie z "double" do "T"
C:\Users\jedrz\Desktop\GRK_Project\cw 9\src\ex_9_1.hpp(424,87): warning C4305: "argument": obcięcie z "double" do "T"
with
[
T=float
]
C:\Users\jedrz\Desktop\grk\cw 9\src\ex_9_1.hpp(319,223): warning C4305: "argument": obcięcie z "double" do "float"
C:\Users\jedrz\Desktop\grk\cw 9\src\ex_9_1.hpp(322,59): warning C4305: "argument": obcięcie z "double" do "T"
C:\Users\jedrz\Desktop\GRK_Project\cw 9\src\ex_9_1.hpp(424,223): warning C4305: "argument": obcięcie z "double" do "float"
C:\Users\jedrz\Desktop\GRK_Project\cw 9\src\ex_9_1.hpp(427,59): warning C4305: "argument": obcięcie z "double" do "T"
with
[
T=float
]
C:\Users\jedrz\Desktop\grk\cw 9\src\ex_9_1.hpp(323,37): warning C4305: "argument": obcięcie z "double" do "float"
C:\Users\jedrz\Desktop\grk\cw 9\src\ex_9_1.hpp(355,2): warning C4305: "argument": obcięcie z "double" do "float"
C:\Users\jedrz\Desktop\grk\cw 9\src\ex_9_1.hpp(403,108): warning C4305: "argument": obcięcie z "double" do "T"
C:\Users\jedrz\Desktop\GRK_Project\cw 9\src\ex_9_1.hpp(428,37): warning C4305: "argument": obcięcie z "double" do "float"
C:\Users\jedrz\Desktop\GRK_Project\cw 9\src\ex_9_1.hpp(461,2): warning C4305: "argument": obcięcie z "double" do "float"
C:\Users\jedrz\Desktop\GRK_Project\cw 9\src\ex_9_1.hpp(467,116): warning C4305: "argument": obcięcie z "double" do "float"
C:\Users\jedrz\Desktop\GRK_Project\cw 9\src\ex_9_1.hpp(468,113): warning C4305: "argument": obcięcie z "double" do "float"
C:\Users\jedrz\Desktop\GRK_Project\cw 9\src\ex_9_1.hpp(519,108): warning C4305: "argument": obcięcie z "double" do "T"
with
[
T=float
]
C:\Users\jedrz\Desktop\grk\cw 9\src\ex_9_1.hpp(479,21): warning C4305: "-=": obcięcie z "double" do "float"
C:\Users\jedrz\Desktop\grk\cw 9\src\ex_9_1.hpp(481,21): warning C4305: "+=": obcięcie z "double" do "float"
C:\Users\jedrz\Desktop\GRK_Project\cw 9\src\ex_9_1.hpp(639,21): warning C4305: "-=": obcięcie z "double" do "float"
C:\Users\jedrz\Desktop\GRK_Project\cw 9\src\ex_9_1.hpp(641,21): warning C4305: "+=": obcięcie z "double" do "float"
Trwa generowanie kodu
65 of 605 functions (10.7%) were compiled, the rest were copied from previous compilation.
18 functions were new in current compilation
18 functions had inline decision re-evaluated but remain unchanged
1 of 604 functions ( 0.2%) were compiled, the rest were copied from previous compilation.
0 functions were new in current compilation
7 functions had inline decision re-evaluated but remain unchanged
Zakończono generowanie kodu
grk-cw9.vcxproj -> C:\Users\jedrz\Desktop\grk\Release\grk-cw9.exe
grk-cw9.vcxproj -> C:\Users\jedrz\Desktop\GRK_Project\Release\grk-cw9.exe

View File

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

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

BIN
cw 9/Release/vc143.pdb Normal file

Binary file not shown.

View File

@ -47,6 +47,10 @@
<None Include="shaders\shader_shadowap_sun.vert" />
<None Include="shaders\shader_skybox.frag" />
<None Include="shaders\shader_skybox.vert" />
<None Include="shaders\shader_tex.frag" />
<None Include="shaders\shader_tex.vert" />
<None Include="shaders\shader_tex_pbr.frag" />
<None Include="shaders\shader_tex_pbr.vert" />
<None Include="shaders\shader_water.frag" />
<None Include="shaders\shader_water.vert" />
<None Include="shaders\test.frag" />
@ -64,14 +68,14 @@
<ConfigurationType>Application</ConfigurationType>
<UseDebugLibraries>true</UseDebugLibraries>
<CharacterSet>Unicode</CharacterSet>
<PlatformToolset>v142</PlatformToolset>
<PlatformToolset>v143</PlatformToolset>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<UseDebugLibraries>false</UseDebugLibraries>
<WholeProgramOptimization>true</WholeProgramOptimization>
<CharacterSet>Unicode</CharacterSet>
<PlatformToolset>v142</PlatformToolset>
<PlatformToolset>v143</PlatformToolset>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
<ImportGroup Label="ExtensionSettings">
@ -124,7 +128,7 @@
<GenerateDebugInformation>true</GenerateDebugInformation>
<EnableCOMDATFolding>true</EnableCOMDATFolding>
<OptimizeReferences>true</OptimizeReferences>
<AdditionalDependencies>opengl32.lib;freeglut.lib;glew32.lib;$(SolutionDir)\dependencies\glfw-3.3.8.bin.WIN32\lib-vc2019\glfw3.lib;$(SolutionDir)\dependencies\glfw-3.3.8.bin.WIN32\lib-vc2019\glfw3dll.lib;zlibd.lib;assimp-vc141-mtd.lib;%(AdditionalDependencies)</AdditionalDependencies>
<AdditionalDependencies>opengl32.lib;freeglut.lib;glew32.lib;$(SolutionDir)\dependencies\glfw-3.3.8.bin.WIN32\lib-vc2019\glfw3.lib;$(SolutionDir)\dependencies\glfw-3.3.8.bin.WIN32\lib-vc2019\glfw3dll.lib;zlibd.lib;assimp-vc141-mtd.lib;Winmm.lib;%(AdditionalDependencies)</AdditionalDependencies>
<AdditionalLibraryDirectories>$(SolutionDir)dependencies\glfw-3.3.8.bin.WIN32\lib-vc2019;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
</Link>
</ItemDefinitionGroup>

View File

@ -133,5 +133,17 @@
<None Include="shaders\shader_water.vert">
<Filter>Shader Files</Filter>
</None>
<None Include="shaders\shader_tex.frag">
<Filter>Shader Files</Filter>
</None>
<None Include="shaders\shader_tex.vert">
<Filter>Shader Files</Filter>
</None>
<None Include="shaders\shader_tex_pbr.frag">
<Filter>Shader Files</Filter>
</None>
<None Include="shaders\shader_tex_pbr.vert">
<Filter>Shader Files</Filter>
</None>
</ItemGroup>
</Project>

55975
cw 9/models/lantern_obj.obj Normal file

File diff suppressed because it is too large Load Diff

11381
cw 9/models/table.obj Normal file

File diff suppressed because it is too large Load Diff

15
cw 9/models/untitled.obj Normal file
View File

@ -0,0 +1,15 @@
# Blender 3.4.1
# www.blender.org
mtllib untitled.mtl
o Plane
v 1.017000 -0.245879 0.050232
v -0.982771 -0.245879 0.020024
v 1.016943 1.754118 0.054007
v -0.982828 1.754118 0.023799
vn 0.0151 0.0019 -0.9999
vt 0.000000 0.000000
vt 1.000000 0.000000
vt 0.000000 1.000000
vt 1.000000 1.000000
s 0
f 1/1/1 2/2/1 4/4/1 3/3/1

View File

@ -103,13 +103,11 @@ float calculateShadow() {
vec4 sunSpacePosNormalized = (0.5 * sunSpacePos / (sunSpacePos.w)) + 0.5;
float closestDepth = texture2D(depthMap, sunSpacePosNormalized.xy).r;
float closestDepth = texture2D(depthMap, sunSpacePosNormalized.xy).x;
if(closestDepth + 0.01 > sunSpacePosNormalized.z){
return 1.0;
} else {
return 0.0;
}
float diff = (0.001+closestDepth) - sunSpacePosNormalized.z;
return (0.5*(diff)/abs(diff))+0.5;
}

View File

@ -0,0 +1,153 @@
#version 430 core
float AMBIENT = 0.03;
float PI = 3.14;
uniform sampler2D depthMap;
uniform vec3 cameraPos;
uniform sampler2D colorTexture;
uniform vec3 sunDir;
uniform vec3 sunColor;
uniform vec3 lightPos;
uniform vec3 lightColor;
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;
in vec2 vecTex;
out vec4 outColor;
in vec3 viewDirTS;
in vec3 lightDirTS;
in vec3 spotlightDirTS;
in vec3 sunDirTS;
in vec4 sunSpacePos;
vec3 color;
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(depthMap, sunSpacePosNormalized.xy).x;
float diff = (0.001+closestDepth) - sunSpacePosNormalized.z;
return (0.5*(diff)/abs(diff))+0.5;
}
void main()
{
color = texture(colorTexture, vecTex).xyz;
//vec3 normal = vec3(0,0,1);
vec3 normal = normalize(vecNormal);
//vec3 viewDir = normalize(viewDirTS);
vec3 viewDir = normalize(cameraPos-worldPos);
//vec3 lightDir = normalize(lightDirTS);
vec3 lightDir = normalize(lightPos-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,normal,viewDir);
ilumination=ilumination+PBRLight(sunDir, sunColor * calculateShadow(), normal, viewDir);
outColor = vec4(vec3(1.0) - exp(-ilumination*exposition),1);
}

View File

@ -0,0 +1,50 @@
#version 430 core
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 LightVP;
out vec3 vecNormal;
out vec3 worldPos;
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 vec2 vecTex;
out vec4 sunSpacePos;
void main()
{
vecTex = vertexTexCoord;
vecTex.y = 1.0 - vecTex.y;
worldPos = (modelMatrix* vec4(vertexPosition,1)).xyz;
vecNormal = (modelMatrix* vec4(vertexNormal,0)).xyz;
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=LightVP*modelMatrix*vec4(vertexPosition,1);
}

View File

@ -0,0 +1,162 @@
#version 430 core
float AMBIENT = 0.03;
float PI = 3.14;
uniform vec3 cameraPos;
uniform sampler2D depthMap;
uniform sampler2D colorTexture;
uniform sampler2D metallicTexture;
uniform sampler2D roughnessTexture;
uniform sampler2D aoTexture;
uniform sampler2D normalSampler;
uniform vec3 sunDir;
uniform vec3 sunColor;
uniform vec3 lightPos;
uniform vec3 lightColor;
uniform vec3 spotlightPos;
uniform vec3 spotlightColor;
uniform vec3 spotlightConeDir;
uniform vec3 spotlightPhi;
uniform float exposition;
in vec3 vecNormal;
in vec3 worldPos;
in vec2 vecTex;
out vec4 outColor;
in vec3 viewDirTS;
in vec3 lightDirTS;
in vec3 spotlightDirTS;
in vec3 sunDirTS;
vec3 color;
float metallic;
float roughness;
in vec4 sunSpacePos;
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(depthMap, sunSpacePosNormalized.xy).x;
float diff = (0.001+closestDepth) - sunSpacePosNormalized.z;
return (0.5*(diff)/abs(diff))+0.5;
}
void main()
{
color = texture2D(colorTexture, vecTex).xyz;
metallic = texture2D(metallicTexture, vecTex).r;
roughness = texture2D(roughnessTexture, vecTex).r;
//vec3 normal = vec3(0,0,1);
//vec3 normal = normalize(vecNormal);
vec3 normal = normalize((texture2D(normalSampler, vecTex).xyz) * 2 - 1);
//normal = normalize(normal * 2.0 - 1.0);
vec3 viewDir = normalize(viewDirTS);
//vec3 viewDir = normalize(cameraPos-worldPos);
vec3 lightDir = normalize(lightDirTS);
//vec3 lightDir = normalize(lightPos-worldPos);
vec3 ambient = texture2D(aoTexture, vecTex).xyz*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,normal,viewDir);
ilumination=ilumination+PBRLight(sunDir, sunColor * calculateShadow(), normal, viewDir);
outColor = vec4(vec3(1.0) - exp(-ilumination*exposition),1);
}

View File

@ -0,0 +1,49 @@
#version 430 core
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 LightVP;
out vec3 vecNormal;
out vec3 worldPos;
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 vec2 vecTex;
out vec4 sunSpacePos;
void main()
{
vecTex = vec2(0, 1) + vertexTexCoord * vec2(1, -1);
worldPos = (modelMatrix* vec4(vertexPosition,1)).xyz;
vecNormal = (modelMatrix* vec4(vertexNormal,0)).xyz;
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=LightVP*modelMatrix*vec4(vertexPosition,1);
}

View File

@ -1,4 +1,4 @@
#version 330 core
#version 430 core
in vec3 pos;
in vec3 interpolatedNormal;

View File

@ -1,4 +1,4 @@
#version 330 core
#version 430 core
layout(location = 0) in vec3 Position;
layout ( location =1) in vec3 Normal;

BIN
cw 9/sound/grass.wav Normal file

Binary file not shown.

BIN
cw 9/sound/main.wav Normal file

Binary file not shown.

BIN
cw 9/sound/necro.wav Normal file

Binary file not shown.

View File

@ -21,6 +21,7 @@ const unsigned int SHADOW_WIDTH = 1024, SHADOW_HEIGHT = 1024;
int WIDTH = 500, HEIGHT = 500;
namespace models {
Core::RenderContext bedContext;
Core::RenderContext chairContext;
@ -37,19 +38,43 @@ namespace models {
Core::RenderContext windowContext;
Core::RenderContext testContext;
Core::RenderContext cubeContext;
Core::RenderContext tableContext;
Core::RenderContext planeSmallContex;
}
std::vector<std::string> faces = {
"textures/rust.jpg",
"textures/rust.jpg",
"textures/rust.jpg",
"textures/rust.jpg",
"textures/rust.jpg",
"textures/rust.jpg",
"textures/skybox/posx.jpg",
"textures/skybox/negx.jpg",
"textures/skybox/posy.jpg",
"textures/skybox/negy.jpg",
"textures/skybox/posz.jpg",
"textures/skybox/negz.jpg",
};
namespace texture {
GLuint water;
GLuint rust;
GLuint table_albedo;
GLuint table_metallic;
GLuint table_ao;
GLuint table_normal;
GLuint table_roughness;
GLuint wood_albedo;
GLuint wood_metallic;
GLuint wood_ao;
GLuint wood_normal;
GLuint wood_roughness;
GLuint metal_albedo;
GLuint metal_metallic;
GLuint metal_ao;
GLuint metal_normal;
GLuint metal_roughness;
GLuint panels_albedo;
GLuint panels_metallic;
GLuint panels_ao;
GLuint panels_normal;
GLuint panels_roughness;
GLuint screen;
}
GLuint depthMapFBO;
@ -59,6 +84,7 @@ GLuint program;
GLuint programSun;
GLuint programTest;
GLuint programTex;
GLuint programTexPBR;
GLuint programDepth;
GLuint programSkybox;
GLuint programWater;
@ -163,8 +189,8 @@ glm::mat4 createPerspectiveMatrix()
glm::mat4 perspectiveMatrix;
float n = 0.05;
float f = 20.;
float a1 = glm::min(aspectRatio, 1.f);
float a2 = glm::min(1 / aspectRatio, 1.f);
float a1 = min(aspectRatio, 1.f);
float a2 = min(1 / aspectRatio, 1.f);
perspectiveMatrix = glm::mat4({
1,0.,0.,0.,
0.,aspectRatio,0.,0.,
@ -212,6 +238,84 @@ void drawObjectPBR(Core::RenderContext& context, glm::mat4 modelMatrix, glm::vec
Core::DrawContext(context);
}
void drawObjectTex(Core::RenderContext& context, glm::mat4 modelMatrix, float roughness, float metallic, GLuint texture) {
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);
glUniform3f(glGetUniformLocation(programTex, "lightPos"), pointlightPos.x, pointlightPos.y, pointlightPos.z);
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(programTex, "spotlightPhi"), spotlightPhi);
Core::SetActiveTexture(texture, "colorTexture", programTex, 0);
//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);
Core::SetActiveTexture(depthMap, "depthMap", programTex, 1);
Core::DrawContext(context);
}
void drawObjectTexPBR(Core::RenderContext& context, glm::mat4 modelMatrix, GLuint roughness, GLuint metallic, GLuint texture, GLuint normal, GLuint ao) {
glm::mat4 viewProjectionMatrix = createPerspectiveMatrix() * createCameraMatrix();
glm::mat4 transformation = viewProjectionMatrix * modelMatrix;
glUniformMatrix4fv(glGetUniformLocation(programTexPBR, "transformation"), 1, GL_FALSE, (float*)&transformation);
glUniformMatrix4fv(glGetUniformLocation(programTexPBR, "modelMatrix"), 1, GL_FALSE, (float*)&modelMatrix);
glUniform1f(glGetUniformLocation(programTexPBR, "exposition"), exposition);
//glUniform1f(glGetUniformLocation(programTex, "roughness"), roughness);
//glUniform1f(glGetUniformLocation(programTex, "metallic"), metallic);
//glUniform3f(glGetUniformLocation(programTex, "color"), color.x, color.y, color.z);
glUniform3f(glGetUniformLocation(programTexPBR, "cameraPos"), cameraPos.x, cameraPos.y, cameraPos.z);
glUniform3f(glGetUniformLocation(programTexPBR, "sunDir"), sunDir.x, sunDir.y, sunDir.z);
glUniform3f(glGetUniformLocation(programTexPBR, "sunColor"), sunColor.x, sunColor.y, sunColor.z);
glUniform3f(glGetUniformLocation(programTexPBR, "lightPos"), pointlightPos.x, pointlightPos.y, pointlightPos.z);
glUniform3f(glGetUniformLocation(programTexPBR, "lightColor"), pointlightColor.x, pointlightColor.y, pointlightColor.z);
glUniform3f(glGetUniformLocation(programTexPBR, "spotlightConeDir"), spotlightConeDir.x, spotlightConeDir.y, spotlightConeDir.z);
glUniform3f(glGetUniformLocation(programTexPBR, "spotlightPos"), spotlightPos.x, spotlightPos.y, spotlightPos.z);
glUniform3f(glGetUniformLocation(programTexPBR, "spotlightColor"), spotlightColor.x, spotlightColor.y, spotlightColor.z);
glUniform1f(glGetUniformLocation(programTexPBR, "spotlightPhi"), spotlightPhi);
Core::SetActiveTexture(texture, "colorTexture", programTexPBR, 5);
Core::SetActiveTexture(metallic, "metallicTexture", programTexPBR, 2);
Core::SetActiveTexture(roughness, "roughnessTexture", programTexPBR, 3);
Core::SetActiveTexture(ao, "aoTexture", programTexPBR, 4);
Core::SetActiveTexture(normal, "normalSampler", programTexPBR,1);
//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);
Core::SetActiveTexture(depthMap, "depthMap", programTexPBR, 0);
Core::DrawContext(context);
}
void drawObjectDepth(Core::RenderContext context, glm::mat4 viewProjectionMatrix, glm::mat4 modelMatrix) {
glUniformMatrix4fv(glGetUniformLocation(programDepth, "viewProjectionMatrix"), 1, GL_FALSE, (float*)&viewProjectionMatrix);
@ -247,13 +351,14 @@ void renderShadowapSun() {
drawObjectDepth(models::deskContext, lightVP, glm::mat4());
drawObjectDepth(models::doorContext, lightVP, glm::mat4());
drawObjectDepth(models::drawerContext, lightVP, glm::mat4());
drawObjectDepth(models::marbleBustContext, lightVP, glm::mat4());
drawObjectDepth(models::marbleBustContext, lightVP, glm::translate(glm::mat4(), glm::vec3(0, 0, -0.2)));
drawObjectDepth(models::marbleBustContext, lightVP, glm::translate(glm::mat4(), glm::vec3(0, 0, 0.2)));
drawObjectDepth(models::materaceContext, lightVP, glm::mat4());
drawObjectDepth(models::pencilsContext, lightVP, glm::mat4());
drawObjectDepth(models::planeContext, lightVP, glm::mat4());
drawObjectDepth(models::roomContext, lightVP, glm::mat4());
drawObjectDepth(models::windowContext, lightVP, glm::mat4());
drawObjectDepth(models::tableContext, lightVP, glm::mat4());
glBindFramebuffer(GL_FRAMEBUFFER, 0);
glViewport(0, 0, WIDTH, HEIGHT);
@ -324,15 +429,16 @@ void renderScene(GLFWwindow* window)
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 spaceshipUp = glm::normalize(glm::cross(spaceshipSide, spaceshipDir));
@ -357,6 +463,16 @@ void renderScene(GLFWwindow* window)
spotlightPos = spaceshipPos + 0.2 * spaceshipDir;
spotlightConeDir = spaceshipDir;
glUseProgram(programTex);
drawObjectTex(models::marbleBustContext, glm::translate(glm::mat4(), glm::vec3(0, 0, -0.2)), 0.2, 0, texture::rust);
drawObjectTex(models::marbleBustContext, glm::translate(glm::mat4(), glm::vec3(0,0,0.2)), 0, 0.2, texture::rust);
drawObjectTex(models::planeSmallContex, glm::translate(glm::mat4(), glm::vec3(0, 0, 2)), 0, 0, texture::screen);
//drawObjectTex(models::deskContext, glm::mat4(), 0.2f, 0.0f, texture::rust);
glUseProgram(programTexPBR);
drawObjectTexPBR(models::tableContext, glm::mat4(), texture::table_roughness, texture::table_metallic, texture::table_albedo, texture::table_normal, texture::table_ao);
drawObjectTexPBR(models::deskContext, glm::mat4(), texture::table_roughness, texture::table_metallic, texture::table_albedo, texture::table_normal, texture::table_ao);
glUseProgram(programWater);
//drawObjectColorWater(waterContext, glm::translate(glm::mat4(1.0), glm::vec3(0.0, -1.0, 0.0)) * glm::scale(glm::vec3(30.0)), glm::vec3(0.1, 0.1, 0.95), time, texture::water);
drawObjectColorWater(waterContext, glm::mat4(), glm::vec4(0.1, 0.1, 0.95, 0.5), time, texture::water);
@ -410,8 +526,32 @@ void init(GLFWwindow* window)
programDepth = shaderLoader.CreateProgram("shaders/shader_shadowap_sun.vert", "shaders/shader_shadowap_sun.frag");
programSkybox = shaderLoader.CreateProgram("shaders/shader_skybox.vert", "shaders/shader_skybox.frag");
programWater = shaderLoader.CreateProgram("shaders/shader_water.vert", "shaders/shader_water.frag");
programTex = shaderLoader.CreateProgram("shaders/shader_tex.vert", "shaders/shader_tex.frag");
programTexPBR = shaderLoader.CreateProgram("shaders/shader_tex_pbr.vert", "shaders/shader_tex_pbr.frag");
water.readOBJ("./models/plane2.obj");
texture::water = Core::LoadTexture("textures/test.png");
texture::rust = Core::LoadTexture("textures/rust.jpg");
texture::table_albedo = Core::LoadTexture("textures/table_albedo.png");
texture::table_metallic = Core::LoadTexture("textures/table_metallic.png");
texture::table_roughness = Core::LoadTexture("textures/table_roughness.png");
texture::table_ao = Core::LoadTexture("textures/table_ao.png");
texture::table_normal = Core::LoadTexture("textures/table_normal.jpg");
texture::wood_albedo = Core::LoadTexture("textures/wood_albedo.jpg");
texture::wood_metallic = Core::LoadTexture("textures/wood_metallic.jpg");
texture::wood_roughness = Core::LoadTexture("textures/wood_roughness.jpg");
texture::wood_ao = Core::LoadTexture("textures/wood_ao.jpg");
texture::wood_normal = Core::LoadTexture("textures/wood_normal.jpg");
texture::screen = Core::LoadTexture("textures/visual.png");
texture::metal_albedo = Core::LoadTexture("textures/metal_albedo.png");
texture::metal_metallic = Core::LoadTexture("textures/metal_metallic.png");
texture::metal_roughness = Core::LoadTexture("textures/metal_roughness.png");
texture::metal_ao = Core::LoadTexture("textures/metal_ao.png");
texture::metal_normal = Core::LoadTexture("textures/metal_normal.png");
texture::panels_albedo = Core::LoadTexture("textures/panels_albedo.png");
texture::panels_metallic = Core::LoadTexture("textures/panels_metallic.png");
texture::panels_roughness = Core::LoadTexture("textures/panels_roughness.png");
texture::panels_ao = Core::LoadTexture("textures/panels_ao.png");
texture::panels_normal = Core::LoadTexture("textures/panels_normal.png");
loadModelToContext("./models/sphere.obj", sphereContext);
loadModelToContext("./models/spaceship.obj", shipContext);
loadModelToContext("./models/bed.obj", models::bedContext);
@ -429,7 +569,9 @@ void init(GLFWwindow* window)
loadModelToContext("./models/window.obj", models::windowContext);
loadModelToContext("./models/test.obj", models::testContext);
loadModelToContext("./models/cube.obj", models::cubeContext);
loadModelToContext("./models/table.obj", models::tableContext);
loadModelToContext("./models/untitled.obj", models::planeSmallContex);
skyboxTexture = loadSkybox(faces);
drawSkybox(models::cubeContext, transformation, skyboxTexture);
/*glUseProgram(programSkybox);
@ -445,6 +587,7 @@ void shutdown(GLFWwindow* window)
shaderLoader.DeleteProgram(program);
}
//obsluga wejscia
void processInput(GLFWwindow* window)
{
@ -471,6 +614,23 @@ void processInput(GLFWwindow* window)
spaceshipDir = glm::vec3(glm::eulerAngleY(angleSpeed) * glm::vec4(spaceshipDir, 0));
if (glfwGetKey(window, GLFW_KEY_D) == GLFW_PRESS)
spaceshipDir = glm::vec3(glm::eulerAngleY(-angleSpeed) * glm::vec4(spaceshipDir, 0));
if (glfwGetKey(window, GLFW_KEY_H) == GLFW_PRESS) {
texture::screen = Core::LoadTexture("textures/main.jpg");
PlaySound(TEXT("sound/main.wav"), NULL, SND_ASYNC);
}
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");
PlaySound(nullptr, nullptr, 0);
}
cameraPos = spaceshipPos - 0.5 * spaceshipDir + glm::vec3(0, 1, 0) * 0.2f;
cameraDir = spaceshipDir;

View File

@ -5,7 +5,7 @@
#include "ext.hpp"
#include <iostream>
#include <cmath>
#include <windows.h>
#include "ex_9_1.hpp"

Binary file not shown.

After

Width:  |  Height:  |  Size: 985 KiB

BIN
cw 9/textures/heroes.jpg Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 786 KiB

BIN
cw 9/textures/main.jpg Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 133 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 6.0 MiB

BIN
cw 9/textures/metal_ao.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.3 MiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.5 MiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.7 MiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 6.0 MiB

BIN
cw 9/textures/necro.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.3 MiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.0 MiB

BIN
cw 9/textures/panels_ao.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 139 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 57 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 499 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.7 MiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.3 MiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 821 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 845 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 859 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 829 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 592 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 824 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 279 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 275 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 217 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 218 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 150 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 287 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 7.7 MiB

BIN
cw 9/textures/table_ao.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.0 MiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 470 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 7.8 MiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.3 MiB

BIN
cw 9/textures/visual.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 472 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 660 KiB

Some files were not shown because too many files have changed in this diff Show More