Merge pull request 'zmiana_statku' (#1) from zmiana_statku into master
Reviewed-on: #1
BIN
.vs/grk-cw/v17/ipch/AutoPCH/fb10e04556d1f6f7/CAMERA.ipch
Normal file
@ -2,9 +2,9 @@
|
|||||||
main.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
|
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\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(91,10): warning C4305: "inicjowanie": obcięcie z "double" do "float"
|
D:\STUDIA_sem5\GRAFIKA-PROJEKT\grk\projekt_grk\src\ex_7_1.hpp(96,10): warning C4305: "inicjowanie": obcięcie z "double" do "float"
|
||||||
D:\STUDIA_sem5\GRAFIKA-PROJEKT\grk\projekt_grk\src\ex_7_1.hpp(174,13): warning C4244: "inicjowanie": konwersja z "double" do "float", możliwa utrata danych
|
D:\STUDIA_sem5\GRAFIKA-PROJEKT\grk\projekt_grk\src\ex_7_1.hpp(204,13): warning C4244: "inicjowanie": konwersja z "double" do "float", możliwa utrata danych
|
||||||
D:\STUDIA_sem5\GRAFIKA-PROJEKT\grk\projekt_grk\src\ex_7_1.hpp(192,29): warning C4305: "inicjowanie": obcięcie z "double" do "float"
|
D:\STUDIA_sem5\GRAFIKA-PROJEKT\grk\projekt_grk\src\ex_7_1.hpp(222,29): warning C4305: "inicjowanie": obcięcie z "double" do "float"
|
||||||
Box.obj : warning LNK4075: zignorowano opcję „/EDITANDCONTINUE” z powodu określenia opcji „/INCREMENTAL:NO”
|
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
|
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
|
grk-cw7.vcxproj -> D:\STUDIA_sem5\GRAFIKA-PROJEKT\grk\Debug\projekt_grk.exe
|
||||||
|
@ -39,12 +39,12 @@
|
|||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<None Include="shaders\shader_5_1.frag" />
|
<None Include="shaders\shader_5_1.frag" />
|
||||||
<None Include="shaders\shader_5_1.vert" />
|
<None Include="shaders\shader_5_1.vert" />
|
||||||
<None Include="shaders\shader_5_1_tex.frag" />
|
|
||||||
<None Include="shaders\shader_5_1_tex.vert" />
|
|
||||||
<None Include="shaders\shader_5_1_tex_copy.frag" />
|
<None Include="shaders\shader_5_1_tex_copy.frag" />
|
||||||
<None Include="shaders\shader_5_1_tex_copy.vert" />
|
<None Include="shaders\shader_5_1_tex_copy.vert" />
|
||||||
<None Include="shaders\shader_5_sun.frag" />
|
<None Include="shaders\shader_sun.frag" />
|
||||||
<None Include="shaders\shader_5_sun.vert" />
|
<None Include="shaders\shader_sun.vert" />
|
||||||
|
<None Include="shaders\shader_pbr.frag" />
|
||||||
|
<None Include="shaders\shader_pbr.vert" />
|
||||||
<None Include="shaders\shader_skybox.frag" />
|
<None Include="shaders\shader_skybox.frag" />
|
||||||
<None Include="shaders\shader_skybox.vert" />
|
<None Include="shaders\shader_skybox.vert" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
@ -91,10 +91,10 @@
|
|||||||
</ClInclude>
|
</ClInclude>
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<None Include="shaders\shader_5_sun.frag">
|
<None Include="shaders\shader_sun.frag">
|
||||||
<Filter>Shader Files</Filter>
|
<Filter>Shader Files</Filter>
|
||||||
</None>
|
</None>
|
||||||
<None Include="shaders\shader_5_sun.vert">
|
<None Include="shaders\shader_sun.vert">
|
||||||
<Filter>Shader Files</Filter>
|
<Filter>Shader Files</Filter>
|
||||||
</None>
|
</None>
|
||||||
<None Include="shaders\shader_5_1.frag">
|
<None Include="shaders\shader_5_1.frag">
|
||||||
@ -103,12 +103,6 @@
|
|||||||
<None Include="shaders\shader_5_1.vert">
|
<None Include="shaders\shader_5_1.vert">
|
||||||
<Filter>Shader Files</Filter>
|
<Filter>Shader Files</Filter>
|
||||||
</None>
|
</None>
|
||||||
<None Include="shaders\shader_5_1_tex.vert">
|
|
||||||
<Filter>Shader Files</Filter>
|
|
||||||
</None>
|
|
||||||
<None Include="shaders\shader_5_1_tex.frag">
|
|
||||||
<Filter>Shader Files</Filter>
|
|
||||||
</None>
|
|
||||||
<None Include="shaders\shader_5_1_tex_copy.frag">
|
<None Include="shaders\shader_5_1_tex_copy.frag">
|
||||||
<Filter>Shader Files</Filter>
|
<Filter>Shader Files</Filter>
|
||||||
</None>
|
</None>
|
||||||
@ -121,5 +115,11 @@
|
|||||||
<None Include="shaders\shader_skybox.vert">
|
<None Include="shaders\shader_skybox.vert">
|
||||||
<Filter>Shader Files</Filter>
|
<Filter>Shader Files</Filter>
|
||||||
</None>
|
</None>
|
||||||
|
<None Include="shaders\shader_pbr.frag">
|
||||||
|
<Filter>Shader Files</Filter>
|
||||||
|
</None>
|
||||||
|
<None Include="shaders\shader_pbr.vert">
|
||||||
|
<Filter>Shader Files</Filter>
|
||||||
|
</None>
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
</Project>
|
</Project>
|
61172
projekt_grk/models/new_spaceship.obj
Normal file
@ -1,21 +0,0 @@
|
|||||||
#version 430 core
|
|
||||||
|
|
||||||
float AMBIENT = 0.1;
|
|
||||||
|
|
||||||
uniform vec3 color;
|
|
||||||
uniform vec3 lightPos;
|
|
||||||
uniform sampler2D colorTexture;
|
|
||||||
|
|
||||||
in vec3 vecNormal;
|
|
||||||
in vec3 worldPos;
|
|
||||||
in vec2 vecTex;
|
|
||||||
|
|
||||||
out vec4 outColor;
|
|
||||||
void main()
|
|
||||||
{
|
|
||||||
vec3 lightDir = normalize(lightPos-worldPos);
|
|
||||||
vec3 normal = normalize(vecNormal);
|
|
||||||
vec3 textureColor = texture2D(colorTexture, vecTex).xyz;
|
|
||||||
float diffuse=max(0,dot(normal,lightDir));
|
|
||||||
outColor = vec4(textureColor*min(1,AMBIENT+diffuse), 1.0);
|
|
||||||
}
|
|
@ -1,23 +0,0 @@
|
|||||||
#version 430 core
|
|
||||||
|
|
||||||
layout(location = 0) in vec3 vertexPosition;
|
|
||||||
layout(location = 1) in vec3 vertexNormal;
|
|
||||||
layout(location = 2) in vec2 vertexTexCoord;
|
|
||||||
layout(location = 3) in vec3 vertexTangent;
|
|
||||||
layout(location = 4) in vec3 vertexBitangent;
|
|
||||||
|
|
||||||
uniform mat4 transformation;
|
|
||||||
uniform mat4 modelMatrix;
|
|
||||||
|
|
||||||
out vec3 vecNormal;
|
|
||||||
out vec3 worldPos;
|
|
||||||
out vec2 vecTex;
|
|
||||||
|
|
||||||
void main()
|
|
||||||
{
|
|
||||||
worldPos = (modelMatrix* vec4(vertexPosition,1)).xyz;
|
|
||||||
vecNormal = (modelMatrix* vec4(vertexNormal,0)).xyz;
|
|
||||||
vecTex = vertexTexCoord;
|
|
||||||
vecTex.y = 1.0 - vecTex.y;
|
|
||||||
gl_Position = transformation * vec4(vertexPosition, 1.0);
|
|
||||||
}
|
|
74
projekt_grk/shaders/shader_pbr.frag
Normal file
@ -0,0 +1,74 @@
|
|||||||
|
#version 430 core
|
||||||
|
|
||||||
|
const float DIFFUSE_INTENSITY = 0.6;
|
||||||
|
const float MAX_RENDER_DISTANCE = 16.0;
|
||||||
|
|
||||||
|
float surfaceRoughness;
|
||||||
|
float metalnessValue;
|
||||||
|
|
||||||
|
uniform vec3 primaryColor;
|
||||||
|
uniform sampler2D colorTexture;
|
||||||
|
uniform sampler2D normalMap;
|
||||||
|
|
||||||
|
uniform sampler2D metalnessMap;
|
||||||
|
uniform sampler2D roughnessMap;
|
||||||
|
|
||||||
|
in vec3 worldPos;
|
||||||
|
in vec2 vecTex;
|
||||||
|
|
||||||
|
in vec3 viewDirTS;
|
||||||
|
in vec3 lightDirTS;
|
||||||
|
in float distanceToCamera;
|
||||||
|
out vec4 fragmentColor;
|
||||||
|
|
||||||
|
|
||||||
|
float calculateMicrofacetDistribution(float roughness, vec3 normal, vec3 halfVector) {
|
||||||
|
float NdotH = max(0.0, dot(normal, halfVector));
|
||||||
|
float roughnessSq = roughness * roughness;
|
||||||
|
float denom = 3.14159 * pow(NdotH * NdotH * (roughnessSq - 1.0) + 1.0, 2.0);
|
||||||
|
return roughnessSq / denom;
|
||||||
|
}
|
||||||
|
|
||||||
|
float calculateGeometryTerm(float roughness, float NdotV, float NdotL) {
|
||||||
|
float k = pow(roughness + 1.0, 2.0) / 8.0;
|
||||||
|
return NdotV / (NdotV * (1.0 - k) + k) * NdotL / (NdotL * (1.0 - k) + k);
|
||||||
|
}
|
||||||
|
|
||||||
|
vec3 calculateFresnelTerm(float metallic, vec3 F0, float VdotH) {
|
||||||
|
return F0 + (1.0 - F0) * pow(1.0 - VdotH, 5.0);
|
||||||
|
}
|
||||||
|
|
||||||
|
void main() {
|
||||||
|
vec3 textureColor = texture(colorTexture, vecTex).xyz;
|
||||||
|
metalnessValue = texture(metalnessMap, vecTex).r;
|
||||||
|
surfaceRoughness = texture(roughnessMap, vecTex).r;
|
||||||
|
|
||||||
|
vec3 normal = texture(normalMap, vecTex).xyz;
|
||||||
|
normal = normalize(normal);
|
||||||
|
|
||||||
|
vec3 viewDir = normalize(viewDirTS);
|
||||||
|
vec3 lightDir = normalize(lightDirTS);
|
||||||
|
vec3 halfVector = normalize(lightDir + viewDir);
|
||||||
|
|
||||||
|
float microfacetDistribution = calculateMicrofacetDistribution(surfaceRoughness, normal, halfVector);
|
||||||
|
|
||||||
|
float NdotV = max(0.0, dot(normal, viewDir));
|
||||||
|
float NdotL = max(dot(normal, lightDir), 0.0000001);
|
||||||
|
float geometryTerm = calculateGeometryTerm(surfaceRoughness, NdotV, NdotL);
|
||||||
|
|
||||||
|
vec3 F0 = mix(vec3(0.04), vec3(1.0), vec3(metalnessValue));
|
||||||
|
float VdotH = max(0.00001, dot(viewDir, halfVector));
|
||||||
|
|
||||||
|
vec3 fresnelTerm = calculateFresnelTerm(metalnessValue, F0, VdotH);
|
||||||
|
vec3 specular = (microfacetDistribution * geometryTerm * fresnelTerm) / (4.0 * NdotL * NdotV + 0.00001);
|
||||||
|
vec3 diffuseReflectance = vec3(1.0) - fresnelTerm;
|
||||||
|
vec3 BRDF = diffuseReflectance * (textureColor / 3.1458493) + specular;
|
||||||
|
|
||||||
|
if (distanceToCamera > MAX_RENDER_DISTANCE) {
|
||||||
|
discard;
|
||||||
|
}
|
||||||
|
|
||||||
|
float diffuse = max(0.0001, dot(normal, lightDir));
|
||||||
|
|
||||||
|
fragmentColor = vec4(BRDF * (DIFFUSE_INTENSITY + diffuse) * 1.5, 1.0);
|
||||||
|
}
|
45
projekt_grk/shaders/shader_pbr.vert
Normal file
@ -0,0 +1,45 @@
|
|||||||
|
#version 430 core
|
||||||
|
|
||||||
|
layout(location = 0) in vec3 vertexPosition;
|
||||||
|
layout(location = 1) in vec3 vertexNormal;
|
||||||
|
layout(location = 2) in vec2 vertexTexCoord;
|
||||||
|
layout(location = 3) in vec3 vertexTangent;
|
||||||
|
layout(location = 4) in vec3 vertexBitangent;
|
||||||
|
|
||||||
|
uniform mat4 transformation;
|
||||||
|
uniform mat4 modelMatrix;
|
||||||
|
|
||||||
|
out vec3 worldPos;
|
||||||
|
out vec2 vecTex;
|
||||||
|
|
||||||
|
uniform vec3 lightPos;
|
||||||
|
uniform vec3 cameraPos;
|
||||||
|
|
||||||
|
out vec3 viewDirTS;
|
||||||
|
out vec3 lightDirTS;
|
||||||
|
out float distanceToCamera;
|
||||||
|
mat3 TBN;
|
||||||
|
|
||||||
|
|
||||||
|
void main()
|
||||||
|
{
|
||||||
|
|
||||||
|
vec3 tangent = normalize(mat3(modelMatrix) * vertexTangent);
|
||||||
|
vec3 bitangent = normalize(mat3(modelMatrix) * vertexBitangent);
|
||||||
|
vec3 normal = normalize(mat3(modelMatrix) * vertexNormal);
|
||||||
|
|
||||||
|
TBN = transpose(mat3(tangent, bitangent, normal));
|
||||||
|
|
||||||
|
vec3 worldPos = (modelMatrix * vec4(vertexPosition, 1)).xyz;
|
||||||
|
|
||||||
|
vec3 viewDir = normalize(cameraPos - worldPos);
|
||||||
|
vec3 lightDir = normalize(lightPos - worldPos);
|
||||||
|
|
||||||
|
viewDirTS = vec3(TBN * viewDir);
|
||||||
|
lightDirTS = vec3(TBN * lightDir);
|
||||||
|
|
||||||
|
vecTex = vertexTexCoord;
|
||||||
|
vecTex.y = 1.0 - vecTex.y;
|
||||||
|
distanceToCamera = length(worldPos - cameraPos);
|
||||||
|
gl_Position = transformation * vec4(vertexPosition, 1.0);
|
||||||
|
}
|
@ -22,7 +22,6 @@ namespace texture {
|
|||||||
GLuint venus;
|
GLuint venus;
|
||||||
GLuint earth;
|
GLuint earth;
|
||||||
GLuint moon;
|
GLuint moon;
|
||||||
GLuint ship;
|
|
||||||
GLuint sun;
|
GLuint sun;
|
||||||
GLuint mars;
|
GLuint mars;
|
||||||
GLuint jupiter;
|
GLuint jupiter;
|
||||||
@ -34,31 +33,37 @@ namespace texture {
|
|||||||
GLuint venusNormal;
|
GLuint venusNormal;
|
||||||
GLuint earthNormal;
|
GLuint earthNormal;
|
||||||
GLuint asteroidNormal;
|
GLuint asteroidNormal;
|
||||||
GLuint shipNormal;
|
|
||||||
GLuint marsNormal;
|
GLuint marsNormal;
|
||||||
GLuint jupiterNormal;
|
GLuint jupiterNormal;
|
||||||
GLuint saturnNormal;
|
GLuint saturnNormal;
|
||||||
GLuint uranusNormal;
|
GLuint uranusNormal;
|
||||||
GLuint neptuneNormal;
|
GLuint neptuneNormal;
|
||||||
|
|
||||||
|
|
||||||
|
GLuint ship;
|
||||||
|
GLuint shipNormal;
|
||||||
|
GLuint shipMetalness;
|
||||||
|
GLuint shipRoughness;
|
||||||
|
|
||||||
GLuint grid;
|
GLuint grid;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
GLuint program;
|
GLuint program;
|
||||||
GLuint programSun;
|
GLuint programSun;
|
||||||
GLuint programTex;
|
GLuint programTex;
|
||||||
GLuint programEarth;
|
|
||||||
GLuint programProcTex;
|
|
||||||
GLuint programSkyBox;
|
GLuint programSkyBox;
|
||||||
|
GLuint programSpaceShip;
|
||||||
Core::Shader_Loader shaderLoader;
|
Core::Shader_Loader shaderLoader;
|
||||||
|
|
||||||
Core::RenderContext shipContext;
|
Core::RenderContext shipContext;
|
||||||
Core::RenderContext sphereContext;
|
Core::RenderContext sphereContext;
|
||||||
Core::RenderContext cubeContext;
|
Core::RenderContext cubeContext;
|
||||||
|
|
||||||
|
|
||||||
glm::vec3 cameraPos = glm::vec3(-4.f, 0, 0);
|
glm::vec3 cameraPos = glm::vec3(-4.f, 0, 0);
|
||||||
glm::vec3 cameraDir = glm::vec3(1.f, 0.f, 0.f);
|
glm::vec3 cameraDir = glm::vec3(1.f, 0, 0.f);
|
||||||
|
|
||||||
glm::vec3 spaceshipPos = glm::vec3(-4.f, 0, 0);
|
glm::vec3 spaceshipPos = glm::vec3(-4.f, 0, 0);
|
||||||
glm::vec3 spaceshipDir = glm::vec3(1.f, 0.f, 0.f);
|
glm::vec3 spaceshipDir = glm::vec3(1.f, 0.f, 0.f);
|
||||||
@ -157,6 +162,31 @@ void drawObjectSkyBox(Core::RenderContext& context, glm::mat4 modelMatrix) {
|
|||||||
glBindTexture(GL_TEXTURE_CUBE_MAP, textureID);
|
glBindTexture(GL_TEXTURE_CUBE_MAP, textureID);
|
||||||
Core::DrawContext(context);
|
Core::DrawContext(context);
|
||||||
glEnable(GL_DEPTH_TEST);
|
glEnable(GL_DEPTH_TEST);
|
||||||
|
}
|
||||||
|
|
||||||
|
void drawSpaceShip(Core::RenderContext& context, glm::mat4 modelMatrix, GLuint textureID, GLuint normalMapId, GLuint metalnessTexture, GLuint roughnessTexture) {
|
||||||
|
glUseProgram(programSpaceShip);
|
||||||
|
glm::mat4 viewProjectionMatrix = createPerspectiveMatrix() * createCameraMatrix();
|
||||||
|
glm::mat4 transformation = viewProjectionMatrix * modelMatrix;
|
||||||
|
|
||||||
|
glUniformMatrix4fv(glGetUniformLocation(programSpaceShip, "transformation"), 1, GL_FALSE, (float*)&transformation);
|
||||||
|
glUniformMatrix4fv(glGetUniformLocation(programSpaceShip, "modelMatrix"), 1, GL_FALSE, (float*)&modelMatrix);
|
||||||
|
glUniform3f(glGetUniformLocation(programSpaceShip, "lightPos"), 0, 0, 0);
|
||||||
|
|
||||||
|
Core::SetActiveTexture(normalMapId, "normalSampler", programSpaceShip, 1);
|
||||||
|
Core::SetActiveTexture(textureID, "colorTexture", programSpaceShip, 0);
|
||||||
|
|
||||||
|
glUniform1i(glGetUniformLocation(programSpaceShip, "metalnessTexture"), 2);
|
||||||
|
glUniform1i(glGetUniformLocation(programSpaceShip, "roughnessTexture"), 3);
|
||||||
|
|
||||||
|
glActiveTexture(GL_TEXTURE2);
|
||||||
|
glBindTexture(GL_TEXTURE_2D, metalnessTexture);
|
||||||
|
|
||||||
|
glActiveTexture(GL_TEXTURE3);
|
||||||
|
glBindTexture(GL_TEXTURE_2D, roughnessTexture);
|
||||||
|
|
||||||
|
glUniform3f(glGetUniformLocation(programSpaceShip, "cameraPos"), cameraPos.x, cameraPos.y, cameraPos.z);
|
||||||
|
Core::DrawContext(context);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -237,7 +267,6 @@ void renderScene(GLFWwindow* window)
|
|||||||
glClearColor(0.0f, 0.3f, 0.3f, 1.0f);
|
glClearColor(0.0f, 0.3f, 0.3f, 1.0f);
|
||||||
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
|
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
|
||||||
|
|
||||||
|
|
||||||
//skybox
|
//skybox
|
||||||
drawObjectSkyBox(cubeContext, glm::translate(cameraPos));
|
drawObjectSkyBox(cubeContext, glm::translate(cameraPos));
|
||||||
|
|
||||||
@ -248,8 +277,10 @@ void renderScene(GLFWwindow* window)
|
|||||||
renderPlanets();
|
renderPlanets();
|
||||||
|
|
||||||
|
|
||||||
|
// obliczanie orientacji statku
|
||||||
glm::vec3 spaceshipSide = glm::normalize(glm::cross(spaceshipDir, glm::vec3(0.f, 1.f, 0.f)));
|
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));
|
glm::vec3 spaceshipUp = glm::normalize(glm::cross(spaceshipSide, spaceshipDir));
|
||||||
|
|
||||||
glm::mat4 specshipCameraRotrationMatrix = glm::mat4({
|
glm::mat4 specshipCameraRotrationMatrix = glm::mat4({
|
||||||
spaceshipSide.x,spaceshipSide.y,spaceshipSide.z,0,
|
spaceshipSide.x,spaceshipSide.y,spaceshipSide.z,0,
|
||||||
spaceshipUp.x,spaceshipUp.y,spaceshipUp.z ,0,
|
spaceshipUp.x,spaceshipUp.y,spaceshipUp.z ,0,
|
||||||
@ -257,10 +288,13 @@ void renderScene(GLFWwindow* window)
|
|||||||
0.,0.,0.,1.,
|
0.,0.,0.,1.,
|
||||||
});
|
});
|
||||||
|
|
||||||
//spaceship drawing
|
|
||||||
drawObjectTexture(shipContext,
|
drawSpaceShip(shipContext,
|
||||||
glm::translate(spaceshipPos) * specshipCameraRotrationMatrix * glm::eulerAngleY(glm::pi<float>()),
|
glm::translate(spaceshipPos) *
|
||||||
texture::ship, texture::shipNormal
|
specshipCameraRotrationMatrix *
|
||||||
|
glm::eulerAngleY(glm::pi<float>()) *
|
||||||
|
glm::scale(glm::vec3(0.04f)), //pomniejszenie statku
|
||||||
|
texture::ship, texture::shipNormal, texture::shipMetalness, texture::shipRoughness
|
||||||
);
|
);
|
||||||
|
|
||||||
glUseProgram(0);
|
glUseProgram(0);
|
||||||
@ -290,21 +324,19 @@ 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_copy.vert", "shaders/shader_5_1_tex_copy.frag");
|
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");
|
programSun = shaderLoader.CreateProgram("shaders/shader_sun.vert", "shaders/shader_sun.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");
|
|
||||||
programSkyBox = shaderLoader.CreateProgram("shaders/shader_skybox.vert", "shaders/shader_skybox.frag");
|
programSkyBox = shaderLoader.CreateProgram("shaders/shader_skybox.vert", "shaders/shader_skybox.frag");
|
||||||
|
programSpaceShip = shaderLoader.CreateProgram("shaders/shader_pbr.vert", "shaders/shader_pbr.frag");
|
||||||
|
|
||||||
|
|
||||||
loadModelToContext("./models/sphere.obj", sphereContext);
|
loadModelToContext("./models/sphere.obj", sphereContext);
|
||||||
loadModelToContext("./models/spaceship.obj", shipContext);
|
loadModelToContext("./models/new_spaceship.obj", shipContext);
|
||||||
loadModelToContext("./models/cube.obj", cubeContext);
|
loadModelToContext("./models/cube.obj", cubeContext);
|
||||||
|
|
||||||
texture::mercury = Core::LoadTexture("textures/mercury/mercury.jpg");
|
texture::mercury = Core::LoadTexture("textures/mercury/mercury.jpg");
|
||||||
texture::venus = Core::LoadTexture("textures/venus/venus.jpg");
|
texture::venus = Core::LoadTexture("textures/venus/venus.jpg");
|
||||||
texture::earth = Core::LoadTexture("textures/earth/earth.png");
|
texture::earth = Core::LoadTexture("textures/earth/earth.png");
|
||||||
texture::ship = Core::LoadTexture("textures/spaceship/spaceship.jpg");
|
|
||||||
texture::moon = Core::LoadTexture("textures/earths_moon/moon.jpg");
|
texture::moon = Core::LoadTexture("textures/earths_moon/moon.jpg");
|
||||||
texture::sun = Core::LoadTexture("textures/sun/sun.jpg");
|
texture::sun = Core::LoadTexture("textures/sun/sun.jpg");
|
||||||
texture::mars = Core::LoadTexture("textures/mars/mars.jpg");
|
texture::mars = Core::LoadTexture("textures/mars/mars.jpg");
|
||||||
@ -316,7 +348,6 @@ void init(GLFWwindow* window)
|
|||||||
texture::mercuryNormal = Core::LoadTexture("textures/mercury/mercury_normal.png");
|
texture::mercuryNormal = Core::LoadTexture("textures/mercury/mercury_normal.png");
|
||||||
texture::venusNormal = Core::LoadTexture("textures/venus/venus_normal.png");
|
texture::venusNormal = Core::LoadTexture("textures/venus/venus_normal.png");
|
||||||
texture::earthNormal = Core::LoadTexture("textures/earth/earth_normal.png");
|
texture::earthNormal = Core::LoadTexture("textures/earth/earth_normal.png");
|
||||||
texture::shipNormal = Core::LoadTexture("textures/spaceship/spaceship_normal.jpg");
|
|
||||||
texture::asteroidNormal = Core::LoadTexture("textures/earths_moon/moon_normal.jpg");
|
texture::asteroidNormal = Core::LoadTexture("textures/earths_moon/moon_normal.jpg");
|
||||||
texture::marsNormal = Core::LoadTexture("textures/mars/mars_normal.jpg");
|
texture::marsNormal = Core::LoadTexture("textures/mars/mars_normal.jpg");
|
||||||
texture::jupiterNormal = Core::LoadTexture("textures/jupiter/jupiter_normal.png");
|
texture::jupiterNormal = Core::LoadTexture("textures/jupiter/jupiter_normal.png");
|
||||||
@ -324,8 +355,13 @@ void init(GLFWwindow* window)
|
|||||||
texture::uranusNormal = Core::LoadTexture("textures/uranus/uranus_normal.png");
|
texture::uranusNormal = Core::LoadTexture("textures/uranus/uranus_normal.png");
|
||||||
texture::neptuneNormal = Core::LoadTexture("textures/neptune/neptune_normal.png");
|
texture::neptuneNormal = Core::LoadTexture("textures/neptune/neptune_normal.png");
|
||||||
|
|
||||||
|
texture::ship = Core::LoadTexture("textures/new_spaceship/black_and_blue/ship_texture.jpg");
|
||||||
|
texture::shipNormal = Core::LoadTexture("textures/new_spaceship/ship_normal.jpg");
|
||||||
|
texture::shipMetalness = Core::LoadTexture("textures/new_spaceship/ship_metalic.jpg");
|
||||||
|
texture::shipRoughness = Core::LoadTexture("textures/new_spaceship/ship_roughness.jpg");
|
||||||
|
|
||||||
//tutaj skybox start
|
|
||||||
|
//skybox
|
||||||
glGenTextures(1, &textureID);
|
glGenTextures(1, &textureID);
|
||||||
glBindTexture(GL_TEXTURE_CUBE_MAP, textureID);
|
glBindTexture(GL_TEXTURE_CUBE_MAP, textureID);
|
||||||
|
|
||||||
@ -333,7 +369,7 @@ void init(GLFWwindow* window)
|
|||||||
"textures/skybox/right.png",
|
"textures/skybox/right.png",
|
||||||
"textures/skybox/left.png",
|
"textures/skybox/left.png",
|
||||||
"textures/skybox/top.png",
|
"textures/skybox/top.png",
|
||||||
"textures/skybox/bottaom.png",
|
"textures/skybox/bottom.png",
|
||||||
"textures/skybox/back.png",
|
"textures/skybox/back.png",
|
||||||
"textures/skybox/front.png"
|
"textures/skybox/front.png"
|
||||||
};
|
};
|
||||||
@ -369,6 +405,7 @@ void processInput(GLFWwindow* window)
|
|||||||
{
|
{
|
||||||
glm::vec3 spaceshipSide = glm::normalize(glm::cross(spaceshipDir, glm::vec3(0.f, 1.f, 0.f)));
|
glm::vec3 spaceshipSide = glm::normalize(glm::cross(spaceshipDir, glm::vec3(0.f, 1.f, 0.f)));
|
||||||
glm::vec3 spaceshipUp = glm::vec3(0.f, 1.f, 0.f);
|
glm::vec3 spaceshipUp = glm::vec3(0.f, 1.f, 0.f);
|
||||||
|
|
||||||
float angleSpeed = 0.005f;
|
float angleSpeed = 0.005f;
|
||||||
float moveSpeed = 0.0025f;
|
float moveSpeed = 0.0025f;
|
||||||
if (glfwGetKey(window, GLFW_KEY_ESCAPE) == GLFW_PRESS) {
|
if (glfwGetKey(window, GLFW_KEY_ESCAPE) == GLFW_PRESS) {
|
||||||
@ -393,15 +430,13 @@ void processInput(GLFWwindow* window)
|
|||||||
|
|
||||||
cameraPos = spaceshipPos - 1.5 * spaceshipDir + glm::vec3(0, 1, 0) * 0.5f;
|
cameraPos = spaceshipPos - 1.5 * spaceshipDir + glm::vec3(0, 1, 0) * 0.5f;
|
||||||
cameraDir = spaceshipDir;
|
cameraDir = spaceshipDir;
|
||||||
|
|
||||||
//cameraDir = glm::normalize(-cameraPos);
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// funkcja jest glowna petla
|
|
||||||
void renderLoop(GLFWwindow* window) {
|
void renderLoop(GLFWwindow* window) {
|
||||||
while (!glfwWindowShouldClose(window))
|
while (!glfwWindowShouldClose(window))
|
||||||
{
|
{
|
||||||
|
|
||||||
processInput(window);
|
processInput(window);
|
||||||
|
|
||||||
renderScene(window);
|
renderScene(window);
|
||||||
|
BIN
projekt_grk/textures/new_spaceship/Material.001_Emissive.jpg
Normal file
After Width: | Height: | Size: 309 KiB |
BIN
projekt_grk/textures/new_spaceship/Material.001_Mixed_AO.jpg
Normal file
After Width: | Height: | Size: 2.9 MiB |
After Width: | Height: | Size: 312 KiB |
After Width: | Height: | Size: 2.4 MiB |
After Width: | Height: | Size: 2.4 MiB |
After Width: | Height: | Size: 307 KiB |
BIN
projekt_grk/textures/new_spaceship/ship_metalic.jpg
Normal file
After Width: | Height: | Size: 3.1 MiB |
BIN
projekt_grk/textures/new_spaceship/ship_normal.jpg
Normal file
After Width: | Height: | Size: 2.9 MiB |
BIN
projekt_grk/textures/new_spaceship/ship_roughness.jpg
Normal file
After Width: | Height: | Size: 1.3 MiB |
BIN
projekt_grk/textures/new_spaceship/ship_texture.jpg
Normal file
After Width: | Height: | Size: 2.5 MiB |
Before Width: | Height: | Size: 910 KiB After Width: | Height: | Size: 891 KiB |
Before Width: | Height: | Size: 797 KiB After Width: | Height: | Size: 772 KiB |