bloom koniec - ale do poprawy

This commit is contained in:
Generacja 2023-02-06 17:29:54 +01:00
parent 73fa84b026
commit 564b7c4e74
56 changed files with 61 additions and 51 deletions

View File

@ -5,6 +5,6 @@
"\\cw 9\\shaders", "\\cw 9\\shaders",
"\\cw 9\\src" "\\cw 9\\src"
], ],
"SelectedNode": "\\cw 9\\src\\main.cpp", "SelectedNode": "\\cw 9\\src",
"PreviewInSolutionExplorer": false "PreviewInSolutionExplorer": false
} }

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.

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,7 +2,7 @@
<Project> <Project>
<ProjectOutputs> <ProjectOutputs>
<ProjectOutput> <ProjectOutput>
<FullPath>C:\Users\s464961\Source\Repos\GRK_Room\Debug\room.exe</FullPath> <FullPath>C:\Users\Genos\Source\Repos\GRK_Room22\Debug\room.exe</FullPath>
</ProjectOutput> </ProjectOutput>
</ProjectOutputs> </ProjectOutputs>
<ContentFiles /> <ContentFiles />

Binary file not shown.

Binary file not shown.

View File

@ -1,2 +1,2 @@
PlatformToolSet=v142:VCToolArchitecture=Native32Bit:VCToolsVersion=14.29.30133:TargetPlatformVersion=10.0.19041.0: PlatformToolSet=v142:VCToolArchitecture=Native32Bit:VCToolsVersion=14.29.30133:TargetPlatformVersion=10.0.19041.0:
Debug|Win32|C:\Users\s464961\Source\Repos\GRK_Room\| Debug|Win32|C:\Users\Genos\Source\Repos\GRK_Room22\|

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.

View File

@ -1,46 +1,41 @@
 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_Room\dependencies\glfw-3.3.8.bin.WIN32\include\GLFW\glfw3.h(123): message : zobacz poprzednią definicję „APIENTRY” C:\Users\Genos\Source\Repos\GRK_Room22\dependencies\glfw-3.3.8.bin.WIN32\include\GLFW\glfw3.h(123): message : zobacz poprzednią definicję „APIENTRY”
