Compare commits
7 Commits
Author | SHA1 | Date | |
---|---|---|---|
95cca1c2c2 | |||
584387449c | |||
2adc47f750 | |||
0a5a4c43b2 | |||
04dedc2dfd | |||
b3e7db568d | |||
83d5734a0d |
@ -1,23 +1,37 @@
|
||||
{
|
||||
"Version": 1,
|
||||
"WorkspaceRootPath": "C:\\Users\\maksg\\Documents\\Grafika_2024\\",
|
||||
"Documents": [],
|
||||
"DocumentGroupContainers": [
|
||||
{
|
||||
"Orientation": 0,
|
||||
"VerticalTabListWidth": 256,
|
||||
"DocumentGroups": [
|
||||
{
|
||||
"DockedWidth": 200,
|
||||
"SelectedChildIndex": -1,
|
||||
"Children": [
|
||||
{
|
||||
"$type": "Bookmark",
|
||||
"Name": "ST:128:0:{116d2292-e37d-41cd-a077-ebacac4c8cc4}"
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
{
|
||||
"Version": 1,
|
||||
"WorkspaceRootPath": "D:\\STUDIA_sem5\\GRAFIKA-PROJEKT\\grk\\",
|
||||
"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": [
|
||||
{
|
||||
"Orientation": 0,
|
||||
"VerticalTabListWidth": 256,
|
||||
"DocumentGroups": [
|
||||
{
|
||||
"DockedWidth": 200,
|
||||
"SelectedChildIndex": 0,
|
||||
"Children": [
|
||||
{
|
||||
"$type": "Document",
|
||||
"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": ""
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
BIN
.vs/grk-cw/v17/ipch/AutoPCH/97bba2bfcfe917a6/EX_7_1.ipch
Normal file
BIN
.vs/grk-cw/v17/ipch/AutoPCH/fb10e04556d1f6f7/CAMERA.ipch
Normal file
@ -1,22 +1,36 @@
|
||||
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
|
||||
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”)
|
||||
C:\Users\maksg\Documents\Grafika_2024\dependencies\glfw-3.3.8.bin.WIN32\include\GLFW\glfw3.h(123,1):
|
||||
zobacz poprzednią definicję „APIENTRY”
|
||||
|
||||
C:\Users\maksg\Documents\Grafika_2024\projekt_grk\src\ex_7_1.hpp(109,10): warning C4305: "inicjowanie": obcięcie z "double" do "float"
|
||||
(kompilowanie pliku źródłowego „src/main.cpp”)
|
||||
|
||||
C:\Users\maksg\Documents\Grafika_2024\projekt_grk\src\ex_7_1.hpp(155,13): warning C4244: "inicjowanie": konwersja z "double" do "float", możliwa utrata danych
|
||||
(kompilowanie pliku źródłowego „src/main.cpp”)
|
||||
|
||||
C:\Users\maksg\Documents\Grafika_2024\projekt_grk\src\ex_7_1.hpp(255,13): warning C4244: "inicjowanie": konwersja z "double" do "float", możliwa utrata danych
|
||||
(kompilowanie pliku źródłowego „src/main.cpp”)
|
||||
|
||||
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”)
|
||||
|
||||
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 -> C:\Users\maksg\Documents\Grafika_2024\Debug\projekt_grk.exe
|
||||
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
|
||||
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”)
|
||||
C:\Users\maksg\Documents\Grafika_2024\dependencies\glfw-3.3.8.bin.WIN32\include\GLFW\glfw3.h(123,1):
|
||||
zobacz poprzednią definicję „APIENTRY”
|
||||
|
||||
C:\Users\maksg\Documents\Grafika_2024\projekt_grk\src\ex_7_1.hpp(109,10): warning C4305: "inicjowanie": obcięcie z "double" do "float"
|
||||
(kompilowanie pliku źródłowego „src/main.cpp”)
|
||||
|
||||
C:\Users\maksg\Documents\Grafika_2024\projekt_grk\src\ex_7_1.hpp(155,13): warning C4244: "inicjowanie": konwersja z "double" do "float", możliwa utrata danych
|
||||
(kompilowanie pliku źródłowego „src/main.cpp”)
|
||||
|
||||
C:\Users\maksg\Documents\Grafika_2024\projekt_grk\src\ex_7_1.hpp(255,13): warning C4244: "inicjowanie": konwersja z "double" do "float", możliwa utrata danych
|
||||
(kompilowanie pliku źródłowego „src/main.cpp”)
|
||||
|
||||
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”)
|
||||
|
||||
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”
|
||||
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
|
||||
|
@ -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
|
||||
|
@ -1,2 +1,2 @@
|
||||
PlatformToolSet=v143:VCToolArchitecture=Native32Bit:VCToolsVersion=14.39.33519:TargetPlatformVersion=10.0.22621.0:
|
||||
Debug|Win32|C:\Users\maksg\Documents\Grafika_2024\|
|
||||
PlatformToolSet=v143:VCToolArchitecture=Native32Bit:VCToolsVersion=14.39.33519:TargetPlatformVersion=10.0.22000.0:
|
||||
Debug|Win32|D:\STUDIA_sem5\GRAFIKA-PROJEKT\grk\|
|
||||
|
@ -39,14 +39,18 @@
|
||||
<ItemGroup>
|
||||
<None Include="shaders\shader_5_1.frag" />
|
||||
<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.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.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.vert" />
|
||||
</ItemGroup>
|
||||
|
@ -91,10 +91,10 @@
|
||||
</ClInclude>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<None Include="shaders\shader_5_sun.frag">
|
||||
<None Include="shaders\shader_sun.frag">
|
||||
<Filter>Shader Files</Filter>
|
||||
</None>
|
||||
<None Include="shaders\shader_5_sun.vert">
|
||||
<None Include="shaders\shader_sun.vert">
|
||||
<Filter>Shader Files</Filter>
|
||||
</None>
|
||||
<None Include="shaders\shader_5_1.frag">
|
||||
@ -103,12 +103,6 @@
|
||||
<None Include="shaders\shader_5_1.vert">
|
||||
<Filter>Shader Files</Filter>
|
||||
</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">
|
||||
<Filter>Shader Files</Filter>
|
||||
</None>
|
||||
@ -127,5 +121,23 @@
|
||||
<None Include="shaders\shader_coin.vert">
|
||||
<Filter>Shader Files</Filter>
|
||||
</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>
|
||||
</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);
|
||||
}
|
@ -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);
|
||||
}
|
23
projekt_grk/shaders/shader_bloom.frag
Normal 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);
|
||||
}
|
11
projekt_grk/shaders/shader_bloom.vert
Normal 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);
|
||||
}
|
33
projekt_grk/shaders/shader_blur.frag
Normal 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);
|
||||
}
|
11
projekt_grk/shaders/shader_blur.vert
Normal 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);
|
||||
}
|
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);
|
||||
}
|
@ -1,12 +1,21 @@
|
||||
#version 430 core
|
||||
|
||||
layout (location = 0) out vec4 outColor;
|
||||
layout (location = 1) out vec4 BrightColor;
|
||||
|
||||
uniform samplerCube skybox;
|
||||
|
||||
in vec3 texCoord;
|
||||
|
||||
out vec4 out_color;
|
||||
|
||||
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;
|
||||
}
|
||||
|
22
projekt_grk/shaders/shader_sun.frag
Normal 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);
|
||||
}
|
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 |