merge noise with master

This commit is contained in:
sasankasa 2024-02-04 13:02:41 +01:00
commit 7f820a35a1
16 changed files with 200 additions and 287 deletions

View File

@ -40,14 +40,10 @@
<None Include="shaders\shader_pbr.vert" />
<None Include="shaders\shader_skybox.frag" />
<None Include="shaders\shader_skybox.vert" />
<None Include="shaders\shader_noise.frag" />
<None Include="shaders\shader_smap.vert" />
<None Include="shaders\shader_tex.frag" />
<None Include="shaders\shader_tex.vert" />
<None Include="shaders\shader_sun.frag" />
<None Include="shaders\shader_sun.vert" />
<None Include="shaders\test.frag" />
<None Include="shaders\test.vert" />
</ItemGroup>
<PropertyGroup Label="Globals">
<ProjectGuid>{3952C396-B1C6-44CD-96DD-C1AC15D32978}</ProjectGuid>

View File

@ -1,16 +0,0 @@
# 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

View File

@ -1,88 +0,0 @@
#version 430 core
uniform float u_time;
out vec4 outColor;
in vec2 vtc;
in vec3 worldPos;
vec2 u_resolution = vec2(1024, 1024);
float random (in vec2 st) {
return fract(sin(dot(st.xy,
vec2(12.9898,78.233)))*
43758.5453123);
}
// Based on Morgan McGuire @morgan3d
// https://www.shadertoy.com/view/4dS3Wd
float noise (in vec2 st) {
vec2 i = floor(st);
vec2 f = fract(st);
// Four corners in 2D of a tile
float a = random(i);
float b = random(i + vec2(1.0, 0.0));
float c = random(i + vec2(0.0, 1.0));
float d = random(i + vec2(1.0, 1.0));
vec2 u = f * f * (3.0 - 2.0 * f);
return mix(a, b, u.x) +
(c - a)* u.y * (1.0 - u.x) +
(d - b) * u.x * u.y;
}
#define OCTAVES 6
float fbm (in vec2 st) {
// Initial values
float value = 0.0;
float amplitude = .5;
float frequency = 0.;
//
// Loop of octaves
for (int i = 0; i < OCTAVES; i++) {
value += amplitude * noise(st);
st *= 2.;
amplitude *= .5;
}
return value;
}
void main() {
/*
vec2 st = vtc;
float cloudIntensity = 15.0;
// Efekt lustrzanego odbicia
vec2 mirroredSt = vec2(1.0 - st.x, st.y);
mirroredSt.x += u_time * 0.07;
vec3 mirroredColor = vec3(0.0);
mirroredColor += fbm(mirroredSt * cloudIntensity);
st.x -= u_time * 0.07;
// Efekt oryginalny
vec3 color = vec3(0.0);
color += fbm(st * cloudIntensity);
// Dodaj gradientowe mieszanie miêdzy orygina³em a lustrzanym odbiciem
float gradient = smoothstep(0.45, 0.55, st.x);
vec3 finalColor = mix(color, mirroredColor, gradient);
outColor = vec4(finalColor, 1.0);
*/
vec2 st = vtc;
st.x -= u_time * 0.07;
vec3 color = vec3(0.0);
color += fbm(st*10.0);
//vec3 mixedColor = mix(vec3(0.4), color, color.r);
//color = mix(vec3(1.0), fbm(st*3.0), 0.1);
outColor = vec4(color,1.0);
}

View File