C:\Users\Genos\source\repos\GRK_Room\cw 9\src\room.hpp(94,30): warning C4305: "inicjowanie": obcięcie z "double" do "float" C:\Users\Genos\source\repos\GRK_Room22\cw 9\src\room.hpp(107,30): warning C4305: "inicjowanie": obcięcie z "double" do "float"
C:\Users\Genos\source\repos\GRK_Room\cw 9\src\room.hpp(109,38): warning C4305: "=": obcięcie z "double" do "float" C:\Users\Genos\source\repos\GRK_Room22\cw 9\src\room.hpp(122,38): warning C4305: "=": obcięcie z "double" do "float"
C:\Users\Genos\source\repos\GRK_Room\cw 9\src\room.hpp(132,16): warning C4305: "inicjowanie": obcięcie z "double" do "float" C:\Users\Genos\source\repos\GRK_Room22\cw 9\src\room.hpp(145,16): warning C4305: "inicjowanie": obcięcie z "double" do "float"
C:\Users\Genos\source\repos\GRK_Room\cw 9\src\room.hpp(153,16): warning C4305: "inicjowanie": obcięcie z "double" do "float" C:\Users\Genos\source\repos\GRK_Room22\cw 9\src\room.hpp(166,16): warning C4305: "inicjowanie": obcięcie z "double" do "float"
C:\Users\Genos\source\repos\GRK_Room\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_Room22\cw 9\src\room.hpp(185,15): warning C4101: "textureID": lokalna zmienna, do której nie istnieje odwołanie
C:\Users\Genos\source\repos\GRK_Room\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_Room22\cw 9\src\room.hpp(268,13): warning C4244: "inicjowanie": konwersja z "double" do "float", możliwa utrata danych
C:\Users\Genos\source\repos\GRK_Room\cw 9\src\room.hpp(263,96): warning C4305: "argument": obcięcie z "double" do "T" C:\Users\Genos\source\repos\GRK_Room22\cw 9\src\room.hpp(279,96): warning C4305: "argument": obcięcie z "double" do "T"
with with
[ [
T=float T=float
] ]
C:\Users\Genos\source\repos\GRK_Room\cw 9\src\room.hpp(267,59): warning C4305: "argument": obcięcie z "double" do "T" C:\Users\Genos\source\repos\GRK_Room22\cw 9\src\room.hpp(283,59): warning C4305: "argument": obcięcie z "double" do "T"
with with
[ [
T=float T=float
] ]
C:\Users\Genos\source\repos\GRK_Room\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_Room22\cw 9\src\room.hpp(441,29): warning C4018: "<": niezgodność typu ze znakiem/bez znaku
C:\Users\Genos\source\repos\GRK_Room\cw 9\src\room.hpp(353,108): warning C4305: "argument": obcięcie z "double" do "T" C:\Users\Genos\source\repos\GRK_Room22\cw 9\src\room.hpp(482,13): warning C4244: "inicjowanie": konwersja z "double" do "float", możliwa utrata danych
C:\Users\Genos\source\repos\GRK_Room22\cw 9\src\room.hpp(495,108): warning C4305: "argument": obcięcie z "double" do "T"
with with
[ [
T=float T=float
] ]
C:\Users\Genos\source\repos\GRK_Room\cw 9\src\room.hpp(361,87): warning C4305: "argument": obcięcie z "double" do "T" C:\Users\Genos\source\repos\GRK_Room22\cw 9\src\room.hpp(506,59): warning C4305: "argument": obcięcie z "double" do "T"
with with
[ [
T=float T=float
] ]
C:\Users\Genos\source\repos\GRK_Room\cw 9\src\room.hpp(361,223): warning C4305: "argument": obcięcie z "double" do "float" C:\Users\Genos\source\repos\GRK_Room22\cw 9\src\room.hpp(507,37): warning C4305: "argument": obcięcie z "double" do "float"
C:\Users\Genos\source\repos\GRK_Room\cw 9\src\room.hpp(364,59): warning C4305: "argument": obcięcie z "double" do "T" C:\Users\Genos\source\repos\GRK_Room22\cw 9\src\room.hpp(540,2): warning C4305: "argument": obcięcie z "double" do "float"
with C:\Users\Genos\source\repos\GRK_Room22\cw 9\src\room.hpp(664,21): warning C4305: "-=": obcięcie z "double" do "float"
[ C:\Users\Genos\source\repos\GRK_Room22\cw 9\src\room.hpp(666,21): warning C4305: "+=": obcięcie z "double" do "float"
T=float
]
C:\Users\Genos\source\repos\GRK_Room\cw 9\src\room.hpp(365,37): warning C4305: "argument": obcięcie z "double" do "float"
C:\Users\Genos\source\repos\GRK_Room\cw 9\src\room.hpp(393,2): warning C4305: "argument": obcięcie z "double" do "float"
C:\Users\Genos\source\repos\GRK_Room\cw 9\src\room.hpp(501,21): warning C4305: "-=": obcięcie z "double" do "float"
C:\Users\Genos\source\repos\GRK_Room\cw 9\src\room.hpp(503,21): warning C4305: "+=": obcięcie z "double" do "float"
Trwa generowanie kodu Trwa generowanie kodu
35 of 586 functions ( 6.0%) were compiled, the rest were copied from previous compilation. 1 of 595 functions ( 0.2%) were compiled, the rest were copied from previous compilation.
0 functions were new in current compilation 0 functions were new in current compilation
15 functions had inline decision re-evaluated but remain unchanged 10 functions had inline decision re-evaluated but remain unchanged
Zakończono generowanie kodu Zakończono generowanie kodu
grk-cw9.vcxproj -> C:\Users\Genos\source\repos\GRK_Room\Release\room.exe grk-cw9.vcxproj -> C:\Users\Genos\Source\Repos\GRK_Room22\Release\room.exe

Binary file not shown.

Binary file not shown.

Binary file not shown.

View File

@ -2,7 +2,7 @@
<Project> <Project>
<ProjectOutputs> <ProjectOutputs>
<ProjectOutput> <ProjectOutput>
<FullPath>C:\Users\Genos\source\repos\GRK_Room\Release\room.exe</FullPath> <FullPath>C:\Users\Genos\Source\Repos\GRK_Room22\Release\room.exe</FullPath>
</ProjectOutput> </ProjectOutput>
</ProjectOutputs> </ProjectOutputs>
<ContentFiles /> <ContentFiles />

Binary file not shown.

Binary file not shown.

