textura nałożona na słońce

This commit is contained in:
mikgaw@st.amu.edu.pl 2024-02-20 15:37:59 +01:00
parent 0e09f79575
commit dc63bd23de
21 changed files with 44 additions and 51 deletions

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

View File

@ -1,44 +1,9 @@
C:\Program Files\Microsoft Visual Studio\2022\Community\MSBuild\Microsoft\VC\v170\Microsoft.CppBuild.targets(531,5): warning MSB8028: Katalog pośredni (Debug\) zawiera pliki udostępnione z innego projektu (grk-cw3.vcxproj, grk-cw4.vcxproj, grk-cw5.vcxproj, grk-cw6.vcxproj, grk-cw7.vcxproj). Może to spowodować niepoprawne zachowanie podczas oczyszczania i ponownej kompilacji.
Box.cpp
Camera.cpp
main.cpp
C:\Program Files (x86)\Windows Kits\10\Include\10.0.22000.0\shared\minwindef.h(130,1): warning C4005: "APIENTRY": ponowna definicja makra
D:\STUDIA_sem5\GRAFIKA-PROJEKT\grk\dependencies\glfw-3.3.8.bin.WIN32\include\GLFW\glfw3.h(123,1): message : zobacz poprzednią definicję „APIENTRY”
D:\STUDIA_sem5\GRAFIKA-PROJEKT\grk\projekt_grk\src\ex_7_1.hpp(72,10): warning C4305: "inicjowanie": obcięcie z "double" do "float"
D:\STUDIA_sem5\GRAFIKA-PROJEKT\grk\projekt_grk\src\ex_7_1.hpp(119,13): warning C4244: "inicjowanie": konwersja z "double" do "float", możliwa utrata danych
Render_Utils.cpp
Shader_Loader.cpp
Texture.cpp
Generowanie kodu...
image_DXT.c
D:\STUDIA_sem5\GRAFIKA-PROJEKT\grk\projekt_grk\src\SOIL\image_DXT.c(92,9): warning C4996: 'fopen': This function or variable may be unsafe. Consider using fopen_s instead. To disable deprecation, use _CRT_SECURE_NO_WARNINGS. See online help for details.
image_helper.c
D:\STUDIA_sem5\GRAFIKA-PROJEKT\grk\projekt_grk\src\SOIL\image_helper.c(325,17): warning C4244: "inicjowanie": konwersja z "double" do "float", możliwa utrata danych
D:\STUDIA_sem5\GRAFIKA-PROJEKT\grk\projekt_grk\src\SOIL\image_helper.c(366,13): warning C4244: "=": konwersja z "double" do "float", możliwa utrata danych
D:\STUDIA_sem5\GRAFIKA-PROJEKT\grk\projekt_grk\src\SOIL\image_helper.c(373,20): warning C4244: "=": konwersja z "float" do "int", możliwa utrata danych
D:\STUDIA_sem5\GRAFIKA-PROJEKT\grk\projekt_grk\src\SOIL\image_helper.c(415,13): warning C4244: "=": konwersja z "double" do "float", możliwa utrata danych
D:\STUDIA_sem5\GRAFIKA-PROJEKT\grk\projekt_grk\src\SOIL\image_helper.c(422,20): warning C4244: "=": konwersja z "float" do "int", możliwa utrata danych
SOIL.c
D:\STUDIA_sem5\GRAFIKA-PROJEKT\grk\projekt_grk\src\SOIL\SOIL.c(1719,36): warning C4018: "<=": niezgodność typu ze znakiem/bez znaku
D:\STUDIA_sem5\GRAFIKA-PROJEKT\grk\projekt_grk\src\SOIL\SOIL.c(1729,19): warning C4018: "<": niezgodność typu ze znakiem/bez znaku
D:\STUDIA_sem5\GRAFIKA-PROJEKT\grk\projekt_grk\src\SOIL\SOIL.c(1841,6): warning C4996: 'fopen': This function or variable may be unsafe. Consider using fopen_s instead. To disable deprecation, use _CRT_SECURE_NO_WARNINGS. See online help for details.
stb_image_aug.c
D:\STUDIA_sem5\GRAFIKA-PROJEKT\grk\projekt_grk\src\SOIL\stb_image_aug.c(177,14): warning C4996: 'fopen': This function or variable may be unsafe. Consider using fopen_s instead. To disable deprecation, use _CRT_SECURE_NO_WARNINGS. See online help for details.
D:\STUDIA_sem5\GRAFIKA-PROJEKT\grk\projekt_grk\src\SOIL\stb_image_aug.c(251,14): warning C4996: 'fopen': This function or variable may be unsafe. Consider using fopen_s instead. To disable deprecation, use _CRT_SECURE_NO_WARNINGS. See online help for details.
D:\STUDIA_sem5\GRAFIKA-PROJEKT\grk\projekt_grk\src\SOIL\stb_image_aug.c(303,14): warning C4996: 'fopen': This function or variable may be unsafe. Consider using fopen_s instead. To disable deprecation, use _CRT_SECURE_NO_WARNINGS. See online help for details.
D:\STUDIA_sem5\GRAFIKA-PROJEKT\grk\projekt_grk\src\SOIL\stb_image_aug.c(1557,14): warning C4996: 'fopen': This function or variable may be unsafe. Consider using fopen_s instead. To disable deprecation, use _CRT_SECURE_NO_WARNINGS. See online help for details.
D:\STUDIA_sem5\GRAFIKA-PROJEKT\grk\projekt_grk\src\SOIL\stb_image_aug.c(2394,14): warning C4996: 'fopen': This function or variable may be unsafe. Consider using fopen_s instead. To disable deprecation, use _CRT_SECURE_NO_WARNINGS. See online help for details.
D:\STUDIA_sem5\GRAFIKA-PROJEKT\grk\projekt_grk\src\SOIL\stb_image_aug.c(2709,14): warning C4996: 'fopen': This function or variable may be unsafe. Consider using fopen_s instead. To disable deprecation, use _CRT_SECURE_NO_WARNINGS. See online help for details.
D:\STUDIA_sem5\GRAFIKA-PROJEKT\grk\projekt_grk\src\SOIL\stb_image_aug.c(2995,14): warning C4996: 'fopen': This function or variable may be unsafe. Consider using fopen_s instead. To disable deprecation, use _CRT_SECURE_NO_WARNINGS. See online help for details.
D:\STUDIA_sem5\GRAFIKA-PROJEKT\grk\projekt_grk\src\SOIL\stb_image_aug.c(3209,14): warning C4996: 'fopen': This function or variable may be unsafe. Consider using fopen_s instead. To disable deprecation, use _CRT_SECURE_NO_WARNINGS. See online help for details.
D:\STUDIA_sem5\GRAFIKA-PROJEKT\grk\projekt_grk\src\SOIL\stb_image_aug.c(3548,14): warning C4996: 'fopen': This function or variable may be unsafe. Consider using fopen_s instead. To disable deprecation, use _CRT_SECURE_NO_WARNINGS. See online help for details.
D:\STUDIA_sem5\GRAFIKA-PROJEKT\grk\projekt_grk\src\SOIL\stb_image_aug.c(3644,14): warning C4996: 'fopen': This function or variable may be unsafe. Consider using fopen_s instead. To disable deprecation, use _CRT_SECURE_NO_WARNINGS. See online help for details.
D:\STUDIA_sem5\GRAFIKA-PROJEKT\grk\projekt_grk\src\SOIL\stbi_DDS_aug_c.h(362,19): warning C4018: ">": niezgodność typu ze znakiem/bez znaku
D:\STUDIA_sem5\GRAFIKA-PROJEKT\grk\projekt_grk\src\SOIL\stbi_DDS_aug_c.h(366,19): warning C4018: ">": niezgodność typu ze znakiem/bez znaku
D:\STUDIA_sem5\GRAFIKA-PROJEKT\grk\projekt_grk\src\SOIL\stbi_DDS_aug_c.h(390,19): warning C4018: "<": niezgodność typu ze znakiem/bez znaku
D:\STUDIA_sem5\GRAFIKA-PROJEKT\grk\projekt_grk\src\SOIL\stbi_DDS_aug_c.h(427,19): warning C4018: "<": niezgodność typu ze znakiem/bez znaku
D:\STUDIA_sem5\GRAFIKA-PROJEKT\grk\projekt_grk\src\SOIL\stbi_DDS_aug_c.h(498,14): warning C4996: 'fopen': This function or variable may be unsafe. Consider using fopen_s instead. To disable deprecation, use _CRT_SECURE_NO_WARNINGS. See online help for details.
Generowanie kodu...
D:\STUDIA_sem5\GRAFIKA-PROJEKT\grk\projekt_grk\src\ex_7_1.hpp(76,10): warning C4305: "inicjowanie": obcięcie z "double" do "float"
D:\STUDIA_sem5\GRAFIKA-PROJEKT\grk\projekt_grk\src\ex_7_1.hpp(147,13): warning C4244: "inicjowanie": konwersja z "double" do "float", możliwa utrata danych
Box.obj : warning LNK4075: zignorowano opcję „/EDITANDCONTINUE” z powodu określenia opcji „/INCREMENTAL:NO”
LINK : warning LNK4098: domyślna biblioteka „MSVCRT” powoduje konflikt z innymi bibliotekami; użyj opcji /NODEFAULTLIB:biblioteka
grk-cw7.vcxproj -> D:\STUDIA_sem5\GRAFIKA-PROJEKT\grk\Debug\projekt_grk.exe

