worked on floor texture;
This commit is contained in:
parent
1cef08d75b
commit
79281ef178
Binary file not shown.
Binary file not shown.
BIN
Release/room.exe
BIN
Release/room.exe
Binary file not shown.
BIN
Release/room.pdb
BIN
Release/room.pdb
Binary file not shown.
@ -1,34 +1,35 @@
|
|||||||
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
|
||||||
D:\UAM\Grafika komputerowa\projekt\GRK_Room\dependencies\glfw-3.3.8.bin.WIN32\include\GLFW\glfw3.h(123): message : zobacz poprzednią definicję „APIENTRY”
|
D:\UAM\Grafika komputerowa\projekt\GRK_Room\dependencies\glfw-3.3.8.bin.WIN32\include\GLFW\glfw3.h(123): message : zobacz poprzednią definicję „APIENTRY”
|
||||||
D:\UAM\Grafika komputerowa\projekt\GRK_Room\cw 9\src\room.hpp(118,30): warning C4305: "inicjowanie": obcięcie z "double" do "float"
|
D:\UAM\Grafika komputerowa\projekt\GRK_Room\cw 9\src\room.hpp(120,30): warning C4305: "inicjowanie": obcięcie z "double" do "float"
|
||||||
D:\UAM\Grafika komputerowa\projekt\GRK_Room\cw 9\src\room.hpp(136,38): warning C4305: "=": obcięcie z "double" do "float"
|
D:\UAM\Grafika komputerowa\projekt\GRK_Room\cw 9\src\room.hpp(138,38): warning C4305: "=": obcięcie z "double" do "float"
|
||||||
D:\UAM\Grafika komputerowa\projekt\GRK_Room\cw 9\src\room.hpp(159,16): warning C4305: "inicjowanie": obcięcie z "double" do "float"
|
D:\UAM\Grafika komputerowa\projekt\GRK_Room\cw 9\src\room.hpp(161,16): warning C4305: "inicjowanie": obcięcie z "double" do "float"
|
||||||
D:\UAM\Grafika komputerowa\projekt\GRK_Room\cw 9\src\room.hpp(178,16): warning C4305: "inicjowanie": obcięcie z "double" do "float"
|
D:\UAM\Grafika komputerowa\projekt\GRK_Room\cw 9\src\room.hpp(180,16): warning C4305: "inicjowanie": obcięcie z "double" do "float"
|
||||||
D:\UAM\Grafika komputerowa\projekt\GRK_Room\cw 9\src\room.hpp(196,15): warning C4101: "textureID": lokalna zmienna, do której nie istnieje odwołanie
|
D:\UAM\Grafika komputerowa\projekt\GRK_Room\cw 9\src\room.hpp(198,15): warning C4101: "textureID": lokalna zmienna, do której nie istnieje odwołanie
|
||||||
D:\UAM\Grafika komputerowa\projekt\GRK_Room\cw 9\src\room.hpp(288,13): warning C4244: "inicjowanie": konwersja z "double" do "float", możliwa utrata danych
|
D:\UAM\Grafika komputerowa\projekt\GRK_Room\cw 9\src\room.hpp(338,13): warning C4244: "inicjowanie": konwersja z "double" do "float", możliwa utrata danych
|
||||||
D:\UAM\Grafika komputerowa\projekt\GRK_Room\cw 9\src\room.hpp(294,96): warning C4305: "argument": obcięcie z "double" do "T"
|
D:\UAM\Grafika komputerowa\projekt\GRK_Room\cw 9\src\room.hpp(344,96): warning C4305: "argument": obcięcie z "double" do "T"
|
||||||
with
|
with
|
||||||
[
|
[
|
||||||
T=float
|
T=float
|
||||||
]
|
]
|
||||||
D:\UAM\Grafika komputerowa\projekt\GRK_Room\cw 9\src\room.hpp(297,59): warning C4305: "argument": obcięcie z "double" do "T"
|
D:\UAM\Grafika komputerowa\projekt\GRK_Room\cw 9\src\room.hpp(347,59): warning C4305: "argument": obcięcie z "double" do "T"
|
||||||
with
|
with
|
||||||
[
|
[
|
||||||
T=float
|
T=float
|
||||||
]
|
]
|
||||||
D:\UAM\Grafika komputerowa\projekt\GRK_Room\cw 9\src\room.hpp(445,29): warning C4018: "<": niezgodność typu ze znakiem/bez znaku
|
D:\UAM\Grafika komputerowa\projekt\GRK_Room\cw 9\src\room.hpp(495,29): warning C4018: "<": niezgodność typu ze znakiem/bez znaku
|
||||||
D:\UAM\Grafika komputerowa\projekt\GRK_Room\cw 9\src\room.hpp(470,13): warning C4244: "inicjowanie": konwersja z "double" do "float", możliwa utrata danych
|
D:\UAM\Grafika komputerowa\projekt\GRK_Room\cw 9\src\room.hpp(520,13): warning C4244: "inicjowanie": konwersja z "double" do "float", możliwa utrata danych
|
||||||
D:\UAM\Grafika komputerowa\projekt\GRK_Room\cw 9\src\room.hpp(487,109): warning C4305: "argument": obcięcie z "double" do "T"
|
D:\UAM\Grafika komputerowa\projekt\GRK_Room\cw 9\src\room.hpp(534,109): warning C4305: "argument": obcięcie z "double" do "T"
|
||||||
with
|
with
|
||||||
[
|
[
|
||||||
T=float
|
T=float
|
||||||
]
|
]
|
||||||
D:\UAM\Grafika komputerowa\projekt\GRK_Room\cw 9\src\room.hpp(539,2): warning C4305: "argument": obcięcie z "double" do "float"
|
D:\UAM\Grafika komputerowa\projekt\GRK_Room\cw 9\src\room.hpp(587,2): warning C4305: "argument": obcięcie z "double" do "float"
|
||||||
D:\UAM\Grafika komputerowa\projekt\GRK_Room\cw 9\src\room.hpp(678,21): warning C4305: "-=": obcięcie z "double" do "float"
|
D:\UAM\Grafika komputerowa\projekt\GRK_Room\cw 9\src\room.hpp(727,21): warning C4305: "-=": obcięcie z "double" do "float"
|
||||||
D:\UAM\Grafika komputerowa\projekt\GRK_Room\cw 9\src\room.hpp(680,21): warning C4305: "+=": obcięcie z "double" do "float"
|
D:\UAM\Grafika komputerowa\projekt\GRK_Room\cw 9\src\room.hpp(729,21): warning C4305: "+=": obcięcie z "double" do "float"
|
||||||
Trwa generowanie kodu
|
Trwa generowanie kodu
|
||||||
Previous IPDB and IOBJ mismatch, fall back to full compilation.
|
47 of 607 functions ( 7.7%) were compiled, the rest were copied from previous compilation.
|
||||||
All 607 functions were compiled because no usable IPDB/IOBJ from previous compilation was found.
|
0 functions were new in current compilation
|
||||||
|
9 functions had inline decision re-evaluated but remain unchanged
|
||||||
Zakończono generowanie kodu
|
Zakończono generowanie kodu
|
||||||
grk-cw9.vcxproj -> D:\UAM\Grafika komputerowa\projekt\GRK_Room\Release\room.exe
|
grk-cw9.vcxproj -> D:\UAM\Grafika komputerowa\projekt\GRK_Room\Release\room.exe
|
||||||
|
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@ -1,4 +1,6 @@
|
|||||||
<?xml version="1.0" encoding="utf-8"?>
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
<Project ToolsVersion="Current" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
<Project ToolsVersion="Current" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||||
<PropertyGroup />
|
<PropertyGroup>
|
||||||
|
<ShowAllFiles>true</ShowAllFiles>
|
||||||
|
</PropertyGroup>
|
||||||
</Project>
|
</Project>
|
@ -1,18 +0,0 @@
|
|||||||
#version 430 core
|
|
||||||
|
|
||||||
float AMBIENT = 0.1;
|
|
||||||
|
|
||||||
uniform vec3 color;
|
|
||||||
uniform vec3 lightPos;
|
|
||||||
|
|
||||||
in vec3 vecNormal;
|
|
||||||
in vec3 worldPos;
|
|
||||||
|
|
||||||
out vec4 outColor;
|
|
||||||
void main()
|
|
||||||
{
|
|
||||||
vec3 lightDir = normalize(lightPos-worldPos);
|
|
||||||
vec3 normal = normalize(vecNormal);
|
|
||||||
float diffuse=max(0,dot(normal,lightDir));
|
|
||||||
outColor = vec4(color*min(1,AMBIENT+diffuse), 1.0);
|
|
||||||
}
|
|
@ -1,18 +0,0 @@
|
|||||||
#version 430 core
|
|
||||||
|
|
||||||
layout(location = 0) in vec3 vertexPosition;
|
|
||||||
layout(location = 1) in vec3 vertexNormal;
|
|
||||||
layout(location = 2) in vec2 vertexTexCoord;
|
|
||||||
|
|
||||||
uniform mat4 transformation;
|
|
||||||
uniform mat4 modelMatrix;
|
|
||||||
|
|
||||||
out vec3 vecNormal;
|
|
||||||
out vec3 worldPos;
|
|
||||||
|
|
||||||
void main()
|
|
||||||
{
|
|
||||||
worldPos = (modelMatrix* vec4(vertexPosition,1)).xyz;
|
|
||||||
vecNormal = (modelMatrix* vec4(vertexNormal,0)).xyz;
|
|
||||||
gl_Position = transformation * vec4(vertexPosition, 1.0);
|
|
||||||
}
|
|
150
cw 9/shaders/shader_tex.frag
Normal file
150
cw 9/shaders/shader_tex.frag
Normal file
@ -0,0 +1,150 @@
|
|||||||
|
#version 430 core
|
||||||
|
|
||||||
|
float AMBIENT = 0.03;
|
||||||
|
float PI = 3.14;
|
||||||
|
|
||||||
|
uniform sampler2D depthMapSun;
|
||||||
|
|
||||||
|
uniform vec3 cameraPos;
|
||||||
|
|
||||||
|
uniform vec3 color;
|
||||||
|
|
||||||
|
uniform vec3 sunDir;
|
||||||
|
uniform vec3 sunColor;
|
||||||
|
|
||||||
|
uniform vec3 lightPos;
|
||||||
|
uniform vec3 lightColor;
|
||||||
|
|
||||||
|
uniform sampler2D colorTexture;
|
||||||
|
in vec2 vecTex;
|
||||||
|
|
||||||
|
uniform vec3 spotlightPos;
|
||||||
|
uniform vec3 spotlightColor;
|
||||||
|
uniform vec3 spotlightConeDir;
|
||||||
|
uniform vec3 spotlightPhi;
|
||||||
|
|
||||||
|
uniform float metallic;
|
||||||
|
uniform float roughness;
|
||||||
|
|
||||||
|
uniform float exposition;
|
||||||
|
|
||||||
|
in vec3 vecNormal;
|
||||||
|
in vec3 worldPos;
|
||||||
|
|
||||||
|
out vec4 outColor;
|
||||||
|
|
||||||
|
|
||||||
|
in vec3 viewDirTS;
|
||||||
|
in vec3 lightDirTS;
|
||||||
|
in vec3 spotlightDirTS;
|
||||||
|
in vec3 sunDirTS;
|
||||||
|
|
||||||
|
in vec4 sunSpacePos;
|
||||||
|
|
||||||
|
in vec3 test;
|
||||||
|
uniform float time;
|
||||||
|
|
||||||
|
float DistributionGGX(vec3 normal, vec3 H, float roughness){
|
||||||
|
float a = roughness*roughness;
|
||||||
|
float a2 = a*a;
|
||||||
|
float NdotH = max(dot(normal, H), 0.0);
|
||||||
|
float NdotH2 = NdotH*NdotH;
|
||||||
|
|
||||||
|
float num = a2;
|
||||||
|
float denom = (NdotH2 * (a2 - 1.0) + 1.0);
|
||||||
|
denom = PI * denom * denom;
|
||||||
|
|
||||||
|
return num / denom;
|
||||||
|
}
|
||||||
|
float GeometrySchlickGGX(float NdotV, float roughness){
|
||||||
|
float r = (roughness + 1.0);
|
||||||
|
float k = (r*r) / 8.0;
|
||||||
|
|
||||||
|
float num = NdotV;
|
||||||
|
float denom = NdotV * (1.0 - k) + k;
|
||||||
|
|
||||||
|
return num / denom;
|
||||||
|
}
|
||||||
|
float GeometrySmith(vec3 normal, vec3 V, vec3 lightDir, float roughness){
|
||||||
|
float NdotV = max(dot(normal, V), 0.0);
|
||||||
|
float NdotL = max(dot(normal, lightDir), 0.0);
|
||||||
|
float ggx2 = GeometrySchlickGGX(NdotV, roughness);
|
||||||
|
float ggx1 = GeometrySchlickGGX(NdotL, roughness);
|
||||||
|
|
||||||
|
return ggx1 * ggx2;
|
||||||
|
}
|
||||||
|
vec3 fresnelSchlick(float cosTheta, vec3 F0){
|
||||||
|
return F0 + (1.0 - F0) * pow(clamp(1.0 - cosTheta, 0.0, 1.0), 5.0);
|
||||||
|
}
|
||||||
|
|
||||||
|
vec3 PBRLight(vec3 lightDir, vec3 radiance, vec3 normal, vec3 V){
|
||||||
|
float diffuse=max(0,dot(normal,lightDir));
|
||||||
|
|
||||||
|
//vec3 V = normalize(cameraPos-worldPos);
|
||||||
|
vec3 F0 = vec3(0.04);
|
||||||
|
F0 = mix(F0, color, metallic);
|
||||||
|
|
||||||
|
vec3 H = normalize(V + lightDir);
|
||||||
|
|
||||||
|
// cook-torrance brdf
|
||||||
|
float NDF = DistributionGGX(normal, H, roughness);
|
||||||
|
float G = GeometrySmith(normal, V, lightDir, roughness);
|
||||||
|
vec3 F = fresnelSchlick(max(dot(H, V), 0.0), F0);
|
||||||
|
|
||||||
|
vec3 kS = F;
|
||||||
|
vec3 kD = vec3(1.0) - kS;
|
||||||
|
kD *= 1.0 - metallic;
|
||||||
|
|
||||||
|
vec3 numerator = NDF * G * F;
|
||||||
|
float denominator = 4.0 * max(dot(normal, V), 0.0) * max(dot(normal, lightDir), 0.0) + 0.0001;
|
||||||
|
vec3 specular = numerator / denominator;
|
||||||
|
|
||||||
|
// add to outgoing radiance Lo
|
||||||
|
float NdotL = max(dot(normal, lightDir), 0.0);
|
||||||
|
return (kD * color / PI + specular) * radiance * NdotL;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
float calculateShadow() {
|
||||||
|
|
||||||
|
vec4 sunSpacePosNormalized = (0.5 * sunSpacePos / (sunSpacePos.w)) + 0.5;
|
||||||
|
|
||||||
|
float closestDepth = texture2D(depthMapSun, sunSpacePosNormalized.xy).x;//r?
|
||||||
|
|
||||||
|
float diff = (0.001+closestDepth) - sunSpacePosNormalized.z;//sunSpacePosNormalized.z;
|
||||||
|
|
||||||
|
return (0.5*(diff)/abs(diff))+0.5;
|
||||||
|
}
|
||||||
|
|
||||||
|
void main()
|
||||||
|
{
|
||||||
|
vec3 lightDir = normalize(lightPos-worldPos);
|
||||||
|
vec3 normal = normalize(vecNormal);
|
||||||
|
vec3 textureColor = texture2D(colorTexture, vecTex).xyz;
|
||||||
|
float diffuse=max(0,dot(normal,lightDir));
|
||||||
|
|
||||||
|
vec3 viewDir = normalize(cameraPos-worldPos);
|
||||||
|
|
||||||
|
vec3 ambient = AMBIENT*color;
|
||||||
|
vec3 attenuatedlightColor = lightColor/pow(length(lightPos-worldPos),2);
|
||||||
|
vec3 ilumination;
|
||||||
|
ilumination = ambient+PBRLight(lightDir,attenuatedlightColor,normal,viewDir);
|
||||||
|
|
||||||
|
//flashlight
|
||||||
|
//vec3 spotlightDir= normalize(spotlightDirTS);
|
||||||
|
vec3 spotlightDir= normalize(spotlightPos-worldPos);
|
||||||
|
|
||||||
|
|
||||||
|
float angle_atenuation = clamp((dot(-normalize(spotlightPos-worldPos),spotlightConeDir)-0.5)*3,0,1);
|
||||||
|
attenuatedlightColor = angle_atenuation*spotlightColor/pow(length(spotlightPos-worldPos),2);
|
||||||
|
ilumination=ilumination+PBRLight(spotlightDir,attenuatedlightColor,normal,viewDir);
|
||||||
|
|
||||||
|
//sun
|
||||||
|
ilumination=ilumination+PBRLight(sunDir, sunColor * calculateShadow(), normal, viewDir);
|
||||||
|
|
||||||
|
//outColor = vec4(textureColor*min(1,AMBIENT+diffuse), 1.0);
|
||||||
|
//outColor = vec4(vec3(1.0) - exp(-ilumination*exposition),1);
|
||||||
|
|
||||||
|
outColor = vec4(textureColor*min(1,AMBIENT+diffuse) - 1*exp(-ilumination*exposition),1);
|
||||||
|
}
|
||||||
|
|
72
cw 9/shaders/shader_tex.vert
Normal file
72
cw 9/shaders/shader_tex.vert
Normal file
@ -0,0 +1,72 @@
|
|||||||
|
#version 430 core
|
||||||
|
|
||||||
|
//layout(location = 0) in vec3 vertexPosition;
|
||||||
|
//layout(location = 1) in vec3 vertexNormal;
|
||||||
|
//layout(location = 2) in vec2 vertexTexCoord;
|
||||||
|
//
|
||||||
|
//uniform mat4 transformation;
|
||||||
|
//uniform mat4 modelMatrix;
|
||||||
|
//
|
||||||
|
//out vec3 vecNormal;
|
||||||
|
//out vec3 worldPos;
|
||||||
|
//out vec2 vecTex;
|
||||||
|
//
|
||||||
|
//void main()
|
||||||
|
//{
|
||||||
|
// worldPos = (modelMatrix * vec4(vertexPosition, 1)).xyz;
|
||||||
|
// vecNormal = (modelMatrix * vec4(vertexNormal, 0)).xyz;
|
||||||
|
// vecTex = vertexTexCoord;
|
||||||
|
// vecTex.y = 1.0 - vecTex.y;
|
||||||
|
// gl_Position = transformation * vec4(vertexPosition, 1.0);
|
||||||
|
//}
|
||||||
|
|
||||||
|
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 LightVPSun;
|
||||||
|
|
||||||
|
out vec3 vecNormal;
|
||||||
|
out vec3 worldPos;
|
||||||
|
out vec2 vecTex;
|
||||||
|
|
||||||
|
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 vec4 sunSpacePos;
|
||||||
|
|
||||||
|
void main()
|
||||||
|
{
|
||||||
|
worldPos = (modelMatrix* vec4(vertexPosition,1)).xyz;
|
||||||
|
vecNormal = (modelMatrix* vec4(vertexNormal,0)).xyz;
|
||||||
|
vecTex = vertexTexCoord;
|
||||||
|
vecTex.y = 1.0 - vecTex.y;
|
||||||
|
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=LightVPSun*modelMatrix*vec4(vertexPosition,1);
|
||||||
|
|
||||||
|
}
|
@ -56,6 +56,8 @@ namespace texture {
|
|||||||
|
|
||||||
GLuint earth;
|
GLuint earth;
|
||||||
GLuint earthNormal;
|
GLuint earthNormal;
|
||||||
|
|
||||||
|
GLuint floor;
|
||||||
}
|
}
|
||||||
|
|
||||||
Core::RenderContext cubeContext;
|
Core::RenderContext cubeContext;
|
||||||
@ -284,6 +286,54 @@ void drawObjectPBR(Core::RenderContext& context, glm::mat4 modelMatrix, glm::vec
|
|||||||
|
|
||||||
Core::DrawContext(context);
|
Core::DrawContext(context);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void drawObjectTexture(Core::RenderContext& context, glm::mat4 modelMatrix, GLuint textureID, glm::vec3 color, float roughness, float metallic) {
|
||||||
|
glUseProgram(programTex);
|
||||||
|
|
||||||
|
glm::mat4 viewProjectionMatrix = createPerspectiveMatrix() * createCameraMatrix();
|
||||||
|
glm::mat4 transformation = viewProjectionMatrix * modelMatrix;
|
||||||
|
|
||||||
|
glUniformMatrix4fv(glGetUniformLocation(programTex, "transformation"), 1, GL_FALSE, (float*)&transformation);
|
||||||
|
glUniformMatrix4fv(glGetUniformLocation(programTex, "modelMatrix"), 1, GL_FALSE, (float*)&modelMatrix);
|
||||||
|
|
||||||
|
glUniform1f(glGetUniformLocation(programTex, "exposition"), exposition);
|
||||||
|
|
||||||
|
glUniform1f(glGetUniformLocation(programTex, "roughness"), roughness);
|
||||||
|
glUniform1f(glGetUniformLocation(programTex, "metallic"), metallic);
|
||||||
|
glUniform3f(glGetUniformLocation(programTex, "color"), color.x, color.y, color.z);
|
||||||
|
|
||||||
|
glUniform3f(glGetUniformLocation(programTex, "cameraPos"), cameraPos.x, cameraPos.y, cameraPos.z);
|
||||||
|
|
||||||
|
glUniform3f(glGetUniformLocation(programTex, "sunDir"), sunDir.x, sunDir.y, sunDir.z);
|
||||||
|
glUniform3f(glGetUniformLocation(programTex, "sunColor"), sunColor.x, sunColor.y, sunColor.z);
|
||||||
|
|
||||||
|
if (lightOn > 0.0f)
|
||||||
|
glUniform3f(glGetUniformLocation(programTex, "lightPos"), pointlightPos.x, pointlightPos.y, pointlightPos.z);
|
||||||
|
else
|
||||||
|
glUniform3f(glGetUniformLocation(programTex, "lightPos"), 1000.f, 1000.f, 1000.f);
|
||||||
|
glUniform3f(glGetUniformLocation(programTex, "lightColor"), pointlightColor.x, pointlightColor.y, pointlightColor.z);
|
||||||
|
|
||||||
|
|
||||||
|
glUniform3f(glGetUniformLocation(programTex, "spotlightConeDir"), spotlightConeDir.x, spotlightConeDir.y, spotlightConeDir.z);
|
||||||
|
glUniform3f(glGetUniformLocation(programTex, "spotlightPos"), spotlightPos.x, spotlightPos.y, spotlightPos.z);
|
||||||
|
glUniform3f(glGetUniformLocation(programTex, "spotlightColor"), spotlightColor.x, spotlightColor.y, spotlightColor.z);
|
||||||
|
glUniform1f(glGetUniformLocation(program, "spotlightPhi"), spotlightPhi);
|
||||||
|
|
||||||
|
glActiveTexture(GL_TEXTURE0);
|
||||||
|
glUniform1i(glGetUniformLocation(programTex, "depthMapSun"), 0);
|
||||||
|
glBindTexture(GL_TEXTURE_2D, depthMap);
|
||||||
|
glUniformMatrix4fv(glGetUniformLocation(programTex, "LightVPSun"), 1, GL_FALSE, (float*)&lightVP);
|
||||||
|
|
||||||
|
glActiveTexture(GL_TEXTURE1);
|
||||||
|
glUniform1i(glGetUniformLocation(programTex, "depthMapShip"), 1);
|
||||||
|
glBindTexture(GL_TEXTURE_2D, depthMapShip);
|
||||||
|
glUniformMatrix4fv(glGetUniformLocation(programTex, "lightShipVP"), 1, GL_FALSE, (float*)&lightShipVP);
|
||||||
|
|
||||||
|
Core::SetActiveTexture(textureID, "colorTexture", programTex, 0);
|
||||||
|
Core::DrawContext(context);
|
||||||
|
glUseProgram(0);
|
||||||
|
}
|
||||||
|
|
||||||
void renderShadowapSun(GLuint depthFBO, glm::mat4 light) {
|
void renderShadowapSun(GLuint depthFBO, glm::mat4 light) {
|
||||||
float time = glfwGetTime();
|
float time = glfwGetTime();
|
||||||
glViewport(0, 0, SHADOW_WIDTH, SHADOW_HEIGHT);
|
glViewport(0, 0, SHADOW_WIDTH, SHADOW_HEIGHT);
|
||||||
@ -470,7 +520,6 @@ void renderScene(GLFWwindow* window)
|
|||||||
float time = glfwGetTime();
|
float time = glfwGetTime();
|
||||||
updateDeltaTime(time);
|
updateDeltaTime(time);
|
||||||
|
|
||||||
|
|
||||||
renderShadowapSun(depthMapFBO, lightVP);
|
renderShadowapSun(depthMapFBO, lightVP);
|
||||||
renderShadowapSun(depthMapShipFBO, lightShipVP);
|
renderShadowapSun(depthMapShipFBO, lightShipVP);
|
||||||
glBindFramebuffer(GL_FRAMEBUFFER, bloomTextureFBO);
|
glBindFramebuffer(GL_FRAMEBUFFER, bloomTextureFBO);
|
||||||
@ -479,8 +528,6 @@ void renderScene(GLFWwindow* window)
|
|||||||
|
|
||||||
drawSkyBox(cubeContext, glm::translate(cameraPos));
|
drawSkyBox(cubeContext, glm::translate(cameraPos));
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
if (lightOn > 0.0f) {
|
if (lightOn > 0.0f) {
|
||||||
glUseProgram(programSun);
|
glUseProgram(programSun);
|
||||||
glm::mat4 viewProjectionMatrix = createPerspectiveMatrix() * createCameraMatrix();
|
glm::mat4 viewProjectionMatrix = createPerspectiveMatrix() * createCameraMatrix();
|
||||||
@ -520,6 +567,7 @@ void renderScene(GLFWwindow* window)
|
|||||||
drawObjectPBR(models::windowContext, glm::eulerAngleY(3.14f) * glm::scale(glm::vec3(1.0f, 1.0f, 2.3f)) * glm::translate(glm::vec3(-2.9f, 0, -0.3f)), glm::vec3(0.402978f, 0.120509f, 0.057729f), 0.2f, 0.0f);
|
drawObjectPBR(models::windowContext, glm::eulerAngleY(3.14f) * glm::scale(glm::vec3(1.0f, 1.0f, 2.3f)) * glm::translate(glm::vec3(-2.9f, 0, -0.3f)), glm::vec3(0.402978f, 0.120509f, 0.057729f), 0.2f, 0.0f);
|
||||||
drawObjectPBR(models::windowContext, glm::eulerAngleY(1.57f) * glm::scale(glm::vec3(1.0f, 1.0f, 2.45f)) * glm::translate(glm::vec3(-0.6f, 0, -0.25f)), glm::vec3(0.402978f, 0.120509f, 0.057729f), 0.2f, 0.0f);
|
drawObjectPBR(models::windowContext, glm::eulerAngleY(1.57f) * glm::scale(glm::vec3(1.0f, 1.0f, 2.45f)) * glm::translate(glm::vec3(-0.6f, 0, -0.25f)), glm::vec3(0.402978f, 0.120509f, 0.057729f), 0.2f, 0.0f);
|
||||||
|
|
||||||
|
//drawObjectTexture(models::planeContext, glm::mat4(), texture::floor, glm::vec3(0.402978f, 0.120509f, 0.057729f), 0.2f, 0.0f);
|
||||||
|
|
||||||
glm::vec3 spaceshipSide = glm::normalize(glm::cross(spaceshipDir, glm::vec3(0.f, 1.f, 0.f)));
|
glm::vec3 spaceshipSide = glm::normalize(glm::cross(spaceshipDir, glm::vec3(0.f, 1.f, 0.f)));
|
||||||
glm::vec3 spaceshipUp = glm::normalize(glm::cross(spaceshipSide, spaceshipDir));
|
glm::vec3 spaceshipUp = glm::normalize(glm::cross(spaceshipSide, spaceshipDir));
|
||||||
@ -594,8 +642,10 @@ void init(GLFWwindow* window)
|
|||||||
loadCubemap(faces);
|
loadCubemap(faces);
|
||||||
initDepthMap();
|
initDepthMap();
|
||||||
|
|
||||||
|
programTex = shaderLoader.CreateProgram("shaders/shader_tex.vert", "shaders/shader_tex.frag");
|
||||||
texture::earth = Core::LoadTexture("textures/room/earth.png");
|
texture::earth = Core::LoadTexture("textures/room/earth.png");
|
||||||
texture::earthNormal = Core::LoadTexture("textures/room/earth_normalmap.png");
|
texture::earthNormal = Core::LoadTexture("textures/room/earth_normalmap.png");
|
||||||
|
texture::floor = Core::LoadTexture("textures/floor/floor_wood.jpg");
|
||||||
|
|
||||||
loadModelToContext("./models/sphere.obj", sphereContext);
|
loadModelToContext("./models/sphere.obj", sphereContext);
|
||||||
loadModelToContext("./models/cube.obj", cubeContext);
|
loadModelToContext("./models/cube.obj", cubeContext);
|
||||||
@ -632,7 +682,6 @@ void init(GLFWwindow* window)
|
|||||||
|
|
||||||
initBloom();
|
initBloom();
|
||||||
initPingPong();
|
initPingPong();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void shutdown(GLFWwindow* window)
|
void shutdown(GLFWwindow* window)
|
||||||
|
BIN
cw 9/textures/floor/floor_wood.jpg
Normal file
BIN
cw 9/textures/floor/floor_wood.jpg
Normal file
Binary file not shown.
After Width: | Height: | Size: 36 MiB |
Loading…
Reference in New Issue
Block a user