This commit is contained in:
Natalia Nowakowska 2024-01-14 21:51:16 +01:00
parent 895af708d0
commit 25ef5f6ca0
11 changed files with 64 additions and 42 deletions

Binary file not shown.

Binary file not shown.

View File

@ -1,23 +1,10 @@
c:\users\andrzej\desktop\grk\2021\grk glfw test\cw 6\debug\vc142.pdb
c:\users\andrzej\desktop\grk\2021\grk glfw test\cw 6\debug\vc142.idb
c:\users\andrzej\desktop\grk\2021\grk glfw test\cw 6\debug\texture.obj
c:\users\andrzej\desktop\grk\2021\grk glfw test\cw 6\debug\shader_loader.obj
c:\users\andrzej\desktop\grk\2021\grk glfw test\cw 6\debug\render_utils.obj
c:\users\andrzej\desktop\grk\2021\grk glfw test\cw 6\debug\main.obj
c:\users\andrzej\desktop\grk\2021\grk glfw test\cw 6\debug\camera.obj
c:\users\andrzej\desktop\grk\2021\grk glfw test\cw 6\debug\box.obj
c:\users\andrzej\desktop\grk\2021\grk glfw test\cw 6\debug\stb_image_aug.obj
c:\users\andrzej\desktop\grk\2021\grk glfw test\cw 6\debug\soil.obj
c:\users\andrzej\desktop\grk\2021\grk glfw test\cw 6\debug\image_helper.obj
c:\users\andrzej\desktop\grk\2021\grk glfw test\cw 6\debug\image_dxt.obj
c:\users\andrzej\desktop\grk\2021\grk glfw test\cw 6\debug\vcpkg.applocal.log
c:\users\andrzej\desktop\grk\2021\grk glfw test\debug\grk-cw6.exe
c:\users\andrzej\desktop\grk\2021\grk glfw test\debug\grk-cw6.pdb
c:\users\andrzej\desktop\grk\2021\grk glfw test\cw 6\debug\main_3_1.obj
c:\users\andrzej\desktop\grk\2021\grk glfw test\cw 6\debug\grk-cw6.tlog\cl.command.1.tlog
c:\users\andrzej\desktop\grk\2021\grk glfw test\cw 6\debug\grk-cw6.tlog\cl.read.1.tlog
c:\users\andrzej\desktop\grk\2021\grk glfw test\cw 6\debug\grk-cw6.tlog\cl.write.1.tlog
c:\users\andrzej\desktop\grk\2021\grk glfw test\cw 6\debug\grk-cw6.tlog\grk-cw6.write.1u.tlog
c:\users\andrzej\desktop\grk\2021\grk glfw test\cw 6\debug\grk-cw6.tlog\link.command.1.tlog
c:\users\andrzej\desktop\grk\2021\grk glfw test\cw 6\debug\grk-cw6.tlog\link.read.1.tlog
c:\users\andrzej\desktop\grk\2021\grk glfw test\cw 6\debug\grk-cw6.tlog\link.write.1.tlog
e:\micha\studia\grafika_komputerowa\grk\grk\cw 6\debug\vc142.pdb
e:\micha\studia\grafika_komputerowa\grk\grk\cw 6\debug\vc142.idb
e:\micha\studia\grafika_komputerowa\grk\grk\cw 6\debug\texture.obj
e:\micha\studia\grafika_komputerowa\grk\grk\cw 6\debug\shader_loader.obj
e:\micha\studia\grafika_komputerowa\grk\grk\cw 6\debug\render_utils.obj
e:\micha\studia\grafika_komputerowa\grk\grk\cw 6\debug\camera.obj
e:\micha\studia\grafika_komputerowa\grk\grk\cw 6\debug\box.obj
e:\micha\studia\grafika_komputerowa\grk\grk\cw 6\debug\grk-cw6.tlog\cl.read.1.tlog
e:\micha\studia\grafika_komputerowa\grk\grk\cw 6\debug\grk-cw6.tlog\cl.write.1.tlog
e:\micha\studia\grafika_komputerowa\grk\grk\cw 6\debug\grk-cw6.tlog\cl.command.1.tlog

Binary file not shown.

Binary file not shown.

View File

@ -7,18 +7,18 @@ uniform vec3 lightPos;
in vec3 vecNormal;
in vec3 worldPos;
in vec2 vtc;
out vec4 outColor;
in vec2 vTC;
uniform sampler2D colorTexture;
void main()
{
vec3 lightDir = normalize(lightPos-worldPos);
vec3 lightDir = normalize(lightPos - worldPos);
vec3 normal = normalize(vecNormal);
float diffuse=max(0,dot(normal,lightDir));
float diffuse = max(0, dot(normal, lightDir));
vec4 textureColor = texture2D(colorTexture, vTC);
outColor = vec4(vec3(textureColor)*min(1,AMBIENT+diffuse), 1.0);
vec4 textureColor = texture2D(colorTexture, vtc);
outColor = vec4(vec3(textureColor) * min(1, AMBIENT + diffuse), 1.0);
}