Binary file not shown.

Binary file not shown.

Binary file not shown.

View File

@ -1,10 +1,15 @@
#version 430 core
uniform vec3 objectColor;
uniform float exposition;
uniform sampler2D sunTexture;
in vec3 interpNormal;
in vec2 TexCoords;
out vec4 outColor;
void main()
{
gl_FragColor = vec4(objectColor, 1.0);
vec3 textureColor = texture(sunTexture, TexCoords).xyz;
vec3 adjustedColor = textureColor * exposition;
outColor = vec4(clamp(adjustedColor, 0.0, 1.0), 1.0);
}

View File

@ -1,15 +1,15 @@
#version 430 core
layout(location = 0) in vec3 vertexPosition;
layout(location = 1) in vec2 vertexTexCoord;
layout(location = 2) in vec3 vertexNormal;
layout(location = 1) in vec3 vertexNormal;
layout(location = 2) in vec2 vertexTexCoord;
uniform mat4 transformation;
out vec3 interpNormal;
out vec2 TexCoords;
void main()
{
gl_Position = transformation * vec4(vertexPosition, 1.0);
interpNormal = vertexNormal;
TexCoords = vertexTexCoord;
}

View File

@ -17,10 +17,13 @@
namespace texture {
//GLuint clouds;
GLuint earth;
GLuint clouds;
GLuint moon;
GLuint ship;
GLuint sun;
GLuint grid;
@ -49,6 +52,7 @@ GLuint VAO,VBO;
float aspectRatio = 1.f;
glm::mat4 createCameraMatrix()
{
glm::vec3 cameraSide = glm::normalize(glm::cross(cameraDir,glm::vec3(0.f,1.f,0.f)));
@ -111,6 +115,22 @@ void drawObjectTexture(Core::RenderContext& context, glm::mat4 modelMatrix, GLui
Core::DrawContext(context);
}
void drawSun(Core::RenderContext& context, glm::mat4 modelMatrix, GLuint textureID)
{
GLuint prog = programSun;
glUseProgram(prog);
glm::mat4 viewProjectionMatrix = createPerspectiveMatrix() * createCameraMatrix();
glm::mat4 transformation = viewProjectionMatrix * modelMatrix;
glUniformMatrix4fv(glGetUniformLocation(prog, "transformation"), 1, GL_FALSE, (float*)&transformation);
glUniform1f(glGetUniformLocation(prog, "exposition"), 1.f);
Core::SetActiveTexture(textureID, "sunTexture", prog, 0);
Core::DrawContext(context);
}
void renderScene(GLFWwindow* window)
{
glClearColor(0.0f, 0.3f, 0.3f, 1.0f);
@ -118,14 +138,15 @@ void renderScene(GLFWwindow* window)
glm::mat4 transformation;
float time = glfwGetTime();
drawSun(sphereContext, glm::mat4(), texture::sun);
drawObjectTexture(sphereContext, glm::mat4(), texture::ship, texture::asteroidNormal);
drawObjectTexture(sphereContext, glm::eulerAngleY(time / 3) * glm::translate(glm::vec3(4.f, 0, 0)) * glm::scale(glm::vec3(0.3f)), texture::earth, texture::earthNormal);
drawObjectTexture(sphereContext,
glm::eulerAngleY(time / 3) * glm::translate(glm::vec3(4.f, 0, 0)) * glm::eulerAngleY(time) * glm::translate(glm::vec3(1.f, 0, 0)) * glm::scale(glm::vec3(0.1f)), texture::moon, texture::asteroidNormal);
drawObjectTexture(sphereContext, glm::eulerAngleY(time / 3) * glm::translate(glm::vec3(4.f, 0, 0)) * glm::eulerAngleY(time) * glm::translate(glm::vec3(1.f, 0, 0)) * glm::scale(glm::vec3(0.1f)), texture::moon, texture::asteroidNormal);
glm::vec3 spaceshipSide = glm::normalize(glm::cross(spaceshipDir, glm::vec3(0.f, 1.f, 0.f)));
glm::vec3 spaceshipUp = glm::normalize(glm::cross(spaceshipSide, spaceshipDir));
@ -173,15 +194,17 @@ void init(GLFWwindow* window)
programTex = shaderLoader.CreateProgram("shaders/shader_5_1_tex_copy.vert", "shaders/shader_5_1_tex_copy.frag");
programEarth = shaderLoader.CreateProgram("shaders/shader_5_1_tex.vert", "shaders/shader_5_1_tex.frag");
programProcTex = 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/spaceship.obj", shipContext);
texture::earth = Core::LoadTexture("textures/earth.png");
texture::earth = Core::LoadTexture("textures/earth2.png");
texture::ship = Core::LoadTexture("textures/spaceship.jpg");
texture::moon = Core::LoadTexture("textures/moon.jpg");
texture::sun = Core::LoadTexture("textures/sun.jpg");
texture::earthNormal = Core::LoadTexture("textures/earth_normalmap.png");
texture::earthNormal = Core::LoadTexture("textures/earth2_normals.png");
texture::shipNormal = Core::LoadTexture("textures/spaceship_normal.jpg");
texture::asteroidNormal = Core::LoadTexture("textures/moon_normal.jpg");

Binary file not shown.

After

Width:  |  Height:  |  Size: 803 KiB