sun is sunning #1

Merged
s473581 merged 1 commits from sun into master 2024-01-14 19:45:31 +01:00
29 changed files with 80 additions and 57 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.

View File

@ -1,23 +1,10 @@
c:\users\andrzej\desktop\grk\2021\grk glfw test\cw 6\debug\vc142.pdb e:\micha\studia\grafika_komputerowa\grk\grk\cw 6\debug\vc142.pdb
c:\users\andrzej\desktop\grk\2021\grk glfw test\cw 6\debug\vc142.idb e:\micha\studia\grafika_komputerowa\grk\grk\cw 6\debug\vc142.idb
c:\users\andrzej\desktop\grk\2021\grk glfw test\cw 6\debug\texture.obj e:\micha\studia\grafika_komputerowa\grk\grk\cw 6\debug\texture.obj
c:\users\andrzej\desktop\grk\2021\grk glfw test\cw 6\debug\shader_loader.obj e:\micha\studia\grafika_komputerowa\grk\grk\cw 6\debug\shader_loader.obj
c:\users\andrzej\desktop\grk\2021\grk glfw test\cw 6\debug\render_utils.obj e:\micha\studia\grafika_komputerowa\grk\grk\cw 6\debug\render_utils.obj
c:\users\andrzej\desktop\grk\2021\grk glfw test\cw 6\debug\main.obj e:\micha\studia\grafika_komputerowa\grk\grk\cw 6\debug\camera.obj
c:\users\andrzej\desktop\grk\2021\grk glfw test\cw 6\debug\camera.obj e:\micha\studia\grafika_komputerowa\grk\grk\cw 6\debug\box.obj
c:\users\andrzej\desktop\grk\2021\grk glfw test\cw 6\debug\box.obj e:\micha\studia\grafika_komputerowa\grk\grk\cw 6\debug\grk-cw6.tlog\cl.read.1.tlog
c:\users\andrzej\desktop\grk\2021\grk glfw test\cw 6\debug\stb_image_aug.obj e:\micha\studia\grafika_komputerowa\grk\grk\cw 6\debug\grk-cw6.tlog\cl.write.1.tlog
c:\users\andrzej\desktop\grk\2021\grk glfw test\cw 6\debug\soil.obj e:\micha\studia\grafika_komputerowa\grk\grk\cw 6\debug\grk-cw6.tlog\cl.command.1.tlog
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

View File

@ -2,7 +2,7 @@
<Project> <Project>
<ProjectOutputs> <ProjectOutputs>
<ProjectOutput> <ProjectOutput>
<FullPath>j:\Downloads\grk\Debug\grk-cw6.exe</FullPath> <FullPath>E:\micha\studia\grafika_komputerowa\grk\grk\Debug\grk-cw6.exe</FullPath>
</ProjectOutput> </ProjectOutput>
</ProjectOutputs> </ProjectOutputs>
<ContentFiles /> <ContentFiles />

View File

