monety #5

Closed
s473595 wants to merge 7 commits from monety into master
58 changed files with 62179 additions and 617 deletions

Binary file not shown.

Binary file not shown.

View File

@ -1,7 +1,12 @@
{ {
"Version": 1, "Version": 1,
"WorkspaceRootPath": "C:\\Users\\maksg\\Documents\\Grafika_2024\\", "WorkspaceRootPath": "D:\\STUDIA_sem5\\GRAFIKA-PROJEKT\\grk\\",
"Documents": [], "Documents": [
{
"AbsoluteMoniker": "D:0:0:{F2FC2E8F-CBA6-49D7-8B73-4BFBCB64D310}|projekt_grk\\grk-cw7.vcxproj|D:\\STUDIA_sem5\\GRAFIKA-PROJEKT\\grk\\projekt_grk\\src\\ex_7_1.hpp||{D0E1A5C6-B359-4E41-9B60-3365922C2A22}",
"RelativeMoniker": "D:0:0:{F2FC2E8F-CBA6-49D7-8B73-4BFBCB64D310}|projekt_grk\\grk-cw7.vcxproj|solutionrelative:projekt_grk\\src\\ex_7_1.hpp||{D0E1A5C6-B359-4E41-9B60-3365922C2A22}"
}
],
"DocumentGroupContainers": [ "DocumentGroupContainers": [
{ {
"Orientation": 0, "Orientation": 0,
@ -9,11 +14,20 @@
"DocumentGroups": [ "DocumentGroups": [
{ {
"DockedWidth": 200, "DockedWidth": 200,
"SelectedChildIndex": -1, "SelectedChildIndex": 0,
"Children": [ "Children": [
{ {
"$type": "Bookmark", "$type": "Document",
"Name": "ST:128:0:{116d2292-e37d-41cd-a077-ebacac4c8cc4}" "DocumentIndex": 0,
"Title": "ex_7_1.hpp",
"DocumentMoniker": "D:\\STUDIA_sem5\\GRAFIKA-PROJEKT\\grk\\projekt_grk\\src\\ex_7_1.hpp",
"RelativeDocumentMoniker": "projekt_grk\\src\\ex_7_1.hpp",
"ToolTip": "D:\\STUDIA_sem5\\GRAFIKA-PROJEKT\\grk\\projekt_grk\\src\\ex_7_1.hpp",
"RelativeToolTip": "projekt_grk\\src\\ex_7_1.hpp",
"ViewState": "AQIAABICAAAAAAAAAAAAAEoCAAAAAAAA",
"Icon": "ae27a6b0-e345-4288-96df-5eaf394ee369.000680|",
"WhenOpened": "2024-02-27T10:49:30.827Z",
"EditorCaption": ""
} }
] ]
} }

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

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,4 +1,4 @@
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. 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.
main.cpp main.cpp
C:\Program Files (x86)\Windows Kits\10\Include\10.0.22621.0\shared\minwindef.h(130,1): warning C4005: "APIENTRY": ponowna definicja makra C:\Program Files (x86)\Windows Kits\10\Include\10.0.22621.0\shared\minwindef.h(130,1): warning C4005: "APIENTRY": ponowna definicja makra
(kompilowanie pliku źródłowego „src/main.cpp”) (kompilowanie pliku źródłowego „src/main.cpp”)
@ -17,6 +17,20 @@ C:\Users\maksg\Documents\Grafika_2024\projekt_grk\src\ex_7_1.hpp(255,13): warnin
C:\Users\maksg\Documents\Grafika_2024\projekt_grk\src\ex_7_1.hpp(273,29): warning C4305: "inicjowanie": obcięcie z "double" do "float" C:\Users\maksg\Documents\Grafika_2024\projekt_grk\src\ex_7_1.hpp(273,29): warning C4305: "inicjowanie": obcięcie z "double" do "float"
(kompilowanie pliku źródłowego „src/main.cpp”) (kompilowanie pliku źródłowego „src/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
(kompilowanie pliku źródłowego „src/main.cpp”)
D:\STUDIA_sem5\GRAFIKA-PROJEKT\grk\dependencies\glfw-3.3.8.bin.WIN32\include\GLFW\glfw3.h(123,1):
zobacz poprzednią definicję „APIENTRY”
D:\STUDIA_sem5\GRAFIKA-PROJEKT\grk\projekt_grk\src\ex_7_1.hpp(110,10): warning C4305: "inicjowanie": obcięcie z "double" do "float"
(kompilowanie pliku źródłowego „src/main.cpp”)
D:\STUDIA_sem5\GRAFIKA-PROJEKT\grk\projekt_grk\src\ex_7_1.hpp(332,13): warning C4244: "inicjowanie": konwersja z "double" do "float", możliwa utrata danych
(kompilowanie pliku źródłowego „src/main.cpp”)
D:\STUDIA_sem5\GRAFIKA-PROJEKT\grk\projekt_grk\src\ex_7_1.hpp(350,29): warning C4305: "inicjowanie": obcięcie z "double" do "float"
(kompilowanie pliku źródłowego „src/main.cpp”)
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 -> C:\Users\maksg\Documents\Grafika_2024\Debug\projekt_grk.exe grk-cw7.vcxproj -> C:\Users\maksg\Documents\Grafika_2024\Debug\projekt_grk.exe

Binary file not shown.

Binary file not shown.

Binary file not shown.

View File

@ -1 +1 @@
^C:\USERS\MAKSG\DOCUMENTS\GRAFIKA_2024\PROJEKT_GRK\DEBUG\BOX.OBJ|C:\USERS\MAKSG\DOCUMENTS\GRAFIKA_2024\PROJEKT_GRK\DEBUG\CAMERA.OBJ|C:\USERS\MAKSG\DOCUMENTS\GRAFIKA_2024\PROJEKT_GRK\DEBUG\IMAGE_DXT.OBJ|C:\USERS\MAKSG\DOCUMENTS\GRAFIKA_2024\PROJEKT_GRK\DEBUG\IMAGE_HELPER.OBJ|C:\USERS\MAKSG\DOCUMENTS\GRAFIKA_2024\PROJEKT_GRK\DEBUG\MAIN.OBJ|C:\USERS\MAKSG\DOCUMENTS\GRAFIKA_2024\PROJEKT_GRK\DEBUG\RENDER_UTILS.OBJ|C:\USERS\MAKSG\DOCUMENTS\GRAFIKA_2024\PROJEKT_GRK\DEBUG\SHADER_LOADER.OBJ|C:\USERS\MAKSG\DOCUMENTS\GRAFIKA_2024\PROJEKT_GRK\DEBUG\SOIL.OBJ|C:\USERS\MAKSG\DOCUMENTS\GRAFIKA_2024\PROJEKT_GRK\DEBUG\STB_IMAGE_AUG.OBJ|C:\USERS\MAKSG\DOCUMENTS\GRAFIKA_2024\PROJEKT_GRK\DEBUG\TEXTURE.OBJ ^D:\STUDIA_SEM5\GRAFIKA-PROJEKT\GRK\PROJEKT_GRK\DEBUG\BOX.OBJ|D:\STUDIA_SEM5\GRAFIKA-PROJEKT\GRK\PROJEKT_GRK\DEBUG\CAMERA.OBJ|D:\STUDIA_SEM5\GRAFIKA-PROJEKT\GRK\PROJEKT_GRK\DEBUG\IMAGE_DXT.OBJ|D:\STUDIA_SEM5\GRAFIKA-PROJEKT\GRK\PROJEKT_GRK\DEBUG\IMAGE_HELPER.OBJ|D:\STUDIA_SEM5\GRAFIKA-PROJEKT\GRK\PROJEKT_GRK\DEBUG\MAIN.OBJ|D:\STUDIA_SEM5\GRAFIKA-PROJEKT\GRK\PROJEKT_GRK\DEBUG\RENDER_UTILS.OBJ|D:\STUDIA_SEM5\GRAFIKA-PROJEKT\GRK\PROJEKT_GRK\DEBUG\SHADER_LOADER.OBJ|D:\STUDIA_SEM5\GRAFIKA-PROJEKT\GRK\PROJEKT_GRK\DEBUG\SOIL.OBJ|D:\STUDIA_SEM5\GRAFIKA-PROJEKT\GRK\PROJEKT_GRK\DEBUG\STB_IMAGE_AUG.OBJ|D:\STUDIA_SEM5\GRAFIKA-PROJEKT\GRK\PROJEKT_GRK\DEBUG\TEXTURE.OBJ

View File

@ -1,2 +1,2 @@
PlatformToolSet=v143:VCToolArchitecture=Native32Bit:VCToolsVersion=14.39.33519:TargetPlatformVersion=10.0.22621.0: PlatformToolSet=v143:VCToolArchitecture=Native32Bit:VCToolsVersion=14.39.33519:TargetPlatformVersion=10.0.22000.0:
Debug|Win32|C:\Users\maksg\Documents\Grafika_2024\| Debug|Win32|D:\STUDIA_sem5\GRAFIKA-PROJEKT\grk\|

Binary file not shown.

Binary file not shown.

Binary file not shown.

View File

@ -39,14 +39,18 @@
<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_5_sun.vert" />
<None Include="shaders\shader_coin.frag" /> <None Include="shaders\shader_coin.frag" />
<None Include="shaders\shader_coin.vert" /> <None Include="shaders\shader_coin.vert" />
<None Include="shaders\shader_bloom.frag" />
<None Include="shaders\shader_bloom.vert" />
<None Include="shaders\shader_blur.frag" />
<None Include="shaders\shader_blur.vert" />
<None Include="shaders\shader_sun.frag" />
<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>

View File

@ -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>
@ -127,5 +121,23 @@
<None Include="shaders\shader_coin.vert"> <None Include="shaders\shader_coin.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>
<None Include="shaders\shader_bloom.frag">
<Filter>Shader Files</Filter>
</None>
<None Include="shaders\shader_bloom.vert">
<Filter>Shader Files</Filter>
</None>
<None Include="shaders\shader_blur.frag">
<Filter>Shader Files</Filter>
</None>
<None Include="shaders\shader_blur.vert">
<Filter>Shader Files</Filter>
</None>
</ItemGroup> </ItemGroup>
</Project> </Project>

File diff suppressed because it is too large Load Diff

View 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);
}

View File

@ -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);
}

View File

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

View File

@ -0,0 +1,23 @@
#version 430 core
out vec4 FragColor;
in vec2 TexCoords;
uniform sampler2D scene;
uniform sampler2D bloomBlur;
uniform bool bloom;
uniform float exposure;
void main()
{
const float gamma = 1.5;
vec3 hdrColor = texture(scene, TexCoords).rgb;
vec3 bloomColor = texture(bloomBlur, TexCoords).rgb;
if(bloom)
hdrColor += bloomColor; // additive blending
// tone mapping
vec3 result = vec3(1.0) - exp(-hdrColor * exposure);
// also gamma correct while we're at it
result = pow(result, vec3(1.0 / gamma));
FragColor = vec4(result, 1.0);
}

View File

@ -0,0 +1,11 @@
#version 430 core
layout (location = 7) in vec3 aPos;
layout (location = 8) in vec2 aTexCoords;
out vec2 TexCoords;
void main()
{
TexCoords = aTexCoords;
gl_Position = vec4(aPos, 1.0);
}

View File

@ -0,0 +1,33 @@
#version 430 core
out vec4 FragColor;
in vec2 TexCoords;
uniform sampler2D image;
uniform int count;
uniform bool horizontal;
uniform float weight[5] = float[] (0.2270270270, 0.1945945946, 0.1216216216, 0.0540540541, 0.0162162162);
void main()
{
vec2 tex_offset = 1.0 / textureSize(image, 0); // gets size of single texel
vec3 result = texture(image, TexCoords).rgb * weight[0];
if(horizontal)
{
for(int i = 1; i < count; ++i)
{
result += texture(image, TexCoords + vec2(tex_offset.x * i, 0.0)).rgb * weight[i];
result += texture(image, TexCoords - vec2(tex_offset.x * i, 0.0)).rgb * weight[i];
}
}
else
{
for(int i = 1; i < 5; ++i)
{
result += texture(image, TexCoords + vec2(0.0, tex_offset.y * i)).rgb * weight[i];
result += texture(image, TexCoords - vec2(0.0, tex_offset.y * i)).rgb * weight[i];
}
}
FragColor = vec4(result, 1.0);
}

View File

@ -0,0 +1,11 @@
#version 430 core
layout (location = 0) in vec3 aPos;
layout (location = 1) in vec2 aTexCoords;
out vec2 TexCoords;
void main()
{
TexCoords = aTexCoords;
gl_Position = vec4(aPos, 1.0);
}

View 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);
}

View 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);
}

View File

@ -1,12 +1,21 @@
#version 430 core #version 430 core
layout (location = 0) out vec4 outColor;
layout (location = 1) out vec4 BrightColor;
uniform samplerCube skybox; uniform samplerCube skybox;
in vec3 texCoord; in vec3 texCoord;
out vec4 out_color;
void main() void main()
{ {
out_color = texture(skybox,texCoord); vec4 texColor = texture(skybox, texCoord);
float brightness = dot(texColor.rgb, vec3(0.2126, 0.7152, 0.0722));
if (brightness > 0.2)
BrightColor = vec4(texColor.rgb, 1.0);
else
BrightColor = vec4(0.0, 0.0, 0.0, 1.0);
outColor = texColor;
} }

View File

@ -0,0 +1,22 @@
#version 430 core
layout (location = 0) out vec4 outColor;
layout (location = 1) out vec4 BrightColor;
uniform float exposition;
uniform sampler2D sunTexture;
in vec2 TexCoords;
void main()
{
vec3 textureColor = texture(sunTexture, TexCoords).xyz;
vec3 adjustedColor = textureColor * exposition;
vec3 finalColor = clamp(adjustedColor, 0.0, 1.0);
outColor = vec4(finalColor, 1.0);
float brightness = dot(finalColor, vec3(0.2126, 0.7152, 0.0722));
if(brightness > 0.2)
BrightColor = vec4(finalColor, 1.0);
else
BrightColor = vec4(0.0, 0.0, 0.0, 1.0);
}

View File

@ -21,7 +21,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;
@ -33,24 +32,31 @@ 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 programCoin; GLuint programCoin;
GLuint programSpaceShip;
GLuint programBlur;
GLuint programBloom;
Core::Shader_Loader shaderLoader; Core::Shader_Loader shaderLoader;
Core::RenderContext shipContext; Core::RenderContext shipContext;
@ -58,8 +64,9 @@ Core::RenderContext sphereContext;
Core::RenderContext cubeContext; Core::RenderContext cubeContext;
Core::RenderContext cylinderContext; Core::RenderContext cylinderContext;
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);
@ -85,6 +92,18 @@ float zCordinatesOfCoin[maxSize] = {
float xCordinatesOfCollectedCoin[maxSize] = {}; float xCordinatesOfCollectedCoin[maxSize] = {};
float zCordinatesOfCollectedCoin[maxSize] = {}; float zCordinatesOfCollectedCoin[maxSize] = {};
unsigned int hdrFBO;
unsigned int colorBuffers[2];
unsigned int pingpongFBO[2];
unsigned int pingpongColorbuffers[2];
unsigned int rboDepth;
int HDR_WIDTH;
int HDR_HEIGHT;
int blur_count = 5;
float bloom_exposure = 2.0f;
bool bloom = true;
glm::mat4 createCameraMatrix() glm::mat4 createCameraMatrix()
{ {
@ -123,6 +142,91 @@ glm::mat4 createPerspectiveMatrix()
return perspectiveMatrix; return perspectiveMatrix;
} }
unsigned int quadVAO = 0;
unsigned int quadVBO;
void renderQuad()
{
if (quadVAO == 0)
{
float quadVertices[] = {
-1.0f, 1.0f, 0.0f, 0.0f, 1.0f,
-1.0f, -1.0f, 0.0f, 0.0f, 0.0f,
1.0f, 1.0f, 0.0f, 1.0f, 1.0f,
1.0f, -1.0f, 0.0f, 1.0f, 0.0f,
};
glGenVertexArrays(1, &quadVAO);
glGenBuffers(1, &quadVBO);
glBindVertexArray(quadVAO);
glBindBuffer(GL_ARRAY_BUFFER, quadVBO);
glBufferData(GL_ARRAY_BUFFER, sizeof(quadVertices), &quadVertices, GL_STATIC_DRAW);
// locations 7 i 8 aby nie by<62>o kolizii z shaderem statku
glEnableVertexAttribArray(7);
glVertexAttribPointer(7, 3, GL_FLOAT, GL_FALSE, 5 * sizeof(float), (void*)0);
glEnableVertexAttribArray(8);
glVertexAttribPointer(8, 2, GL_FLOAT, GL_FALSE, 5 * sizeof(float), (void*)(3 * sizeof(float)));
}
glBindVertexArray(quadVAO);
glDrawArrays(GL_TRIANGLE_STRIP, 0, 4);
glBindVertexArray(0);
}
void blur(GLFWwindow* window) {
glfwGetWindowSize(window, &HDR_WIDTH, &HDR_HEIGHT);
glGenFramebuffers(2, pingpongFBO);
glGenTextures(2, pingpongColorbuffers);
for (unsigned int i = 0; i < 2; i++)
{
glBindFramebuffer(GL_FRAMEBUFFER, pingpongFBO[i]);
glBindTexture(GL_TEXTURE_2D, pingpongColorbuffers[i]);
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA16F, HDR_WIDTH, HDR_HEIGHT, 0, GL_RGBA, GL_FLOAT, NULL);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE); // we clamp to the edge as the blur filter would otherwise sample repeated texture values!
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, pingpongColorbuffers[i], 0);
// also check if framebuffers are complete (no need for depth buffer)
if (glCheckFramebufferStatus(GL_FRAMEBUFFER) != GL_FRAMEBUFFER_COMPLETE)
std::cout << "Framebuffer not complete!" << std::endl;
}
}
void initRBOandHDR(GLFWwindow* window) {
glfwGetWindowSize(window, &HDR_WIDTH, &HDR_HEIGHT);
glGenFramebuffers(1, &hdrFBO);
glBindFramebuffer(GL_FRAMEBUFFER, hdrFBO);
glGenTextures(2, colorBuffers);
for (unsigned int i = 0; i < 2; i++) {
glBindTexture(GL_TEXTURE_2D, colorBuffers[i]);
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA16F, HDR_WIDTH, HDR_HEIGHT, 0, GL_RGBA, GL_FLOAT, NULL);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0 + i, GL_TEXTURE_2D, colorBuffers[i], 0);
}
glGenRenderbuffers(1, &rboDepth);
glBindRenderbuffer(GL_RENDERBUFFER, rboDepth);
glRenderbufferStorage(GL_RENDERBUFFER, GL_DEPTH_COMPONENT, HDR_WIDTH, HDR_HEIGHT);
glFramebufferRenderbuffer(GL_FRAMEBUFFER, GL_DEPTH_ATTACHMENT, GL_RENDERBUFFER, rboDepth);
unsigned int attachments[2] = { GL_COLOR_ATTACHMENT0, GL_COLOR_ATTACHMENT1 };
glDrawBuffers(2, attachments);
if (glCheckFramebufferStatus(GL_FRAMEBUFFER) != GL_FRAMEBUFFER_COMPLETE)
std::cout << "Framebuffer not complete!" << std::endl;
glBindFramebuffer(GL_FRAMEBUFFER, 0);
}
void drawObjectColor(Core::RenderContext& context, glm::mat4 modelMatrix, glm::vec3 color) { void drawObjectColor(Core::RenderContext& context, glm::mat4 modelMatrix, glm::vec3 color) {
GLuint prog = program; GLuint prog = program;
glUseProgram(prog); glUseProgram(prog);
@ -225,6 +329,36 @@ void drawSun(Core::RenderContext& context, glm::mat4 modelMatrix, GLuint texture
Core::DrawContext(context); Core::DrawContext(context);
} }
void drawSunBlur() {
bool horizontal = true, first_iteration = true;
unsigned int amount = 10;
glUseProgram(programBlur);
glUniform1i(glGetUniformLocation(programBlur, "count"), blur_count);
for (unsigned int i = 0; i < amount; i++)
{
glBindFramebuffer(GL_FRAMEBUFFER, pingpongFBO[horizontal]);
glUniform1i(glGetUniformLocation(programBlur, "horizontal"), horizontal);
glBindTexture(GL_TEXTURE_2D, first_iteration ? colorBuffers[1] : pingpongColorbuffers[!horizontal]);
renderQuad();
horizontal = !horizontal;
if (first_iteration)
first_iteration = false;
}
glBindFramebuffer(GL_FRAMEBUFFER, 0);
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
glUseProgram(programBloom);
glActiveTexture(GL_TEXTURE0);
glBindTexture(GL_TEXTURE_2D, colorBuffers[0]);
glActiveTexture(GL_TEXTURE1);
glBindTexture(GL_TEXTURE_2D, pingpongColorbuffers[!horizontal]);
glUniform1i(glGetUniformLocation(programBloom, "bloom"), bloom);
glUniform1f(glGetUniformLocation(programBloom, "exposure"), bloom_exposure);
renderQuad();
}
void drawObjectSkyBox(Core::RenderContext& context, glm::mat4 modelMatrix) { void drawObjectSkyBox(Core::RenderContext& context, glm::mat4 modelMatrix) {
glDisable(GL_DEPTH_TEST); glDisable(GL_DEPTH_TEST);
glUseProgram(programSkyBox); glUseProgram(programSkyBox);
@ -238,14 +372,38 @@ 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);
} }
void renderPlanet(float time, float orbitRadius, float orbitRotationSpeed, float selfRotationSpeed, float scale, GLuint planetTexture, GLuint normalTexture) { void renderPlanet(float time, float orbitRadius, float orbitRotationSpeed, float selfRotationSpeed, float scale, GLuint planetTexture, GLuint normalTexture) {
glm::mat4 planetTransform = glm::rotate(glm::mat4(1.0f), time * orbitRotationSpeed, glm::vec3(0, 1, 0)) // orbitowanie dooko³a s³oñca glm::mat4 planetTransform = glm::rotate(glm::mat4(1.0f), time * orbitRotationSpeed, glm::vec3(0, 1, 0)) // orbitowanie dooko<EFBFBD>a s<>o<EFBFBD>ca
* glm::translate(glm::vec3(orbitRadius, 0, 0)) // translacja na odp. odleg³oœæ * glm::translate(glm::vec3(orbitRadius, 0, 0)) // translacja na odp. odleg<EFBFBD>o<EFBFBD><EFBFBD>
* glm::rotate(glm::mat4(1.0f), time * selfRotationSpeed, glm::vec3(0, 1, 0)) //obrót planety wokó³ w³asnej osi * glm::rotate(glm::mat4(1.0f), time * selfRotationSpeed, glm::vec3(0, 1, 0)) //obr<EFBFBD>t planety wok<6F> w<>asnej osi
* glm::scale(glm::vec3(scale)); //skalowanie planety * glm::scale(glm::vec3(scale)); //skalowanie planety
drawObjectTexture(sphereContext, planetTransform, planetTexture, normalTexture); drawObjectTexture(sphereContext, planetTransform, planetTexture, normalTexture);
@ -299,7 +457,7 @@ void renderPlanets() {
renderPlanet(time, venusOrbitRadius, venusRotationSpeed, venusSelfRotationSpeed, venusScale, texture::venus, texture::venusNormal); renderPlanet(time, venusOrbitRadius, venusRotationSpeed, venusSelfRotationSpeed, venusScale, texture::venus, texture::venusNormal);
renderPlanet(time, earthOrbitRadius, earthRotationSpeed, earthSelfRotationSpeed, earthScale, texture::earth, texture::earthNormal); renderPlanet(time, earthOrbitRadius, earthRotationSpeed, earthSelfRotationSpeed, earthScale, texture::earth, texture::earthNormal);
//earths moon, musi byæ inaczej renderowany bo on nie orbituje wokó³ s³oñca tylko ziemi. PóŸniej to mo¿na jakoœ lepiej rozwi¹zaæ. //earths moon, musi by<EFBFBD> inaczej renderowany bo on nie orbituje wok<6F> s<>o<EFBFBD>ca tylko ziemi. P<>niej to mo<6D>na jako<6B> lepiej rozwi<77>za<7A>.
drawObjectTexture(sphereContext, drawObjectTexture(sphereContext,
glm::eulerAngleY(time * earthRotationSpeed) * glm::translate(glm::vec3(earthOrbitRadius, 0, 0)) * glm::eulerAngleY(time * moonRotationSpeed) * glm::translate(glm::vec3(moonOrbitRadius, 0, 0)) * glm::scale(glm::vec3(moonScale)), glm::eulerAngleY(time * earthRotationSpeed) * glm::translate(glm::vec3(earthOrbitRadius, 0, 0)) * glm::eulerAngleY(time * moonRotationSpeed) * glm::translate(glm::vec3(moonOrbitRadius, 0, 0)) * glm::scale(glm::vec3(moonScale)),
texture::moon, texture::moon,
@ -318,6 +476,8 @@ 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);
glBindFramebuffer(GL_FRAMEBUFFER, hdrFBO);
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
//skybox //skybox
drawObjectSkyBox(cubeContext, glm::translate(cameraPos)); drawObjectSkyBox(cubeContext, glm::translate(cameraPos));
@ -331,8 +491,10 @@ void renderScene(GLFWwindow* window)
renderPlanets(); renderPlanets();
renderCoins(); renderCoins();
// 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,
@ -340,18 +502,27 @@ 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
); );
glBindFramebuffer(GL_FRAMEBUFFER, 0);
drawSunBlur();
glUseProgram(0); glUseProgram(0);
glfwSwapBuffers(window); glfwSwapBuffers(window);
} }
void framebuffer_size_callback(GLFWwindow* window, int width, int height) void framebuffer_size_callback(GLFWwindow* window, int width, int height)
{ {
aspectRatio = width / float(height); aspectRatio = width / float(height);
initRBOandHDR(window);
blur(window);
glViewport(0, 0, width, height); glViewport(0, 0, width, height);
} }
void loadModelToContext(std::string path, Core::RenderContext& context) void loadModelToContext(std::string path, Core::RenderContext& context)
@ -370,26 +541,27 @@ void loadModelToContext(std::string path, Core::RenderContext& context)
void init(GLFWwindow* window) void init(GLFWwindow* window)
{ {
glfwSetFramebufferSizeCallback(window, framebuffer_size_callback); glfwSetFramebufferSizeCallback(window, framebuffer_size_callback);
initRBOandHDR(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");
programCoin = shaderLoader.CreateProgram("shaders/shader_coin.vert", "shaders/shader_coin.frag"); programCoin = shaderLoader.CreateProgram("shaders/shader_coin.vert", "shaders/shader_coin.frag");
programSpaceShip = shaderLoader.CreateProgram("shaders/shader_pbr.vert", "shaders/shader_pbr.frag");
programBlur = shaderLoader.CreateProgram("shaders/shader_blur.vert", "shaders/shader_blur.frag");
programBloom = shaderLoader.CreateProgram("shaders/shader_bloom.vert", "shaders/shader_bloom.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);
loadModelToContext("./models/cylinder.obj", cylinderContext); loadModelToContext("./models/cylinder.obj", cylinderContext);
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");
@ -401,7 +573,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");
@ -409,8 +580,12 @@ 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);
@ -418,7 +593,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"
}; };
@ -442,6 +617,13 @@ void init(GLFWwindow* window)
glTexParameteri(GL_TEXTURE_CUBE_MAP, GL_TEXTURE_WRAP_R, GL_CLAMP_TO_EDGE); glTexParameteri(GL_TEXTURE_CUBE_MAP, GL_TEXTURE_WRAP_R, GL_CLAMP_TO_EDGE);
//skybox end //skybox end
blur(window);
glUseProgram(programBlur);
glUniform1i(glGetUniformLocation(programBloom, "image"), 0);
glUseProgram(programBloom);
glUniform1i(glGetUniformLocation(programBloom, "scene"), 0);
glUniform1i(glGetUniformLocation(programBloom, "bloomBlur"), 1);
} }
void shutdown(GLFWwindow* window) void shutdown(GLFWwindow* window)
@ -449,11 +631,11 @@ void shutdown(GLFWwindow* window)
shaderLoader.DeleteProgram(program); shaderLoader.DeleteProgram(program);
} }
//obsluga wejscia
void processInput(GLFWwindow* window) 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) {
@ -478,17 +660,12 @@ 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);
glfwPollEvents(); glfwPollEvents();
} }

Binary file not shown.

After

Width:  |  Height:  |  Size: 309 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.9 MiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 312 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.4 MiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.4 MiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 307 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.1 MiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.9 MiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.3 MiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.5 MiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 910 KiB

After

Width:  |  Height:  |  Size: 891 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 797 KiB

After

Width:  |  Height:  |  Size: 772 KiB