View File

@ -1,2 +1,2 @@
PlatformToolSet=v142:VCToolArchitecture=Native32Bit:VCToolsVersion=14.29.30133:TargetPlatformVersion=10.0.19041.0: PlatformToolSet=v142:VCToolArchitecture=Native32Bit:VCToolsVersion=14.29.30133:TargetPlatformVersion=10.0.19041.0:
Release|Win32|C:\Users\Genos\source\repos\GRK_Room\| Release|Win32|C:\Users\Genos\Source\Repos\GRK_Room22\|

Binary file not shown.

Binary file not shown.

View File

@ -5,10 +5,16 @@ layout (location = 1) out vec4 BloomColor;
uniform vec3 color; uniform vec3 color;
uniform float exposition; uniform float exposition;
out vec4 outColor; out vec4 outColor;
void main() void main()
{ {
//outColor = vec4(vec3(1.0) - exp(-color*exposition),1); outColor = vec4(vec3(1.0) - exp(-color*exposition),1);
outColor = vec4(color, 1.0); //outColor = vec4(color, 1.0);
float brightness = dot(FragColor.rgb, vec3(0.2126, 0.7152, 0.0722));
if(brightness > 1.0)
BloomColor = vec4(FragColor.rgb, 1.0);
else
BloomColor = vec4(0.0, 0.0, 0.0, 1.0);
BloomColor = vec4(color, 1.0);
} }

View File

@ -9,6 +9,6 @@ out vec2 TexCoords;
void main() void main()
{ {
//gl_Position = vec4(vertexPosition*0.5, 1.0); gl_Position = vec4(vertexPosition, 1.0);
TexCoords = vertexTexCoord; TexCoords = vertexTexCoord;
} }

View File

@ -4,9 +4,16 @@ uniform samplerCube skybox;
in vec3 texCoord; in vec3 texCoord;
out vec4 out_color; layout (location = 0) out vec4 FragColor;
layout (location = 1) out vec4 BloomColor;
void main() void main()
{ {
out_color = texture(skybox,texCoord); FragColor = texture(skybox,texCoord);
float brightness = dot(FragColor.rgb, vec3(0.2126, 0.7152, 0.0722));
if(brightness > 1.0)
BloomColor = vec4(FragColor.rgb, 1.0);
else
BloomColor = vec4(0.0, 0.0, 0.0, 1.0);
} }

View File

@ -16,22 +16,22 @@ float weight[5] = float[] (0.227027, 0.1945946, 0.1216216, 0.054054, 0.016216);
vec4 blur() vec4 blur()
{ {
vec2 tex_offset = 1.0 / textureSize(color, 0); // gets size of single texel vec2 tex_offset = 1.0 / textureSize(color, 0); // gets size of single texel
vec3 result = texture(color, tc).rgb * weight[0]; // current fragment's contribution vec3 result = texture(highlight, tc).rgb * weight[0]; // current fragment's contribution
bool horizontal = true; bool horizontal = true;
if(horizontal) if(horizontal)
{ {
for(int i = 1; i < 5; ++i) for(int i = 1; i < 5; ++i)
{ {
result += texture(color, tc + vec2(tex_offset.x * i, 0.0)).rgb * weight[i]; result += texture(highlight, tc + vec2(tex_offset.x * i, 0.0)).rgb * weight[i];
result += texture(color, tc - vec2(tex_offset.x * i, 0.0)).rgb * weight[i]; result += texture(highlight, tc - vec2(tex_offset.x * i, 0.0)).rgb * weight[i];
} }
} }
else else
{ {
for(int i = 1; i < 5; ++i) for(int i = 1; i < 5; ++i)
{ {
result += texture(color, tc + vec2(0.0, tex_offset.y * i)).rgb * weight[i]; result += texture(highlight, tc + vec2(0.0, tex_offset.y * i)).rgb * weight[i];
result += texture(color, tc - vec2(0.0, tex_offset.y * i)).rgb * weight[i]; result += texture(highlight, tc - vec2(0.0, tex_offset.y * i)).rgb * weight[i];
} }
} }
return vec4(result, 1.0); return vec4(result, 1.0);
@ -43,6 +43,6 @@ void main()
//FragColor = vec4(vec3(rescale_z(depthValue)+0.5), 1.0); //FragColor = vec4(vec3(rescale_z(depthValue)+0.5), 1.0);
//FragColor = vec4(vec3((depthValue)+0.5), 1.0); //FragColor = vec4(vec3((depthValue)+0.5), 1.0);
FragColor = vec4( blur()); FragColor = vec4(texture(highlight, tc).rgb+texture(color, tc).rgb,1);
//FragColor = vec4( (texture(color, tc)-0.98)*50); //FragColor = vec4( (texture(color, tc)-0.98)*50);
} }

