Improved skybox
@ -2,7 +2,7 @@
|
||||
<Project>
|
||||
<ProjectOutputs>
|
||||
<ProjectOutput>
|
||||
<FullPath>C:\Users\User\Desktop\grk-cw\Debug\grk-cw6.exe</FullPath>
|
||||
<FullPath>C:\Users\Michal\source\repos\GRK\Debug\grk-cw6.exe</FullPath>
|
||||
</ProjectOutput>
|
||||
</ProjectOutputs>
|
||||
<ContentFiles />
|
||||
|
@ -1,6 +1,6 @@
|
||||
main_6_1.cpp
|
||||
E:\Projects\Visual Studio 2019\GRK\cw 6\src\main_6_1.cpp(93,23): warning C4244: '=': conversion from 'int' to 'float', possible loss of data
|
||||
E:\Projects\Visual Studio 2019\GRK\cw 6\src\main_6_1.cpp(94,23): warning C4244: '=': conversion from 'int' to 'float', possible loss of data
|
||||
E:\Projects\Visual Studio 2019\GRK\cw 6\src\main_6_1.cpp(228,12): warning C4244: 'argument': conversion from 'time_t' to 'unsigned int', possible loss of data
|
||||
Camera.obj : warning LNK4075: ignoring '/EDITANDCONTINUE' due to '/INCREMENTAL:NO' specification
|
||||
grk-cw6.vcxproj -> E:\Projects\Visual Studio 2019\GRK\Debug\grk-cw6.exe
|
||||
C:\Users\Michal\source\repos\GRK\cw 6\src\main_6_1.cpp(96,23): warning C4244: "=": konwersja z "int" do "float", możliwa utrata danych
|
||||
C:\Users\Michal\source\repos\GRK\cw 6\src\main_6_1.cpp(97,23): warning C4244: "=": konwersja z "int" do "float", możliwa utrata danych
|
||||
C:\Users\Michal\source\repos\GRK\cw 6\src\main_6_1.cpp(349,12): warning C4244: "argument": konwersja z "time_t" do "unsigned int", możliwa utrata danych
|
||||
Camera.obj : warning LNK4075: zignorowano opcję „/EDITANDCONTINUE” z powodu określenia opcji „/INCREMENTAL:NO”
|
||||
grk-cw6.vcxproj -> C:\Users\Michal\source\repos\GRK\Debug\grk-cw6.exe
|
||||
|
@ -1,2 +1,2 @@
|
||||
#TargetFrameworkVersion=v4.0:PlatformToolSet=v142:EnableManagedIncrementalBuild=false:VCToolArchitecture=Native32Bit:WindowsTargetPlatformVersion=10.0
|
||||
Debug|Win32|E:\Projects\Visual Studio 2019\GRK\|
|
||||
PlatformToolSet=v142:VCToolArchitecture=Native32Bit:VCToolsVersion=14.29.30133:TargetPlatformVersion=10.0.19041.0:
|
||||
Debug|Win32|C:\Users\Michal\source\repos\GRK\|
|
||||
|
11
cw 6/shaders/skybox_tex.frag
Normal file
@ -0,0 +1,11 @@
|
||||
#version 410 core
|
||||
out vec4 FragColor;
|
||||
|
||||
in vec3 TexCoords;
|
||||
|
||||
uniform samplerCube skybox;
|
||||
|
||||
void main()
|
||||
{
|
||||
FragColor = texture(skybox, TexCoords);
|
||||
}
|
12
cw 6/shaders/skybox_tex.vert
Normal file
@ -0,0 +1,12 @@
|
||||
#version 410 core
|
||||
layout (location = 0) in vec3 aPos;
|
||||
|
||||
out vec3 TexCoords;
|
||||
|
||||
uniform mat4 projectionView;
|
||||
|
||||
void main()
|
||||
{
|
||||
TexCoords = aPos;
|
||||
gl_Position = projectionView * vec4(aPos, 1.0);
|
||||
}
|
@ -10,9 +10,11 @@
|
||||
#include "Render_Utils.h"
|
||||
#include "Camera.h"
|
||||
#include "Texture.h"
|
||||
#include "SOIL/stb_image_aug.h"
|
||||
|
||||
GLuint programColor;
|
||||
GLuint programTexture;
|
||||
GLuint skyboxTexture;
|
||||
|
||||
Core::Shader_Loader shaderLoader;
|
||||
|
||||
@ -57,7 +59,8 @@ glm::quat rotation_x;
|
||||
float dy = 0;
|
||||
float dx = 0;
|
||||
|
||||
|
||||
unsigned int skyboxVAO, skyboxVBO;
|
||||
unsigned int cubemapTexture;
|
||||
|
||||
void keyboard(unsigned char key, int x, int y)
|
||||
{
|
||||
@ -163,6 +166,100 @@ void drawObjectTexture(Core::RenderContext context, glm::mat4 modelMatrix, GLuin
|
||||
|
||||
glUseProgram(0);
|
||||
}
|
||||
|
||||
//Zmienna z teksturami skyboxa
|
||||
std::vector<std::string> faces = {
|
||||
"textures/skybox/right.jpg",
|
||||
"textures/skybox/left.jpg",
|
||||
"textures/skybox/top.jpg",
|
||||
"textures/skybox/bottom.jpg",
|
||||
"textures/skybox/front.jpg",
|
||||
"textures/skybox/back.jpg",
|
||||
};
|
||||
|
||||
//Funkcja do stworzenia skyboxa
|
||||
unsigned int loadCubemap(std::vector<std::string> faces)
|
||||
{
|
||||
unsigned int textureID;
|
||||
glGenTextures(1, &textureID);
|
||||
glBindTexture(GL_TEXTURE_CUBE_MAP, textureID);
|
||||
|
||||
int width, height, nrChannels;
|
||||
for (unsigned int i = 0; i < faces.size(); i++)
|
||||
{
|
||||
unsigned char* data = stbi_load(faces[i].c_str(), &width, &height, &nrChannels, 0);
|
||||
if (data)
|
||||
{
|
||||
glTexImage2D(GL_TEXTURE_CUBE_MAP_POSITIVE_X + i,
|
||||
0, GL_RGB, width, height, 0, GL_RGB, GL_UNSIGNED_BYTE, data
|
||||
);
|
||||
stbi_image_free(data);
|
||||
}
|
||||
else
|
||||
{
|
||||
std::cout << "Cubemap tex failed to load at path: " << faces[i] << std::endl;
|
||||
stbi_image_free(data);
|
||||
}
|
||||
}
|
||||
glTexParameteri(GL_TEXTURE_CUBE_MAP, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
|
||||
glTexParameteri(GL_TEXTURE_CUBE_MAP, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
|
||||
glTexParameteri(GL_TEXTURE_CUBE_MAP, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
|
||||
glTexParameteri(GL_TEXTURE_CUBE_MAP, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
|
||||
glTexParameteri(GL_TEXTURE_CUBE_MAP, GL_TEXTURE_WRAP_R, GL_CLAMP_TO_EDGE);
|
||||
|
||||
return textureID;
|
||||
}
|
||||
|
||||
//Rozmiar skyboxa
|
||||
float skyboxSize = 50.0f;
|
||||
|
||||
//Wspolrzedne skyboxa
|
||||
float skyboxVertices[] = {
|
||||
-skyboxSize, skyboxSize, -skyboxSize,
|
||||
-skyboxSize, -skyboxSize, -skyboxSize,
|
||||
skyboxSize, -skyboxSize, -skyboxSize,
|
||||
skyboxSize, -skyboxSize, -skyboxSize,
|
||||
skyboxSize, skyboxSize, -skyboxSize,
|
||||
-skyboxSize, skyboxSize, -skyboxSize,
|
||||
|
||||
-skyboxSize, -skyboxSize, skyboxSize,
|
||||
-skyboxSize, -skyboxSize, -skyboxSize,
|
||||
-skyboxSize, skyboxSize, -skyboxSize,
|
||||
-skyboxSize, skyboxSize, -skyboxSize,
|
||||
-skyboxSize, skyboxSize, skyboxSize,
|
||||
-skyboxSize, -skyboxSize, skyboxSize,
|
||||
|
||||
skyboxSize, -skyboxSize, -skyboxSize,
|
||||
skyboxSize, -skyboxSize, skyboxSize,
|
||||
skyboxSize, skyboxSize, skyboxSize,
|
||||
skyboxSize, skyboxSize, skyboxSize,
|
||||
skyboxSize, skyboxSize, -skyboxSize,
|
||||
skyboxSize, -skyboxSize, -skyboxSize,
|
||||
|
||||
-skyboxSize, -skyboxSize, skyboxSize,
|
||||
-skyboxSize, skyboxSize, skyboxSize,
|
||||
skyboxSize, skyboxSize, skyboxSize,
|
||||
skyboxSize, skyboxSize, skyboxSize,
|
||||
skyboxSize, -skyboxSize, skyboxSize,
|
||||
-skyboxSize, -skyboxSize, skyboxSize,
|
||||
|
||||
-skyboxSize, skyboxSize, -skyboxSize,
|
||||
skyboxSize, skyboxSize, -skyboxSize,
|
||||
skyboxSize, skyboxSize, skyboxSize,
|
||||
skyboxSize, skyboxSize, skyboxSize,
|
||||
-skyboxSize, skyboxSize, skyboxSize,
|
||||
-skyboxSize, skyboxSize, -skyboxSize,
|
||||
|
||||
-skyboxSize, -skyboxSize, -skyboxSize,
|
||||
-skyboxSize, -skyboxSize, skyboxSize,
|
||||
skyboxSize, -skyboxSize, -skyboxSize,
|
||||
skyboxSize, -skyboxSize, -skyboxSize,
|
||||
-skyboxSize, -skyboxSize, skyboxSize,
|
||||
skyboxSize, -skyboxSize, skyboxSize
|
||||
};
|
||||
|
||||
|
||||
|
||||
void renderScene()
|
||||
{
|
||||
// Aktualizacja macierzy widoku i rzutowania
|
||||
@ -200,6 +297,30 @@ void renderScene()
|
||||
drawObjectTexture(fishContext, modelMatrix, textureFish01);
|
||||
}
|
||||
|
||||
glUseProgram(skyboxTexture);
|
||||
glUniform1i(glGetUniformLocation(skyboxTexture, "skybox"), 0);
|
||||
glm::mat4 transformation = perspectiveMatrix * glm::mat4(glm::mat3(cameraMatrix));
|
||||
glUniformMatrix4fv(glGetUniformLocation(skyboxTexture, "projectionView"), 1, GL_FALSE, (float*)&transformation);
|
||||
//Przypisanie VAO i rysowanie skyboxa
|
||||
glBindVertexArray(skyboxVAO);
|
||||
glActiveTexture(GL_TEXTURE0);
|
||||
glBindTexture(GL_TEXTURE_CUBE_MAP, cubemapTexture);
|
||||
glDrawArrays(GL_TRIANGLES, 0, 36);
|
||||
glBindVertexArray(0);
|
||||
|
||||
//Próba mg³y
|
||||
glClearColor(0.5f, 0.5f, 0.5f, 1.0f); // We'll Clear To The Color Of The Fog ( Modified )
|
||||
float color[] = { 0.5f, 0.5f, 0.5f, 1.0f };
|
||||
glFogi(GL_FOG_MODE, GL_EXP2); // Fog Mode
|
||||
glFogfv(GL_FOG_COLOR, color); // Set Fog Color
|
||||
glFogf(GL_FOG_DENSITY, 0.35f); // How Dense Will The Fog Be
|
||||
glHint(GL_FOG_HINT, GL_DONT_CARE); // Fog Hint Value
|
||||
glFogf(GL_FOG_START, 1.0f); // Fog Start Depth
|
||||
glFogf(GL_FOG_END, 5.0f); // Fog End Depth
|
||||
glEnable(GL_FOG);
|
||||
|
||||
glDepthFunc(GL_LESS);
|
||||
|
||||
|
||||
|
||||
glutSwapBuffers();
|
||||
@ -229,6 +350,19 @@ void init()
|
||||
glEnable(GL_DEPTH_TEST);
|
||||
programColor = shaderLoader.CreateProgram("shaders/shader_color.vert", "shaders/shader_color.frag");
|
||||
programTexture = shaderLoader.CreateProgram("shaders/shader_tex.vert", "shaders/shader_tex.frag");
|
||||
skyboxTexture = shaderLoader.CreateProgram("shaders/skybox_tex.vert", "shaders/skybox_tex.frag");
|
||||
|
||||
//Zaladowanie tekstur do skyboxa
|
||||
cubemapTexture = loadCubemap(faces);
|
||||
//Przygotowanie VAO i VBO
|
||||
glGenVertexArrays(1, &skyboxVAO);
|
||||
glGenBuffers(1, &skyboxVBO);
|
||||
glBindVertexArray(skyboxVAO);
|
||||
glBindBuffer(GL_ARRAY_BUFFER, skyboxVBO);
|
||||
glBufferData(GL_ARRAY_BUFFER, sizeof(skyboxVertices), &skyboxVertices, GL_STATIC_DRAW);
|
||||
glEnableVertexAttribArray(0);
|
||||
glVertexAttribPointer(0, 3, GL_FLOAT, GL_FALSE, 3 * sizeof(float), (void*)0);
|
||||
|
||||
loadModelToContext("models/Submarine.3DS", shipContext);
|
||||
loadModelToContext("models/TropicalFish01.3ds", fishContext);
|
||||
textureAsteroid = Core::LoadTexture("textures/asteroid.png");
|
||||
@ -239,6 +373,7 @@ void shutdown()
|
||||
{
|
||||
shaderLoader.DeleteProgram(programColor);
|
||||
shaderLoader.DeleteProgram(programTexture);
|
||||
shaderLoader.DeleteProgram(skyboxTexture);
|
||||
}
|
||||
|
||||
void idle()
|
||||
|
BIN
cw 6/textures/skybox/back.jpg
Normal file
After Width: | Height: | Size: 445 KiB |
BIN
cw 6/textures/skybox/bottom.jpg
Normal file
After Width: | Height: | Size: 486 KiB |
BIN
cw 6/textures/skybox/front.jpg
Normal file
After Width: | Height: | Size: 390 KiB |
BIN
cw 6/textures/skybox/left.jpg
Normal file
After Width: | Height: | Size: 366 KiB |
BIN
cw 6/textures/skybox/right.jpg
Normal file
After Width: | Height: | Size: 387 KiB |
BIN
cw 6/textures/skybox/top.jpg
Normal file
After Width: | Height: | Size: 304 KiB |
@ -1 +1,9 @@
|
||||
grk-cw8.vcxproj -> C:\Users\Michal\source\repos\GRK\Debug\grk-cw8.exe
|
||||
main_8_1.cpp
|
||||
C:\Users\Michal\source\repos\GRK\cw 8\src\main_8_1.cpp(37,42): warning C4305: "argument": obcięcie z "double" do "float"
|
||||
C:\Users\Michal\source\repos\GRK\cw 8\src\main_8_1.cpp(416,15): warning C4244: "argument": konwersja z "time_t" do "unsigned int", możliwa utrata danych
|
||||
Camera.obj : warning LNK4075: zignorowano opcję „/EDITANDCONTINUE” z powodu określenia opcji „/INCREMENTAL:NO”
|
||||
PhysXExtensions_static_32.lib(ExtCpuWorkerThread.obj) : warning LNK4099: nie znaleziono pliku PDB „PhysXExtensions_static_32.pdb” z elementem „PhysXExtensions_static_32.lib(ExtCpuWorkerThread.obj)” lub w pozycji „C:\Users\Michal\source\repos\GRK\Debug\PhysXExtensions_static_32.pdb”; obiekt zostanie skonsolidowany bez informacji debugowania
|
||||
PhysXExtensions_static_32.lib(ExtDefaultCpuDispatcher.obj) : warning LNK4099: nie znaleziono pliku PDB „” z elementem „PhysXExtensions_static_32.lib(ExtDefaultCpuDispatcher.obj)” lub w pozycji „”; obiekt zostanie skonsolidowany bez informacji debugowania
|
||||
PhysXExtensions_static_32.lib(ExtDefaultErrorCallback.obj) : warning LNK4099: nie znaleziono pliku PDB „PhysXExtensions_static_32.pdb” z elementem „PhysXExtensions_static_32.lib(ExtDefaultErrorCallback.obj)” lub w pozycji „C:\Users\Michal\source\repos\GRK\Debug\PhysXExtensions_static_32.pdb”; obiekt zostanie skonsolidowany bez informacji debugowania
|
||||
PhysXExtensions_static_32.lib(ExtDefaultSimulationFilterShader.obj) : warning LNK4099: nie znaleziono pliku PDB „PhysXExtensions_static_32.pdb” z elementem „PhysXExtensions_static_32.lib(ExtDefaultSimulationFilterShader.obj)” lub w pozycji „C:\Users\Michal\source\repos\GRK\Debug\PhysXExtensions_static_32.pdb”; obiekt zostanie skonsolidowany bez informacji debugowania
|
||||
grk-cw8.vcxproj -> C:\Users\Michal\source\repos\GRK\Debug\grk-cw8.exe
|
||||
|
@ -285,8 +285,8 @@ std::vector<std::string> faces = {
|
||||
"textures/right.jpg",
|
||||
"textures/left.jpg",
|
||||
"textures/top.jpg",
|
||||
"textures//bottom.jpg",
|
||||
"textures//front.jpg",
|
||||
"textures/sand.png",
|
||||
"textures/front.jpg",
|
||||
"textures/back.jpg",
|
||||
};
|
||||
|
||||
@ -324,7 +324,7 @@ unsigned int loadCubemap(std::vector<std::string> faces)
|
||||
}
|
||||
|
||||
|
||||
float skyboxSize = 30.0f;
|
||||
float skyboxSize = 60.0f;
|
||||
|
||||
float skyboxVertices[] = {
|
||||
-skyboxSize, skyboxSize, -skyboxSize,
|
||||
@ -374,13 +374,15 @@ float skyboxVertices[] = {
|
||||
void renderScene()
|
||||
{
|
||||
|
||||
|
||||
|
||||
cameraMatrix = createCameraMatrix();
|
||||
perspectiveMatrix = Core::createPerspectiveMatrix();
|
||||
|
||||
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
|
||||
glClearColor(0.0f, 0.1f, 0.3f, 1.0f);
|
||||
|
||||
|
||||
//drawObjectTexture(planeContext, glm::rotate(glm::radians(90.f), glm::vec3(0.f, 0.f, 1.f)), groundTexture);
|
||||
drawObjectTexture(boxContext, boxModelMatrix, boxTexture); // boxModelMatrix was updated in updateTransforms()
|
||||
|
||||
glUseProgram(skyboxTexture);
|
||||
glUniform1i(glGetUniformLocation(skyboxTexture, "skybox"), 0);
|
||||
@ -393,7 +395,15 @@ void renderScene()
|
||||
glDrawArrays(GL_TRIANGLES, 0, 36);
|
||||
glBindVertexArray(0);
|
||||
|
||||
|
||||
glClearColor(0.5f, 0.5f, 0.5f, 1.0f); // We'll Clear To The Color Of The Fog ( Modified )
|
||||
float color[] = { 0.5f, 0.5f, 0.5f, 1.0f };
|
||||
glFogi(GL_FOG_MODE, GL_EXP2); // Fog Mode
|
||||
glFogfv(GL_FOG_COLOR, color); // Set Fog Color
|
||||
glFogf(GL_FOG_DENSITY, 0.35f); // How Dense Will The Fog Be
|
||||
glHint(GL_FOG_HINT, GL_DONT_CARE); // Fog Hint Value
|
||||
glFogf(GL_FOG_START, 1.0f); // Fog Start Depth
|
||||
glFogf(GL_FOG_END, 5.0f); // Fog End Depth
|
||||
glEnable(GL_FOG);
|
||||
|
||||
glDepthFunc(GL_LESS); // set depth function back to default
|
||||
|
||||
@ -409,6 +419,7 @@ void init()
|
||||
programTexture = shaderLoader.CreateProgram("shaders/shader_tex.vert", "shaders/shader_tex.frag");
|
||||
skyboxTexture = shaderLoader.CreateProgram("shaders/skybox_tex.vert", "shaders/skybox_tex.frag");
|
||||
|
||||
|
||||
cubemapTexture = loadCubemap(faces);
|
||||
|
||||
glGenVertexArrays(1, &VAO);
|
||||
@ -419,6 +430,9 @@ void init()
|
||||
glEnableVertexAttribArray(0);
|
||||
glVertexAttribPointer(0, 3, GL_FLOAT, GL_FALSE, 3 * sizeof(float), (void*)0);
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
initRenderables();
|
||||
|
BIN
cw 8/textures/sand.png
Normal file
After Width: | Height: | Size: 567 KiB |