tone mapping

This commit is contained in:
Natalia Nowakowska 2024-01-14 23:28:27 +01:00
parent 1f49f47872
commit 74ffe6d81a
24 changed files with 44 additions and 70 deletions

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.

View File

@ -2,11 +2,7 @@
<Project> <Project>
<ProjectOutputs> <ProjectOutputs>
<ProjectOutput> <ProjectOutput>
<<<<<<< HEAD
<FullPath>D:\grk2024\dgrk-2023-planeta\grk\Debug\grk-cw6.exe</FullPath> <FullPath>D:\grk2024\dgrk-2023-planeta\grk\Debug\grk-cw6.exe</FullPath>
=======
<FullPath>E:\micha\studia\grafika_komputerowa\grk\grk\Debug\grk-cw6.exe</FullPath>
>>>>>>> master
</ProjectOutput> </ProjectOutput>
</ProjectOutputs> </ProjectOutputs>
<ContentFiles /> <ContentFiles />

View File

@ -1,77 +1,41 @@
<<<<<<< HEAD
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. 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": 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:\grk2024\dgrk-2023-planeta\grk\dependencies\glfw-3.3.8.bin.WIN32\include\GLFW\glfw3.h(123): message : zobacz poprzednią definicję „APIENTRY” D:\grk2024\dgrk-2023-planeta\grk\dependencies\glfw-3.3.8.bin.WIN32\include\GLFW\glfw3.h(123): message : zobacz poprzednią definicję „APIENTRY”
D:\grk2024\dgrk-2023-planeta\grk\cw 6\src\ex_6_1.hpp(72,30): warning C4305: "inicjowanie": obcięcie z "double" do "float" D:\grk2024\dgrk-2023-planeta\grk\cw 6\src\ex_6_1.hpp(73,30): warning C4305: "inicjowanie": obcięcie z "double" do "float"
D:\grk2024\dgrk-2023-planeta\grk\cw 6\src\ex_6_1.hpp(124,16): warning C4305: "inicjowanie": obcięcie z "double" do "float" D:\grk2024\dgrk-2023-planeta\grk\cw 6\src\ex_6_1.hpp(125,16): warning C4305: "inicjowanie": obcięcie z "double" do "float"
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(161,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(266,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" D:\grk2024\dgrk-2023-planeta\grk\cw 6\src\ex_6_1.hpp(273,52): warning C4305: "argument": obcięcie z "double" do "T"
=======
C:\Program Files (x86)\Microsoft Visual Studio\2019\Enterprise\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.
main.cpp
C:\Program Files (x86)\Windows Kits\10\Include\10.0.19041.0\shared\minwindef.h(130,1): warning C4005: 'APIENTRY': macro redefinition
E:\micha\studia\grafika_komputerowa\grk\grk\dependencies\glfw-3.3.8.bin.WIN32\include\GLFW\glfw3.h(123): message : see previous definition of 'APIENTRY'
E:\micha\studia\grafika_komputerowa\grk\grk\cw 6\src\ex_6_1.hpp(96,16): warning C4305: 'initializing': truncation from 'double' to 'float'
E:\micha\studia\grafika_komputerowa\grk\grk\cw 6\src\ex_6_1.hpp(152,13): warning C4244: 'initializing': conversion from 'double' to 'float', possible loss of data
E:\micha\studia\grafika_komputerowa\grk\grk\cw 6\src\ex_6_1.hpp(156,52): warning C4305: 'argument': truncation from 'double' to 'T'
>>>>>>> master
with with
[ [
T=float T=float
] ]
<<<<<<< HEAD D:\grk2024\dgrk-2023-planeta\grk\cw 6\src\ex_6_1.hpp(277,50): warning C4305: "argument": obcięcie z "double" do "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"
=======
E:\micha\studia\grafika_komputerowa\grk\grk\cw 6\src\ex_6_1.hpp(160,50): warning C4305: 'argument': truncation from 'double' to 'T'
>>>>>>> master
with with
[ [
T=float T=float
] ]
<<<<<<< HEAD D:\grk2024\dgrk-2023-planeta\grk\cw 6\src\ex_6_1.hpp(281,49): warning C4305: "argument": obcięcie z "double" do "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"
=======
E:\micha\studia\grafika_komputerowa\grk\grk\cw 6\src\ex_6_1.hpp(164,49): warning C4305: 'argument': truncation from 'double' to 'T'
>>>>>>> master
with with
[ [
T=float T=float
] ]
<<<<<<< HEAD D:\grk2024\dgrk-2023-planeta\grk\cw 6\src\ex_6_1.hpp(285,48): warning C4305: "argument": obcięcie z "double" do "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"
=======
E:\micha\studia\grafika_komputerowa\grk\grk\cw 6\src\ex_6_1.hpp(168,48): warning C4305: 'argument': truncation from 'double' to 'T'
>>>>>>> master
with with
[ [
T=float T=float
] ]
<<<<<<< HEAD D:\grk2024\dgrk-2023-planeta\grk\cw 6\src\ex_6_1.hpp(289,48): warning C4305: "argument": obcięcie z "double" do "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"
=======
E:\micha\studia\grafika_komputerowa\grk\grk\cw 6\src\ex_6_1.hpp(172,48): warning C4305: 'argument': truncation from 'double' to 'T'
>>>>>>> master
with with
[ [
T=float T=float
] ]
<<<<<<< HEAD D:\grk2024\dgrk-2023-planeta\grk\cw 6\src\ex_6_1.hpp(293,48): warning C4305: "argument": obcięcie z "double" do "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"
=======
E:\micha\studia\grafika_komputerowa\grk\grk\cw 6\src\ex_6_1.hpp(176,48): warning C4305: 'argument': truncation from 'double' to 'T'
>>>>>>> master
with with
[ [
T=float T=float
] ]
<<<<<<< HEAD
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-cw6.vcxproj -> D:\grk2024\dgrk-2023-planeta\grk\Debug\grk-cw6.exe grk-cw6.vcxproj -> D:\grk2024\dgrk-2023-planeta\grk\Debug\grk-cw6.exe
=======
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-cw6.vcxproj -> E:\micha\studia\grafika_komputerowa\grk\grk\Debug\grk-cw6.exe
>>>>>>> master

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

View File

@ -41,6 +41,8 @@
<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_5_sun.vert" />
<None Include="shaders\shader_smap.frag" /> <None Include="shaders\shader_smap.frag" />
<None Include="shaders\shader_smap.vert" /> <None Include="shaders\shader_smap.vert" />
<None Include="shaders\shader_sun.frag" /> <None Include="shaders\shader_sun.frag" />

View File

@ -121,5 +121,11 @@
<None Include="shaders\shader_sun.vert"> <None Include="shaders\shader_sun.vert">
<Filter>Shader Files</Filter> <Filter>Shader Files</Filter>
</None> </None>
<None Include="shaders\shader_5_sun.frag">
<Filter>Shader Files</Filter>
</None>
<None Include="shaders\shader_5_sun.vert">
<Filter>Shader Files</Filter>
</None>
</ItemGroup> </ItemGroup>
</Project> </Project>

View File

@ -4,21 +4,35 @@ float AMBIENT = 0.1;
uniform vec3 color; uniform vec3 color;
uniform vec3 lightPos; uniform vec3 lightPos;
uniform vec3 lightColor;
in vec3 vecNormal; in vec3 vecNormal;
in vec3 worldPos; in vec3 worldPos;
in vec2 vtc; in vec2 vtc;
vec4 textureColor;
out vec4 outColor; out vec4 outColor;
vec3 outputColor;
uniform sampler2D colorTexture; uniform sampler2D colorTexture;
vec3 toneMapping(vec3 color){
float exposure = 0.06;
vec3 mapped = 1 - exp(-color*exposure);
return mapped;
}
void main() void main()
{ {
vec3 lightDir = normalize(lightPos - worldPos); vec3 lightDir = normalize(lightPos - worldPos);
vec3 normal = normalize(vecNormal); vec3 normal = normalize(vecNormal);
float diffuse = max(0, dot(normal, lightDir)); float diffuse = max(0, dot(normal, lightDir));
textureColor = texture2D(colorTexture, vtc);
vec3 distance = lightColor/(lightPos - worldPos)*(lightPos - worldPos);
outputColor = vec3(textureColor) * min(1, AMBIENT + diffuse)* distance;
//gamma correction
//outputColor = pow(outputColor, vec3(1.0/2.2));
vec4 textureColor = texture2D(colorTexture, vtc); outputColor = toneMapping(outputColor);
outColor = vec4(vec3(textureColor) * min(1, AMBIENT + diffuse), 1.0); outColor = vec4(outputColor , 1.0);
} }

View File

@ -72,13 +72,13 @@ glm::vec3 spotlightConeDir = glm::vec3(0, 0, 0);
glm::vec3 spotlightColor = glm::vec3(0.4, 0.4, 0.9) * 3; glm::vec3 spotlightColor = glm::vec3(0.4, 0.4, 0.9) * 3;
float spotlightPhi = 3.14 / 4; float spotlightPhi = 3.14 / 4;
glm::vec3 lightColor = glm::vec3(0.9, 0.7, 0.8); glm::vec3 lightColor = glm::vec3(20.f, 20.f, 20.f);
unsigned int depthMapFBO; unsigned int depthMapFBO;
unsigned int depthMap; unsigned int depthMap;
const unsigned int SHADOW_WIDTH = 1024, SHADOW_HEIGHT = 1024; const unsigned int SHADOW_WIDTH = 1024, SHADOW_HEIGHT = 1024;
int WIDTH = 500, HEIGHT = 500;
@ -157,6 +157,7 @@ void initDepthMap() {
} }
void renderShadowapSun() { void renderShadowapSun() {
int WIDTH = 500, HEIGHT = 500;
float time = glfwGetTime(); float time = glfwGetTime();
glViewport(0, 0, SHADOW_WIDTH, SHADOW_HEIGHT); glViewport(0, 0, SHADOW_WIDTH, SHADOW_HEIGHT);
//uzupelnij o renderowanie glebokosci do tekstury //uzupelnij o renderowanie glebokosci do tekstury
@ -173,18 +174,7 @@ void renderShadowapSun() {
glBindFramebuffer(GL_FRAMEBUFFER, 0); glBindFramebuffer(GL_FRAMEBUFFER, 0);
glViewport(0, 0, WIDTH, HEIGHT); //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);
} }
@ -195,7 +185,8 @@ void drawObjectTexture(Core::RenderContext& context, glm::mat4 modelMatrix, GLui
glm::mat4 transformation = viewProjectionMatrix * modelMatrix; glm::mat4 transformation = viewProjectionMatrix * modelMatrix;
glUniformMatrix4fv(glGetUniformLocation(programTex, "transformation"), 1, GL_FALSE, (float*)&transformation); glUniformMatrix4fv(glGetUniformLocation(programTex, "transformation"), 1, GL_FALSE, (float*)&transformation);
glUniformMatrix4fv(glGetUniformLocation(programTex, "modelMatrix"), 1, GL_FALSE, (float*)&modelMatrix); glUniformMatrix4fv(glGetUniformLocation(programTex, "modelMatrix"), 1, GL_FALSE, (float*)&modelMatrix);
glUniform3f(glGetUniformLocation(program, "lightPos"), 0.0, 0.0, 0.0); glUniform3f(glGetUniformLocation(programTex, "lightPos"), 0.0, 0.0, 0.0);
glUniform3f(glGetUniformLocation(programTex, "lightColor"), lightColor.x, lightColor.y, lightColor.z);
Core::DrawContext(context); Core::DrawContext(context);
glUseProgram(0); glUseProgram(0);
} }
@ -274,7 +265,8 @@ void renderScene(GLFWwindow* window)
glm::mat4 transformation; glm::mat4 transformation;
float time = glfwGetTime(); float time = glfwGetTime();
renderShadowapSun(); //shadowmap, poki co nie pozwala na skalowanie okna dlatego zakomentowane
//renderShadowapSun();
glm::mat4 sunScale = glm::scale(glm::vec3(1.75)); glm::mat4 sunScale = glm::scale(glm::vec3(1.75));
@ -371,7 +363,7 @@ void init(GLFWwindow* window)
initDepthMap(); 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"); programDepth = shaderLoader.CreateProgram("shaders/shader_smap.vert", "shaders/shader_smap.frag");
//programTest = shaderLoader.CreateProgram("shaders/test.vert", "shaders/test.frag"); //programTest = shaderLoader.CreateProgram("shaders/test.vert", "shaders/test.frag");
programSun = shaderLoader.CreateProgram("shaders/shader_5_sun.vert", "shaders/shader_5_sun.frag"); programSun = shaderLoader.CreateProgram("shaders/shader_5_sun.vert", "shaders/shader_5_sun.frag");