View File

@ -23,7 +23,7 @@ int main(int argc, char** argv)
#endif #endif
// tworzenie okna za pomoca glfw // tworzenie okna za pomoca glfw
GLFWwindow* window = glfwCreateWindow(500, 500, "The Best Room", NULL, NULL); GLFWwindow* window = glfwCreateWindow(800, 800, "The Best Room", NULL, NULL);
if (window == NULL) if (window == NULL)
{ {
std::cout << "Failed to create GLFW window" << std::endl; std::cout << "Failed to create GLFW window" << std::endl;
@ -34,7 +34,7 @@ int main(int argc, char** argv)
// ladowanie OpenGL za pomoca glew // ladowanie OpenGL za pomoca glew
glewInit(); glewInit();
glViewport(0, 0, 500, 500); glViewport(0, 0, 800, 800);
init(window); init(window);

View File

@ -20,7 +20,7 @@
const unsigned int SHADOW_WIDTH = 1024, SHADOW_HEIGHT = 1024; const unsigned int SHADOW_WIDTH = 1024, SHADOW_HEIGHT = 1024;
int WIDTH = 500, HEIGHT = 500; int WIDTH = 800, HEIGHT = 800;
namespace models { namespace models {
Core::RenderContext couchContext; Core::RenderContext couchContext;
@ -427,14 +427,15 @@ void initPingPong()
glFramebufferTexture2D( glFramebufferTexture2D(
GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, pingpongBuffer[i], 0 GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, pingpongBuffer[i], 0
); );
glBindTexture(GL_TEXTURE_2D, 0);
} }
} }
void pingPongBluring(float time) void pingPongBluring()
{ {
bool horizontal = true, first_iteration = true; bool horizontal = true, first_iteration = true;
int amount = 10; int amount = 50;
glUseProgram(programBlur); glUseProgram(programBlur);
for (unsigned int i = 0; i < amount; i++) for (unsigned int i = 0; i < amount; i++)
@ -444,7 +445,8 @@ void pingPongBluring(float time)
glBindTexture( glBindTexture(
GL_TEXTURE_2D, first_iteration ? colorBuffers[1] : pingpongBuffer[!horizontal] GL_TEXTURE_2D, first_iteration ? colorBuffers[1] : pingpongBuffer[!horizontal]
); );
Core::DrawContext(models::couchContext); Core::SetActiveTexture(first_iteration ? colorBuffers[1] : pingpongBuffer[!horizontal], "image",programBlur, 0);
Core::DrawContext(models::testContext);
horizontal = !horizontal; horizontal = !horizontal;
if (first_iteration) if (first_iteration)
first_iteration = false; first_iteration = false;
@ -544,16 +546,16 @@ void renderScene(GLFWwindow* window)
spotlightPos = spaceshipPos + 0.2 * spaceshipDir; spotlightPos = spaceshipPos + 0.2 * spaceshipDir;
spotlightConeDir = spaceshipDir; spotlightConeDir = spaceshipDir;
pingPongBluring();
glBindFramebuffer(GL_FRAMEBUFFER, 0); glBindFramebuffer(GL_FRAMEBUFFER, 0);
//test depth buffer //test depth buffer
//glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); //glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
glUseProgram(programTest); glUseProgram(programTest);
Core::SetActiveTexture(colorBuffers[0], "color", programTest, 0); Core::SetActiveTexture(colorBuffers[0], "color", programTest, 0);
Core::SetActiveTexture(colorBuffers[1], "highlight", programTest, 1); Core::SetActiveTexture(pingpongBuffer[1], "highlight", programTest, 1);
//Core::SetActiveTexture(colorBuffers[0],prog) //Core::SetActiveTexture(colorBuffers[0],prog)
Core::DrawContext(models::testContext); //Core::DrawContext(models::testContext);
glUseProgram(0); glUseProgram(0);
glfwSwapBuffers(window); glfwSwapBuffers(window);