normal mapping fix
@ -42,11 +42,11 @@ C:\Users\jedrz\Desktop\GRK_Project\cw 9\src\ex_9_1.hpp(519,108): warning C4305:
|
||||
[
|
||||
T=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"
|
||||
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
|
||||
4 of 604 functions ( 0.7%) were compiled, the rest were copied from previous compilation.
|
||||
1 of 604 functions ( 0.2%) were compiled, the rest were copied from previous compilation.
|
||||
0 functions were new in current compilation
|
||||
6 functions had inline decision re-evaluated but remain unchanged
|
||||
7 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
|
||||
|
@ -122,23 +122,23 @@ float calculateShadow() {
|
||||
|
||||
void main()
|
||||
{
|
||||
color = texture(colorTexture, vecTex).xyz;
|
||||
metallic = texture(metallicTexture, vecTex).r;
|
||||
roughness = texture(roughnessTexture, vecTex).r;
|
||||
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 = texture(normalSampler, vecTex).rgb;
|
||||
//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 viewDir = normalize(viewDirTS);
|
||||
//vec3 viewDir = normalize(cameraPos-worldPos);
|
||||
|
||||
//vec3 lightDir = normalize(lightDirTS);
|
||||
vec3 lightDir = normalize(lightPos-worldPos);
|
||||
vec3 lightDir = normalize(lightDirTS);
|
||||
//vec3 lightDir = normalize(lightPos-worldPos);
|
||||
|
||||
|
||||
vec3 ambient = texture(aoTexture, vecTex).xyz*color;
|
||||
vec3 ambient = texture2D(aoTexture, vecTex).xyz*color;
|
||||
vec3 attenuatedlightColor = lightColor/pow(length(lightPos-worldPos),2);
|
||||
vec3 ilumination;
|
||||
ilumination = ambient+PBRLight(lightDir,attenuatedlightColor,normal,viewDir);
|
||||
|
@ -27,8 +27,7 @@ out vec4 sunSpacePos;
|
||||
|
||||
void main()
|
||||
{
|
||||
vecTex = vertexTexCoord;
|
||||
vecTex.y = 1.0 - vecTex.y;
|
||||
vecTex = vec2(0, 1) + vertexTexCoord * vec2(1, -1);
|
||||
|
||||
worldPos = (modelMatrix* vec4(vertexPosition,1)).xyz;
|
||||
vecNormal = (modelMatrix* vec4(vertexNormal,0)).xyz;
|
||||
@ -48,63 +47,3 @@ void main()
|
||||
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);
|
||||
|
||||
}
|
||||
*/
|
@ -301,11 +301,11 @@ 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, 1);
|
||||
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,5);
|
||||
Core::SetActiveTexture(normal, "normalSampler", programTexPBR,1);
|
||||
|
||||
//Core::DrawContext(context);
|
||||
|
||||
@ -471,7 +471,7 @@ void renderScene(GLFWwindow* window)
|
||||
|
||||
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);
|
||||
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);
|
||||
@ -535,7 +535,7 @@ void init(GLFWwindow* window)
|
||||
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.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");
|
||||
@ -615,10 +615,18 @@ void processInput(GLFWwindow* window)
|
||||
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");
|
||||
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);
|
||||
}
|
||||
|
BIN
cw 9/textures/Bez tytułu.png
Normal file
After Width: | Height: | Size: 985 KiB |
Before Width: | Height: | Size: 133 KiB After Width: | Height: | Size: 786 KiB |
BIN
cw 9/textures/main.jpg
Normal file
After Width: | Height: | Size: 133 KiB |
BIN
cw 9/textures/necro.png
Normal file
After Width: | Height: | Size: 4.3 MiB |
BIN
cw 9/textures/rust_normal.jpg
Normal file
After Width: | Height: | Size: 3.3 MiB |
Before Width: | Height: | Size: 6.5 MiB After Width: | Height: | Size: 7.8 MiB |
BIN
cw 9/textures/x.png
Normal file
After Width: | Height: | Size: 2.3 MiB |