@ -1,39 +1,39 @@
C:\software\vs19\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. 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 main.cpp
C:\Program Files (x86)\Windows Kits\10\Include\10.0.19041.0\shared\minwindef.h(130,1): warning C4005: 'APIENTRY': macro redefinition C:\Program Files (x86)\Windows Kits\10\Include\10.0.19041.0\shared\minwindef.h(130,1): warning C4005: 'APIENTRY': macro redefinition
j:\Downloads\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\dependencies\glfw-3.3.8.bin.WIN32\include\GLFW\glfw3.h(123): message : see previous definition of 'APIENTRY'
j:\Downloads\grk\cw 6\src\ex_6_1.hpp(92,16): warning C4305: 'initializing': truncation from 'double' to 'float' E:\micha\studia\grafika_komputerowa\grk\grk\cw 6\src\ex_6_1.hpp(96,16): warning C4305: 'initializing': truncation from 'double' to 'float'
j:\Downloads\grk\cw 6\src\ex_6_1.hpp(135,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(152,13): warning C4244: 'initializing': conversion from 'double' to 'float', possible loss of data
j:\Downloads\grk\cw 6\src\ex_6_1.hpp(139,52): warning C4305: 'argument': truncation from 'double' to 'T' E:\micha\studia\grafika_komputerowa\grk\grk\cw 6\src\ex_6_1.hpp(156,52): warning C4305: 'argument': truncation from 'double' to 'T'
with with
[ [
T=float T=float
] ]
j:\Downloads\grk\cw 6\src\ex_6_1.hpp(143,50): warning C4305: 'argument': truncation from 'double' to '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'
with with
[ [
T=float T=float
] ]
j:\Downloads\grk\cw 6\src\ex_6_1.hpp(147,49): warning C4305: 'argument': truncation from 'double' to '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'
with with
[ [
T=float T=float
] ]
j:\Downloads\grk\cw 6\src\ex_6_1.hpp(151,48): warning C4305: 'argument': truncation from 'double' to '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'
with with
[ [
T=float T=float
] ]
j:\Downloads\grk\cw 6\src\ex_6_1.hpp(155,48): warning C4305: 'argument': truncation from 'double' to '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'
with with
[ [
T=float T=float
] ]
j:\Downloads\grk\cw 6\src\ex_6_1.hpp(159,48): warning C4305: 'argument': truncation from 'double' to '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'
with with
[ [
T=float T=float
] ]
Box.obj : warning LNK4075: ignoring '/EDITANDCONTINUE' due to '/INCREMENTAL:NO' specification 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 LINK : warning LNK4098: defaultlib 'MSVCRT' conflicts with use of other libs; use /NODEFAULTLIB:library
grk-cw6.vcxproj -> j:\Downloads\grk\Debug\grk-cw6.exe grk-cw6.vcxproj -> E:\micha\studia\grafika_komputerowa\grk\grk\Debug\grk-cw6.exe

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|j:\Downloads\grk\| Debug|Win32|E:\micha\studia\grafika_komputerowa\grk\grk\|

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

@ -7,18 +7,18 @@ uniform vec3 lightPos;
in vec3 vecNormal; in vec3 vecNormal;
in vec3 worldPos; in vec3 worldPos;
in vec2 vtc;
out vec4 outColor; out vec4 outColor;
in vec2 vTC;
uniform sampler2D colorTexture; uniform sampler2D colorTexture;
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));
vec4 textureColor = texture2D(colorTexture, vTC); vec4 textureColor = texture2D(colorTexture, vtc);
outColor = vec4(vec3(textureColor)*min(1,AMBIENT+diffuse), 1.0); outColor = vec4(vec3(textureColor) * min(1, AMBIENT + diffuse), 1.0);
} }

View File

@ -10,7 +10,7 @@ uniform mat4 modelMatrix;
out vec3 vecNormal; out vec3 vecNormal;
out vec3 worldPos; out vec3 worldPos;
out vec2 vTC; out vec2 vtc;
void main() void main()
{ {
@ -18,5 +18,5 @@ void main()
vecNormal = (modelMatrix* vec4(vertexNormal,0)).xyz; vecNormal = (modelMatrix* vec4(vertexNormal,0)).xyz;
gl_Position = transformation * vec4(vertexPosition, 1.0); 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 #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() 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

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

View File

@ -24,6 +24,7 @@ namespace texture {
GLuint mercury; GLuint mercury;
GLuint venus; GLuint venus;
GLuint mars; GLuint mars;
GLuint sun;
GLuint grid; GLuint grid;
@ -116,6 +117,19 @@ 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);
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); Core::DrawContext(context);
glUseProgram(0); glUseProgram(0);
} }
@ -164,14 +178,12 @@ void renderScene(GLFWwindow* window)
glm::mat4 shipTranslate = glm::translate(shipPos); glm::mat4 shipTranslate = glm::translate(shipPos);
glUseProgram(program); //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);
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, mercuryRotate * mercuryTranslate * mercuryScale, texture::mercury); //mercury
@ -212,6 +224,7 @@ void init(GLFWwindow* window)
glEnable(GL_DEPTH_TEST); glEnable(GL_DEPTH_TEST);
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_5_sun.vert", "shaders/shader_5_sun.frag");
loadModelToContext("./models/sphere.obj", sphereContext); loadModelToContext("./models/sphere.obj", sphereContext);
loadModelToContext("./models/spaceship.obj", shipContext); loadModelToContext("./models/spaceship.obj", shipContext);
@ -224,6 +237,7 @@ void init(GLFWwindow* window)
texture::mercury = Core::LoadTexture("./textures/mercury.jpg"); texture::mercury = Core::LoadTexture("./textures/mercury.jpg");
texture::venus = Core::LoadTexture("./textures/venus.jpg"); texture::venus = Core::LoadTexture("./textures/venus.jpg");
texture::mars = Core::LoadTexture("./textures/mars.jpg"); texture::mars = Core::LoadTexture("./textures/mars.jpg");
texture::sun = Core::LoadTexture("./textures/sun.jpg");
//texture::earthNormal = Core::LoadTexture("./textures/earth_normalmap.png"); //texture::earthNormal = Core::LoadTexture("./textures/earth_normalmap.png");
//texture::asteroidNormal = Core::LoadTexture("./textures/moon_normals.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