normal mapy

This commit is contained in:
Generacja 2023-01-23 13:18:35 +01:00
parent 373b2b2ca2
commit de5862f670
17 changed files with 47 additions and 27 deletions

View File

@ -2,43 +2,43 @@
main.cpp main.cpp
C:\Program Files (x86)\Windows Kits\10\Include\10.0.19041.0\shared\minwindef.h(130,1): warning C4005: "APIENTRY": ponowna definicja makra C:\Program Files (x86)\Windows Kits\10\Include\10.0.19041.0\shared\minwindef.h(130,1): warning C4005: "APIENTRY": ponowna definicja makra
C:\Users\Genos\Source\Repos\GRK_Room2\dependencies\glfw-3.3.8.bin.WIN32\include\GLFW\glfw3.h(123): message : zobacz poprzednią definicję „APIENTRY” C:\Users\Genos\Source\Repos\GRK_Room2\dependencies\glfw-3.3.8.bin.WIN32\include\GLFW\glfw3.h(123): message : zobacz poprzednią definicję „APIENTRY”
C:\Users\Genos\source\repos\GRK_Room2\cw 9\src\room.hpp(94,30): warning C4305: "inicjowanie": obcięcie z "double" do "float" C:\Users\Genos\source\repos\GRK_Room2\cw 9\src\room.hpp(97,30): warning C4305: "inicjowanie": obcięcie z "double" do "float"
C:\Users\Genos\source\repos\GRK_Room2\cw 9\src\room.hpp(109,38): warning C4305: "=": obcięcie z "double" do "float" C:\Users\Genos\source\repos\GRK_Room2\cw 9\src\room.hpp(112,38): warning C4305: "=": obcięcie z "double" do "float"
C:\Users\Genos\source\repos\GRK_Room2\cw 9\src\room.hpp(132,16): warning C4305: "inicjowanie": obcięcie z "double" do "float" C:\Users\Genos\source\repos\GRK_Room2\cw 9\src\room.hpp(135,16): warning C4305: "inicjowanie": obcięcie z "double" do "float"
C:\Users\Genos\source\repos\GRK_Room2\cw 9\src\room.hpp(153,16): warning C4305: "inicjowanie": obcięcie z "double" do "float" C:\Users\Genos\source\repos\GRK_Room2\cw 9\src\room.hpp(156,16): warning C4305: "inicjowanie": obcięcie z "double" do "float"
C:\Users\Genos\source\repos\GRK_Room2\cw 9\src\room.hpp(172,15): warning C4101: "textureID": lokalna zmienna, do której nie istnieje odwołanie C:\Users\Genos\source\repos\GRK_Room2\cw 9\src\room.hpp(175,15): warning C4101: "textureID": lokalna zmienna, do której nie istnieje odwołanie
C:\Users\Genos\source\repos\GRK_Room2\cw 9\src\room.hpp(252,13): warning C4244: "inicjowanie": konwersja z "double" do "float", możliwa utrata danych C:\Users\Genos\source\repos\GRK_Room2\cw 9\src\room.hpp(258,13): warning C4244: "inicjowanie": konwersja z "double" do "float", możliwa utrata danych
C:\Users\Genos\source\repos\GRK_Room2\cw 9\src\room.hpp(263,96): warning C4305: "argument": obcięcie z "double" do "T" C:\Users\Genos\source\repos\GRK_Room2\cw 9\src\room.hpp(269,96): warning C4305: "argument": obcięcie z "double" do "T"
with with
[ [
T=float T=float
] ]
C:\Users\Genos\source\repos\GRK_Room2\cw 9\src\room.hpp(267,59): warning C4305: "argument": obcięcie z "double" do "T" C:\Users\Genos\source\repos\GRK_Room2\cw 9\src\room.hpp(273,59): warning C4305: "argument": obcięcie z "double" do "T"
with with
[ [
T=float T=float
] ]
C:\Users\Genos\source\repos\GRK_Room2\cw 9\src\room.hpp(343,13): warning C4244: "inicjowanie": konwersja z "double" do "float", możliwa utrata danych C:\Users\Genos\source\repos\GRK_Room2\cw 9\src\room.hpp(349,13): warning C4244: "inicjowanie": konwersja z "double" do "float", możliwa utrata danych
C:\Users\Genos\source\repos\GRK_Room2\cw 9\src\room.hpp(353,108): warning C4305: "argument": obcięcie z "double" do "T" C:\Users\Genos\source\repos\GRK_Room2\cw 9\src\room.hpp(359,108): warning C4305: "argument": obcięcie z "double" do "T"
with with
[ [
T=float T=float
] ]
C:\Users\Genos\source\repos\GRK_Room2\cw 9\src\room.hpp(361,87): warning C4305: "argument": obcięcie z "double" do "T" C:\Users\Genos\source\repos\GRK_Room2\cw 9\src\room.hpp(367,87): warning C4305: "argument": obcięcie z "double" do "T"
with with
[ [
T=float T=float
] ]
C:\Users\Genos\source\repos\GRK_Room2\cw 9\src\room.hpp(361,223): warning C4305: "argument": obcięcie z "double" do "float" C:\Users\Genos\source\repos\GRK_Room2\cw 9\src\room.hpp(367,223): warning C4305: "argument": obcięcie z "double" do "float"
C:\Users\Genos\source\repos\GRK_Room2\cw 9\src\room.hpp(364,59): warning C4305: "argument": obcięcie z "double" do "T" C:\Users\Genos\source\repos\GRK_Room2\cw 9\src\room.hpp(370,59): warning C4305: "argument": obcięcie z "double" do "T"
with with
[ [
T=float T=float
] ]
C:\Users\Genos\source\repos\GRK_Room2\cw 9\src\room.hpp(365,37): warning C4305: "argument": obcięcie z "double" do "float" C:\Users\Genos\source\repos\GRK_Room2\cw 9\src\room.hpp(371,37): warning C4305: "argument": obcięcie z "double" do "float"
C:\Users\Genos\source\repos\GRK_Room2\cw 9\src\room.hpp(393,2): warning C4305: "argument": obcięcie z "double" do "float" C:\Users\Genos\source\repos\GRK_Room2\cw 9\src\room.hpp(399,2): warning C4305: "argument": obcięcie z "double" do "float"
C:\Users\Genos\source\repos\GRK_Room2\cw 9\src\room.hpp(501,21): warning C4305: "-=": obcięcie z "double" do "float" C:\Users\Genos\source\repos\GRK_Room2\cw 9\src\room.hpp(510,21): warning C4305: "-=": obcięcie z "double" do "float"
C:\Users\Genos\source\repos\GRK_Room2\cw 9\src\room.hpp(503,21): warning C4305: "+=": obcięcie z "double" do "float" C:\Users\Genos\source\repos\GRK_Room2\cw 9\src\room.hpp(512,21): warning C4305: "+=": obcięcie z "double" do "float"
Box.obj : warning LNK4075: zignorowano opcję „/EDITANDCONTINUE” z powodu określenia opcji „/INCREMENTAL:NO” 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 LINK : warning LNK4098: domyślna biblioteka „MSVCRT” powoduje konflikt z innymi bibliotekami; użyj opcji /NODEFAULTLIB:biblioteka
grk-cw9.vcxproj -> C:\Users\Genos\Source\Repos\GRK_Room2\Debug\room.exe grk-cw9.vcxproj -> C:\Users\Genos\Source\Repos\GRK_Room2\Debug\room.exe

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

