dodanie nowych okienek i kilku nowych parametrów, poprawienie kilku elementów
This commit is contained in:
parent
19067e20c1
commit
1fcde042d9
@ -52,6 +52,10 @@
|
|||||||
<ClInclude Include="src\Texture.h" />
|
<ClInclude Include="src\Texture.h" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
|
<None Include="shaders\shaderBlur.frag" />
|
||||||
|
<None Include="shaders\shaderBlur.vert" />
|
||||||
|
<None Include="shaders\shader_bloom_final.frag" />
|
||||||
|
<None Include="shaders\shader_bloom_final.vert" />
|
||||||
<None Include="shaders\shader_pbr.frag" />
|
<None Include="shaders\shader_pbr.frag" />
|
||||||
<None Include="shaders\shader_pbr.vert" />
|
<None Include="shaders\shader_pbr.vert" />
|
||||||
<None Include="shaders\shader_skybox.frag" />
|
<None Include="shaders\shader_skybox.frag" />
|
||||||
|
@ -166,5 +166,17 @@
|
|||||||
<None Include="shaders\shader_pbr.vert">
|
<None Include="shaders\shader_pbr.vert">
|
||||||
<Filter>Shader Files</Filter>
|
<Filter>Shader Files</Filter>
|
||||||
</None>
|
</None>
|
||||||
|
<None Include="shaders\shader_bloom_final.frag">
|
||||||
|
<Filter>Shader Files</Filter>
|
||||||
|
</None>
|
||||||
|
<None Include="shaders\shader_bloom_final.vert">
|
||||||
|
<Filter>Shader Files</Filter>
|
||||||
|
</None>
|
||||||
|
<None Include="shaders\shaderBlur.frag">
|
||||||
|
<Filter>Shader Files</Filter>
|
||||||
|
</None>
|
||||||
|
<None Include="shaders\shaderBlur.vert">
|
||||||
|
<Filter>Shader Files</Filter>
|
||||||
|
</None>
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
</Project>
|
</Project>
|
@ -2,6 +2,15 @@
|
|||||||
Pos=60,60
|
Pos=60,60
|
||||||
Size=400,400
|
Size=400,400
|
||||||
|
|
||||||
[Window][Menu]
|
[Window][Planet]
|
||||||
Pos=27,35
|
Pos=1,170
|
||||||
Size=380,347
|
Size=327,229
|
||||||
|
|
||||||
|
[Window][Sun]
|
||||||
|
Pos=1,400
|
||||||
|
Size=327,121
|
||||||
|
|
||||||
|
[Window][General]
|
||||||
|
Pos=1,0
|
||||||
|
Size=327,169
|
||||||
|
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
#version 330 core
|
#version 430 core
|
||||||
out vec4 FragColor;
|
out vec4 FragColor;
|
||||||
|
|
||||||
in vec2 TexCoords;
|
in vec2 TexCoords;
|
||||||
@ -23,7 +23,7 @@ void main()
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
for(int i = 1; i < 5; ++i)
|
for(int i = 1; i < count; ++i)
|
||||||
{
|
{
|
||||||
result += texture(image, TexCoords + vec2(0.0, tex_offset.y * i)).rgb * weight[i];
|
result += texture(image, TexCoords + vec2(0.0, tex_offset.y * i)).rgb * weight[i];
|
||||||
result += texture(image, TexCoords - vec2(0.0, tex_offset.y * i)).rgb * weight[i];
|
result += texture(image, TexCoords - vec2(0.0, tex_offset.y * i)).rgb * weight[i];
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
#version 330 core
|
#version 430 core
|
||||||
layout (location = 0) in vec3 aPos;
|
layout (location = 0) in vec3 aPos;
|
||||||
layout (location = 1) in vec2 aTexCoords;
|
layout (location = 1) in vec2 aTexCoords;
|
||||||
|
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
#version 330 core
|
#version 430 core
|
||||||
out vec4 FragColor;
|
out vec4 FragColor;
|
||||||
|
|
||||||
in vec2 TexCoords;
|
in vec2 TexCoords;
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
#version 330 core
|
#version 430 core
|
||||||
layout (location = 0) in vec3 aPos;
|
layout (location = 0) in vec3 aPos;
|
||||||
layout (location = 1) in vec2 aTexCoords;
|
layout (location = 1) in vec2 aTexCoords;
|
||||||
|
|
||||||
|
@ -203,21 +203,20 @@ void main()
|
|||||||
//sun
|
//sun
|
||||||
illumination = illumination + PBRLight(sunDir, sunColor, normal, viewDir, toneMappedColor);
|
illumination = illumination + PBRLight(sunDir, sunColor, normal, viewDir, toneMappedColor);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
vec3 pbrColor = vec3(1.0) - exp(-illumination * exposition);
|
vec3 pbrColor = vec3(1.0) - exp(-illumination * exposition);
|
||||||
|
|
||||||
vec3 finalColor = pbrColor;
|
vec3 finalColor;
|
||||||
|
|
||||||
if (atmosphereCheck)
|
if (atmosphereCheck)
|
||||||
{
|
{
|
||||||
vec3 noiseColor = noiseColor() * min(1, 20.0 * max(0.02, dot(normal, lightDir))) * lightColor * cloudBrightness;
|
vec3 noiseColor = noiseColor() * min(1, 20.0 * max(0.02, dot(normal, lightDir))) * lightColor * cloudBrightness;
|
||||||
finalColor = mix(pbrColor, noiseColor, noiseColor.r);
|
finalColor = mix(pbrColor, noiseColor, noiseColor.r);
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
finalColor = pbrColor;
|
||||||
|
|
||||||
|
float brightness = dot(finalColor, vec3(0.2126, 0.7152, 0.0722));
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
float brightness = dot(finalColor, vec3(0.2126, 0.7152, 0.0722));
|
|
||||||
if(brightness > 0.2)
|
if(brightness > 0.2)
|
||||||
BrightColor = vec4(finalColor, 1.0);
|
BrightColor = vec4(finalColor, 1.0);
|
||||||
else
|
else
|
||||||
|
@ -7,7 +7,7 @@ uniform vec3 lightColor;
|
|||||||
|
|
||||||
uniform vec3 cameraPos;
|
uniform vec3 cameraPos;
|
||||||
|
|
||||||
uniform bool atmosphereCheck;
|
uniform bool glowCheck;
|
||||||
|
|
||||||
uniform float time;
|
uniform float time;
|
||||||
|
|
||||||
@ -19,8 +19,6 @@ in vec2 vtc;
|
|||||||
|
|
||||||
uniform sampler2D colorTexture;
|
uniform sampler2D colorTexture;
|
||||||
|
|
||||||
vec4 noiseColor;
|
|
||||||
|
|
||||||
vec3 toneMapping(vec3 color)
|
vec3 toneMapping(vec3 color)
|
||||||
{
|
{
|
||||||
float exposure = 0.06;
|
float exposure = 0.06;
|
||||||
@ -67,7 +65,7 @@ float fbm ( in vec2 _st) {
|
|||||||
return v;
|
return v;
|
||||||
}
|
}
|
||||||
|
|
||||||
vec4 noiseTexture(float time) {
|
vec3 noiseColor() {
|
||||||
vec2 st = vtc.xy * 9.;
|
vec2 st = vtc.xy * 9.;
|
||||||
vec3 color = vec3(0.0);
|
vec3 color = vec3(0.0);
|
||||||
|
|
||||||
@ -93,7 +91,7 @@ vec4 noiseTexture(float time) {
|
|||||||
vec3(1.000,0.306,0.143),
|
vec3(1.000,0.306,0.143),
|
||||||
clamp(length(r.x),0.0,1.0));
|
clamp(length(r.x),0.0,1.0));
|
||||||
|
|
||||||
noiseColor = vec4((f*f*f+1.384*f*f+1.044*f)*color,1.);
|
vec3 noiseColor = vec3((f*f*f+1.384*f*f+1.044*f)*color);
|
||||||
|
|
||||||
return noiseColor;
|
return noiseColor;
|
||||||
}
|
}
|
||||||
@ -105,22 +103,28 @@ void main()
|
|||||||
|
|
||||||
vec3 textureColor = texture2D(colorTexture, vtc).rgb;
|
vec3 textureColor = texture2D(colorTexture, vtc).rgb;
|
||||||
|
|
||||||
if (atmosphereCheck)
|
if (glowCheck)
|
||||||
{
|
{
|
||||||
float atmosphereDot = dot(normal, viewDir);
|
float glowDot = dot(normal, viewDir);
|
||||||
vec3 atmosphereColor = vec3(1.0, 0.08, 0.02);
|
vec3 glowColor = vec3(1.0, 0.08, 0.02);
|
||||||
textureColor = mix(textureColor, atmosphereColor, pow(1 - atmosphereDot, 2));
|
textureColor = mix(textureColor, glowColor, pow(1 - glowDot, 2));
|
||||||
}
|
}
|
||||||
|
|
||||||
vec3 distance = lightColor / pow(length(lightPos - worldPos), 2.0) * 15;
|
vec3 mixedColor;
|
||||||
|
|
||||||
vec4 textureNoise = noiseTexture(time);
|
if (glowCheck)
|
||||||
vec3 mixedTexture = mix(textureColor, textureNoise.rgb, 0.45f);
|
{
|
||||||
|
vec3 noiseColor = noiseColor();
|
||||||
|
mixedColor = mix(textureColor, noiseColor, 0.35);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
mixedColor = textureColor * lightColor * 0.2f;
|
||||||
|
|
||||||
vec3 toneMappedColor = toneMapping(mixedTexture * distance);
|
vec3 distance = lightColor / pow(length(lightPos - worldPos), 2.0) * 100;
|
||||||
|
vec3 toneMappedColor = toneMapping(mixedColor * distance);
|
||||||
//gamma correction
|
//gamma correction
|
||||||
toneMappedColor = pow(toneMappedColor, vec3(1.0/2.2));
|
toneMappedColor = pow(toneMappedColor, vec3(1.0/2.2));
|
||||||
vec3 finalColor = toneMappedColor * lightColor * 0.2f;
|
vec3 finalColor = toneMappedColor;
|
||||||
|
|
||||||
float brightness = dot(finalColor, vec3(0.2126, 0.7152, 0.0722));
|
float brightness = dot(finalColor, vec3(0.2126, 0.7152, 0.0722));
|
||||||
|
|
||||||
|
@ -31,8 +31,8 @@ GLuint programTex;
|
|||||||
GLuint programPbr;
|
GLuint programPbr;
|
||||||
GLuint programSun;
|
GLuint programSun;
|
||||||
GLuint programSkyBox;
|
GLuint programSkyBox;
|
||||||
GLuint programBloomFinal;
|
|
||||||
GLuint programBlur;
|
GLuint programBlur;
|
||||||
|
GLuint programBloomFinal;
|
||||||
|
|
||||||
Core::Shader_Loader shaderLoader;
|
Core::Shader_Loader shaderLoader;
|
||||||
|
|
||||||
@ -44,7 +44,7 @@ const char* const planetTexPaths[] = { "./textures/planets/mercury.png", "./text
|
|||||||
"./textures/planets/volcanic.png", "./textures/planets/desert.png", "./textures/planets/tropical.png", "./textures/planets/toxic.jpg", "./textures/planets/swamp.png",
|
"./textures/planets/volcanic.png", "./textures/planets/desert.png", "./textures/planets/tropical.png", "./textures/planets/toxic.jpg", "./textures/planets/swamp.png",
|
||||||
"./textures/planets/savannah.png", "./textures/planets/alpine.png", "./textures/planets/ceres.jpg", "./textures/planets/eris.jpg", "./textures/planets/haumea.jpg",
|
"./textures/planets/savannah.png", "./textures/planets/alpine.png", "./textures/planets/ceres.jpg", "./textures/planets/eris.jpg", "./textures/planets/haumea.jpg",
|
||||||
"./textures/planets/makemake.jpg" };
|
"./textures/planets/makemake.jpg" };
|
||||||
int planetTexIndex = 80;
|
int planetTexIndex = 0;
|
||||||
GLuint planetTex;
|
GLuint planetTex;
|
||||||
|
|
||||||
glm::vec3 planetPos = glm::vec3(0.f, 0.f, 0.f);
|
glm::vec3 planetPos = glm::vec3(0.f, 0.f, 0.f);
|
||||||
@ -54,15 +54,17 @@ float planetRough = 0.5f;
|
|||||||
float planetMetal = 0.5f;
|
float planetMetal = 0.5f;
|
||||||
|
|
||||||
const char* const sunTexPaths[] = { "./textures/suns/lava.png", "./textures/suns/sol.jpg", "./textures/suns/orange.jpg", "./textures/suns/star.png", "./textures/suns/sun.jpg" };
|
const char* const sunTexPaths[] = { "./textures/suns/lava.png", "./textures/suns/sol.jpg", "./textures/suns/orange.jpg", "./textures/suns/star.png", "./textures/suns/sun.jpg" };
|
||||||
int sunTexIndex = 20;
|
int sunTexIndex = 0;
|
||||||
GLuint sunTex;
|
GLuint sunTex;
|
||||||
|
|
||||||
glm::vec3 sunPos = glm::vec3(20.f, 0.f, 20.f);
|
glm::vec3 sunPos = glm::vec3(20.f, 0.f, 20.f);
|
||||||
glm::vec3 sunDir = glm::vec3(1.f, 0.f, 1.f);
|
glm::vec3 sunDir = glm::vec3(1.f, 0.f, 1.f);
|
||||||
float sunSize = 0.05f;
|
float sunSize = 0.05f;
|
||||||
|
|
||||||
|
bool glowCheck = false;
|
||||||
bool atmosphereCheck = false;
|
bool atmosphereCheck = false;
|
||||||
bool lightingCheck = false;
|
bool lightingCheck = false;
|
||||||
|
bool skyBoxCheck = false;
|
||||||
|
|
||||||
const char* skyBoxPaths[] = { "./textures/skybox/space_rt.png", "./textures/skybox/space_lf.png", "./textures/skybox/space_up.png", "./textures/skybox/space_dn.png",
|
const char* skyBoxPaths[] = { "./textures/skybox/space_rt.png", "./textures/skybox/space_lf.png", "./textures/skybox/space_up.png", "./textures/skybox/space_dn.png",
|
||||||
"./textures/skybox/space_bk.png", "./textures/skybox/space_ft.png" };
|
"./textures/skybox/space_bk.png", "./textures/skybox/space_ft.png" };
|
||||||
@ -83,7 +85,6 @@ unsigned int colorBuffers[2];
|
|||||||
|
|
||||||
unsigned int rboDepth;
|
unsigned int rboDepth;
|
||||||
|
|
||||||
|
|
||||||
unsigned int pingpongFBO[2];
|
unsigned int pingpongFBO[2];
|
||||||
unsigned int pingpongColorbuffers[2];
|
unsigned int pingpongColorbuffers[2];
|
||||||
|
|
||||||
@ -101,6 +102,8 @@ float cloudIntensity = 15.f;
|
|||||||
float cloudMotion = 0.f;
|
float cloudMotion = 0.f;
|
||||||
float cloudBrightness = 0.08f;
|
float cloudBrightness = 0.08f;
|
||||||
|
|
||||||
|
float PI = 3.14159f;
|
||||||
|
|
||||||
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)));
|
||||||
glm::vec3 cameraUp = glm::normalize(glm::cross(cameraSide, cameraDir));
|
glm::vec3 cameraUp = glm::normalize(glm::cross(cameraSide, cameraDir));
|
||||||
@ -124,7 +127,6 @@ glm::mat4 createPerspectiveMatrix() {
|
|||||||
float n = 0.01f;
|
float n = 0.01f;
|
||||||
float f = 200.f;
|
float f = 200.f;
|
||||||
float fov = 105.f;
|
float fov = 105.f;
|
||||||
float PI = 3.14159f;
|
|
||||||
float S = 1 / (tan((fov / 2) * (PI / 180)));
|
float S = 1 / (tan((fov / 2) * (PI / 180)));
|
||||||
|
|
||||||
perspectiveMatrix = glm::mat4({
|
perspectiveMatrix = glm::mat4({
|
||||||
@ -168,36 +170,90 @@ void renderQuad()
|
|||||||
glBindVertexArray(0);
|
glBindVertexArray(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void showGUI() {
|
void showGUI() {
|
||||||
ImGui_ImplOpenGL3_NewFrame();
|
ImGui_ImplOpenGL3_NewFrame();
|
||||||
ImGui_ImplGlfw_NewFrame();
|
ImGui_ImplGlfw_NewFrame();
|
||||||
ImGui::NewFrame();
|
ImGui::NewFrame();
|
||||||
ImGui::Begin("Menu");
|
|
||||||
ImGui::SliderFloat("Size", &planetSize, 0.001f, 0.01f);
|
|
||||||
ImGui::SliderFloat("Rotation", &planetRot, -1.5f, 1.5f);
|
|
||||||
ImGui::SliderFloat("Light Power", &lightPower, 0.01f, 20.0f);
|
|
||||||
ImGui::SliderInt("Bloom", &blur_count, 0, 6);
|
|
||||||
if (ImGui::Button("Texture", ImVec2(60, 20))) {
|
|
||||||
planetTex = Core::LoadTexture(planetTexPaths[std::abs(++planetTexIndex % 20)]);
|
|
||||||
}
|
|
||||||
ImGui::SameLine();
|
|
||||||
if (ImGui::Button("Sun", ImVec2(60, 20))) {
|
|
||||||
sunTex = Core::LoadTexture(sunTexPaths[std::abs(++sunTexIndex % 5)]);
|
|
||||||
}
|
|
||||||
|
|
||||||
ImGui::Text("PBR Settings");
|
|
||||||
ImGui::Checkbox("Lighting Model", &lightingCheck);
|
|
||||||
ImGui::SliderFloat("Metal", &planetMetal, 0.01f, 1.0f);
|
|
||||||
ImGui::SliderFloat("Roughness", &planetRough, 0.01f, 1.0f);
|
|
||||||
|
|
||||||
ImGui::Text("Atmosphere Settings"); ImGui::Checkbox("Atmosphere", &atmosphereCheck);
|
if (ImGui::Begin("General"))
|
||||||
|
{
|
||||||
|
ImGui::Checkbox("SkyBox", &skyBoxCheck);
|
||||||
|
ImGui::Checkbox("Lighting Model: ", &lightingCheck);
|
||||||
|
ImGui::SameLine();
|
||||||
|
|
||||||
ImGui::SliderFloat("Cloud Intensity", &cloudIntensity, 0.01f, 20.0f);
|
if (lightingCheck) {
|
||||||
ImGui::SliderFloat("Cloud Brightness", &cloudBrightness, 0.01f, 0.28f);
|
ImGui::Text("PBR");
|
||||||
ImGui::SliderFloat("Cloud Motion", &cloudMotion, 0.01f, 8.0f);
|
ImGui::SliderFloat("Roughness", &planetRough, 0.0f, 1.0f, "%.3f", ImGuiSliderFlags_AlwaysClamp);
|
||||||
|
ImGui::SliderFloat("Metallicity", &planetMetal, 0.0f, 1.0f, "%.3f", ImGuiSliderFlags_AlwaysClamp);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
ImGui::Text("Diffuse");
|
||||||
|
|
||||||
ImGui::End();
|
ImGui::SliderFloat("Exposure", &lightPower, 1.0f, 20.0f, "%.3f", ImGuiSliderFlags_AlwaysClamp);
|
||||||
|
|
||||||
|
ImGui::SliderInt("Bloom Level", &blur_count, 1, 5, "%d", ImGuiSliderFlags_AlwaysClamp);
|
||||||
|
|
||||||
|
}ImGui::End();
|
||||||
|
|
||||||
|
if(ImGui::Begin("Planet"))
|
||||||
|
{
|
||||||
|
ImGui::Text("Texture");
|
||||||
|
if (ImGui::Button("Prev", ImVec2(60, 20))) {
|
||||||
|
--planetTexIndex;
|
||||||
|
|
||||||
|
if (planetTexIndex < 0)
|
||||||
|
planetTexIndex = sizeof(planetTexPaths) / sizeof(planetTexPaths[0]) - 1;
|
||||||
|
|
||||||
|
planetTex = Core::LoadTexture(planetTexPaths[planetTexIndex]);
|
||||||
|
}
|
||||||
|
ImGui::SameLine();
|
||||||
|
if (ImGui::Button("Next", ImVec2(60, 20))) {
|
||||||
|
++planetTexIndex;
|
||||||
|
|
||||||
|
if (planetTexIndex > sizeof(planetTexPaths) / sizeof(planetTexPaths[0]) - 1)
|
||||||
|
planetTexIndex = 0;
|
||||||
|
|
||||||
|
planetTex = Core::LoadTexture(planetTexPaths[planetTexIndex]);
|
||||||
|
}
|
||||||
|
|
||||||
|
ImGui::SliderFloat("Size", &planetSize, 0.001f, 0.01f, "%.5f", ImGuiSliderFlags_AlwaysClamp);
|
||||||
|
ImGui::SliderFloat("Rotation", &planetRot, -2.0f, 2.0f, "%.3f", ImGuiSliderFlags_AlwaysClamp);
|
||||||
|
|
||||||
|
ImGui::Checkbox("Atmosphere", &atmosphereCheck);
|
||||||
|
if (atmosphereCheck) {
|
||||||
|
ImGui::Text("Clouds");
|
||||||
|
ImGui::SliderFloat("Intensity", &cloudIntensity, 0.0f, 100.0f, "%.3f", ImGuiSliderFlags_AlwaysClamp);
|
||||||
|
ImGui::SliderFloat("Brightness", &cloudBrightness, 0.01f, 0.20f, "%.3f", ImGuiSliderFlags_AlwaysClamp);
|
||||||
|
ImGui::SliderFloat("Motion", &cloudMotion, -0.5f, 0.5f, "%.3f", ImGuiSliderFlags_AlwaysClamp);
|
||||||
|
}
|
||||||
|
}ImGui::End();
|
||||||
|
|
||||||
|
if (ImGui::Begin("Sun"))
|
||||||
|
{
|
||||||
|
ImGui::Text("Texture");
|
||||||
|
if (ImGui::Button("Prev", ImVec2(60, 20))) {
|
||||||
|
--sunTexIndex;
|
||||||
|
|
||||||
|
if (sunTexIndex < 0)
|
||||||
|
sunTexIndex = sizeof(sunTexPaths) / sizeof(sunTexPaths[0]) - 1;
|
||||||
|
|
||||||
|
sunTex = Core::LoadTexture(sunTexPaths[sunTexIndex]);
|
||||||
|
}
|
||||||
|
ImGui::SameLine();
|
||||||
|
if (ImGui::Button("Next", ImVec2(60, 20))) {
|
||||||
|
++sunTexIndex;
|
||||||
|
|
||||||
|
if (sunTexIndex > sizeof(sunTexPaths) / sizeof(sunTexPaths[0]) - 1)
|
||||||
|
sunTexIndex = 0;
|
||||||
|
|
||||||
|
sunTex = Core::LoadTexture(sunTexPaths[sunTexIndex]);
|
||||||
|
}
|
||||||
|
|
||||||
|
ImGui::SliderFloat("Size", &sunSize, 0.01f, 0.1f, "%.4f", ImGuiSliderFlags_AlwaysClamp);
|
||||||
|
|
||||||
|
ImGui::Checkbox("Glow", &glowCheck);
|
||||||
|
|
||||||
|
}ImGui::End();
|
||||||
|
|
||||||
ImGui::Render();
|
ImGui::Render();
|
||||||
ImGui_ImplOpenGL3_RenderDrawData(ImGui::GetDrawData());
|
ImGui_ImplOpenGL3_RenderDrawData(ImGui::GetDrawData());
|
||||||
@ -337,7 +393,7 @@ void drawSun(Core::RenderContext& context, glm::mat4 modelMatrix, GLuint texture
|
|||||||
|
|
||||||
glUniform3f(glGetUniformLocation(programSun, "cameraPos"), cameraPos.x, cameraPos.y, cameraPos.z);
|
glUniform3f(glGetUniformLocation(programSun, "cameraPos"), cameraPos.x, cameraPos.y, cameraPos.z);
|
||||||
|
|
||||||
glUniform1i(glGetUniformLocation(programSun, "atmosphereCheck"), atmosphereCheck);
|
glUniform1i(glGetUniformLocation(programSun, "glowCheck"), glowCheck);
|
||||||
glUniform1f(glGetUniformLocation(programSun, "time"), glfwGetTime());
|
glUniform1f(glGetUniformLocation(programSun, "time"), glfwGetTime());
|
||||||
|
|
||||||
Core::DrawContext(context);
|
Core::DrawContext(context);
|
||||||
@ -358,12 +414,11 @@ void drawSkyBox(Core::RenderContext& context, glm::mat4 modelMatrix, GLuint text
|
|||||||
glUseProgram(0);
|
glUseProgram(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
void drawPlanetBlur() {
|
void drawBlur() {
|
||||||
bool horizontal = true, first_iteration = true;
|
bool horizontal = true, first_iteration = true;
|
||||||
unsigned int amount = 10;
|
|
||||||
glUseProgram(programBlur);
|
glUseProgram(programBlur);
|
||||||
glUniform1i(glGetUniformLocation(programBlur, "count"), blur_count);
|
glUniform1i(glGetUniformLocation(programBlur, "count"), blur_count);
|
||||||
for (unsigned int i = 0; i < amount; i++)
|
for (unsigned int i = 0; i < blur_count * 2; i++)
|
||||||
{
|
{
|
||||||
glBindFramebuffer(GL_FRAMEBUFFER, pingpongFBO[horizontal]);
|
glBindFramebuffer(GL_FRAMEBUFFER, pingpongFBO[horizontal]);
|
||||||
glUniform1i(glGetUniformLocation(programBlur, "horizontal"), horizontal);
|
glUniform1i(glGetUniformLocation(programBlur, "horizontal"), horizontal);
|
||||||
@ -389,7 +444,7 @@ void drawPlanetBlur() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void renderScene(GLFWwindow* window) {
|
void renderScene(GLFWwindow* window) {
|
||||||
glClearColor(0.0f, 0.0f, 0.0f, 1.0f);
|
glClearColor(0.0f, 0.0f, 0.05f, 1.0f);
|
||||||
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
|
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
|
||||||
float time = glfwGetTime();
|
float time = glfwGetTime();
|
||||||
glBindFramebuffer(GL_FRAMEBUFFER, hdrFBO);
|
glBindFramebuffer(GL_FRAMEBUFFER, hdrFBO);
|
||||||
@ -408,7 +463,7 @@ void renderScene(GLFWwindow* window) {
|
|||||||
//rysowanie słońca
|
//rysowanie słońca
|
||||||
glm::mat4 sunScale = glm::scale(glm::vec3(sunSize));
|
glm::mat4 sunScale = glm::scale(glm::vec3(sunSize));
|
||||||
glm::mat4 sunTranslate = glm::translate(sunPos);
|
glm::mat4 sunTranslate = glm::translate(sunPos);
|
||||||
glm::mat4 sunRotate = glm::rotate(180.f, glm::vec3(0, 1, 0));
|
glm::mat4 sunRotate = glm::rotate(PI, glm::vec3(0, 1, 0));
|
||||||
|
|
||||||
drawSun(sphereContext, sunTranslate * sunRotate * sunScale, sunTex);
|
drawSun(sphereContext, sunTranslate * sunRotate * sunScale, sunTex);
|
||||||
|
|
||||||
@ -417,15 +472,15 @@ void renderScene(GLFWwindow* window) {
|
|||||||
glm::mat4 skyBoxScale = glm::scale(glm::vec3(skyBoxSize));
|
glm::mat4 skyBoxScale = glm::scale(glm::vec3(skyBoxSize));
|
||||||
glm::mat4 skyBoxTranslate = glm::translate(skyBoxPos);
|
glm::mat4 skyBoxTranslate = glm::translate(skyBoxPos);
|
||||||
|
|
||||||
drawSkyBox(cubeContext, skyBoxTranslate * skyBoxScale, skyBoxTex);
|
if (skyBoxCheck)
|
||||||
|
drawSkyBox(cubeContext, skyBoxTranslate * skyBoxScale, skyBoxTex);
|
||||||
|
|
||||||
glBindFramebuffer(GL_FRAMEBUFFER, 0);
|
glBindFramebuffer(GL_FRAMEBUFFER, 0);
|
||||||
|
|
||||||
drawPlanetBlur();
|
drawBlur();
|
||||||
|
|
||||||
showGUI();
|
showGUI();
|
||||||
|
|
||||||
|
|
||||||
glfwSwapBuffers(window);
|
glfwSwapBuffers(window);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -453,16 +508,40 @@ void loadModelToContext(std::string path, Core::RenderContext& context) {
|
|||||||
void key_callback(GLFWwindow* window, int key, int scancode, int action, int mods)
|
void key_callback(GLFWwindow* window, int key, int scancode, int action, int mods)
|
||||||
{
|
{
|
||||||
//tekstura planety
|
//tekstura planety
|
||||||
if (key == GLFW_KEY_T && action == GLFW_PRESS)
|
if (key == GLFW_KEY_T && action == GLFW_PRESS) {
|
||||||
planetTex = Core::LoadTexture(planetTexPaths[std::abs(++planetTexIndex % 20)]);
|
++planetTexIndex;
|
||||||
if (key == GLFW_KEY_Y && action == GLFW_PRESS && planetTexIndex > 0)
|
|
||||||
planetTex = Core::LoadTexture(planetTexPaths[std::abs(--planetTexIndex % 20)]);
|
if (planetTexIndex > sizeof(planetTexPaths) / sizeof(planetTexPaths[0]) - 1)
|
||||||
|
planetTexIndex = 0;
|
||||||
|
|
||||||
|
planetTex = Core::LoadTexture(planetTexPaths[planetTexIndex]);
|
||||||
|
}
|
||||||
|
if (key == GLFW_KEY_Y && action == GLFW_PRESS) {
|
||||||
|
--planetTexIndex;
|
||||||
|
|
||||||
|
if (planetTexIndex < 0)
|
||||||
|
planetTexIndex = sizeof(planetTexPaths) / sizeof(planetTexPaths[0]) - 1;
|
||||||
|
|
||||||
|
planetTex = Core::LoadTexture(planetTexPaths[planetTexIndex]);
|
||||||
|
}
|
||||||
|
|
||||||
//tekstura słońca
|
//tekstura słońca
|
||||||
if (key == GLFW_KEY_U && action == GLFW_PRESS)
|
if (key == GLFW_KEY_U && action == GLFW_PRESS) {
|
||||||
sunTex = Core::LoadTexture(sunTexPaths[std::abs(++sunTexIndex % 5)]);
|
++sunTexIndex;
|
||||||
if (key == GLFW_KEY_I && action == GLFW_PRESS && sunTexIndex > 0)
|
|
||||||
sunTex = Core::LoadTexture(sunTexPaths[std::abs(--sunTexIndex % 5)]);
|
if (sunTexIndex > sizeof(sunTexPaths) / sizeof(sunTexPaths[0]) - 1)
|
||||||
|
sunTexIndex = 0;
|
||||||
|
|
||||||
|
sunTex = Core::LoadTexture(sunTexPaths[sunTexIndex]);
|
||||||
|
}
|
||||||
|
if (key == GLFW_KEY_I && action == GLFW_PRESS) {
|
||||||
|
--sunTexIndex;
|
||||||
|
|
||||||
|
if (sunTexIndex < 0)
|
||||||
|
sunTexIndex = sizeof(sunTexPaths) / sizeof(sunTexPaths[0]) - 1;
|
||||||
|
|
||||||
|
sunTex = Core::LoadTexture(sunTexPaths[sunTexIndex]);
|
||||||
|
}
|
||||||
|
|
||||||
//atmosfera
|
//atmosfera
|
||||||
if (key == GLFW_KEY_O && action == GLFW_PRESS)
|
if (key == GLFW_KEY_O && action == GLFW_PRESS)
|
||||||
@ -472,12 +551,20 @@ void key_callback(GLFWwindow* window, int key, int scancode, int action, int mod
|
|||||||
if (key == GLFW_KEY_P && action == GLFW_PRESS)
|
if (key == GLFW_KEY_P && action == GLFW_PRESS)
|
||||||
lightingCheck = !lightingCheck;
|
lightingCheck = !lightingCheck;
|
||||||
|
|
||||||
|
//poświata słońca
|
||||||
|
if (key == GLFW_KEY_E && action == GLFW_PRESS)
|
||||||
|
glowCheck = !glowCheck;
|
||||||
|
|
||||||
|
//skybox
|
||||||
|
if (key == GLFW_KEY_Q && action == GLFW_PRESS)
|
||||||
|
skyBoxCheck = !skyBoxCheck;
|
||||||
|
|
||||||
|
//bloom
|
||||||
if (key == GLFW_KEY_M && action == GLFW_PRESS) {
|
if (key == GLFW_KEY_M && action == GLFW_PRESS) {
|
||||||
blur_count++;
|
blur_count++;
|
||||||
if (blur_count > 5)
|
if (blur_count > 5)
|
||||||
blur_count = 1;
|
blur_count = 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//obsluga wejscia
|
//obsluga wejscia
|
||||||
@ -513,17 +600,17 @@ void processInput(GLFWwindow* window)
|
|||||||
//obrót planety
|
//obrót planety
|
||||||
float rotationSpeed = 0.0025f;
|
float rotationSpeed = 0.0025f;
|
||||||
|
|
||||||
if (glfwGetKey(window, GLFW_KEY_RIGHT) == GLFW_PRESS && planetRot < 1.5f)
|
if (glfwGetKey(window, GLFW_KEY_RIGHT) == GLFW_PRESS && planetRot < 2.0f)
|
||||||
planetRot += rotationSpeed;
|
planetRot += rotationSpeed;
|
||||||
else if (glfwGetKey(window, GLFW_KEY_LEFT) == GLFW_PRESS && planetRot > -1.5f)
|
else if (glfwGetKey(window, GLFW_KEY_LEFT) == GLFW_PRESS && planetRot > -2.0f)
|
||||||
planetRot -= rotationSpeed;
|
planetRot -= rotationSpeed;
|
||||||
|
|
||||||
//jasność
|
//jasność
|
||||||
float powerSpeed = 0.05f;
|
float powerSpeed = 0.05f;
|
||||||
|
|
||||||
if (glfwGetKey(window, GLFW_KEY_1) == GLFW_PRESS && lightPower < 16.f)
|
if (glfwGetKey(window, GLFW_KEY_1) == GLFW_PRESS && lightPower < 20.f)
|
||||||
lightPower += powerSpeed;
|
lightPower += powerSpeed;
|
||||||
else if (glfwGetKey(window, GLFW_KEY_2) == GLFW_PRESS && lightPower > 2.f)
|
else if (glfwGetKey(window, GLFW_KEY_2) == GLFW_PRESS && lightPower > 1.f)
|
||||||
lightPower -= powerSpeed;
|
lightPower -= powerSpeed;
|
||||||
|
|
||||||
lightColor = glm::vec3(lightPower, lightPower, lightPower);
|
lightColor = glm::vec3(lightPower, lightPower, lightPower);
|
||||||
@ -555,17 +642,17 @@ void processInput(GLFWwindow* window)
|
|||||||
//ruch chmur
|
//ruch chmur
|
||||||
float motionSpeed = 0.0025f;
|
float motionSpeed = 0.0025f;
|
||||||
|
|
||||||
if (glfwGetKey(window, GLFW_KEY_V) == GLFW_PRESS && cloudMotion < 1.5f)
|
if (glfwGetKey(window, GLFW_KEY_V) == GLFW_PRESS && cloudMotion < 0.5f)
|
||||||
cloudMotion += motionSpeed;
|
cloudMotion += motionSpeed;
|
||||||
else if (glfwGetKey(window, GLFW_KEY_C) == GLFW_PRESS && cloudMotion > -1.5f)
|
else if (glfwGetKey(window, GLFW_KEY_C) == GLFW_PRESS && cloudMotion > -0.5f)
|
||||||
cloudMotion -= motionSpeed;
|
cloudMotion -= motionSpeed;
|
||||||
|
|
||||||
//jasność chmur
|
//jasność chmur
|
||||||
float brightnessSpeed = 0.0005f;
|
float brightnessSpeed = 0.0005f;
|
||||||
|
|
||||||
if (glfwGetKey(window, GLFW_KEY_N) == GLFW_PRESS && cloudBrightness < 0.16f)
|
if (glfwGetKey(window, GLFW_KEY_N) == GLFW_PRESS && cloudBrightness < 0.2f)
|
||||||
cloudBrightness += brightnessSpeed;
|
cloudBrightness += brightnessSpeed;
|
||||||
else if (glfwGetKey(window, GLFW_KEY_B) == GLFW_PRESS && cloudBrightness > 0.02f)
|
else if (glfwGetKey(window, GLFW_KEY_B) == GLFW_PRESS && cloudBrightness > 0.01f)
|
||||||
cloudBrightness -= brightnessSpeed;
|
cloudBrightness -= brightnessSpeed;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -580,10 +667,8 @@ void init(GLFWwindow* window) {
|
|||||||
ImGui::CreateContext();
|
ImGui::CreateContext();
|
||||||
ImGuiIO& io = ImGui::GetIO(); (void)io;
|
ImGuiIO& io = ImGui::GetIO(); (void)io;
|
||||||
ImGui_ImplGlfw_InitForOpenGL(window, true);
|
ImGui_ImplGlfw_InitForOpenGL(window, true);
|
||||||
ImGui_ImplOpenGL3_Init("#version 330");
|
ImGui_ImplOpenGL3_Init("#version 430");
|
||||||
ImGui::StyleColorsDark;
|
ImGui::StyleColorsDark;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
glfwSetKeyCallback(window, key_callback);
|
glfwSetKeyCallback(window, key_callback);
|
||||||
|
|
||||||
@ -612,6 +697,8 @@ void shutdown(GLFWwindow* window) {
|
|||||||
shaderLoader.DeleteProgram(programPbr);
|
shaderLoader.DeleteProgram(programPbr);
|
||||||
shaderLoader.DeleteProgram(programSun);
|
shaderLoader.DeleteProgram(programSun);
|
||||||
shaderLoader.DeleteProgram(programSkyBox);
|
shaderLoader.DeleteProgram(programSkyBox);
|
||||||
|
shaderLoader.DeleteProgram(programBlur);
|
||||||
|
shaderLoader.DeleteProgram(programBloomFinal);
|
||||||
ImGui_ImplOpenGL3_Shutdown();
|
ImGui_ImplOpenGL3_Shutdown();
|
||||||
ImGui_ImplGlfw_Shutdown();
|
ImGui_ImplGlfw_Shutdown();
|
||||||
ImGui::DestroyContext();
|
ImGui::DestroyContext();
|
||||||
|
Loading…
Reference in New Issue
Block a user