pbr fix + sound
@ -1,52 +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_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"
|
||||
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_Project\cw 9\src\ex_9_1.hpp(327,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_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"
|
||||
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_Project\cw 9\src\ex_9_1.hpp(404,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_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"
|
||||
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_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"
|
||||
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_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"
|
||||
C:\Users\jedrz\Desktop\GRK_Project\cw 9\src\ex_9_1.hpp(631,21): warning C4305: "-=": obcięcie z "double" do "float"
|
||||
C:\Users\jedrz\Desktop\GRK_Project\cw 9\src\ex_9_1.hpp(633,21): warning C4305: "+=": obcięcie z "double" do "float"
|
||||
Trwa generowanie kodu
|
||||
4 of 604 functions ( 0.7%) were compiled, the rest were copied from previous compilation.
|
||||
0 functions were new in current compilation
|
||||
9 functions had inline decision re-evaluated but remain unchanged
|
||||
6 functions had inline decision re-evaluated but remain unchanged
|
||||
Zakończono generowanie kodu
|
||||
grk-cw9.vcxproj -> C:\Users\jedrz\Desktop\GRK_Project\Release\grk-cw9.exe
|
||||
|
@ -128,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>
|
||||
|
15
cw 9/models/untitled.obj
Normal 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
|
@ -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;
|
||||
}
|
||||
|
||||
|
||||
|
@ -38,6 +38,8 @@ in vec3 lightDirTS;
|
||||
in vec3 spotlightDirTS;
|
||||
in vec3 sunDirTS;
|
||||
|
||||
in vec4 sunSpacePos;
|
||||
|
||||
vec3 color;
|
||||
|
||||
|
||||
@ -101,6 +103,17 @@ vec3 PBRLight(vec3 lightDir, vec3 radiance, vec3 normal, vec3 V){
|
||||
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()
|
||||
{
|
||||
@ -132,7 +145,8 @@ void main()
|
||||
ilumination=ilumination+PBRLight(spotlightDir,attenuatedlightColor,normal,viewDir);
|
||||
|
||||
//sun
|
||||
ilumination=ilumination+PBRLight(sunDir,sunColor,normal,viewDir);
|
||||
//ilumination=ilumination+PBRLight(sunDir,sunColor,normal,viewDir);
|
||||
ilumination=ilumination+PBRLight(sunDir, sunColor * calculateShadow(), normal, viewDir);
|
||||
|
||||
|
||||
outColor = vec4(vec3(1.0) - exp(-ilumination*exposition),1);
|
||||
|
@ -8,6 +8,7 @@ layout(location = 4) in vec3 vertexBitangent;
|
||||
|
||||
uniform mat4 transformation;
|
||||
uniform mat4 modelMatrix;
|
||||
uniform mat4 LightVP;
|
||||
|
||||
out vec3 vecNormal;
|
||||
out vec3 worldPos;
|
||||
@ -22,6 +23,7 @@ out vec3 lightDirTS;
|
||||
out vec3 spotlightDirTS;
|
||||
out vec3 sunDirTS;
|
||||
out vec2 vecTex;
|
||||
out vec4 sunSpacePos;
|
||||
|
||||
void main()
|
||||
{
|
||||
@ -43,5 +45,6 @@ void main()
|
||||
vec3 SL = normalize(spotlightPos-worldPos);
|
||||
spotlightDirTS = TBN*SL;
|
||||
sunDirTS = TBN*sunDir;
|
||||
sunSpacePos=LightVP*modelMatrix*vec4(vertexPosition,1);
|
||||
|
||||
}
|
@ -3,14 +3,16 @@
|
||||
float AMBIENT = 0.03;
|
||||
float PI = 3.14;
|
||||
|
||||
uniform sampler2D depthMap;
|
||||
|
||||
|
||||
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;
|
||||
@ -43,6 +45,8 @@ vec3 color;
|
||||
float metallic;
|
||||
float roughness;
|
||||
|
||||
in vec4 sunSpacePos;
|
||||
|
||||
|
||||
float DistributionGGX(vec3 normal, vec3 H, float roughness){
|
||||
float a = roughness*roughness;
|
||||
@ -104,6 +108,17 @@ vec3 PBRLight(vec3 lightDir, vec3 radiance, vec3 normal, vec3 V){
|
||||
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()
|
||||
{
|
||||
@ -113,6 +128,8 @@ void main()
|
||||
|
||||
//vec3 normal = vec3(0,0,1);
|
||||
vec3 normal = normalize(vecNormal);
|
||||
//vec3 normal = texture(normalSampler, vecTex).rgb;
|
||||
//normal = normalize(normal * 2.0 - 1.0);
|
||||
|
||||
//vec3 viewDir = normalize(viewDirTS);
|
||||
vec3 viewDir = normalize(cameraPos-worldPos);
|
||||
@ -121,11 +138,12 @@ void main()
|
||||
vec3 lightDir = normalize(lightPos-worldPos);
|
||||
|
||||
|
||||
|
||||
vec3 ambient = texture(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);
|
||||
@ -137,9 +155,8 @@ void main()
|
||||
ilumination=ilumination+PBRLight(spotlightDir,attenuatedlightColor,normal,viewDir);
|
||||
|
||||
//sun
|
||||
ilumination=ilumination+PBRLight(sunDir,sunColor,normal,viewDir);
|
||||
|
||||
//ilumination=ilumination+PBRLight(sunDir,sunColor,normal,viewDir);
|
||||
ilumination=ilumination+PBRLight(sunDir, sunColor * calculateShadow(), normal, viewDir);
|
||||
|
||||
outColor = vec4(vec3(1.0) - exp(-ilumination*exposition),1);
|
||||
outColor = vec4(texture(colorTexture, vecTex).rgb,1);
|
||||
}
|
@ -8,6 +8,7 @@ layout(location = 4) in vec3 vertexBitangent;
|
||||
|
||||
uniform mat4 transformation;
|
||||
uniform mat4 modelMatrix;
|
||||
uniform mat4 LightVP;
|
||||
|
||||
out vec3 vecNormal;
|
||||
out vec3 worldPos;
|
||||
@ -16,25 +17,21 @@ uniform vec3 lightPos;
|
||||
uniform vec3 spotlightPos;
|
||||
uniform vec3 cameraPos;
|
||||
uniform vec3 sunDir;
|
||||
uniform sampler2D normalSampler;
|
||||
|
||||
out vec3 viewDirTS;
|
||||
out vec3 lightDirTS;
|
||||
out vec3 spotlightDirTS;
|
||||
out vec3 sunDirTS;
|
||||
out vec2 vecTex;
|
||||
|
||||
vec3 normal;
|
||||
out vec4 sunSpacePos;
|
||||
|
||||
void main()
|
||||
{
|
||||
normal = texture(normalSampler, vecTex).rgb;
|
||||
normal = normalize(normal * 2.0 - 1.0);
|
||||
vecTex = vertexTexCoord;
|
||||
vecTex.y = 1.0 - vecTex.y;
|
||||
|
||||
worldPos = (modelMatrix* vec4(vertexPosition,1)).xyz;
|
||||
vecNormal = (modelMatrix* vec4(normal,0)).xyz;
|
||||
vecNormal = (modelMatrix* vec4(vertexNormal,0)).xyz;
|
||||
gl_Position = transformation * vec4(vertexPosition, 1.0);
|
||||
|
||||
vec3 w_tangent = normalize(mat3(modelMatrix)*vertexTangent);
|
||||
@ -48,5 +45,66 @@ void main()
|
||||
vec3 SL = normalize(spotlightPos-worldPos);
|
||||
spotlightDirTS = TBN*SL;
|
||||
sunDirTS = TBN*sunDir;
|
||||
sunSpacePos=LightVP*modelMatrix*vec4(vertexPosition,1);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
#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;
|
||||
uniform sampler2D normalSampler;
|
||||
|
||||
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;
|
||||
|
||||
vec3 normal;
|
||||
|
||||
void main()
|
||||
{
|
||||
vecTex = vertexTexCoord;
|
||||
vecTex.y = 1.0 - vecTex.y;
|
||||
|
||||
normal = texture(normalSampler, vecTex).xyz;
|
||||
normal = normalize(normal * 2.0 - 1.0);
|
||||
|
||||
worldPos = (modelMatrix* vec4(vertexPosition,1)).xyz;
|
||||
vecNormal = (modelMatrix* vec4(normal,0)).xyz;
|
||||
//vecNormal = normalize(vecNormal);
|
||||
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);
|
||||
|
||||
}
|
||||
*/
|
@ -1,4 +1,4 @@
|
||||
#version 330 core
|
||||
#version 430 core
|
||||
|
||||
in vec3 pos;
|
||||
in vec3 interpolatedNormal;
|
||||
|
@ -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
BIN
cw 9/sound/main.wav
Normal file
BIN
cw 9/sound/necro.wav
Normal 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;
|
||||
@ -38,6 +39,7 @@ namespace models {
|
||||
Core::RenderContext testContext;
|
||||
Core::RenderContext cubeContext;
|
||||
Core::RenderContext tableContext;
|
||||
Core::RenderContext planeSmallContex;
|
||||
}
|
||||
|
||||
std::vector<std::string> faces = {
|
||||
@ -57,6 +59,22 @@ namespace texture {
|
||||
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;
|
||||
@ -171,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.,
|
||||
@ -248,11 +266,11 @@ void drawObjectTex(Core::RenderContext& context, glm::mat4 modelMatrix, float ro
|
||||
glUniform1f(glGetUniformLocation(programTex, "spotlightPhi"), spotlightPhi);
|
||||
Core::SetActiveTexture(texture, "colorTexture", programTex, 0);
|
||||
|
||||
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(program, "LightVP"), 1, GL_FALSE, (float*)&lightVP);
|
||||
Core::SetActiveTexture(depthMap, "depthMap", program, 0);
|
||||
glUniformMatrix4fv(glGetUniformLocation(programTex, "LightVP"), 1, GL_FALSE, (float*)&lightVP);
|
||||
Core::SetActiveTexture(depthMap, "depthMap", programTex, 1);
|
||||
|
||||
Core::DrawContext(context);
|
||||
}
|
||||
@ -283,17 +301,17 @@ void drawObjectTexPBR(Core::RenderContext& context, glm::mat4 modelMatrix, GLuin
|
||||
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, 0);
|
||||
Core::SetActiveTexture(metallic, "metallicTexture", programTexPBR, 1);
|
||||
Core::SetActiveTexture(roughness, "roughnessTexture", programTexPBR, 2);
|
||||
Core::SetActiveTexture(ao, "aoTexture", programTexPBR, 3);
|
||||
Core::SetActiveTexture(normal, "normalSampler", programTexPBR,4);
|
||||
Core::SetActiveTexture(texture, "colorTexture", programTexPBR, 1);
|
||||
Core::SetActiveTexture(metallic, "metallicTexture", programTexPBR, 2);
|
||||
Core::SetActiveTexture(roughness, "roughnessTexture", programTexPBR, 3);
|
||||
Core::SetActiveTexture(ao, "aoTexture", programTexPBR, 4);
|
||||
Core::SetActiveTexture(normal, "normalSampler", programTexPBR,5);
|
||||
|
||||
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(program, "LightVP"), 1, GL_FALSE, (float*)&lightVP);
|
||||
Core::SetActiveTexture(depthMap, "depthMap", program, 0);
|
||||
glUniformMatrix4fv(glGetUniformLocation(programTexPBR, "LightVP"), 1, GL_FALSE, (float*)&lightVP);
|
||||
Core::SetActiveTexture(depthMap, "depthMap", programTexPBR, 0);
|
||||
|
||||
Core::DrawContext(context);
|
||||
}
|
||||
@ -411,7 +429,7 @@ 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::materaceContext, glm::mat4(), glm::vec3(0.9f, 0.9f, 0.9f), 0.8f, 0.0f);
|
||||
@ -448,9 +466,12 @@ void renderScene(GLFWwindow* window)
|
||||
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::panels_roughness, texture::panels_metallic, texture::panels_albedo, texture::panels_normal, texture::panels_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);
|
||||
@ -515,6 +536,22 @@ void init(GLFWwindow* window)
|
||||
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.png");
|
||||
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);
|
||||
@ -533,7 +570,8 @@ void init(GLFWwindow* window)
|
||||
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);
|
||||
@ -549,6 +587,7 @@ void shutdown(GLFWwindow* window)
|
||||
shaderLoader.DeleteProgram(program);
|
||||
}
|
||||
|
||||
|
||||
//obsluga wejscia
|
||||
void processInput(GLFWwindow* window)
|
||||
{
|
||||
@ -575,6 +614,15 @@ 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/heroes.jpg");
|
||||
PlaySound(TEXT("sound/main.wav"), NULL, SND_ASYNC);
|
||||
}
|
||||
if (glfwGetKey(window, GLFW_KEY_J) == 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;
|
||||
|
@ -5,7 +5,7 @@
|
||||
#include "ext.hpp"
|
||||
#include <iostream>
|
||||
#include <cmath>
|
||||
|
||||
#include <windows.h>
|
||||
#include "ex_9_1.hpp"
|
||||
|
||||
|
||||
|
BIN
cw 9/textures/heroes.jpg
Normal file
After Width: | Height: | Size: 133 KiB |
BIN
cw 9/textures/metal_albedo.png
Normal file
After Width: | Height: | Size: 6.0 MiB |
BIN
cw 9/textures/metal_ao.png
Normal file
After Width: | Height: | Size: 1.3 MiB |
BIN
cw 9/textures/metal_metallic.png
Normal file
After Width: | Height: | Size: 1.5 MiB |
BIN
cw 9/textures/metal_normal.png
Normal file
After Width: | Height: | Size: 5.7 MiB |
BIN
cw 9/textures/metal_roughness.png
Normal file
After Width: | Height: | Size: 6.0 MiB |
BIN
cw 9/textures/panels_albedo.png
Normal file
After Width: | Height: | Size: 4.0 MiB |
BIN
cw 9/textures/panels_ao.png
Normal file
After Width: | Height: | Size: 139 KiB |
BIN
cw 9/textures/panels_metallic.png
Normal file
After Width: | Height: | Size: 57 KiB |
BIN
cw 9/textures/panels_normal.png
Normal file
After Width: | Height: | Size: 499 KiB |
BIN
cw 9/textures/panels_roughness.png
Normal file
After Width: | Height: | Size: 1.7 MiB |
BIN
cw 9/textures/visual.png
Normal file
After Width: | Height: | Size: 472 KiB |
BIN
cw 9/textures/wood_albedo.jpg
Normal file
After Width: | Height: | Size: 660 KiB |
BIN
cw 9/textures/wood_ao.jpg
Normal file
After Width: | Height: | Size: 226 KiB |
BIN
cw 9/textures/wood_metallic.jpg
Normal file
After Width: | Height: | Size: 34 KiB |
BIN
cw 9/textures/wood_normal.jpg
Normal file
After Width: | Height: | Size: 300 KiB |
BIN
cw 9/textures/wood_roughness.jpg
Normal file
After Width: | Height: | Size: 419 KiB |