WIP tone mapping framebuffer
This commit is contained in:
parent
903bb3eaf8
commit
895af708d0
BIN
grk/.vs/grk-cw/v16/.suo
Normal file
BIN
grk/.vs/grk-cw/v16/.suo
Normal file
Binary file not shown.
BIN
grk/.vs/grk-cw/v16/Browse.VC.db
Normal file
BIN
grk/.vs/grk-cw/v16/Browse.VC.db
Normal file
Binary file not shown.
BIN
grk/.vs/grk-cw/v16/ipch/AutoPCH/520a626c2b6c2b48/MAIN.ipch
Normal file
BIN
grk/.vs/grk-cw/v16/ipch/AutoPCH/520a626c2b6c2b48/MAIN.ipch
Normal file
Binary file not shown.
Binary file not shown.
BIN
grk/Debug/grk-cw6.exe
Normal file
BIN
grk/Debug/grk-cw6.exe
Normal file
Binary file not shown.
BIN
grk/Debug/grk-cw6.pdb
Normal file
BIN
grk/Debug/grk-cw6.pdb
Normal file
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@ -2,7 +2,7 @@
|
|||||||
<Project>
|
<Project>
|
||||||
<ProjectOutputs>
|
<ProjectOutputs>
|
||||||
<ProjectOutput>
|
<ProjectOutput>
|
||||||
<FullPath>j:\Downloads\grk\Debug\grk-cw6.exe</FullPath>
|
<FullPath>D:\grk2024\dgrk-2023-planeta\grk\Debug\grk-cw6.exe</FullPath>
|
||||||
</ProjectOutput>
|
</ProjectOutput>
|
||||||
</ProjectOutputs>
|
</ProjectOutputs>
|
||||||
<ContentFiles />
|
<ContentFiles />
|
||||||
|
@ -1,39 +1,41 @@
|
|||||||
C:\software\vs19\MSBuild\Microsoft\VC\v160\Microsoft.CppBuild.targets(513,5): warning MSB8028: The intermediate directory (Debug\) contains files shared from another project (grk-cw3.vcxproj, grk-cw4.vcxproj, grk-cw5.vcxproj). This can lead to incorrect clean and rebuild behavior.
|
C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\MSBuild\Microsoft\VC\v160\Microsoft.CppBuild.targets(491,5): warning MSB8028: Katalog pośredni (Debug\) zawiera pliki udostępnione z innego projektu (grk-cw3.vcxproj, grk-cw4.vcxproj, grk-cw5.vcxproj). Może to spowodować niepoprawne zachowanie podczas oczyszczania i ponownej kompilacji.
|
||||||
main.cpp
|
main.cpp
|
||||||
C:\Program Files (x86)\Windows Kits\10\Include\10.0.19041.0\shared\minwindef.h(130,1): warning C4005: 'APIENTRY': macro redefinition
|
C:\Program Files (x86)\Windows Kits\10\Include\10.0.19041.0\shared\minwindef.h(130,1): warning C4005: "APIENTRY": ponowna definicja makra
|
||||||
j:\Downloads\grk\dependencies\glfw-3.3.8.bin.WIN32\include\GLFW\glfw3.h(123): message : see previous definition of 'APIENTRY'
|
D:\grk2024\dgrk-2023-planeta\grk\dependencies\glfw-3.3.8.bin.WIN32\include\GLFW\glfw3.h(123): message : zobacz poprzednią definicję „APIENTRY”
|
||||||
j:\Downloads\grk\cw 6\src\ex_6_1.hpp(92,16): warning C4305: 'initializing': truncation from 'double' to 'float'
|
D:\grk2024\dgrk-2023-planeta\grk\cw 6\src\ex_6_1.hpp(72,30): warning C4305: "inicjowanie": obcięcie z "double" do "float"
|
||||||
j:\Downloads\grk\cw 6\src\ex_6_1.hpp(135,13): warning C4244: 'initializing': conversion from 'double' to 'float', possible loss of data
|
D:\grk2024\dgrk-2023-planeta\grk\cw 6\src\ex_6_1.hpp(124,16): warning C4305: "inicjowanie": obcięcie z "double" do "float"
|
||||||
j:\Downloads\grk\cw 6\src\ex_6_1.hpp(139,52): warning C4305: 'argument': truncation from 'double' to 'T'
|
D:\grk2024\dgrk-2023-planeta\grk\cw 6\src\ex_6_1.hpp(159,13): warning C4244: "inicjowanie": konwersja z "double" do "float", możliwa utrata danych
|
||||||
|
D:\grk2024\dgrk-2023-planeta\grk\cw 6\src\ex_6_1.hpp(261,13): warning C4244: "inicjowanie": konwersja z "double" do "float", możliwa utrata danych
|
||||||
|
D:\grk2024\dgrk-2023-planeta\grk\cw 6\src\ex_6_1.hpp(267,52): warning C4305: "argument": obcięcie z "double" do "T"
|
||||||
with
|
with
|
||||||
[
|
[
|
||||||
T=float
|
T=float
|
||||||
]
|
]
|
||||||
j:\Downloads\grk\cw 6\src\ex_6_1.hpp(143,50): warning C4305: 'argument': truncation from 'double' to 'T'
|
D:\grk2024\dgrk-2023-planeta\grk\cw 6\src\ex_6_1.hpp(271,50): warning C4305: "argument": obcięcie z "double" do "T"
|
||||||
with
|
with
|
||||||
[
|
[
|
||||||
T=float
|
T=float
|
||||||
]
|
]
|
||||||
j:\Downloads\grk\cw 6\src\ex_6_1.hpp(147,49): warning C4305: 'argument': truncation from 'double' to 'T'
|
D:\grk2024\dgrk-2023-planeta\grk\cw 6\src\ex_6_1.hpp(275,49): warning C4305: "argument": obcięcie z "double" do "T"
|
||||||
with
|
with
|
||||||
[
|
[
|
||||||
T=float
|
T=float
|
||||||
]
|
]
|
||||||
j:\Downloads\grk\cw 6\src\ex_6_1.hpp(151,48): warning C4305: 'argument': truncation from 'double' to 'T'
|
D:\grk2024\dgrk-2023-planeta\grk\cw 6\src\ex_6_1.hpp(279,48): warning C4305: "argument": obcięcie z "double" do "T"
|
||||||
with
|
with
|
||||||
[
|
[
|
||||||
T=float
|
T=float
|
||||||
]
|
]
|
||||||
j:\Downloads\grk\cw 6\src\ex_6_1.hpp(155,48): warning C4305: 'argument': truncation from 'double' to 'T'
|
D:\grk2024\dgrk-2023-planeta\grk\cw 6\src\ex_6_1.hpp(283,48): warning C4305: "argument": obcięcie z "double" do "T"
|
||||||
with
|
with
|
||||||
[
|
[
|
||||||
T=float
|
T=float
|
||||||
]
|
]
|
||||||
j:\Downloads\grk\cw 6\src\ex_6_1.hpp(159,48): warning C4305: 'argument': truncation from 'double' to 'T'
|
D:\grk2024\dgrk-2023-planeta\grk\cw 6\src\ex_6_1.hpp(287,48): warning C4305: "argument": obcięcie z "double" do "T"
|
||||||
with
|
with
|
||||||
[
|
[
|
||||||
T=float
|
T=float
|
||||||
]
|
]
|
||||||
Box.obj : warning LNK4075: ignoring '/EDITANDCONTINUE' due to '/INCREMENTAL:NO' specification
|
Box.obj : warning LNK4075: zignorowano opcję „/EDITANDCONTINUE” z powodu określenia opcji „/INCREMENTAL:NO”
|
||||||
LINK : warning LNK4098: defaultlib 'MSVCRT' conflicts with use of other libs; use /NODEFAULTLIB:library
|
LINK : warning LNK4098: domyślna biblioteka „MSVCRT” powoduje konflikt z innymi bibliotekami; użyj opcji /NODEFAULTLIB:biblioteka
|
||||||
grk-cw6.vcxproj -> j:\Downloads\grk\Debug\grk-cw6.exe
|
grk-cw6.vcxproj -> D:\grk2024\dgrk-2023-planeta\grk\Debug\grk-cw6.exe
|
||||||
|
Binary file not shown.
Binary file not shown.
Binary file not shown.
@ -1,2 +1,2 @@
|
|||||||
PlatformToolSet=v142:VCToolArchitecture=Native32Bit:VCToolsVersion=14.29.30133:TargetPlatformVersion=10.0.19041.0:
|
PlatformToolSet=v142:VCToolArchitecture=Native32Bit:VCToolsVersion=14.28.29333:TargetPlatformVersion=10.0.19041.0:
|
||||||
Debug|Win32|j:\Downloads\grk\|
|
Debug|Win32|D:\grk2024\dgrk-2023-planeta\grk\|
|
||||||
|
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@ -41,8 +41,12 @@
|
|||||||
<None Include="shaders\shader_5_1.vert" />
|
<None Include="shaders\shader_5_1.vert" />
|
||||||
<None Include="shaders\shader_5_1_tex.frag" />
|
<None Include="shaders\shader_5_1_tex.frag" />
|
||||||
<None Include="shaders\shader_5_1_tex.vert" />
|
<None Include="shaders\shader_5_1_tex.vert" />
|
||||||
<None Include="shaders\shader_5_sun.frag" />
|
<None Include="shaders\shader_smap.frag" />
|
||||||
<None Include="shaders\shader_5_sun.vert" />
|
<None Include="shaders\shader_smap.vert" />
|
||||||
|
<None Include="shaders\shader_sun.frag" />
|
||||||
|
<None Include="shaders\shader_sun.vert" />
|
||||||
|
<None Include="shaders\test.frag" />
|
||||||
|
<None Include="shaders\test.vert" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<PropertyGroup Label="Globals">
|
<PropertyGroup Label="Globals">
|
||||||
<ProjectGuid>{3952C396-B1C6-44CD-96DD-C1AC15D32978}</ProjectGuid>
|
<ProjectGuid>{3952C396-B1C6-44CD-96DD-C1AC15D32978}</ProjectGuid>
|
||||||
|
@ -91,12 +91,6 @@
|
|||||||
</ClInclude>
|
</ClInclude>
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<None Include="shaders\shader_5_sun.frag">
|
|
||||||
<Filter>Shader Files</Filter>
|
|
||||||
</None>
|
|
||||||
<None Include="shaders\shader_5_sun.vert">
|
|
||||||
<Filter>Shader Files</Filter>
|
|
||||||
</None>
|
|
||||||
<None Include="shaders\shader_5_1.frag">
|
<None Include="shaders\shader_5_1.frag">
|
||||||
<Filter>Shader Files</Filter>
|
<Filter>Shader Files</Filter>
|
||||||
</None>
|
</None>
|
||||||
@ -109,5 +103,23 @@
|
|||||||
<None Include="shaders\shader_5_1_tex.frag">
|
<None Include="shaders\shader_5_1_tex.frag">
|
||||||
<Filter>Shader Files</Filter>
|
<Filter>Shader Files</Filter>
|
||||||
</None>
|
</None>
|
||||||
|
<None Include="shaders\shader_smap.frag">
|
||||||
|
<Filter>Shader Files</Filter>
|
||||||
|
</None>
|
||||||
|
<None Include="shaders\shader_smap.vert">
|
||||||
|
<Filter>Shader Files</Filter>
|
||||||
|
</None>
|
||||||
|
<None Include="shaders\test.frag">
|
||||||
|
<Filter>Shader Files</Filter>
|
||||||
|
</None>
|
||||||
|
<None Include="shaders\test.vert">
|
||||||
|
<Filter>Shader Files</Filter>
|
||||||
|
</None>
|
||||||
|
<None Include="shaders\shader_sun.frag">
|
||||||
|
<Filter>Shader Files</Filter>
|
||||||
|
</None>
|
||||||
|
<None Include="shaders\shader_sun.vert">
|
||||||
|
<Filter>Shader Files</Filter>
|
||||||
|
</None>
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
</Project>
|
</Project>
|
16
grk/cw 6/models/test.obj
Normal file
16
grk/cw 6/models/test.obj
Normal file
@ -0,0 +1,16 @@
|
|||||||
|
# Blender v3.2.1 OBJ File: 'untitled.blend'
|
||||||
|
# www.blender.org
|
||||||
|
mtllib plane.mtl
|
||||||
|
o Plane.001
|
||||||
|
v -1.000000 -1.000000 -0.000000
|
||||||
|
v 1.000000 -1.000000 -0.000000
|
||||||
|
v -1.000000 1.000000 0.000000
|
||||||
|
v 1.000000 1.000000 0.000000
|
||||||
|
vt 0.000000 0.000000
|
||||||
|
vt 1.000000 0.000000
|
||||||
|
vt 1.000000 1.000000
|
||||||
|
vt 0.000000 1.000000
|
||||||
|
vn 0.0000 -0.0000 1.0000
|
||||||
|
usemtl None
|
||||||
|
s off
|
||||||
|
f 1/1/1 2/2/1 4/3/1 3/4/1
|
6
grk/cw 6/shaders/shader_smap.frag
Normal file
6
grk/cw 6/shaders/shader_smap.frag
Normal file
@ -0,0 +1,6 @@
|
|||||||
|
#version 430 core
|
||||||
|
|
||||||
|
void main()
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
13
grk/cw 6/shaders/shader_smap.vert
Normal file
13
grk/cw 6/shaders/shader_smap.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);
|
||||||
|
}
|
@ -1,8 +1,8 @@
|
|||||||
#version 430 core
|
#version 430 core
|
||||||
|
|
||||||
layout(location = 0) in vec3 vertexPosition;
|
layout(location = 0) in vec3 vertexPosition;
|
||||||
layout(location = 1) in vec2 vertexTexCoord;
|
layout(location = 1) in vec3 vertexNormal;
|
||||||
layout(location = 2) in vec3 vertexNormal;
|
layout(location = 2) in vec2 vertexTexCoord;
|
||||||
|
|
||||||
uniform mat4 transformation;
|
uniform mat4 transformation;
|
||||||
|
|
12
grk/cw 6/shaders/test.frag
Normal file
12
grk/cw 6/shaders/test.frag
Normal file
@ -0,0 +1,12 @@
|
|||||||
|
#version 330 core
|
||||||
|
out vec4 FragColor;
|
||||||
|
|
||||||
|
in vec2 tc;
|
||||||
|
|
||||||
|
uniform sampler2D depthMap;
|
||||||
|
|
||||||
|
void main()
|
||||||
|
{
|
||||||
|
float depthValue = texture(depthMap, tc).r;
|
||||||
|
FragColor = vec4(vec3(depthValue+0.5), 1.0);
|
||||||
|
}
|
14
grk/cw 6/shaders/test.vert
Normal file
14
grk/cw 6/shaders/test.vert
Normal file
@ -0,0 +1,14 @@
|
|||||||
|
#version 430 core
|
||||||
|
|
||||||
|
layout(location = 0) in vec3 vertexPosition;
|
||||||
|
layout(location = 1) in vec3 vertexNormal;
|
||||||
|
layout(location = 2) in vec2 vertexTexCoord;
|
||||||
|
|
||||||
|
|
||||||
|
out vec2 tc;
|
||||||
|
|
||||||
|
void main()
|
||||||
|
{
|
||||||
|
tc = vertexTexCoord;
|
||||||
|
gl_Position = vec4(vertexPosition*0.9, 1.0);
|
||||||
|
}
|
@ -16,6 +16,11 @@
|
|||||||
#include <string>
|
#include <string>
|
||||||
|
|
||||||
|
|
||||||
|
namespace models {
|
||||||
|
Core::RenderContext testContext;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
namespace texture {
|
namespace texture {
|
||||||
GLuint earth;
|
GLuint earth;
|
||||||
GLuint clouds;
|
GLuint clouds;
|
||||||
@ -34,13 +39,20 @@ namespace texture {
|
|||||||
|
|
||||||
GLuint program;
|
GLuint program;
|
||||||
GLuint programSun;
|
GLuint programSun;
|
||||||
|
GLuint programDepth;
|
||||||
GLuint programTex;
|
GLuint programTex;
|
||||||
|
GLuint programTest;
|
||||||
|
|
||||||
Core::Shader_Loader shaderLoader;
|
Core::Shader_Loader shaderLoader;
|
||||||
|
|
||||||
Core::RenderContext shipContext;
|
Core::RenderContext shipContext;
|
||||||
Core::RenderContext sphereContext;
|
Core::RenderContext sphereContext;
|
||||||
|
|
||||||
|
|
||||||
|
glm::vec3 sunPos = glm::vec3(-4.740971f, 2.149999f, 0.369280f);
|
||||||
|
glm::vec3 sunDir = glm::vec3(-0.93633f, 0.351106, 0.003226f);
|
||||||
|
glm::vec3 sunColor = glm::vec3(0.9f, 0.9f, 0.7f) * 5;
|
||||||
|
|
||||||
glm::vec3 cameraPos = glm::vec3(-4.f, 0, 0);
|
glm::vec3 cameraPos = glm::vec3(-4.f, 0, 0);
|
||||||
glm::vec3 cameraDir = glm::vec3(1.f, 0.f, 0.f);
|
glm::vec3 cameraDir = glm::vec3(1.f, 0.f, 0.f);
|
||||||
GLuint VAO, VBO;
|
GLuint VAO, VBO;
|
||||||
@ -49,9 +61,26 @@ glm::vec3 shipPos = glm::vec3(-4.f, 0, 0);
|
|||||||
glm::vec3 shipDir = glm::vec3(1.f, 0.f, 0.f);
|
glm::vec3 shipDir = glm::vec3(1.f, 0.f, 0.f);
|
||||||
|
|
||||||
float aspectRatio = 1.f;
|
float aspectRatio = 1.f;
|
||||||
|
float exposition = 1.f;
|
||||||
|
|
||||||
|
glm::vec3 pointlightPos = glm::vec3(0, 2, 0);
|
||||||
|
glm::vec3 pointlightColor = glm::vec3(0.9, 0.6, 0.6);
|
||||||
|
|
||||||
|
glm::vec3 spotlightPos = glm::vec3(0, 0, 0);
|
||||||
|
glm::vec3 spotlightConeDir = glm::vec3(0, 0, 0);
|
||||||
|
glm::vec3 spotlightColor = glm::vec3(0.4, 0.4, 0.9) * 3;
|
||||||
|
float spotlightPhi = 3.14 / 4;
|
||||||
|
|
||||||
glm::vec3 lightColor = glm::vec3(0.9, 0.7, 0.8);
|
glm::vec3 lightColor = glm::vec3(0.9, 0.7, 0.8);
|
||||||
|
|
||||||
|
unsigned int depthMapFBO;
|
||||||
|
unsigned int depthMap;
|
||||||
|
const unsigned int SHADOW_WIDTH = 1024, SHADOW_HEIGHT = 1024;
|
||||||
|
|
||||||
|
int WIDTH = 500, HEIGHT = 500;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
glm::mat4 createCameraMatrix()
|
glm::mat4 createCameraMatrix()
|
||||||
{
|
{
|
||||||
glm::vec3 cameraSide = glm::normalize(glm::cross(cameraDir, glm::vec3(0.f, 1.f, 0.f)));
|
glm::vec3 cameraSide = glm::normalize(glm::cross(cameraDir, glm::vec3(0.f, 1.f, 0.f)));
|
||||||
@ -109,6 +138,55 @@ glm::mat4 createPerspectiveMatrix()
|
|||||||
return perspectiveMatrix;
|
return perspectiveMatrix;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
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 renderShadowapSun() {
|
||||||
|
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);
|
||||||
|
|
||||||
|
|
||||||
|
glBindFramebuffer(GL_FRAMEBUFFER, 0);
|
||||||
|
glViewport(0, 0, WIDTH, HEIGHT);
|
||||||
|
}
|
||||||
|
|
||||||
|
void drawObjectSun(Core::RenderContext& context, glm::mat4 modelMatrix, GLuint texture) {
|
||||||
|
glUseProgram(programSun);
|
||||||
|
Core::SetActiveTexture(texture, "colorTexture", programTex, 0);
|
||||||
|
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);
|
||||||
|
Core::DrawContext(context);
|
||||||
|
glUseProgram(0);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
void drawObjectTexture(Core::RenderContext& context, glm::mat4 modelMatrix, GLuint texture) {
|
void drawObjectTexture(Core::RenderContext& context, glm::mat4 modelMatrix, GLuint texture) {
|
||||||
glUseProgram(programTex);
|
glUseProgram(programTex);
|
||||||
Core::SetActiveTexture(texture, "colorTexture", programTex, 0);
|
Core::SetActiveTexture(texture, "colorTexture", programTex, 0);
|
||||||
@ -125,11 +203,56 @@ void drawObjectColor(Core::RenderContext& context, glm::mat4 modelMatrix, glm::v
|
|||||||
glUniform3f(glGetUniformLocation(program, "color"), color.x, color.y, color.z);
|
glUniform3f(glGetUniformLocation(program, "color"), color.x, color.y, color.z);
|
||||||
glm::mat4 viewProjectionMatrix = createPerspectiveMatrix() * createCameraMatrix();
|
glm::mat4 viewProjectionMatrix = createPerspectiveMatrix() * createCameraMatrix();
|
||||||
glm::mat4 transformation = viewProjectionMatrix * modelMatrix;
|
glm::mat4 transformation = viewProjectionMatrix * modelMatrix;
|
||||||
|
|
||||||
glUniformMatrix4fv(glGetUniformLocation(program, "transformation"), 1, GL_FALSE, (float*)&transformation);
|
glUniformMatrix4fv(glGetUniformLocation(program, "transformation"), 1, GL_FALSE, (float*)&transformation);
|
||||||
glUniformMatrix4fv(glGetUniformLocation(program, "modelMatrix"), 1, GL_FALSE, (float*)&modelMatrix);
|
glUniformMatrix4fv(glGetUniformLocation(program, "modelMatrix"), 1, GL_FALSE, (float*)&modelMatrix);
|
||||||
Core::DrawContext(context);
|
Core::DrawContext(context);
|
||||||
glUseProgram(0);
|
glUseProgram(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void drawObjectDepth(Core::RenderContext& context, glm::mat4 viewProjection, glm::mat4 modelMatrix) {
|
||||||
|
glUseProgram(programDepth);
|
||||||
|
|
||||||
|
glm::mat4 viewProjectionMatrix = createPerspectiveMatrix() * createCameraMatrix();
|
||||||
|
glm::mat4 transformation = viewProjectionMatrix * modelMatrix;
|
||||||
|
|
||||||
|
glUniformMatrix4fv(glGetUniformLocation(programDepth, "viewProjectionMatrix"), 1, GL_FALSE, (float*)&viewProjectionMatrix);
|
||||||
|
glUniformMatrix4fv(glGetUniformLocation(programDepth, "modelMatrix"), 1, GL_FALSE, (float*)&modelMatrix);
|
||||||
|
Core::DrawContext(context);
|
||||||
|
glUseProgram(0);
|
||||||
|
}
|
||||||
|
|
||||||
|
void drawObjectPBR(Core::RenderContext& context, glm::mat4 modelMatrix, glm::vec3 color, float roughness, float metallic) {
|
||||||
|
|
||||||
|
glm::mat4 viewProjectionMatrix = createPerspectiveMatrix() * createCameraMatrix();
|
||||||
|
glm::mat4 transformation = viewProjectionMatrix * modelMatrix;
|
||||||
|
glUniformMatrix4fv(glGetUniformLocation(program, "transformation"), 1, GL_FALSE, (float*)&transformation);
|
||||||
|
glUniformMatrix4fv(glGetUniformLocation(program, "modelMatrix"), 1, GL_FALSE, (float*)&modelMatrix);
|
||||||
|
|
||||||
|
glUniform1f(glGetUniformLocation(program, "exposition"), exposition);
|
||||||
|
|
||||||
|
glUniform1f(glGetUniformLocation(program, "roughness"), roughness);
|
||||||
|
glUniform1f(glGetUniformLocation(program, "metallic"), metallic);
|
||||||
|
|
||||||
|
glUniform3f(glGetUniformLocation(program, "color"), color.x, color.y, color.z);
|
||||||
|
|
||||||
|
glUniform3f(glGetUniformLocation(program, "cameraPos"), cameraPos.x, cameraPos.y, cameraPos.z);
|
||||||
|
|
||||||
|
glUniform3f(glGetUniformLocation(program, "sunDir"), sunDir.x, sunDir.y, sunDir.z);
|
||||||
|
glUniform3f(glGetUniformLocation(program, "sunColor"), sunColor.x, sunColor.y, sunColor.z);
|
||||||
|
|
||||||
|
glUniform3f(glGetUniformLocation(program, "lightPos"), pointlightPos.x, pointlightPos.y, pointlightPos.z);
|
||||||
|
glUniform3f(glGetUniformLocation(program, "lightColor"), pointlightColor.x, pointlightColor.y, pointlightColor.z);
|
||||||
|
|
||||||
|
glUniform3f(glGetUniformLocation(program, "spotlightConeDir"), spotlightConeDir.x, spotlightConeDir.y, spotlightConeDir.z);
|
||||||
|
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);
|
||||||
|
Core::DrawContext(context);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
void renderScene(GLFWwindow* window)
|
void renderScene(GLFWwindow* window)
|
||||||
{
|
{
|
||||||
glClearColor(0.0f, 0.0f, 0.2f, 1.0f);
|
glClearColor(0.0f, 0.0f, 0.2f, 1.0f);
|
||||||
@ -137,6 +260,8 @@ void renderScene(GLFWwindow* window)
|
|||||||
glm::mat4 transformation;
|
glm::mat4 transformation;
|
||||||
float time = glfwGetTime();
|
float time = glfwGetTime();
|
||||||
|
|
||||||
|
renderShadowapSun();
|
||||||
|
|
||||||
glm::mat4 sunScale = glm::scale(glm::vec3(1.75));
|
glm::mat4 sunScale = glm::scale(glm::vec3(1.75));
|
||||||
|
|
||||||
glm::mat4 mercuryScale = glm::scale(glm::vec3(0.24));
|
glm::mat4 mercuryScale = glm::scale(glm::vec3(0.24));
|
||||||
@ -185,6 +310,26 @@ void renderScene(GLFWwindow* window)
|
|||||||
|
|
||||||
drawObjectTexture(shipContext, shipTranslate * shipRotate * shipScale, texture::ship); //ship
|
drawObjectTexture(shipContext, shipTranslate * shipRotate * shipScale, texture::ship); //ship
|
||||||
|
|
||||||
|
|
||||||
|
/*
|
||||||
|
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
|
||||||
|
glUseProgram(programTest);
|
||||||
|
glActiveTexture(GL_TEXTURE0);
|
||||||
|
glBindTexture(GL_TEXTURE_2D, depthMap);
|
||||||
|
Core::DrawContext(models::testContext);
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
glm::mat4 lightVP = glm::ortho(-10.f, 10.f, -10.f, 10.f, 1.0f, 30.0f) * glm::lookAt(sunPos, sunPos - sunDir, glm::vec3(0, 1, 0));
|
||||||
|
|
||||||
|
drawObjectDepth(sphereContext, lightVP, sunScale);
|
||||||
|
drawObjectDepth(sphereContext, lightVP, mercuryRotate * mercuryTranslate * mercuryScale);
|
||||||
|
drawObjectDepth(sphereContext, lightVP, venusRotate * venusTranslate * venusScale);
|
||||||
|
drawObjectDepth(sphereContext, lightVP, earthRotate * earthTranslate * earthScale);
|
||||||
|
drawObjectDepth(sphereContext, lightVP, marsRotate * marsTranslate * marsScale);
|
||||||
|
drawObjectDepth(sphereContext, lightVP, shipTranslate * shipRotate * shipScale);
|
||||||
|
glBindFramebuffer(GL_FRAMEBUFFER, 0);
|
||||||
|
glUseProgram(0);
|
||||||
glfwSwapBuffers(window);
|
glfwSwapBuffers(window);
|
||||||
}
|
}
|
||||||
void framebuffer_size_callback(GLFWwindow* window, int width, int height)
|
void framebuffer_size_callback(GLFWwindow* window, int width, int height)
|
||||||
@ -210,11 +355,17 @@ void init(GLFWwindow* window)
|
|||||||
glfwSetFramebufferSizeCallback(window, framebuffer_size_callback);
|
glfwSetFramebufferSizeCallback(window, framebuffer_size_callback);
|
||||||
|
|
||||||
glEnable(GL_DEPTH_TEST);
|
glEnable(GL_DEPTH_TEST);
|
||||||
|
|
||||||
|
initDepthMap();
|
||||||
program = shaderLoader.CreateProgram("shaders/shader_5_1.vert", "shaders/shader_5_1.frag");
|
program = shaderLoader.CreateProgram("shaders/shader_5_1.vert", "shaders/shader_5_1.frag");
|
||||||
programTex = shaderLoader.CreateProgram("shaders/shader_5_1_tex.vert", "shaders/shader_5_1_tex.frag");
|
programTex = shaderLoader.CreateProgram("shaders/shader_5_1_tex.vert", "shaders/shader_5_1_tex.frag");
|
||||||
|
programSun = shaderLoader.CreateProgram("shaders/shader_sun.vert", "shaders/shader_sun.frag");
|
||||||
|
programDepth = shaderLoader.CreateProgram("shaders/shader_smap.vert", "shaders/shader_smap.frag");
|
||||||
|
//programTest = shaderLoader.CreateProgram("shaders/test.vert", "shaders/test.frag");
|
||||||
|
|
||||||
loadModelToContext("./models/sphere.obj", sphereContext);
|
loadModelToContext("./models/sphere.obj", sphereContext);
|
||||||
loadModelToContext("./models/spaceship.obj", shipContext);
|
loadModelToContext("./models/spaceship.obj", shipContext);
|
||||||
|
//loadModelToContext("./models/test.obj", models::testContext);
|
||||||
|
|
||||||
texture::earth = Core::LoadTexture("./textures/earth2.png");
|
texture::earth = Core::LoadTexture("./textures/earth2.png");
|
||||||
texture::clouds = Core::LoadTexture("./textures/clouds.jpg");
|
texture::clouds = Core::LoadTexture("./textures/clouds.jpg");
|
||||||
|
@ -1,10 +1,12 @@
|
|||||||
|
|
||||||
Microsoft Visual Studio Solution File, Format Version 12.00
|
Microsoft Visual Studio Solution File, Format Version 12.00
|
||||||
# Visual Studio 15
|
# Visual Studio Version 16
|
||||||
VisualStudioVersion = 15.0.28307.852
|
VisualStudioVersion = 16.0.31019.35
|
||||||
MinimumVisualStudioVersion = 10.0.40219.1
|
MinimumVisualStudioVersion = 10.0.40219.1
|
||||||
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "grk-cw1", "cw 1\grk-cw1.vcxproj", "{1B448102-E76C-4347-BDC7-40D02A567DB6}"
|
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "grk-cw1", "cw 1\grk-cw1.vcxproj", "{1B448102-E76C-4347-BDC7-40D02A567DB6}"
|
||||||
EndProject
|
EndProject
|
||||||
|
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "grk-cw6", "cw 6\grk-cw6.vcxproj", "{3952C396-B1C6-44CD-96DD-C1AC15D32978}"
|
||||||
|
EndProject
|
||||||
Global
|
Global
|
||||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||||
Debug|x86 = Debug|x86
|
Debug|x86 = Debug|x86
|
||||||
@ -15,6 +17,10 @@ Global
|
|||||||
{1B448102-E76C-4347-BDC7-40D02A567DB6}.Debug|x86.Build.0 = Debug|Win32
|
{1B448102-E76C-4347-BDC7-40D02A567DB6}.Debug|x86.Build.0 = Debug|Win32
|
||||||
{1B448102-E76C-4347-BDC7-40D02A567DB6}.Release|x86.ActiveCfg = Release|Win32
|
{1B448102-E76C-4347-BDC7-40D02A567DB6}.Release|x86.ActiveCfg = Release|Win32
|
||||||
{1B448102-E76C-4347-BDC7-40D02A567DB6}.Release|x86.Build.0 = Release|Win32
|
{1B448102-E76C-4347-BDC7-40D02A567DB6}.Release|x86.Build.0 = Release|Win32
|
||||||
|
{3952C396-B1C6-44CD-96DD-C1AC15D32978}.Debug|x86.ActiveCfg = Debug|Win32
|
||||||
|
{3952C396-B1C6-44CD-96DD-C1AC15D32978}.Debug|x86.Build.0 = Debug|Win32
|
||||||
|
{3952C396-B1C6-44CD-96DD-C1AC15D32978}.Release|x86.ActiveCfg = Release|Win32
|
||||||
|
{3952C396-B1C6-44CD-96DD-C1AC15D32978}.Release|x86.Build.0 = Release|Win32
|
||||||
EndGlobalSection
|
EndGlobalSection
|
||||||
GlobalSection(SolutionProperties) = preSolution
|
GlobalSection(SolutionProperties) = preSolution
|
||||||
HideSolutionNode = FALSE
|
HideSolutionNode = FALSE
|
||||||
|
Loading…
Reference in New Issue
Block a user