Added not working shadows, but spaceship now can fire a laser with room
This commit is contained in:
parent
64d1cbdfbd
commit
2049ba1822
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@ -1,71 +1,39 @@
|
||||
Box.cpp
|
||||
Camera.cpp
|
||||
Laser.cpp
|
||||
main.cpp
|
||||
main.cpp
|
||||
C:\Program Files (x86)\Windows Kits\10\Include\10.0.22000.0\shared\minwindef.h(130,1): warning C4005: 'APIENTRY': macro redefinition
|
||||
C:\Users\arciom\Desktop\GRK_game_scene\dependencies\glfw-3.3.8.bin.WIN32\include\GLFW\glfw3.h(123): message : see previous definition of 'APIENTRY'
|
||||
C:\Users\arciom\Desktop\GRK_game_scene\cw 9\src\ex_9_1.hpp(79,30): warning C4305: 'initializing': truncation from 'double' to 'float'
|
||||
C:\Users\arciom\Desktop\GRK_game_scene\cw 9\src\ex_9_1.hpp(98,38): warning C4305: '=': truncation from 'double' to 'float'
|
||||
C:\Users\arciom\Desktop\GRK_game_scene\cw 9\src\ex_9_1.hpp(121,16): warning C4305: 'initializing': truncation from 'double' to 'float'
|
||||
C:\Users\arciom\Desktop\GRK_game_scene\cw 9\src\ex_9_1.hpp(171,13): warning C4244: 'initializing': conversion from 'double' to 'float', possible loss of data
|
||||
C:\Users\arciom\Desktop\GRK_game_scene\cw 9\src\ex_9_1.hpp(194,13): warning C4244: 'initializing': conversion from 'double' to 'float', possible loss of data
|
||||
C:\Users\arciom\Desktop\GRK_game_scene\cw 9\src\ex_9_1.hpp(211,13): warning C4244: 'initializing': conversion from 'double' to 'float', possible loss of data
|
||||
C:\Users\arciom\Desktop\GRK_game_scene\cw 9\src\ex_9_1.hpp(218,108): warning C4305: 'argument': truncation from 'double' to 'T'
|
||||
C:\Users\arciom\Desktop\GRK_game_scene\cw 9\src\ex_9_1.hpp(100,30): warning C4305: 'initializing': truncation from 'double' to 'float'
|
||||
C:\Users\arciom\Desktop\GRK_game_scene\cw 9\src\ex_9_1.hpp(132,38): warning C4305: '=': truncation from 'double' to 'float'
|
||||
C:\Users\arciom\Desktop\GRK_game_scene\cw 9\src\ex_9_1.hpp(155,16): warning C4305: 'initializing': truncation from 'double' to 'float'
|
||||
C:\Users\arciom\Desktop\GRK_game_scene\cw 9\src\ex_9_1.hpp(215,13): warning C4244: 'initializing': conversion from 'double' to 'float', possible loss of data
|
||||
C:\Users\arciom\Desktop\GRK_game_scene\cw 9\src\ex_9_1.hpp(277,13): warning C4244: 'initializing': conversion from 'double' to 'float', possible loss of data
|
||||
C:\Users\arciom\Desktop\GRK_game_scene\cw 9\src\ex_9_1.hpp(299,13): warning C4244: 'initializing': conversion from 'double' to 'float', possible loss of data
|
||||
C:\Users\arciom\Desktop\GRK_game_scene\cw 9\src\ex_9_1.hpp(306,108): warning C4305: 'argument': truncation from 'double' to 'T'
|
||||
with
|
||||
[
|
||||
T=float
|
||||
]
|
||||
C:\Users\arciom\Desktop\GRK_game_scene\cw 9\src\ex_9_1.hpp(226,87): warning C4305: 'argument': truncation from 'double' to 'T'
|
||||
C:\Users\arciom\Desktop\GRK_game_scene\cw 9\src\ex_9_1.hpp(320,87): warning C4305: 'argument': truncation from 'double' to 'T'
|
||||
with
|
||||
[
|
||||
T=float
|
||||
]
|
||||
C:\Users\arciom\Desktop\GRK_game_scene\cw 9\src\ex_9_1.hpp(226,223): warning C4305: 'argument': truncation from 'double' to 'float'
|
||||
C:\Users\arciom\Desktop\GRK_game_scene\cw 9\src\ex_9_1.hpp(229,59): warning C4305: 'argument': truncation from 'double' to 'T'
|
||||
C:\Users\arciom\Desktop\GRK_game_scene\cw 9\src\ex_9_1.hpp(320,223): warning C4305: 'argument': truncation from 'double' to 'float'
|
||||
C:\Users\arciom\Desktop\GRK_game_scene\cw 9\src\ex_9_1.hpp(323,59): warning C4305: 'argument': truncation from 'double' to 'T'
|
||||
with
|
||||
[
|
||||
T=float
|
||||
]
|
||||
C:\Users\arciom\Desktop\GRK_game_scene\cw 9\src\ex_9_1.hpp(230,37): warning C4305: 'argument': truncation from 'double' to 'float'
|
||||
C:\Users\arciom\Desktop\GRK_game_scene\cw 9\src\ex_9_1.hpp(263,2): warning C4305: 'argument': truncation from 'double' to 'float'
|
||||
C:\Users\arciom\Desktop\GRK_game_scene\cw 9\src\ex_9_1.hpp(404,21): warning C4305: '-=': truncation from 'double' to 'float'
|
||||
C:\Users\arciom\Desktop\GRK_game_scene\cw 9\src\ex_9_1.hpp(406,21): warning C4305: '+=': truncation from 'double' to 'float'
|
||||
C:\Users\arciom\Desktop\GRK_game_scene\cw 9\src\ex_9_1.hpp(418,43): warning C4244: 'argument': conversion from 'double' to 'float', possible loss of data
|
||||
C:\Users\arciom\Desktop\GRK_game_scene\cw 9\src\ex_9_1.hpp(421,28): warning C4305: 'argument': truncation from 'double' to 'float'
|
||||
Render_Utils.cpp
|
||||
Shader_Loader.cpp
|
||||
SpaceShip.cpp
|
||||
Texture.cpp
|
||||
Generating Code...
|
||||
image_DXT.c
|
||||
C:\Users\arciom\Desktop\GRK_game_scene\cw 9\src\SOIL\image_DXT.c(92,9): warning C4996: 'fopen': This function or variable may be unsafe. Consider using fopen_s instead. To disable deprecation, use _CRT_SECURE_NO_WARNINGS. See online help for details.
|
||||
image_helper.c
|
||||
C:\Users\arciom\Desktop\GRK_game_scene\cw 9\src\SOIL\image_helper.c(325,1): warning C4244: 'initializing': conversion from 'double' to 'float', possible loss of data
|
||||
C:\Users\arciom\Desktop\GRK_game_scene\cw 9\src\SOIL\image_helper.c(366,58): warning C4244: '=': conversion from 'double' to 'float', possible loss of data
|
||||
C:\Users\arciom\Desktop\GRK_game_scene\cw 9\src\SOIL\image_helper.c(373,46): warning C4244: '=': conversion from 'float' to 'int', possible loss of data
|
||||
C:\Users\arciom\Desktop\GRK_game_scene\cw 9\src\SOIL\image_helper.c(415,58): warning C4244: '=': conversion from 'double' to 'float', possible loss of data
|
||||
C:\Users\arciom\Desktop\GRK_game_scene\cw 9\src\SOIL\image_helper.c(422,62): warning C4244: '=': conversion from 'float' to 'int', possible loss of data
|
||||
SOIL.c
|
||||
C:\Users\arciom\Desktop\GRK_game_scene\cw 9\src\SOIL\SOIL.c(1719,36): warning C4018: '<=': signed/unsigned mismatch
|
||||
C:\Users\arciom\Desktop\GRK_game_scene\cw 9\src\SOIL\SOIL.c(1729,19): warning C4018: '<': signed/unsigned mismatch
|
||||
C:\Users\arciom\Desktop\GRK_game_scene\cw 9\src\SOIL\SOIL.c(1841,6): warning C4996: 'fopen': This function or variable may be unsafe. Consider using fopen_s instead. To disable deprecation, use _CRT_SECURE_NO_WARNINGS. See online help for details.
|
||||
stb_image_aug.c
|
||||
C:\Users\arciom\Desktop\GRK_game_scene\cw 9\src\SOIL\stb_image_aug.c(177,14): warning C4996: 'fopen': This function or variable may be unsafe. Consider using fopen_s instead. To disable deprecation, use _CRT_SECURE_NO_WARNINGS. See online help for details.
|
||||
C:\Users\arciom\Desktop\GRK_game_scene\cw 9\src\SOIL\stb_image_aug.c(251,14): warning C4996: 'fopen': This function or variable may be unsafe. Consider using fopen_s instead. To disable deprecation, use _CRT_SECURE_NO_WARNINGS. See online help for details.
|
||||
C:\Users\arciom\Desktop\GRK_game_scene\cw 9\src\SOIL\stb_image_aug.c(303,14): warning C4996: 'fopen': This function or variable may be unsafe. Consider using fopen_s instead. To disable deprecation, use _CRT_SECURE_NO_WARNINGS. See online help for details.
|
||||
C:\Users\arciom\Desktop\GRK_game_scene\cw 9\src\SOIL\stb_image_aug.c(1557,14): warning C4996: 'fopen': This function or variable may be unsafe. Consider using fopen_s instead. To disable deprecation, use _CRT_SECURE_NO_WARNINGS. See online help for details.
|
||||
C:\Users\arciom\Desktop\GRK_game_scene\cw 9\src\SOIL\stb_image_aug.c(2394,14): warning C4996: 'fopen': This function or variable may be unsafe. Consider using fopen_s instead. To disable deprecation, use _CRT_SECURE_NO_WARNINGS. See online help for details.
|
||||
C:\Users\arciom\Desktop\GRK_game_scene\cw 9\src\SOIL\stb_image_aug.c(2709,14): warning C4996: 'fopen': This function or variable may be unsafe. Consider using fopen_s instead. To disable deprecation, use _CRT_SECURE_NO_WARNINGS. See online help for details.
|
||||
C:\Users\arciom\Desktop\GRK_game_scene\cw 9\src\SOIL\stb_image_aug.c(2995,14): warning C4996: 'fopen': This function or variable may be unsafe. Consider using fopen_s instead. To disable deprecation, use _CRT_SECURE_NO_WARNINGS. See online help for details.
|
||||
C:\Users\arciom\Desktop\GRK_game_scene\cw 9\src\SOIL\stb_image_aug.c(3209,14): warning C4996: 'fopen': This function or variable may be unsafe. Consider using fopen_s instead. To disable deprecation, use _CRT_SECURE_NO_WARNINGS. See online help for details.
|
||||
C:\Users\arciom\Desktop\GRK_game_scene\cw 9\src\SOIL\stb_image_aug.c(3548,14): warning C4996: 'fopen': This function or variable may be unsafe. Consider using fopen_s instead. To disable deprecation, use _CRT_SECURE_NO_WARNINGS. See online help for details.
|
||||
C:\Users\arciom\Desktop\GRK_game_scene\cw 9\src\SOIL\stb_image_aug.c(3644,14): warning C4996: 'fopen': This function or variable may be unsafe. Consider using fopen_s instead. To disable deprecation, use _CRT_SECURE_NO_WARNINGS. See online help for details.
|
||||
C:\Users\arciom\Desktop\GRK_game_scene\cw 9\src\SOIL\stbi_DDS_aug_c.h(362,19): warning C4018: '>': signed/unsigned mismatch
|
||||
C:\Users\arciom\Desktop\GRK_game_scene\cw 9\src\SOIL\stbi_DDS_aug_c.h(366,19): warning C4018: '>': signed/unsigned mismatch
|
||||
C:\Users\arciom\Desktop\GRK_game_scene\cw 9\src\SOIL\stbi_DDS_aug_c.h(390,19): warning C4018: '<': signed/unsigned mismatch
|
||||
C:\Users\arciom\Desktop\GRK_game_scene\cw 9\src\SOIL\stbi_DDS_aug_c.h(427,19): warning C4018: '<': signed/unsigned mismatch
|
||||
C:\Users\arciom\Desktop\GRK_game_scene\cw 9\src\SOIL\stbi_DDS_aug_c.h(498,14): warning C4996: 'fopen': This function or variable may be unsafe. Consider using fopen_s instead. To disable deprecation, use _CRT_SECURE_NO_WARNINGS. See online help for details.
|
||||
Generating Code...
|
||||
C:\Users\arciom\Desktop\GRK_game_scene\cw 9\src\ex_9_1.hpp(324,37): warning C4305: 'argument': truncation from 'double' to 'float'
|
||||
C:\Users\arciom\Desktop\GRK_game_scene\cw 9\src\ex_9_1.hpp(392,2): warning C4305: 'argument': truncation from 'double' to 'float'
|
||||
C:\Users\arciom\Desktop\GRK_game_scene\cw 9\src\ex_9_1.hpp(401,20): warning C4018: '<': signed/unsigned mismatch
|
||||
C:\Users\arciom\Desktop\GRK_game_scene\cw 9\src\ex_9_1.hpp(403,47): warning C4305: 'argument': truncation from 'double' to 'float'
|
||||
C:\Users\arciom\Desktop\GRK_game_scene\cw 9\src\ex_9_1.hpp(404,48): warning C4305: 'argument': truncation from 'double' to 'float'
|
||||
C:\Users\arciom\Desktop\GRK_game_scene\cw 9\src\ex_9_1.hpp(487,21): warning C4018: '<': signed/unsigned mismatch
|
||||
C:\Users\arciom\Desktop\GRK_game_scene\cw 9\src\ex_9_1.hpp(489,49): warning C4244: 'argument': conversion from 'double' to 'float', possible loss of data
|
||||
C:\Users\arciom\Desktop\GRK_game_scene\cw 9\src\ex_9_1.hpp(639,21): warning C4305: '-=': truncation from 'double' to 'float'
|
||||
C:\Users\arciom\Desktop\GRK_game_scene\cw 9\src\ex_9_1.hpp(641,21): warning C4305: '+=': truncation from 'double' to 'float'
|
||||
C:\Users\arciom\Desktop\GRK_game_scene\cw 9\src\ex_9_1.hpp(669,21): warning C4018: '<': signed/unsigned mismatch
|
||||
C:\Users\arciom\Desktop\GRK_game_scene\cw 9\src\ex_9_1.hpp(671,49): warning C4244: 'argument': conversion from 'double' to 'float', possible loss of data
|
||||
Box.obj : warning LNK4075: ignoring '/EDITANDCONTINUE' due to '/INCREMENTAL:NO' specification
|
||||
LINK : warning LNK4098: defaultlib 'MSVCRT' conflicts with use of other libs; use /NODEFAULTLIB:library
|
||||
grk-cw9.vcxproj -> C:\Users\arciom\Desktop\GRK_game_scene\Debug\grk-cw9.exe
|
||||
|
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@ -49,6 +49,8 @@
|
||||
<None Include="shaders\test.vert" />
|
||||
<None Include="shader_laser.frag" />
|
||||
<None Include="shader_laser.vert" />
|
||||
<None Include="shader_shadowap_sun.frag" />
|
||||
<None Include="shader_shadowap_sun.vert" />
|
||||
</ItemGroup>
|
||||
<PropertyGroup Label="Globals">
|
||||
<ProjectGuid>{5BACD057-4B83-4CB6-A367-40A10BCE2149}</ProjectGuid>
|
||||
|
@ -127,5 +127,11 @@
|
||||
<None Include="shader_laser.frag">
|
||||
<Filter>Shader Files</Filter>
|
||||
</None>
|
||||
<None Include="shader_shadowap_sun.vert">
|
||||
<Filter>Shader Files</Filter>
|
||||
</None>
|
||||
<None Include="shader_shadowap_sun.frag">
|
||||
<Filter>Shader Files</Filter>
|
||||
</None>
|
||||
</ItemGroup>
|
||||
</Project>
|
15
cw 9/shader_shadowap_sun.frag
Normal file
15
cw 9/shader_shadowap_sun.frag
Normal file
@ -0,0 +1,15 @@
|
||||
#version 430 core
|
||||
|
||||
//in vec4 sunSpacePos;
|
||||
|
||||
|
||||
//void calculateShadow() {
|
||||
// vec3 sunSpacePosNormalized = 0.5 * vec3(sunSpacePos) + 0.5;
|
||||
//}
|
||||
|
||||
void main() {
|
||||
//hell
|
||||
|
||||
// calculateShadow();
|
||||
|
||||
}
|
18
cw 9/shader_shadowap_sun.vert
Normal file
18
cw 9/shader_shadowap_sun.vert
Normal file
@ -0,0 +1,18 @@
|
||||
#version 430 core
|
||||
|
||||
layout(location = 0) in vec3 vertexPosition;
|
||||
layout(location = 1) in vec3 vertexNormal;
|
||||
layout(location = 2) in vec2 vertexTexCoord;
|
||||
|
||||
uniform mat4 viewProjectionMatrix;
|
||||
uniform mat4 modelMatrix;
|
||||
|
||||
//uniform mat4 LightVP;
|
||||
|
||||
//out vec4 sunSpacePos;
|
||||
|
||||
void main()
|
||||
{
|
||||
gl_Position = viewProjectionMatrix * modelMatrix * vec4(vertexPosition, 1.0);
|
||||
// sunSpacePos=LightVP*modelMatrix*vec4(vertexPosition,1);
|
||||
}
|
@ -36,6 +36,8 @@ in vec3 lightDirTS;
|
||||
in vec3 spotlightDirTS;
|
||||
in vec3 sunDirTS;
|
||||
|
||||
in vec4 sunSpacePos;
|
||||
|
||||
in vec3 test;
|
||||
|
||||
float DistributionGGX(vec3 normal, vec3 H, float roughness){
|
||||
@ -99,6 +101,22 @@ vec3 PBRLight(vec3 lightDir, vec3 radiance, vec3 normal, vec3 V){
|
||||
}
|
||||
|
||||
|
||||
float calculateShadow() {
|
||||
|
||||
vec3 sunSpacePosNormalized = 0.5 * (vec3(sunSpacePos) / sunSpacePos.w) + 0.5;
|
||||
|
||||
vec4 closestDepth = texture2D(depthMap, sunSpacePosNormalized.xy);
|
||||
|
||||
|
||||
if (closestDepth.r > sunSpacePosNormalized.z) {
|
||||
return 1.0;
|
||||
}
|
||||
else {
|
||||
return 0.0;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void main()
|
||||
{
|
||||
//vec3 normal = vec3(0,0,1);
|
||||
@ -112,7 +130,7 @@ void main()
|
||||
|
||||
|
||||
vec3 ambient = AMBIENT*color;
|
||||
vec3 attenuatedlightColor = lightColor/pow(length(lightPos-worldPos),2);
|
||||
vec3 attenuatedlightColor = lightColor/pow(length(lightPos-worldPos),2); //dla pocisku
|
||||
vec3 ilumination;
|
||||
ilumination = ambient+PBRLight(lightDir,attenuatedlightColor,normal,viewDir);
|
||||
|
||||
@ -126,7 +144,7 @@ void main()
|
||||
ilumination=ilumination+PBRLight(spotlightDir,attenuatedlightColor,normal,viewDir);
|
||||
|
||||
//sun
|
||||
ilumination=ilumination+PBRLight(sunDir,sunColor,normal,viewDir);
|
||||
ilumination=ilumination+PBRLight(sunDir, calculateShadow() * sunColor,normal,viewDir); //dla pocisku
|
||||
|
||||
|
||||
outColor = vec4(vec3(1.0) - exp(-ilumination*exposition),1);
|
||||
|
@ -9,6 +9,8 @@ layout(location = 4) in vec3 vertexBitangent;
|
||||
uniform mat4 transformation;
|
||||
uniform mat4 modelMatrix;
|
||||
|
||||
uniform mat4 LightVP;
|
||||
|
||||
out vec3 vecNormal;
|
||||
out vec3 worldPos;
|
||||
|
||||
@ -22,6 +24,8 @@ out vec3 lightDirTS;
|
||||
out vec3 spotlightDirTS;
|
||||
out vec3 sunDirTS;
|
||||
|
||||
out vec4 sunSpacePos;
|
||||
|
||||
void main()
|
||||
{
|
||||
worldPos = (modelMatrix* vec4(vertexPosition,1)).xyz;
|
||||
@ -40,4 +44,6 @@ void main()
|
||||
spotlightDirTS = TBN*SL;
|
||||
sunDirTS = TBN*sunDir;
|
||||
|
||||
sunSpacePos=LightVP*modelMatrix*vec4(vertexPosition,1);
|
||||
|
||||
}
|
||||
|
5
cw 9/shaders/shader_shadowap_sun.frag
Normal file
5
cw 9/shaders/shader_shadowap_sun.frag
Normal file
@ -0,0 +1,5 @@
|
||||
#version 430 core
|
||||
|
||||
void main()
|
||||
{
|
||||
}
|
13
cw 9/shaders/shader_shadowap_sun.vert
Normal file
13
cw 9/shaders/shader_shadowap_sun.vert
Normal file
@ -0,0 +1,13 @@
|
||||
#version 430 core
|
||||
|
||||
layout(location = 0) in vec3 vertexPosition;
|
||||
layout(location = 1) in vec3 vertexNormal;
|
||||
layout(location = 2) in vec2 vertexTexCoord;
|
||||
|
||||
uniform mat4 viewProjectionMatrix;
|
||||
uniform mat4 modelMatrix;
|
||||
|
||||
void main()
|
||||
{
|
||||
gl_Position = viewProjectionMatrix * modelMatrix * vec4(vertexPosition, 1.0);
|
||||
}
|
@ -69,6 +69,7 @@ GLuint program;
|
||||
GLuint programSun;
|
||||
GLuint programTest;
|
||||
GLuint programTex;
|
||||
GLuint programDepth;
|
||||
|
||||
GLuint programLaser;
|
||||
|
||||
@ -194,6 +195,16 @@ void drawObjectPBR(Core::RenderContext& context, glm::mat4 modelMatrix, glm::vec
|
||||
glUniform3f(glGetUniformLocation(program, "spotlightPos"), spotlightPos.x, spotlightPos.y, spotlightPos.z);
|
||||
glUniform3f(glGetUniformLocation(program, "spotlightColor"), spotlightColor.x, spotlightColor.y, spotlightColor.z);
|
||||
glUniform1f(glGetUniformLocation(program, "spotlightPhi"), spotlightPhi);
|
||||
|
||||
//
|
||||
glActiveTexture(GL_TEXTURE0);
|
||||
glBindTexture(GL_TEXTURE_2D, depthMap);
|
||||
|
||||
glm::mat4 lightVP = glm::ortho(-10.f, 10.f, -10.f, 10.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::DrawContext(context);
|
||||
|
||||
}
|
||||
@ -224,14 +235,57 @@ void drawLaser(Laser laser, Core::RenderContext laserContext, float dyst) {
|
||||
}
|
||||
|
||||
|
||||
void initDepthMap() {
|
||||
glGenFramebuffers(1, &depthMapFBO);
|
||||
|
||||
glGenTextures(1, &depthMap);
|
||||
glBindTexture(GL_TEXTURE_2D, depthMap);
|
||||
glTexImage2D(GL_TEXTURE_2D, 0, GL_DEPTH_COMPONENT,
|
||||
SHADOW_WIDTH, SHADOW_HEIGHT, 0, GL_DEPTH_COMPONENT, GL_FLOAT, NULL);
|
||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
|
||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
|
||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT);
|
||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT);
|
||||
|
||||
|
||||
glBindFramebuffer(GL_FRAMEBUFFER, depthMapFBO);
|
||||
glFramebufferTexture2D(GL_FRAMEBUFFER, GL_DEPTH_ATTACHMENT, GL_TEXTURE_2D, depthMap, 0);
|
||||
glDrawBuffer(GL_NONE);
|
||||
glReadBuffer(GL_NONE);
|
||||
glBindFramebuffer(GL_FRAMEBUFFER, 0);
|
||||
}
|
||||
|
||||
|
||||
void drawObjectDepth(Core::RenderContext context, glm::mat4 viewProjectionMatrix, glm::mat4 modelMatrix) {
|
||||
|
||||
/*glm::mat4 lightProjection = glm::ortho(-10.f, 10.f, -10.f, 10.f, 1.0f, 30.0f);
|
||||
|
||||
viewProjectionMatrix = glm::lookAt(sunPos, sunPos - sunDir, glm::vec3(0, 1, 0));*/
|
||||
|
||||
glUseProgram(programDepth);
|
||||
glUniformMatrix4fv(glGetUniformLocation(programDepth, "viewProjectionMatrix"), 1, GL_FALSE, (float*)&viewProjectionMatrix);
|
||||
glUniformMatrix4fv(glGetUniformLocation(programDepth, "modelMatrix"), 1, GL_FALSE, (float*)&modelMatrix);
|
||||
glUseProgram(program);
|
||||
Core::DrawContext(context);
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
void renderShadowapSun() {
|
||||
float time = glfwGetTime();
|
||||
glViewport(0, 0, SHADOW_WIDTH, SHADOW_HEIGHT);
|
||||
//glViewport(0, 0, SHADOW_WIDTH, SHADOW_HEIGHT);
|
||||
//uzupelnij o renderowanie glebokosci do tekstury
|
||||
|
||||
|
||||
|
||||
|
||||
//ustawianie przestrzeni rysowania
|
||||
glViewport(0, 0, SHADOW_WIDTH, SHADOW_HEIGHT);
|
||||
//bindowanie FBO
|
||||
glBindFramebuffer(GL_FRAMEBUFFER, depthMapFBO);
|
||||
//czyszczenie mapy głębokości
|
||||
glClear(GL_DEPTH_BUFFER_BIT);
|
||||
//ustawianie programu
|
||||
glUseProgram(programDepth);
|
||||
|
||||
|
||||
glBindFramebuffer(GL_FRAMEBUFFER, 0);
|
||||
@ -257,6 +311,12 @@ void renderScene(GLFWwindow* window)
|
||||
|
||||
glUseProgram(program);
|
||||
|
||||
glm::mat4 lightVP = glm::ortho(-10.f, 10.f, -10.f, 10.f, 1.0f, 40.0f) * glm::lookAt(sunPos, sunPos - sunDir, glm::vec3(0, 1, 0));
|
||||
drawObjectDepth(models::roomContext, lightVP, glm::mat4());
|
||||
|
||||
drawObjectDepth(models::windowContext, lightVP, glm::mat4());
|
||||
|
||||
|
||||
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,
|
||||
@ -264,17 +324,52 @@ void renderScene(GLFWwindow* window)
|
||||
glm::vec3(0.5, 0.5, 0.5), 0.7, 0.0);
|
||||
|
||||
drawObjectPBR(models::bedContext, glm::mat4(), glm::vec3(0.03f, 0.03f, 0.03f), 0.2f, 0.0f);
|
||||
//
|
||||
|
||||
drawObjectDepth(models::bedContext, lightVP, glm::mat4());
|
||||
|
||||
drawObjectPBR(models::chairContext, glm::mat4(), glm::vec3(0.195239f, 0.37728f, 0.8f), 0.4f, 0.0f);
|
||||
//
|
||||
drawObjectDepth(models::chairContext, lightVP, glm::mat4());
|
||||
|
||||
drawObjectPBR(models::deskContext, glm::mat4(), glm::vec3(0.428691f, 0.08022f, 0.036889f), 0.2f, 0.0f);
|
||||
//
|
||||
drawObjectDepth(models::deskContext, lightVP, glm::mat4());
|
||||
|
||||
|
||||
drawObjectPBR(models::doorContext, glm::mat4(), glm::vec3(0.402978f, 0.120509f, 0.057729f), 0.2f, 0.0f);
|
||||
//
|
||||
drawObjectDepth(models::doorContext, lightVP, glm::mat4());
|
||||
|
||||
|
||||
drawObjectPBR(models::drawerContext, glm::mat4(), glm::vec3(0.428691f, 0.08022f, 0.036889f), 0.2f, 0.0f);
|
||||
//
|
||||
drawObjectDepth(models::drawerContext, lightVP, glm::mat4());
|
||||
|
||||
|
||||
drawObjectPBR(models::marbleBustContext, glm::mat4(), glm::vec3(1.f, 1.f, 1.f), 0.5f, 1.0f);
|
||||
//
|
||||
drawObjectDepth(models::marbleBustContext, lightVP, glm::mat4());
|
||||
|
||||
drawObjectPBR(models::materaceContext, glm::mat4(), glm::vec3(0.9f, 0.9f, 0.9f), 0.8f, 0.0f);
|
||||
//
|
||||
drawObjectDepth(models::materaceContext, lightVP, glm::mat4());
|
||||
|
||||
drawObjectPBR(models::pencilsContext, glm::mat4(), glm::vec3(0.10039f, 0.018356f, 0.001935f), 0.1f, 0.0f);
|
||||
//
|
||||
drawObjectDepth(models::pencilsContext, lightVP, glm::mat4());
|
||||
|
||||
drawObjectPBR(models::planeContext, glm::mat4(), glm::vec3(0.402978f, 0.120509f, 0.057729f), 0.2f, 0.0f);
|
||||
//
|
||||
drawObjectDepth(models::planeContext, lightVP, glm::mat4());
|
||||
|
||||
drawObjectPBR(models::roomContext, glm::mat4(), glm::vec3(0.9f, 0.9f, 0.9f), 0.8f, 0.0f);
|
||||
//
|
||||
//drawObjectDepth(models::roomContext, lightVP, glm::mat4());
|
||||
|
||||
drawObjectPBR(models::windowContext, glm::mat4(), glm::vec3(0.402978f, 0.120509f, 0.057729f), 0.2f, 0.0f);
|
||||
//
|
||||
//drawObjectDepth(models::windowContext, lightVP, glm::mat4());
|
||||
|
||||
glm::vec3 spaceshipSide = glm::normalize(glm::cross(spaceShip.getSpaceShipDir(), glm::vec3(0.f, 1.f, 0.f)));
|
||||
glm::vec3 spaceshipUp = glm::normalize(glm::cross(spaceshipSide, spaceShip.getSpaceShipDir()));
|
||||
@ -295,6 +390,8 @@ void renderScene(GLFWwindow* window)
|
||||
glm::vec3(0.3, 0.3, 0.5),
|
||||
0.2, 1.0
|
||||
);
|
||||
//
|
||||
drawObjectDepth(shipContext, lightVP, glm::translate(spaceShip.getSpaceShipPos()) * specshipCameraRotrationMatrix * glm::eulerAngleY(glm::pi<float>()) * glm::scale(glm::vec3(0.03f)));
|
||||
|
||||
spotlightPos = spaceShip.getSpaceShipPos() + 0.2 * spaceShip.getSpaceShipDir();
|
||||
spotlightConeDir = spaceShip.getSpaceShipDir();
|
||||
@ -302,8 +399,11 @@ void renderScene(GLFWwindow* window)
|
||||
|
||||
//draw lasers
|
||||
for (int i = 0; i < lasers.size(); i++) {
|
||||
drawLaser(lasers[i], lasersContexts[i], 0.1);
|
||||
drawLaser(lasers[i], lasersContexts[i], -0.1);
|
||||
if (lasers[i].isLaserFly()) {
|
||||
drawLaser(lasers[i], lasersContexts[i], 0.1);
|
||||
drawLaser(lasers[i], lasersContexts[i], -0.1);
|
||||
}
|
||||
|
||||
|
||||
/*if (i % 2 == 0) {
|
||||
drawLaser(lasers[i], lasersContexts[i], 0.1);
|
||||
@ -320,11 +420,11 @@ void renderScene(GLFWwindow* window)
|
||||
|
||||
|
||||
//test depth buffer
|
||||
//glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
|
||||
//glUseProgram(programTest);
|
||||
//glActiveTexture(GL_TEXTURE0);
|
||||
//glBindTexture(GL_TEXTURE_2D, depthMap);
|
||||
//Core::DrawContext(models::testContext);
|
||||
/*glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
|
||||
glUseProgram(programTest);
|
||||
glActiveTexture(GL_TEXTURE0);
|
||||
glBindTexture(GL_TEXTURE_2D, depthMap);
|
||||
Core::DrawContext(models::testContext);*/
|
||||
|
||||
glUseProgram(0);
|
||||
glfwSwapBuffers(window);
|
||||
@ -419,6 +519,8 @@ void init(GLFWwindow* window)
|
||||
programTest = shaderLoader.CreateProgram("shaders/test.vert", "shaders/test.frag");
|
||||
programSun = shaderLoader.CreateProgram("shaders/shader_8_sun.vert", "shaders/shader_8_sun.frag");
|
||||
|
||||
programDepth = shaderLoader.CreateProgram("shaders/shader_shadowap_sun.vert", "shaders/shader_shadowap_sun.frag");
|
||||
|
||||
//programLaser = shaderLoader.CreateProgram("shaders/shader_laser.vert", "shaders/shader_laser.frag");
|
||||
|
||||
loadModelToContext("./models/sphere.obj", sphereContext);
|
||||
@ -453,6 +555,9 @@ void init(GLFWwindow* window)
|
||||
}
|
||||
|
||||
|
||||
initDepthMap();
|
||||
|
||||
|
||||
/*for (int i = 0; i < spaceShip.getMaxNumberOfLasers(); i++) {
|
||||
|
||||
loadModelToContext("./models/newlaser2.obj", spaceShip.getGun()[i].getLaserContext());
|
||||
|
Loading…
Reference in New Issue
Block a user