@ -1,23 +1,23 @@
#version 430 core
float AMBIENT = 0.25f;
float PI = 3.14159f;
float AMBIENT = 0.05;
float PI = 3.14159;
uniform sampler2D depthMap;
uniform sampler2D colorTexture;
uniform float exposition;
uniform float metallic;
uniform float roughness;
uniform vec3 cameraPos;
uniform sampler2D colorTexture; //planet texture
uniform vec3 sunDir;
uniform vec3 sunColor;
uniform vec3 lightPos;
uniform vec3 lightColor;
uniform float metallic; //pbr
uniform float roughness; //pbr
uniform float exposition; //pbr
uniform bool atmosphereCheck;
uniform float u_time;
uniform float cloudLight;
@ -34,8 +34,6 @@ in vec3 viewDirTS;
in vec3 lightDirTS;
in vec3 sunDirTS;
vec4 textureColor;
float DistributionGGX(vec3 normal, vec3 H, float roughness)
{
float a = roughness * roughness;
@ -105,7 +103,7 @@ vec3 PBRLight(vec3 lightDir, vec3 radiance, vec3 normal, vec3 V, vec3 color)
vec3 toneMapping(vec3 color)
{
float exposure = 0.03;
float exposure = 0.06;
vec3 mapped = 1 - exp(-color * exposure);
return mapped;
}
@ -172,22 +170,23 @@ vec4 noiseColor() {
return noiseColor;
}
void main() {
vec3 normal = normalize(vecNormal);
vec3 viewDir = normalize(cameraPos - worldPos);
vec3 lightDir = normalize(lightPos - worldPos);
vec4 textureColor = texture2D(colorTexture, vtc);
float diffuse = max(0, dot(normal, lightDir));
vec3 distance = lightColor / pow(length(lightPos - worldPos), 2.0) * 300;
vec3 toneMappedColor = toneMapping(vec3(textureColor) * min(1, AMBIENT + diffuse) * distance);
float atmosphereDot = dot(normal, viewDir);
vec3 atmosphereColor = vec3(0.04, 0.2, 1.0);
if (atmosphereCheck)
textureColor = mix(textureColor, vec4(atmosphereColor / atmosphereDot, 1.0), 0.1);
vec3 distance = lightColor / pow(length(lightPos - worldPos), 2.0) * 10;
vec3 toneMappedColor = toneMapping(vec3(textureColor) * distance);
//gamma correction
//toneMappedColor = pow(toneMappedColor, vec3(1.0/2.2));
toneMappedColor = pow(toneMappedColor, vec3(1.0/2.2));
vec3 ambient = AMBIENT * toneMappedColor;
vec3 attenuatedLightColor = lightColor / pow(length(lightPos - worldPos), 2);
@ -197,11 +196,11 @@ void main() {
//sun
illumination = illumination + PBRLight(sunDir, sunColor, normal, viewDir, toneMappedColor);
textureColor = vec4(vec3(1.0) - exp(-illumination * exposition), 1);
vec3 pbrColor = vec3(1.0) - exp(-illumination * exposition);
vec4 noiseColor = noiseColor() * min(1, AMBIENT + diffuse) * vec4(lightColor, 0.0) / cloudLight;
vec3 mixedColor = mix(textureColor.rgb, noiseColor.rgb, noiseColor.r);
vec3 mixedColor = mix(pbrColor.rgb, noiseColor.rgb, noiseColor.r);
outColor = vec4(mixedColor * min(1, AMBIENT + diffuse), 1.0);
outColor = vec4(mixedColor, 1.0);
}

View File

@ -10,5 +10,5 @@ out vec4 out_color;
void main()
{
vec4 textureColor = texture(skybox, texCoord);
out_color = vec4(vec3(textureColor) * lightColor * 0.3f, 1.0f);
out_color = vec4(vec3(textureColor) * lightColor * 0.35f, 1.0f);
}

View File

@ -1,13 +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 viewProjectionMatrix;
uniform mat4 modelMatrix;
void main()
{
gl_Position = viewProjectionMatrix * modelMatrix * vec4(vertexPosition, 1.0);
}

View File

@ -1,10 +1,12 @@
#version 430 core
float AMBIENT = 0.1;
uniform vec3 lightPos;
uniform vec3 lightColor;
uniform vec3 cameraPos;
uniform bool atmosphereCheck;
in vec3 vecNormal;
in vec3 worldPos;
in vec2 vtc;
@ -13,8 +15,30 @@ out vec4 outColor;
uniform sampler2D colorTexture;
vec3 toneMapping(vec3 color)
{
float exposure = 0.06;
vec3 mapped = 1 - exp(-color * exposure);
return mapped;
}
void main()
{
vec3 normal = normalize(vecNormal);
vec3 viewDir = normalize(cameraPos - worldPos);
vec4 textureColor = texture2D(colorTexture, vtc);
outColor = vec4(vec3(textureColor) * lightColor * 0.15f, 1.0);
float atmosphereDot = dot(normal, viewDir);
vec3 atmosphereColor = vec3(1.0, 0.04, 0.01);
if (atmosphereCheck)
textureColor = mix(textureColor, vec4(atmosphereColor / atmosphereDot, 1.0), 0.25);
vec3 distance = lightColor / pow(length(lightPos - worldPos), 2.0) * 25;
vec3 toneMappedColor = toneMapping(vec3(textureColor) * distance);
//gamma correction
toneMappedColor = pow(toneMappedColor, vec3(1.0/2.2));
outColor = vec4(toneMappedColor * lightColor * 0.2f, 1.0);
}

View File

@ -13,6 +13,9 @@ out vec2 vtc;
void main()
{
worldPos = (modelMatrix * vec4(vertexPosition, 1)).xyz;
vecNormal = (modelMatrix * vec4(vertexNormal, 0)).xyz;
gl_Position = transformation * vec4(vertexPosition, 1.0);
vtc = vec2(vertexTexCoord.x, 1.0 - vertexTexCoord.y);
}

View File

@ -1,19 +1,22 @@
#version 430 core
float AMBIENT = 0.1;
float AMBIENT = 0.05;
uniform sampler2D colorTexture;
uniform vec3 color;
uniform vec3 lightPos;
uniform vec3 lightColor;
uniform vec3 cameraPos;
uniform bool atmosphereCheck;
in vec3 vecNormal;
in vec3 worldPos;
in vec2 vtc;
vec4 textureColor;
out vec4 outColor;
vec3 outputColor;
uniform sampler2D colorTexture;
out vec4 outColor;
vec3 toneMapping(vec3 color)
{
@ -24,17 +27,24 @@ vec3 toneMapping(vec3 color)
void main()
{
vec3 lightDir = normalize(lightPos - worldPos);
vec3 normal = normalize(vecNormal);
vec3 viewDir = normalize(cameraPos - worldPos);
vec3 lightDir = normalize(lightPos - worldPos);
float diffuse = max(0, dot(normal, lightDir));
textureColor = texture2D(colorTexture, vtc);
vec3 distance = lightColor / pow(length(lightPos - worldPos), 2.0) * 200;
outputColor = vec3(textureColor) * min(1, AMBIENT + diffuse) * distance;
vec4 textureColor = texture2D(colorTexture, vtc);
//gamma correction
//outputColor = pow(outputColor, vec3(1.0/2.2));
float atmosphereDot = dot(normal, viewDir);
vec3 atmosphereColor = vec3(0.04, 0.2, 1.0);
outputColor = toneMapping(outputColor);
outColor = vec4(outputColor , 1.0);
if (atmosphereCheck)
textureColor = mix(textureColor, vec4(atmosphereColor / atmosphereDot, 1.0), 0.05);
vec3 distance = lightColor / pow(length(lightPos - worldPos), 2.0) * 10000;
vec3 toneMappedColor = toneMapping(vec3(textureColor) * min(1, AMBIENT + diffuse) * distance);
//gamma correction
//toneMappedColor = pow(toneMappedColor, vec3(1.0/2.2));
outColor = vec4(toneMappedColor, 1);
}

View File

@ -1,12 +0,0 @@
#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);
}

View File

@ -1,14 +0,0 @@
#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);
}

View File

@ -14,12 +14,10 @@
#include <assimp/postprocess.h>
#include <string>
GLuint programDepth;
GLuint programTex;
GLuint programPbr;
GLuint programSun;
GLuint programSkyBox;
GLuint programNoise;
Core::Shader_Loader shaderLoader;
@ -48,6 +46,9 @@ glm::vec3 sunPos = glm::vec3(20.f, 0.f, 20.f);
glm::vec3 sunDir = glm::vec3(1.f, 0.f, 1.f);
float sunSize = 0.05f;
bool atmosphereCheck = false;
bool lightingCheck = false;
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" };
GLuint skyBoxTex;
@ -70,7 +71,7 @@ unsigned int depthMapFBO;
int HDR_WIDTH = 1024;
int HDR_HEIGHT = 1024;
float lightPower = 10.f;
float lightPower = 8.f;
glm::vec3 lightColor = glm::vec3(lightPower, lightPower, lightPower);
float cloudLight = 20.f;
@ -155,45 +156,26 @@ void initDepthMap() {
glBindFramebuffer(GL_FRAMEBUFFER, 0);
}
void drawPlanet(Core::RenderContext& context, glm::mat4 modelMatrix, GLuint texture) {
void drawPlanetTex(Core::RenderContext& context, glm::mat4 modelMatrix, GLuint texture) {
glUseProgram(programTex);
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);
glUniform3f(glGetUniformLocation(programTex, "lightPos"), sunPos.x, sunPos.y, sunPos.z);
glUniform3f(glGetUniformLocation(programTex, "lightColor"), lightColor.x, lightColor.y, lightColor.z);
glUniform3f(glGetUniformLocation(programPbr, "cameraPos"), cameraPos.x, cameraPos.y, cameraPos.z);
glUniform1i(glGetUniformLocation(programPbr, "atmosphereCheck"), atmosphereCheck);
Core::DrawContext(context);
glUseProgram(0);
}
void drawSun(Core::RenderContext& context, glm::mat4 modelMatrix, GLuint texture) {
glUseProgram(programSun);
Core::SetActiveTexture(texture, "colorTexture", programSun, 0);
glm::mat4 viewProjectionMatrix = createPerspectiveMatrix() * createCameraMatrix();
glm::mat4 transformation = viewProjectionMatrix * modelMatrix;
glUniformMatrix4fv(glGetUniformLocation(programSun, "transformation"), 1, GL_FALSE, (float*)&transformation);
glUniformMatrix4fv(glGetUniformLocation(programSun, "modelMatrix"), 1, GL_FALSE, (float*)&modelMatrix);
glUniform3f(glGetUniformLocation(programSun, "lightPos"), sunPos.x, sunPos.y, sunPos.z);
glUniform3f(glGetUniformLocation(programSun, "lightColor"), lightColor.x, lightColor.y, lightColor.z);
Core::DrawContext(context);
glUseProgram(0);
}
void drawSkyBox(Core::RenderContext& context, glm::mat4 modelMatrix, GLuint texture) {
glUseProgram(programSkyBox);
Core::SetActiveSkyBox(texture, "skybox", programSkyBox, 0);
glm::mat4 viewProjectionMatrix = createPerspectiveMatrix() * createCameraMatrix();
glm::mat4 transformation = viewProjectionMatrix * modelMatrix;
glUniformMatrix4fv(glGetUniformLocation(programSkyBox, "transformation"), 1, GL_FALSE, (float*)&transformation);
glUniformMatrix4fv(glGetUniformLocation(programSkyBox, "modelMatrix"), 1, GL_FALSE, (float*)&modelMatrix);
glUniform3f(glGetUniformLocation(programSkyBox, "lightColor"), lightColor.x, lightColor.y, lightColor.z);
Core::DrawContext(context);
glUseProgram(0);
}
void drawObjectPBR(Core::RenderContext& context, glm::mat4 modelMatrix, GLuint texture, float roughness, float metallic) {
void drawPlanetPbr(Core::RenderContext& context, glm::mat4 modelMatrix, GLuint texture) {
glUseProgram(programPbr);
Core::SetActiveTexture(texture, "colorTexture", programPbr, 0);
glm::mat4 viewProjectionMatrix = createPerspectiveMatrix() * createCameraMatrix();
@ -202,9 +184,8 @@ void drawObjectPBR(Core::RenderContext& context, glm::mat4 modelMatrix, GLuint t
glUniformMatrix4fv(glGetUniformLocation(programPbr, "modelMatrix"), 1, GL_FALSE, (float*)&modelMatrix);
glUniform1f(glGetUniformLocation(programPbr, "exposition"), lightPower);
glUniform1f(glGetUniformLocation(programPbr, "roughness"), roughness);
glUniform1f(glGetUniformLocation(programPbr, "metallic"), metallic);
glUniform1f(glGetUniformLocation(programPbr, "roughness"), planetRough);
glUniform1f(glGetUniformLocation(programPbr, "metallic"), planetMetal);
glUniform3f(glGetUniformLocation(programPbr, "cameraPos"), cameraPos.x, cameraPos.y, cameraPos.z);
@ -220,12 +201,47 @@ void drawObjectPBR(Core::RenderContext& context, glm::mat4 modelMatrix, GLuint t
glUniform1f(glGetUniformLocation(programPbr, "cloudIntensity"), cloudIntensity);
glUniform1f(glGetUniformLocation(programPbr, "cloudSpeed"), cloudSpeed);
glUniform1i(glGetUniformLocation(programPbr, "atmosphereCheck"), atmosphereCheck);
Core::DrawContext(context);
glUseProgram(0);
}
void drawSun(Core::RenderContext& context, glm::mat4 modelMatrix, GLuint texture) {
glUseProgram(programSun);
Core::SetActiveTexture(texture, "colorTexture", programSun, 0);
glm::mat4 viewProjectionMatrix = createPerspectiveMatrix() * createCameraMatrix();
glm::mat4 transformation = viewProjectionMatrix * modelMatrix;
glUniformMatrix4fv(glGetUniformLocation(programSun, "transformation"), 1, GL_FALSE, (float*)&transformation);
glUniformMatrix4fv(glGetUniformLocation(programSun, "modelMatrix"), 1, GL_FALSE, (float*)&modelMatrix);
glUniform3f(glGetUniformLocation(programSun, "lightPos"), sunPos.x, sunPos.y, sunPos.z);
glUniform3f(glGetUniformLocation(programSun, "lightColor"), lightColor.x, lightColor.y, lightColor.z);
glUniform3f(glGetUniformLocation(programPbr, "cameraPos"), cameraPos.x, cameraPos.y, cameraPos.z);
glUniform1i(glGetUniformLocation(programPbr, "atmosphereCheck"), atmosphereCheck);
Core::DrawContext(context);
glUseProgram(0);
}
void drawSkyBox(Core::RenderContext& context, glm::mat4 modelMatrix, GLuint texture) {
glUseProgram(programSkyBox);
Core::SetActiveSkyBox(texture, "skybox", programSkyBox, 0);
glm::mat4 viewProjectionMatrix = createPerspectiveMatrix() * createCameraMatrix();
glm::mat4 transformation = viewProjectionMatrix * modelMatrix;
glUniformMatrix4fv(glGetUniformLocation(programSkyBox, "transformation"), 1, GL_FALSE, (float*)&transformation);
glUniformMatrix4fv(glGetUniformLocation(programSkyBox, "modelMatrix"), 1, GL_FALSE, (float*)&modelMatrix);
glUniform3f(glGetUniformLocation(programSkyBox, "lightColor"), lightColor.x, lightColor.y, lightColor.z);
Core::DrawContext(context);
glUseProgram(0);
}
void renderScene(GLFWwindow* window) {
glClearColor(0.5f, 0.0f, 0.25f, 1.0f);
glClearColor(0.0f, 0.0f, 0.0f, 1.0f);
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
float time = glfwGetTime();
@ -234,10 +250,10 @@ void renderScene(GLFWwindow* window) {
glm::mat4 planetRotate = glm::rotate(time * planetRot, glm::vec3(0, 1, 0));
glm::mat4 planetTranslate = glm::translate(planetPos);
glm::mat4 planetMatrix = planetTranslate * planetRotate * planetScale;
//rysowanie planety
drawObjectPBR(sphereContext, planetMatrix, planetTex, planetRough, planetMetal);
if (lightingCheck)
drawPlanetPbr(sphereContext, planetTranslate * planetRotate * planetScale, planetTex);
else
drawPlanetTex(sphereContext, planetTranslate * planetRotate * planetScale, planetTex);
//rysowanie słońca
glm::mat4 sunScale = glm::scale(glm::vec3(sunSize));
@ -272,36 +288,27 @@ void loadModelToContext(std::string path, Core::RenderContext& context) {
context.initFromAssimpMesh(scene->mMeshes[0]);
}
void init(GLFWwindow* window) {
glfwSetFramebufferSizeCallback(window, framebuffer_size_callback);
void key_callback(GLFWwindow* window, int key, int scancode, int action, int mods)
{
//tekstura planety
if (key == GLFW_KEY_T && action == GLFW_PRESS)
planetTex = Core::LoadTexture(planetTexPaths[std::abs(++planetTexIndex % 20)]);
if (key == GLFW_KEY_Y && action == GLFW_PRESS && planetTexIndex > 0)
planetTex = Core::LoadTexture(planetTexPaths[std::abs(--planetTexIndex % 20)]);
glEnable(GL_DEPTH_TEST);
//glDisable(GL_DEPTH_TEST);
//tekstura słońca
if (key == GLFW_KEY_U && action == GLFW_PRESS)
sunTex = Core::LoadTexture(sunTexPaths[std::abs(++sunTexIndex % 5)]);
if (key == GLFW_KEY_I && action == GLFW_PRESS && sunTexIndex > 0)
sunTex = Core::LoadTexture(sunTexPaths[std::abs(--sunTexIndex % 5)]);
//initDepthMap();
initHDR();
//programDepth = shaderLoader.CreateProgram("shaders/shader_smap.vert", "shaders/shader_smap.frag");
programTex = shaderLoader.CreateProgram("shaders/shader_tex.vert", "shaders/shader_tex.frag");
programPbr = shaderLoader.CreateProgram("shaders/shader_pbr.vert", "shaders/shader_pbr.frag");
programSun = shaderLoader.CreateProgram("shaders/shader_sun.vert", "shaders/shader_sun.frag");
programSkyBox = shaderLoader.CreateProgram("shaders/shader_skybox.vert", "shaders/shader_skybox.frag");
//atmosfera
if (key == GLFW_KEY_O && action == GLFW_PRESS)
atmosphereCheck = !atmosphereCheck;
loadModelToContext("./models/sphere.obj", sphereContext);
loadModelToContext("./models/cube.obj", cubeContext);
planetTex = Core::LoadTexture(planetTexPaths[std::abs(planetTexIndex % 20)]);
sunTex = Core::LoadTexture(sunTexPaths[std::abs(sunTexIndex % 5)]);
skyBoxTex = Core::LoadSkyBox(skyBoxPaths);
}
void shutdown(GLFWwindow* window) {
shaderLoader.DeleteProgram(programDepth);
shaderLoader.DeleteProgram(programTex);
shaderLoader.DeleteProgram(programPbr);
shaderLoader.DeleteProgram(programSun);
shaderLoader.DeleteProgram(programSkyBox);
//typ światła
if (key == GLFW_KEY_P && action == GLFW_PRESS)
lightingCheck = !lightingCheck;
}
//obsluga wejscia
@ -311,7 +318,7 @@ void processInput(GLFWwindow* window)
if (glfwGetKey(window, GLFW_KEY_ESCAPE) == GLFW_PRESS)
glfwSetWindowShouldClose(window, true);
//ruch kamerą
//ruch kamery
glm::vec3 cameraSide = glm::normalize(glm::cross(cameraDir, glm::vec3(0.f, 1.f, 0.f)));
float cameraSpeed = 0.02f;
@ -342,32 +349,12 @@ void processInput(GLFWwindow* window)
if (glfwGetKey(window, GLFW_KEY_LEFT) == GLFW_PRESS && planetRot > -1.f)
planetRot -= rotationSpeed;
//zmiana tekstury planety
if (glfwGetKey(window, GLFW_KEY_T) == GLFW_PRESS) {
planetTex = Core::LoadTexture(planetTexPaths[std::abs(++planetTexIndex % 20)]);
Sleep(200);
}
if (glfwGetKey(window, GLFW_KEY_Y) == GLFW_PRESS && planetTexIndex > 0) {
planetTex = Core::LoadTexture(planetTexPaths[std::abs(--planetTexIndex % 20)]);
Sleep(200);
}
//zmiana tekstury słońca
if (glfwGetKey(window, GLFW_KEY_U) == GLFW_PRESS) {
sunTex = Core::LoadTexture(sunTexPaths[std::abs(++sunTexIndex % 5)]);
Sleep(200);
}
if (glfwGetKey(window, GLFW_KEY_I) == GLFW_PRESS && sunTexIndex > 0) {
sunTex = Core::LoadTexture(sunTexPaths[std::abs(--sunTexIndex % 5)]);
Sleep(200);
}
//jasność
float powerSpeed = 0.05f;
if (glfwGetKey(window, GLFW_KEY_1) == GLFW_PRESS && lightPower < 25.f)
if (glfwGetKey(window, GLFW_KEY_1) == GLFW_PRESS && lightPower < 16.f)
lightPower += powerSpeed;
if (glfwGetKey(window, GLFW_KEY_2) == GLFW_PRESS && lightPower > 2.5f)
if (glfwGetKey(window, GLFW_KEY_2) == GLFW_PRESS && lightPower > 2.f)
lightPower -= powerSpeed;
lightColor = glm::vec3(lightPower, lightPower, lightPower);
@ -389,6 +376,38 @@ void processInput(GLFWwindow* window)
planetMetal -= metalSpeed;
}
void init(GLFWwindow* window) {
glfwSetFramebufferSizeCallback(window, framebuffer_size_callback);
glEnable(GL_DEPTH_TEST);
//glDisable(GL_DEPTH_TEST);
//initDepthMap();
//initHDR();
glfwSetKeyCallback(window, key_callback);
programTex = shaderLoader.CreateProgram("shaders/shader_tex.vert", "shaders/shader_tex.frag");
programPbr = shaderLoader.CreateProgram("shaders/shader_pbr.vert", "shaders/shader_pbr.frag");
programSun = shaderLoader.CreateProgram("shaders/shader_sun.vert", "shaders/shader_sun.frag");
programSkyBox = shaderLoader.CreateProgram("shaders/shader_skybox.vert", "shaders/shader_skybox.frag");
loadModelToContext("./models/sphere.obj", sphereContext);
loadModelToContext("./models/cube.obj", cubeContext);
planetTex = Core::LoadTexture(planetTexPaths[std::abs(planetTexIndex % 20)]);
sunTex = Core::LoadTexture(sunTexPaths[std::abs(sunTexIndex % 5)]);
skyBoxTex = Core::LoadSkyBox(skyBoxPaths);
}
void shutdown(GLFWwindow* window) {
shaderLoader.DeleteProgram(programTex);
shaderLoader.DeleteProgram(programPbr);
shaderLoader.DeleteProgram(programSun);
shaderLoader.DeleteProgram(programSkyBox);
}
// funkcja jest glowna petla
void renderLoop(GLFWwindow* window) {
while (!glfwWindowShouldClose(window))

View File

@ -20,14 +20,3 @@ Bloom poświata (bardzo wazne, najlepiej od tego zaczac)
*Atmospheric Scattering Shader
Perlin noise atmosfera, chmury (bardzo wazne najlepiej od tego zaczac, wszyscy musza to miec opanowane :) )
? Parallel Transport Frames animacja (raczej nie bedzie potrzebne)
Sterowanie:
W/S - przybliżanie kamery
A/D - obrót kamery
UP/DOWN - wielkość planety
LEFT/RIGHT - obrót planety
T/Y - tekstura planety
U/I - tekstura słońca
1/2 - jasność
3/4 - chropowatość
5/6 - metaliczność

15
sterowanie.txt Normal file
View File

@ -0,0 +1,15 @@
W/S - przybliżanie kamery
A/D - obrót kamery
UP/DOWN - wielkość planety
LEFT/RIGHT - obrót planety
T/Y - tekstura planety
U/I - tekstura słońca
1/2 - jasność
3/4 - chropowatość
5/6 - metaliczność
O - atmosfera
P - typ oświetlenia

View File

@ -1,8 +1,9 @@
na 29.01.2024
na 08.02 / 09.02
https://andkok.faculty.wmi.amu.edu.pl/grk/
Do zrobienia:
- pbr (done)
- bloom
- perlin noise
- perlin noise
- więcej interakcji?
- lepsze tekstury i multitexturing?