View File

@ -6,9 +6,12 @@ float PI = 3.14;
uniform sampler2D depthMap; uniform sampler2D depthMap;
uniform sampler2D depthMapShip; uniform sampler2D depthMapShip;
uniform sampler2D colorTexture;
uniform sampler2D normalSampler;
uniform vec3 cameraPos; uniform vec3 cameraPos;
uniform vec3 color; vec3 color;
uniform vec3 sunDir; uniform vec3 sunDir;
uniform vec3 sunColor; uniform vec3 sunColor;
@ -42,6 +45,8 @@ in vec3 test;
in vec4 sunSpacePos; in vec4 sunSpacePos;
in vec4 shipPos; in vec4 shipPos;
in vec2 vecTex;
float calculateShadow(vec3 normal, vec3 light, vec4 pos, sampler2D depth) { float calculateShadow(vec3 normal, vec3 light, vec4 pos, sampler2D depth) {
vec4 posNormalized = (pos / pos.w) * 0.5 + 0.5; vec4 posNormalized = (pos / pos.w) * 0.5 + 0.5;
float closestDepth = texture2D(depth, posNormalized.xy).r; float closestDepth = texture2D(depth, posNormalized.xy).r;
@ -117,13 +122,16 @@ vec3 PBRLight(vec3 lightDir, vec3 radiance, vec3 normal, vec3 V){
void main() void main()
{ {
//vec3 normal = vec3(0,0,1); //vec3 normal = vec3(0,0,1);
vec3 normal = normalize(vecNormal); //vec3 normal = normalize(vecNormal);
//vec3 viewDir = normalize(viewDirTS); color = texture2D(colorTexture, vecTex).xyz;
vec3 viewDir = normalize(cameraPos-worldPos); vec3 normal = normalize((texture2D(normalSampler, vecTex).xyz) * 2 - 1);
//vec3 lightDir = normalize(lightDirTS); vec3 viewDir = normalize(viewDirTS);
vec3 lightDir = normalize(lightPos-worldPos); //vec3 viewDir = normalize(cameraPos-worldPos);
vec3 lightDir = normalize(lightDirTS);
//vec3 lightDir = normalize(lightPos-worldPos);
vec3 ambient = AMBIENT*color; vec3 ambient = AMBIENT*color;
@ -132,8 +140,8 @@ void main()
ilumination = ambient+PBRLight(lightDir,attenuatedlightColor,normal,viewDir); ilumination = ambient+PBRLight(lightDir,attenuatedlightColor,normal,viewDir);
//flashlight //flashlight
//vec3 spotlightDir= normalize(spotlightDirTS); vec3 spotlightDir= normalize(spotlightDirTS);
vec3 spotlightDir= normalize(spotlightPos-worldPos); //vec3 spotlightDir= normalize(spotlightPos-worldPos);
float angle_atenuation = clamp((dot(-normalize(spotlightPos-worldPos),spotlightConeDir)-0.5)*3,0,1); float angle_atenuation = clamp((dot(-normalize(spotlightPos-worldPos),spotlightConeDir)-0.5)*3,0,1);

View File

@ -26,6 +26,7 @@ out vec3 sunDirTS;
out vec4 sunSpacePos; out vec4 sunSpacePos;
out vec4 shipPos; out vec4 shipPos;
out vec2 vecTex;
void main() void main()
{ {
@ -39,6 +40,8 @@ void main()
vec3 w_tangent = normalize(mat3(modelMatrix)*vertexTangent); vec3 w_tangent = normalize(mat3(modelMatrix)*vertexTangent);
vec3 w_bitangent = normalize(mat3(modelMatrix)*vertexBitangent); vec3 w_bitangent = normalize(mat3(modelMatrix)*vertexBitangent);
mat3 TBN = transpose(mat3(w_tangent, w_bitangent, vecNormal)); mat3 TBN = transpose(mat3(w_tangent, w_bitangent, vecNormal));
vecTex = vertexTexCoord;
vec3 V = normalize(cameraPos-worldPos); vec3 V = normalize(cameraPos-worldPos);
viewDirTS = TBN*V; viewDirTS = TBN*V;

View File

@ -7,7 +7,7 @@
#include "Shader_Loader.h" #include "Shader_Loader.h"
#include "Render_Utils.h" #include "Render_Utils.h"
//#include "Texture.h" #include "Texture.h"
#include "Box.cpp" #include "Box.cpp"
#include <assimp/Importer.hpp> #include <assimp/Importer.hpp>
@ -38,6 +38,9 @@ namespace models {
namespace texture { namespace texture {
GLuint cubemapTexture; GLuint cubemapTexture;
GLuint earth;
GLuint earthNormal;
} }
Core::RenderContext cubeContext;; Core::RenderContext cubeContext;;
@ -232,7 +235,7 @@ void drawObjectPBR(Core::RenderContext& context, glm::mat4 modelMatrix, glm::vec
glUniform1f(glGetUniformLocation(program, "roughness"), roughness); glUniform1f(glGetUniformLocation(program, "roughness"), roughness);
glUniform1f(glGetUniformLocation(program, "metallic"), metallic); glUniform1f(glGetUniformLocation(program, "metallic"), metallic);
glUniform3f(glGetUniformLocation(program, "color"), color.x, color.y, color.z); //glUniform3f(glGetUniformLocation(program, "color"), color.x, color.y, color.z);
glUniform3f(glGetUniformLocation(program, "cameraPos"), cameraPos.x, cameraPos.y, cameraPos.z); glUniform3f(glGetUniformLocation(program, "cameraPos"), cameraPos.x, cameraPos.y, cameraPos.z);
@ -246,6 +249,9 @@ void drawObjectPBR(Core::RenderContext& context, glm::mat4 modelMatrix, glm::vec
glUniform3f(glGetUniformLocation(program, "spotlightPos"), spotlightPos.x, spotlightPos.y, spotlightPos.z); glUniform3f(glGetUniformLocation(program, "spotlightPos"), spotlightPos.x, spotlightPos.y, spotlightPos.z);
glUniform3f(glGetUniformLocation(program, "spotlightColor"), spotlightColor.x, spotlightColor.y, spotlightColor.z); glUniform3f(glGetUniformLocation(program, "spotlightColor"), spotlightColor.x, spotlightColor.y, spotlightColor.z);
glUniform1f(glGetUniformLocation(program, "spotlightPhi"), spotlightPhi); glUniform1f(glGetUniformLocation(program, "spotlightPhi"), spotlightPhi);
Core::SetActiveTexture(texture::earth, "colorTexture", program, 2);
Core::SetActiveTexture(texture::earthNormal, "normalSampler", program, 3);
Core::DrawContext(context); Core::DrawContext(context);
} }
void renderShadowapSun(GLuint depthFBO, glm::mat4 light) { void renderShadowapSun(GLuint depthFBO, glm::mat4 light) {
@ -441,6 +447,9 @@ void init(GLFWwindow* window)
loadCubemap(faces); loadCubemap(faces);
initDepthMap(); initDepthMap();
texture::earth = Core::LoadTexture("textures/room/earth.png");
texture::earthNormal = Core::LoadTexture("textures/room/earth_normalmap.png");
loadModelToContext("./models/sphere.obj", sphereContext); loadModelToContext("./models/sphere.obj", sphereContext);
loadModelToContext("./models/spaceship.obj", shipContext); loadModelToContext("./models/spaceship.obj", shipContext);
loadModelToContext("./models/cube.obj", cubeContext); loadModelToContext("./models/cube.obj", cubeContext);

Binary file not shown.

Before

Width:  |  Height:  |  Size: 27 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 123 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 224 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 158 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 148 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 13 MiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 163 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 9.0 MiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 31 KiB