View File

@ -10,7 +10,7 @@ uniform mat4 modelMatrix;
out vec3 vecNormal;
out vec3 worldPos;
out vec2 vTC;
out vec2 vtc;
void main()
{
@ -18,5 +18,5 @@ void main()
vecNormal = (modelMatrix* vec4(vertexNormal,0)).xyz;
gl_Position = transformation * vec4(vertexPosition, 1.0);
vTC = vertexTexCoord;
vtc = vec2(vertexTexCoord.x, 1.0 - vertexTexCoord.y);
}

View File

@ -1,10 +1,25 @@
#version 430 core
uniform vec3 objectColor;
float AMBIENT = 0.1;
in vec3 interpNormal;
uniform vec3 color;
uniform vec3 lightPos;
in vec3 vecNormal;
in vec3 worldPos;
in vec2 vtc;
out vec4 outColor;
uniform sampler2D colorTexture;
void main()
{
gl_FragColor = vec4(objectColor, 1.0);
vec3 lightDir = normalize(lightPos - worldPos);
vec3 normal = normalize(vecNormal);
float diffuse = max(0, dot(normal, lightDir));
vec4 textureColor = texture2D(colorTexture, vtc);
outColor = vec4(vec3(textureColor) * min(1, AMBIENT + diffuse), 1.0) * 7.0;
}

View File

@ -5,11 +5,18 @@ layout(location = 1) in vec3 vertexNormal;
layout(location = 2) in vec2 vertexTexCoord;
uniform mat4 transformation;
uniform mat4 modelMatrix;
out vec3 interpNormal;
out vec3 vecNormal;
out vec3 worldPos;
out vec2 vtc;
void main()
{
worldPos = (modelMatrix * vec4(vertexPosition, 1)).xyz;
vecNormal = (modelMatrix * vec4(vertexNormal, 1)).xyz;
gl_Position = transformation * vec4(vertexPosition, 1.0);
interpNormal = vertexNormal;
//vtc = vec2(vertexTexCoord.x, 1.0 - vertexTexCoord.y);
vtc = vertexTexCoord;
}

View File

@ -29,6 +29,7 @@ namespace texture {
GLuint mercury;
GLuint venus;
GLuint mars;
GLuint sun;
GLuint grid;
@ -194,6 +195,19 @@ void drawObjectTexture(Core::RenderContext& context, glm::mat4 modelMatrix, GLui
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(program, "lightPos"), 0.0, 0.0, 0.0);
Core::DrawContext(context);
glUseProgram(0);
}
void drawSun(Core::RenderContext& context, glm::mat4 modelMatrix, GLuint texture) {
glUseProgram(programSun);
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);
Core::SetActiveTexture(texture, "colorTexture", programSun, 3);
glUniform3f(glGetUniformLocation(programSun, "lightPos"), 0, 0, 0);
Core::DrawContext(context);
glUseProgram(0);
}
@ -289,15 +303,13 @@ void renderScene(GLFWwindow* window)
glm::mat4 shipTranslate = glm::translate(shipPos);
glUseProgram(program);
//glUniform3f(glGetUniformLocation(program, "lightDir"), 1.0, -1.0, 0.0);
//glUniform3f(glGetUniformLocation(program, "lightColor"), lightColor.x, lightColor.y, lightColor.z);
//glUniform3f(glGetUniformLocation(program, "cameraPos"), cameraPos.x, cameraPos.y, cameraPos.z);
glUniform3f(glGetUniformLocation(program, "lightPos"), 0.0, 0.0, 0.0);
glUseProgram(0);
//glUseProgram(program);
drawObjectColor(sphereContext, sunScale, glm::vec3(0.9, 0.9, 0.2)); //sun
//glUniform3f(glGetUniformLocation(program, "lightPos"), 0.0, 0.0, 0.0);
//glUseProgram(0);
drawSun(sphereContext, sunScale, texture::sun);
drawObjectTexture(sphereContext, mercuryRotate * mercuryTranslate * mercuryScale, texture::mercury); //mercury
drawObjectTexture(sphereContext, venusRotate * venusTranslate * venusScale, texture::venus); //venus
@ -375,6 +387,7 @@ void init(GLFWwindow* window)
texture::mercury = Core::LoadTexture("./textures/mercury.jpg");
texture::venus = Core::LoadTexture("./textures/venus.jpg");
texture::mars = Core::LoadTexture("./textures/mars.jpg");
texture::sun = Core::LoadTexture("./textures/sun.jpg");
//texture::earthNormal = Core::LoadTexture("./textures/earth_normalmap.png");
//texture::asteroidNormal = Core::LoadTexture("./textures/moon_normals.png");

BIN
grk/cw 6/textures/sun.jpg Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 803 KiB