Modified depthMap and shadows methods, shaders for shadows. Now shadows is working correctly
This commit is contained in:
parent
2049ba1822
commit
097ce521b6
Binary file not shown.
Binary file not shown.
@ -4,36 +4,46 @@ C:\Users\arciom\Desktop\GRK_game_scene\dependencies\glfw-3.3.8.bin.WIN32\include
|
||||
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'
|
||||
C:\Users\arciom\Desktop\GRK_game_scene\cw 9\src\ex_9_1.hpp(221,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(236,98): 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(320,87): warning C4305: 'argument': truncation from 'double' to 'T'
|
||||
C:\Users\arciom\Desktop\GRK_game_scene\cw 9\src\ex_9_1.hpp(239,68): 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(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'
|
||||
C:\Users\arciom\Desktop\GRK_game_scene\cw 9\src\ex_9_1.hpp(273,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(320,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(329,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(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
|
||||
C:\Users\arciom\Desktop\GRK_game_scene\cw 9\src\ex_9_1.hpp(337,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(337,223): warning C4305: 'argument': truncation from 'double' to 'float'
|
||||
C:\Users\arciom\Desktop\GRK_game_scene\cw 9\src\ex_9_1.hpp(340,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(341,37): warning C4305: 'argument': truncation from 'double' to 'float'
|
||||
C:\Users\arciom\Desktop\GRK_game_scene\cw 9\src\ex_9_1.hpp(372,2): warning C4305: 'argument': truncation from 'double' to 'float'
|
||||
C:\Users\arciom\Desktop\GRK_game_scene\cw 9\src\ex_9_1.hpp(379,20): warning C4018: '<': signed/unsigned mismatch
|
||||
C:\Users\arciom\Desktop\GRK_game_scene\cw 9\src\ex_9_1.hpp(381,47): warning C4305: 'argument': truncation from 'double' to 'float'
|
||||
C:\Users\arciom\Desktop\GRK_game_scene\cw 9\src\ex_9_1.hpp(382,48): warning C4305: 'argument': truncation from 'double' to 'float'
|
||||
C:\Users\arciom\Desktop\GRK_game_scene\cw 9\src\ex_9_1.hpp(465,21): warning C4018: '<': signed/unsigned mismatch
|
||||
C:\Users\arciom\Desktop\GRK_game_scene\cw 9\src\ex_9_1.hpp(467,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(624,21): warning C4305: '-=': truncation from 'double' to 'float'
|
||||
C:\Users\arciom\Desktop\GRK_game_scene\cw 9\src\ex_9_1.hpp(626,21): warning C4305: '+=': truncation from 'double' to 'float'
|
||||
C:\Users\arciom\Desktop\GRK_game_scene\cw 9\src\ex_9_1.hpp(654,21): warning C4018: '<': signed/unsigned mismatch
|
||||
C:\Users\arciom\Desktop\GRK_game_scene\cw 9\src\ex_9_1.hpp(656,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.
@ -1,15 +1,6 @@
|
||||
#version 430 core
|
||||
|
||||
//in vec4 sunSpacePos;
|
||||
|
||||
|
||||
//void calculateShadow() {
|
||||
// vec3 sunSpacePosNormalized = 0.5 * vec3(sunSpacePos) + 0.5;
|
||||
//}
|
||||
|
||||
void main() {
|
||||
//hell
|
||||
|
||||
// calculateShadow();
|
||||
|
||||
}
|
@ -7,12 +7,7 @@ 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);
|
||||
}
|
@ -3,7 +3,7 @@
|
||||
float AMBIENT = 0.03;
|
||||
float PI = 3.14;
|
||||
|
||||
uniform sampler2D depthMap;
|
||||
uniform sampler2D depthMapSun;
|
||||
|
||||
uniform vec3 cameraPos;
|
||||
|
||||
@ -103,17 +103,13 @@ vec3 PBRLight(vec3 lightDir, vec3 radiance, vec3 normal, vec3 V){
|
||||
|
||||
float calculateShadow() {
|
||||
|
||||
vec3 sunSpacePosNormalized = 0.5 * (vec3(sunSpacePos) / sunSpacePos.w) + 0.5;
|
||||
vec4 sunSpacePosNormalized = (0.5 * sunSpacePos / (sunSpacePos.w)) + 0.5;
|
||||
|
||||
vec4 closestDepth = texture2D(depthMap, sunSpacePosNormalized.xy);
|
||||
float closestDepth = texture2D(depthMapSun, sunSpacePosNormalized.xy).x;//r?
|
||||
|
||||
float diff = (0.001+closestDepth) - sunSpacePosNormalized.z;//sunSpacePosNormalized.z;
|
||||
|
||||
if (closestDepth.r > sunSpacePosNormalized.z) {
|
||||
return 1.0;
|
||||
}
|
||||
else {
|
||||
return 0.0;
|
||||
}
|
||||
return (0.5*(diff)/abs(diff))+0.5;
|
||||
}
|
||||
|
||||
|
||||
@ -144,7 +140,7 @@ void main()
|
||||
ilumination=ilumination+PBRLight(spotlightDir,attenuatedlightColor,normal,viewDir);
|
||||
|
||||
//sun
|
||||
ilumination=ilumination+PBRLight(sunDir, calculateShadow() * sunColor,normal,viewDir); //dla pocisku
|
||||
ilumination=ilumination+PBRLight(sunDir, sunColor * calculateShadow(), normal, viewDir); //dla pocisku
|
||||
|
||||
|
||||
outColor = vec4(vec3(1.0) - exp(-ilumination*exposition),1);
|
||||
|
@ -9,7 +9,7 @@ layout(location = 4) in vec3 vertexBitangent;
|
||||
uniform mat4 transformation;
|
||||
uniform mat4 modelMatrix;
|
||||
|
||||
uniform mat4 LightVP;
|
||||
uniform mat4 LightVPSun;
|
||||
|
||||
out vec3 vecNormal;
|
||||
out vec3 worldPos;
|
||||
@ -44,6 +44,6 @@ void main()
|
||||
spotlightDirTS = TBN*SL;
|
||||
sunDirTS = TBN*sunDir;
|
||||
|
||||
sunSpacePos=LightVP*modelMatrix*vec4(vertexPosition,1);
|
||||
sunSpacePos=LightVPSun*modelMatrix*vec4(vertexPosition,1);
|
||||
|
||||
}
|
||||
|
@ -62,8 +62,8 @@ namespace models {
|
||||
|
||||
}
|
||||
|
||||
GLuint depthMapFBO;
|
||||
GLuint depthMap;
|
||||
GLuint depthMapFBOSun;
|
||||
GLuint depthMapSun;
|
||||
|
||||
GLuint program;
|
||||
GLuint programSun;
|
||||
@ -196,17 +196,75 @@ void drawObjectPBR(Core::RenderContext& context, glm::mat4 modelMatrix, glm::vec
|
||||
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);
|
||||
//
|
||||
//For shadows
|
||||
glm::mat4 lightVPSun = 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, "LightVPSun"), 1, GL_FALSE, (float*)&lightVPSun);
|
||||
glUniform1i(glGetUniformLocation(program, "depthMapSun"), 2);
|
||||
glActiveTexture(GL_TEXTURE0 + 2);
|
||||
glBindTexture(GL_TEXTURE_2D, depthMapSun);
|
||||
|
||||
|
||||
Core::DrawContext(context);
|
||||
}
|
||||
|
||||
|
||||
void drawObjectDepth(Core::RenderContext context, glm::mat4 viewProjectionMatrix, glm::mat4 modelMatrix) {
|
||||
|
||||
glUniformMatrix4fv(glGetUniformLocation(programDepth, "viewProjectionMatrix"), 1, GL_FALSE, (float*)&viewProjectionMatrix);
|
||||
glUniformMatrix4fv(glGetUniformLocation(programDepth, "modelMatrix"), 1, GL_FALSE, (float*)&modelMatrix);
|
||||
Core::DrawContext(context);
|
||||
}
|
||||
|
||||
|
||||
void renderShadowapSun(GLuint depthMapFBO, glm::mat4 lightVP) {
|
||||
float time = glfwGetTime();
|
||||
glViewport(0, 0, SHADOW_WIDTH, SHADOW_HEIGHT);
|
||||
//uzupelnij o renderowanie glebokosci do tekstury
|
||||
glUseProgram(programDepth);
|
||||
|
||||
//ustawianie przestrzeni rysowania
|
||||
glViewport(0, 0, SHADOW_WIDTH, SHADOW_HEIGHT);
|
||||
//bindowanie FBO
|
||||
glBindFramebuffer(GL_FRAMEBUFFER, depthMapFBO);
|
||||
//czyszczenie mapy głębokości
|
||||
glClear(GL_DEPTH_BUFFER_BIT);
|
||||
//ustawianie programu
|
||||
glUseProgram(programDepth);
|
||||
|
||||
|
||||
drawObjectDepth(sphereContext, lightVP, glm::translate(pointlightPos) * glm::scale(glm::vec3(0.1)) * glm::eulerAngleY(time / 3) * glm::translate(glm::vec3(4.f, 0, 0)) * glm::scale(glm::vec3(0.3f)));
|
||||
|
||||
drawObjectDepth(sphereContext,
|
||||
lightVP, glm::translate(pointlightPos) * glm::scale(glm::vec3(0.1)) * glm::eulerAngleY(time / 3) * glm::translate(glm::vec3(4.f, 0, 0)) * glm::eulerAngleY(time) * glm::translate(glm::vec3(1.f, 0, 0)) * glm::scale(glm::vec3(0.1f)));
|
||||
|
||||
drawObjectDepth(models::bedContext, lightVP, glm::mat4());
|
||||
drawObjectDepth(models::chairContext, lightVP, glm::mat4());
|
||||
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::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());
|
||||
|
||||
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()));
|
||||
glm::mat4 specshipCameraRotrationMatrix = glm::mat4({
|
||||
spaceshipSide.x,spaceshipSide.y,spaceshipSide.z,0,
|
||||
spaceshipUp.x,spaceshipUp.y,spaceshipUp.z ,0,
|
||||
-spaceShip.getSpaceShipDir().x,-spaceShip.getSpaceShipDir().y,-spaceShip.getSpaceShipDir().z,0,
|
||||
0.,0.,0.,1.,
|
||||
});
|
||||
|
||||
drawObjectDepth(shipContext, lightVP,
|
||||
glm::translate(spaceShip.getSpaceShipPos()) * specshipCameraRotrationMatrix * glm::eulerAngleY(glm::pi<float>()) * glm::scale(glm::vec3(0.03f)));
|
||||
|
||||
|
||||
glBindFramebuffer(GL_FRAMEBUFFER, 0);
|
||||
glViewport(0, 0, WIDTH, HEIGHT);
|
||||
}
|
||||
|
||||
|
||||
@ -235,11 +293,12 @@ void drawLaser(Laser laser, Core::RenderContext laserContext, float dyst) {
|
||||
}
|
||||
|
||||
|
||||
void initDepthMap() {
|
||||
glGenFramebuffers(1, &depthMapFBO);
|
||||
void initDepthMap()
|
||||
{
|
||||
glGenFramebuffers(1, &depthMapFBOSun);
|
||||
|
||||
glGenTextures(1, &depthMap);
|
||||
glBindTexture(GL_TEXTURE_2D, depthMap);
|
||||
glGenTextures(1, &depthMapSun);
|
||||
glBindTexture(GL_TEXTURE_2D, depthMapSun);
|
||||
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);
|
||||
@ -247,58 +306,22 @@ void initDepthMap() {
|
||||
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);
|
||||
glBindFramebuffer(GL_FRAMEBUFFER, depthMapFBOSun);
|
||||
glFramebufferTexture2D(GL_FRAMEBUFFER, GL_DEPTH_ATTACHMENT, GL_TEXTURE_2D, depthMapSun, 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);
|
||||
//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);
|
||||
glViewport(0, 0, WIDTH, HEIGHT);
|
||||
}
|
||||
|
||||
void renderScene(GLFWwindow* window)
|
||||
{
|
||||
glClearColor(0.4f, 0.4f, 0.8f, 1.0f);
|
||||
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
|
||||
float time = glfwGetTime();
|
||||
updateDeltaTime(time);
|
||||
renderShadowapSun();
|
||||
|
||||
glm::mat4 lightVPSun = glm::ortho(-3.f, 2.3f, -1.3f, 3.f, -1.0f, 40.0f) * glm::lookAt(sunPos, sunPos - sunDir, glm::vec3(0, 1, 0));
|
||||
renderShadowapSun(depthMapFBOSun, lightVPSun);
|
||||
|
||||
//space lamp
|
||||
glUseProgram(programSun);
|
||||
@ -311,12 +334,6 @@ 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,
|
||||
@ -324,52 +341,16 @@ 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()));
|
||||
@ -380,7 +361,6 @@ void renderScene(GLFWwindow* window)
|
||||
0.,0.,0.,1.,
|
||||
});
|
||||
|
||||
|
||||
//drawObjectColor(shipContext,
|
||||
// glm::translate(cameraPos + 1.5 * cameraDir + cameraUp * -0.5f) * inveseCameraRotrationMatrix * glm::eulerAngleY(glm::pi<float>()),
|
||||
// glm::vec3(0.3, 0.3, 0.5)
|
||||
@ -390,8 +370,6 @@ 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();
|
||||
@ -423,7 +401,7 @@ void renderScene(GLFWwindow* window)
|
||||
/*glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
|
||||
glUseProgram(programTest);
|
||||
glActiveTexture(GL_TEXTURE0);
|
||||
glBindTexture(GL_TEXTURE_2D, depthMap);
|
||||
glBindTexture(GL_TEXTURE_2D, depthMapSun);
|
||||
Core::DrawContext(models::testContext);*/
|
||||
|
||||
glUseProgram(0);
|
||||
@ -514,6 +492,8 @@ void init(GLFWwindow* window)
|
||||
|
||||
glfwSetCursorPosCallback(window, cursor_position_callback);
|
||||
|
||||
initDepthMap();
|
||||
|
||||
glEnable(GL_DEPTH_TEST);
|
||||
program = shaderLoader.CreateProgram("shaders/shader_9_1.vert", "shaders/shader_9_1.frag");
|
||||
programTest = shaderLoader.CreateProgram("shaders/test.vert", "shaders/test.frag");
|
||||
@ -555,9 +535,6 @@ void init(GLFWwindow* window)
|
||||
}
|
||||
|
||||
|
||||
initDepthMap();
|
||||
|
||||
|
||||
/*for (int i = 0; i < spaceShip.getMaxNumberOfLasers(); i++) {
|
||||
|
||||
loadModelToContext("./models/newlaser2.obj", spaceShip.getGun()[i].getLaserContext());
|
||||
@ -620,6 +597,10 @@ void processInput(GLFWwindow* window)
|
||||
|
||||
if (!spaceShip.getAttackDecision()) {
|
||||
//laser.setLaserDir(spaceShip.getSpaceShipDir());
|
||||
|
||||
/*for (int i = 0; i < lasers.size(); i++) {
|
||||
lasers[i].setLaserDir(spaceShip.getSpaceShipDir());
|
||||
}*/
|
||||
}
|
||||
}
|
||||
if (glfwGetKey(window, GLFW_KEY_D) == GLFW_PRESS) {
|
||||
@ -629,6 +610,10 @@ void processInput(GLFWwindow* window)
|
||||
|
||||
if (!spaceShip.getAttackDecision()) {
|
||||
//laser.setLaserDir(spaceShip.getSpaceShipDir());
|
||||
|
||||
/*for (int i = 0; i < lasers.size(); i++) {
|
||||
lasers[i].setLaserDir(spaceShip.getSpaceShipDir());
|
||||
}*/
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user