Restructuring the project directory
This commit is contained in:
14
data/lights.json
Normal file
14
data/lights.json
Normal file
@@ -0,0 +1,14 @@
|
||||
{
|
||||
"directionalLight": {
|
||||
"intensity": 0.5,
|
||||
"direction": [-0.2, -1.0, -0.3],
|
||||
"color": [1.0, 1.0, 1.0]
|
||||
},
|
||||
"pointLights": [
|
||||
{
|
||||
"intensity": 10.0,
|
||||
"position": [0.0, 1.0, 0.0],
|
||||
"color": [1.0, 1.0, 1.0]
|
||||
}
|
||||
]
|
||||
}
|
||||
43
data/models.json
Normal file
43
data/models.json
Normal file
@@ -0,0 +1,43 @@
|
||||
{
|
||||
"models": [
|
||||
{
|
||||
"unique_name": "fallback",
|
||||
"path": "data/res/models/fallback.ffo"
|
||||
},
|
||||
{
|
||||
"unique_name": "backpack",
|
||||
"path": "data/res/models/backpack.ffo"
|
||||
},
|
||||
{
|
||||
"unique_name": "ground",
|
||||
"path": "data/res/models/wood_floor.ffo"
|
||||
},
|
||||
{
|
||||
"unique_name": "cube",
|
||||
"path": "data/res/models/cube.ffo"
|
||||
}
|
||||
],
|
||||
"entities": [
|
||||
{
|
||||
"unique_name": "backpack",
|
||||
"model": "backpack",
|
||||
"shaderProgram": "defaultProgram",
|
||||
"position": [0.0, 1.0, 0.0],
|
||||
"rotation": [0.0, 0.0, 0.0],
|
||||
"scale": 0.6
|
||||
},
|
||||
{
|
||||
"unique_name": "ground",
|
||||
"model": "ground",
|
||||
"shaderProgram": "defaultProgram"
|
||||
},
|
||||
{
|
||||
"unique_name": "light",
|
||||
"model": "cube",
|
||||
"shaderProgram": "lightProgram"
|
||||
}
|
||||
],
|
||||
"skybox": {
|
||||
"texturePath": "data/res/textures/skybox/"
|
||||
}
|
||||
}
|
||||
1
data/res
Submodule
1
data/res
Submodule
Submodule data/res added at 84f2a02390
21
data/screens.json
Normal file
21
data/screens.json
Normal file
@@ -0,0 +1,21 @@
|
||||
{
|
||||
"loadingScreen": [
|
||||
{
|
||||
"position": [0.0, 0.0],
|
||||
"dimensions": [1.0, 1.0],
|
||||
"texture": "data/res/textures/loading.png"
|
||||
}
|
||||
],
|
||||
"mainMenuScreen": [
|
||||
{
|
||||
"position": [0.5, 0.5],
|
||||
"dimensions": [0.25, 0.25],
|
||||
"texture": "data/res/textures/container.png"
|
||||
},
|
||||
{
|
||||
"position": [0.75, 0.0],
|
||||
"dimensions": [0.25, 0.25],
|
||||
"texture": "data/res/textures/tex2.png"
|
||||
}
|
||||
]
|
||||
}
|
||||
40
data/shaderPrograms.json
Normal file
40
data/shaderPrograms.json
Normal file
@@ -0,0 +1,40 @@
|
||||
{
|
||||
"shaderPrograms": [
|
||||
{
|
||||
"unique_name": "defaultProgram",
|
||||
"vertexPath": "data/shaders/basic.vert",
|
||||
"fragmentPath": "data/shaders/basic.frag"
|
||||
},
|
||||
{
|
||||
"unique_name": "lightProgram",
|
||||
"vertexPath": "data/shaders/light.vert",
|
||||
"fragmentPath": "data/shaders/light.frag"
|
||||
},
|
||||
{
|
||||
"unique_name": "skyboxProgram",
|
||||
"vertexPath": "data/shaders/skybox.vert",
|
||||
"fragmentPath": "data/shaders/skybox.frag"
|
||||
},
|
||||
{
|
||||
"unique_name": "postProcessingProgram",
|
||||
"vertexPath": "data/shaders/postprocessing.vert",
|
||||
"fragmentPath": "data/shaders/postprocessing.frag"
|
||||
},
|
||||
{
|
||||
"unique_name": "menuProgram",
|
||||
"vertexPath": "data/shaders/menu.vert",
|
||||
"fragmentPath": "data/shaders/menu.frag"
|
||||
},
|
||||
{
|
||||
"unique_name": "directionalShadowDepthProgram",
|
||||
"vertexPath": "data/shaders/directionalShadowDepth.vert",
|
||||
"fragmentPath": "data/shaders/directionalShadowDepth.frag"
|
||||
},
|
||||
{
|
||||
"unique_name": "pointShadowDepthProgram",
|
||||
"vertexPath": "data/shaders/pointShadowDepth.vert",
|
||||
"fragmentPath": "data/shaders/pointShadowDepth.frag",
|
||||
"geometryPath": "data/shaders/pointShadowDepth.geom"
|
||||
}
|
||||
]
|
||||
}
|
||||
270
data/shaders/basic.frag
Normal file
270
data/shaders/basic.frag
Normal file
@@ -0,0 +1,270 @@
|
||||
#version 330 core
|
||||
|
||||
layout(location = 0) out vec4 f_color;
|
||||
|
||||
in vec3 v_normal;
|
||||
in vec2 v_texCoord;
|
||||
in vec3 v_fragmentPosition;
|
||||
in vec4 v_fragmentPositionDirectionalLightSpace;
|
||||
|
||||
struct Material {
|
||||
sampler2D texture_diffuse0;
|
||||
sampler2D texture_diffuse1;
|
||||
sampler2D texture_specular0;
|
||||
sampler2D texture_specular1;
|
||||
sampler2D texture_normal0;
|
||||
sampler2D texture_normal1;
|
||||
sampler2D texture_height0;
|
||||
sampler2D texture_height1;
|
||||
sampler2D texture_gloss0;
|
||||
sampler2D texture_gloss1;
|
||||
float shininess;
|
||||
};
|
||||
uniform Material u_material;
|
||||
|
||||
struct DirectionalLight {
|
||||
bool isActive;
|
||||
vec3 direction;
|
||||
|
||||
vec3 ambient;
|
||||
vec3 diffuse;
|
||||
vec3 specular;
|
||||
};
|
||||
uniform DirectionalLight u_directionalLight;
|
||||
|
||||
struct PointLight {
|
||||
bool isActive;
|
||||
vec3 position;
|
||||
|
||||
float K_q;
|
||||
|
||||
vec3 ambient;
|
||||
vec3 diffuse;
|
||||
vec3 specular;
|
||||
};
|
||||
#define NUM_POINT_LIGHTS 16
|
||||
uniform PointLight u_pointLight[NUM_POINT_LIGHTS];
|
||||
|
||||
/*struct SpotLight {
|
||||
bool isActive;
|
||||
vec3 position;
|
||||
vec3 direction;
|
||||
|
||||
float innerCutOff;
|
||||
float outerCutOff;
|
||||
|
||||
float K_q;
|
||||
|
||||
vec3 ambient;
|
||||
vec3 diffuse;
|
||||
vec3 specular;
|
||||
};
|
||||
uniform SpotLight u_spotLight;*/
|
||||
|
||||
uniform mat3 u_normalMatrix;
|
||||
uniform vec3 u_viewPosition;
|
||||
|
||||
uniform sampler2D u_texture_directionalShadowMap;
|
||||
uniform samplerCube u_texture_pointShadowMap0;
|
||||
//uniform samplerCube u_texture_pointShadowMap1;
|
||||
//uniform samplerCube u_texture_pointShadowMap2;
|
||||
//uniform samplerCube u_texture_pointShadowMap3;
|
||||
|
||||
vec3 sampleOffsetDirections[20] = vec3[] (
|
||||
vec3( 1, 1, 1), vec3( 1, -1, 1), vec3(-1, -1, 1), vec3(-1, 1, 1),
|
||||
vec3( 1, 1, -1), vec3( 1, -1, -1), vec3(-1, -1, -1), vec3(-1, 1, -1),
|
||||
vec3( 1, 1, 0), vec3( 1, -1, 0), vec3(-1, -1, 0), vec3(-1, 1, 0),
|
||||
vec3( 1, 0, 1), vec3(-1, 0, 1), vec3( 1, 0, -1), vec3(-1, 0, -1),
|
||||
vec3( 0, 1, 1), vec3( 0, -1, 1), vec3( 0, -1, -1), vec3( 0, 1, -1)
|
||||
);
|
||||
|
||||
uniform bool b_drawShadows;
|
||||
|
||||
uniform float pointShadowDepthMapFarPlane;
|
||||
|
||||
vec3 directionalLightContribution(DirectionalLight light, vec3 normal, vec3 viewDir);
|
||||
vec3 pointLightContribution(PointLight light, vec3 normal, vec3 fragPos, vec3 viewDir);
|
||||
//vec3 spotLightContribution(PointLight light, vec3 normal, vec3 fragPos, vec3 viewDir);
|
||||
|
||||
void computeShading(
|
||||
vec3 light_ambient, vec3 light_diffuse, vec3 light_specular,
|
||||
vec3 lightDir, vec3 viewDir, vec3 normal,
|
||||
out vec3 ambient, out vec3 diffuse, out vec3 specular
|
||||
);
|
||||
|
||||
float computeAttenuation(vec3 lightPos, vec3 fragPos, float K_q);
|
||||
|
||||
float computeDirectionalShadows(vec4 fragPosLightSpace, vec3 normal, vec3 lightDir);
|
||||
float computePointShadows(vec3 fragPos, vec3 lightPos);
|
||||
|
||||
void main() {
|
||||
|
||||
vec3 fragmentColor = vec3(0.0f);
|
||||
|
||||
vec3 normal = normalize(u_normalMatrix * v_normal);
|
||||
vec3 viewDir = normalize(u_viewPosition - v_fragmentPosition);
|
||||
|
||||
fragmentColor += directionalLightContribution(u_directionalLight, normal, viewDir);
|
||||
|
||||
for(int i = 0; i < NUM_POINT_LIGHTS; i++) {
|
||||
fragmentColor += pointLightContribution(u_pointLight[i], normal, v_fragmentPosition, viewDir);
|
||||
}
|
||||
|
||||
// There are currently no spotlights
|
||||
//fragmentColor += spotLightContribution(u_spotLight, normal, v_fragmentPosition, viewDir);
|
||||
|
||||
f_color = vec4(fragmentColor, 1.0f);
|
||||
|
||||
}
|
||||
|
||||
vec3 directionalLightContribution(DirectionalLight light, vec3 normal, vec3 viewDir) {
|
||||
|
||||
// Only compute if light source is active
|
||||
if(!light.isActive)
|
||||
return vec3(0.0f);
|
||||
|
||||
vec3 lightDir = normalize(-light.direction);
|
||||
|
||||
vec3 ambient, diffuse, specular;
|
||||
computeShading(light.ambient, light.diffuse, light.specular, lightDir, viewDir, normal, ambient, diffuse, specular);
|
||||
|
||||
float shadows = 0.0f;
|
||||
if(b_drawShadows)
|
||||
shadows = computeDirectionalShadows(v_fragmentPositionDirectionalLightSpace, normal, lightDir);
|
||||
|
||||
return (ambient + (1.0f - shadows) * (diffuse + specular));
|
||||
}
|
||||
|
||||
vec3 pointLightContribution(PointLight light, vec3 normal, vec3 fragPos, vec3 viewDir) {
|
||||
|
||||
// Only compute if light source is active
|
||||
if(!light.isActive)
|
||||
return vec3(0.0f);
|
||||
|
||||
vec3 lightDir = normalize(light.position - fragPos);
|
||||
|
||||
vec3 ambient, diffuse, specular;
|
||||
computeShading(light.ambient, light.diffuse, light.specular, lightDir, viewDir, normal, ambient, diffuse, specular);
|
||||
|
||||
float attenuation = computeAttenuation(light.position, fragPos, light.K_q);
|
||||
ambient *= attenuation;
|
||||
diffuse *= attenuation;
|
||||
specular *= attenuation;
|
||||
|
||||
float shadows = 0.0f;
|
||||
if(b_drawShadows)
|
||||
shadows = computePointShadows(fragPos, light.position);
|
||||
|
||||
return (ambient + (1.0f - shadows) * (diffuse + specular));
|
||||
}
|
||||
|
||||
/*vec3 spotLightContribution(SpotLight light, vec3 normal, vec3 fragPos, vec3 viewDir) {
|
||||
|
||||
// Only compute if light source is active
|
||||
if(!light.isActive)
|
||||
return vec3(0.0f);
|
||||
|
||||
vec3 lightDir = normalize(light.position - fragPos);
|
||||
|
||||
vec3 ambient, diffuse, specular;
|
||||
computeShading(light.ambient, light.diffuse, light.specular, lightDir, viewDir, normal, ambient, diffuse, specular);
|
||||
|
||||
float attenuation = computeAttenuation(light.position, fragPos, light.K_q);
|
||||
ambient *= attenuation;
|
||||
diffuse *= attenuation;
|
||||
specular *= attenuation;
|
||||
|
||||
float theta = dot(lightDir, normalize(-light.direction));
|
||||
float epsilon = light.innerCutOff - light.outerCutOff;
|
||||
float intensity = clamp((theta - light.outerCutOff) / epsilon, 0.0f, 1.0f);
|
||||
|
||||
diffuse *= intensity;
|
||||
specular *= intensity;
|
||||
|
||||
return (ambient + diffuse + specular);
|
||||
}*/
|
||||
|
||||
void computeShading(
|
||||
vec3 light_ambient, vec3 light_diffuse, vec3 light_specular,
|
||||
vec3 lightDir, vec3 viewDir, vec3 normal,
|
||||
out vec3 ambient, out vec3 diffuse, out vec3 specular) {
|
||||
|
||||
// Diffuse shading
|
||||
float diffuseShading = max(dot(normal, lightDir), 0.0f);
|
||||
|
||||
// Specular shading
|
||||
vec3 halfwayDir = normalize(lightDir + viewDir);
|
||||
float specularShading = pow(max(dot(normal, halfwayDir), 0.0f), u_material.shininess);
|
||||
|
||||
vec4 diffuseTex = texture(u_material.texture_diffuse0, v_texCoord);
|
||||
vec4 specularTex = texture(u_material.texture_specular0, v_texCoord);
|
||||
|
||||
ambient = light_ambient * vec3(diffuseTex);
|
||||
diffuse = light_diffuse * diffuseShading * vec3(diffuseTex);
|
||||
specular = light_specular * specularShading * vec3(specularTex);
|
||||
|
||||
}
|
||||
|
||||
float computeAttenuation(vec3 lightPos, vec3 fragPos, float K_q) {
|
||||
|
||||
float distanceLightFragment = length(lightPos - fragPos);
|
||||
|
||||
return 1.0f / (K_q * distanceLightFragment * distanceLightFragment);
|
||||
|
||||
}
|
||||
|
||||
float computeDirectionalShadows(vec4 fragPosLightSpace, vec3 normal, vec3 lightDir) {
|
||||
|
||||
// Perspective divide
|
||||
vec3 projCoords = fragPosLightSpace.xyz / fragPosLightSpace.w;
|
||||
|
||||
// Transform from [-1,1] to [0,1]
|
||||
projCoords *= 0.5f;
|
||||
projCoords += 0.5f;
|
||||
|
||||
if(projCoords.z > 1.0f) return 0.0f;
|
||||
|
||||
float closestDepth = texture(u_texture_directionalShadowMap, projCoords.xy).r;
|
||||
float currentDepth = projCoords.z;
|
||||
|
||||
float bias = max(0.05 * (1.0 - dot(normal, lightDir)), 0.005);
|
||||
bias *= 0.25f;
|
||||
|
||||
float shadow = 0.0;
|
||||
vec2 texelSize = 1.0 / textureSize(u_texture_directionalShadowMap, 0);
|
||||
for(int x = -1; x <= 1; x++) {
|
||||
for(int y = -1; y <= 1; y++) {
|
||||
float pcfDepth = texture(u_texture_directionalShadowMap, projCoords.xy + vec2(x, y) * texelSize).r;
|
||||
shadow += currentDepth - bias > pcfDepth ? 1.0 : 0.0;
|
||||
}
|
||||
}
|
||||
shadow /= 9.0f;
|
||||
|
||||
|
||||
return shadow;
|
||||
}
|
||||
|
||||
float computePointShadows(vec3 fragPos, vec3 lightPos) {
|
||||
|
||||
// get vector between fragment position and light position
|
||||
vec3 fragToLight = fragPos - lightPos;
|
||||
|
||||
// now get current linear depth as the length between the fragment and light position
|
||||
float currentDepth = length(fragToLight);
|
||||
|
||||
float shadow = 0.0;
|
||||
float bias = 0.05;
|
||||
int samples = 20;
|
||||
float viewDistance = length(u_viewPosition - fragPos);
|
||||
float diskRadius = 0.05;
|
||||
|
||||
for(int i = 0; i < samples; ++i) {
|
||||
float closestDepth = texture(u_texture_pointShadowMap0, fragToLight + sampleOffsetDirections[i] * diskRadius).r;
|
||||
closestDepth *= pointShadowDepthMapFarPlane;
|
||||
if(currentDepth - bias > closestDepth)
|
||||
shadow += 1.0;
|
||||
}
|
||||
|
||||
shadow /= float(samples);
|
||||
return shadow;
|
||||
}
|
||||
26
data/shaders/basic.vert
Normal file
26
data/shaders/basic.vert
Normal file
@@ -0,0 +1,26 @@
|
||||
#version 330 core
|
||||
|
||||
layout(location = 0) in vec3 a_position;
|
||||
layout(location = 1) in vec3 a_normal;
|
||||
layout(location = 2) in vec2 a_texCoord;
|
||||
|
||||
out vec3 v_normal;
|
||||
out vec2 v_texCoord;
|
||||
|
||||
out vec3 v_fragmentPosition;
|
||||
out vec4 v_fragmentPositionDirectionalLightSpace;
|
||||
|
||||
uniform mat4 u_modelViewProjMatrix;
|
||||
uniform mat4 u_modelMatrix;
|
||||
|
||||
uniform mat4 u_directionalLightViewProjMatrix;
|
||||
|
||||
void main() {
|
||||
gl_Position = u_modelViewProjMatrix * vec4(a_position, 1.0f);
|
||||
|
||||
v_fragmentPosition = vec3(u_modelMatrix * vec4(a_position, 1.0f));
|
||||
v_fragmentPositionDirectionalLightSpace = u_directionalLightViewProjMatrix * vec4(v_fragmentPosition, 1.0);
|
||||
|
||||
v_normal = a_normal;
|
||||
v_texCoord = a_texCoord;
|
||||
}
|
||||
7
data/shaders/directionalShadowDepth.frag
Normal file
7
data/shaders/directionalShadowDepth.frag
Normal file
@@ -0,0 +1,7 @@
|
||||
#version 330 core
|
||||
|
||||
void main() {
|
||||
|
||||
// Empty as we aren't rendering to any color buffer
|
||||
|
||||
}
|
||||
11
data/shaders/directionalShadowDepth.vert
Normal file
11
data/shaders/directionalShadowDepth.vert
Normal file
@@ -0,0 +1,11 @@
|
||||
#version 330 core
|
||||
|
||||
layout(location = 0) in vec3 a_position;
|
||||
|
||||
uniform mat4 u_modelViewProjMatrix;
|
||||
|
||||
void main() {
|
||||
|
||||
gl_Position = u_modelViewProjMatrix * vec4(a_position, 1.0f);
|
||||
|
||||
}
|
||||
9
data/shaders/light.frag
Normal file
9
data/shaders/light.frag
Normal file
@@ -0,0 +1,9 @@
|
||||
#version 330 core
|
||||
|
||||
layout(location = 0) out vec4 f_color;
|
||||
|
||||
uniform vec3 v_lightColor;
|
||||
|
||||
void main() {
|
||||
f_color = vec4(v_lightColor, 1.0f);
|
||||
}
|
||||
9
data/shaders/light.vert
Normal file
9
data/shaders/light.vert
Normal file
@@ -0,0 +1,9 @@
|
||||
#version 330 core
|
||||
|
||||
layout(location = 0) in vec3 a_position;
|
||||
|
||||
uniform mat4 u_modelViewProjMatrix;
|
||||
|
||||
void main() {
|
||||
gl_Position = u_modelViewProjMatrix * vec4(a_position, 1.0f);
|
||||
}
|
||||
15
data/shaders/menu.frag
Normal file
15
data/shaders/menu.frag
Normal file
@@ -0,0 +1,15 @@
|
||||
#version 330 core
|
||||
|
||||
layout(location = 0) out vec4 f_color;
|
||||
|
||||
in vec2 v_texCoord;
|
||||
|
||||
struct Material {
|
||||
sampler2D texture_diffuse0;
|
||||
};
|
||||
uniform Material u_material;
|
||||
|
||||
void main()
|
||||
{
|
||||
f_color = texture(u_material.texture_diffuse0, v_texCoord);
|
||||
}
|
||||
12
data/shaders/menu.vert
Normal file
12
data/shaders/menu.vert
Normal file
@@ -0,0 +1,12 @@
|
||||
#version 330 core
|
||||
|
||||
layout(location = 0) in vec3 a_position;
|
||||
layout(location = 2) in vec2 a_texCoord;
|
||||
|
||||
out vec2 v_texCoord;
|
||||
|
||||
void main()
|
||||
{
|
||||
v_texCoord = a_texCoord;
|
||||
gl_Position = vec4(a_position, 1.0);
|
||||
}
|
||||
17
data/shaders/pointShadowDepth.frag
Normal file
17
data/shaders/pointShadowDepth.frag
Normal file
@@ -0,0 +1,17 @@
|
||||
#version 330 core
|
||||
in vec4 v_fragmentPosition;
|
||||
|
||||
uniform vec3 v_lightPos;
|
||||
uniform float pointShadowDepthMapFarPlane;
|
||||
|
||||
void main() {
|
||||
|
||||
// Distance between fragment and light source
|
||||
float lightDistance = length(v_fragmentPosition.xyz - v_lightPos);
|
||||
|
||||
// map to [0;1] range
|
||||
lightDistance = lightDistance / pointShadowDepthMapFarPlane;
|
||||
|
||||
gl_FragDepth = lightDistance;
|
||||
|
||||
}
|
||||
25
data/shaders/pointShadowDepth.geom
Normal file
25
data/shaders/pointShadowDepth.geom
Normal file
@@ -0,0 +1,25 @@
|
||||
#version 330 core
|
||||
layout (triangles) in;
|
||||
layout (triangle_strip, max_vertices=18) out;
|
||||
|
||||
uniform mat4 u_shadowMatrices[6];
|
||||
|
||||
out vec4 v_fragmentPosition;
|
||||
|
||||
void main() {
|
||||
|
||||
for(int face = 0; face < 6; face++) {
|
||||
|
||||
gl_Layer = face;
|
||||
for(int i = 0; i < 3; i++) {
|
||||
|
||||
v_fragmentPosition = gl_in[i].gl_Position;
|
||||
gl_Position = u_shadowMatrices[face] * v_fragmentPosition;
|
||||
EmitVertex();
|
||||
|
||||
}
|
||||
|
||||
EndPrimitive();
|
||||
|
||||
}
|
||||
}
|
||||
11
data/shaders/pointShadowDepth.vert
Normal file
11
data/shaders/pointShadowDepth.vert
Normal file
@@ -0,0 +1,11 @@
|
||||
#version 330 core
|
||||
|
||||
layout(location = 0) in vec3 a_position;
|
||||
|
||||
uniform mat4 u_modelMatrix;
|
||||
|
||||
void main() {
|
||||
|
||||
gl_Position = u_modelMatrix * vec4(a_position, 1.0f);
|
||||
|
||||
}
|
||||
27
data/shaders/postprocessing.frag
Normal file
27
data/shaders/postprocessing.frag
Normal file
@@ -0,0 +1,27 @@
|
||||
#version 330 core
|
||||
|
||||
const float GAMMA = 2.2f;
|
||||
|
||||
layout(location = 0) out vec4 f_color;
|
||||
|
||||
in vec2 v_tex_coords;
|
||||
|
||||
uniform float u_exposure;
|
||||
uniform bool u_exposureCorrection;
|
||||
|
||||
uniform sampler2D u_texture;
|
||||
|
||||
void main() {
|
||||
|
||||
vec3 fragmentColor = vec3(texture2D(u_texture, v_tex_coords));
|
||||
|
||||
// Exposure tone mapping
|
||||
if(u_exposureCorrection)
|
||||
fragmentColor = vec3(1.0) - exp(-fragmentColor * u_exposure);
|
||||
|
||||
// Gamma correction
|
||||
fragmentColor = pow(fragmentColor, vec3(1.0/GAMMA));
|
||||
|
||||
f_color = vec4(fragmentColor, 1.0f);
|
||||
|
||||
}
|
||||
11
data/shaders/postprocessing.vert
Normal file
11
data/shaders/postprocessing.vert
Normal file
@@ -0,0 +1,11 @@
|
||||
#version 330 core
|
||||
|
||||
out vec2 v_tex_coords;
|
||||
|
||||
void main() {
|
||||
float x = -1.0 + float((gl_VertexID & 1) << 2);
|
||||
float y = -1.0 + float((gl_VertexID & 2) << 1);
|
||||
v_tex_coords.x = (x+1.0)*0.5;
|
||||
v_tex_coords.y = (y+1.0)*0.5;
|
||||
gl_Position = vec4(x, y, 0, 1);
|
||||
}
|
||||
15
data/shaders/skybox.frag
Normal file
15
data/shaders/skybox.frag
Normal file
@@ -0,0 +1,15 @@
|
||||
#version 330 core
|
||||
|
||||
layout(location = 0) out vec4 f_color;
|
||||
|
||||
in vec3 v_texCoord;
|
||||
|
||||
uniform samplerCube u_skybox;
|
||||
|
||||
void main() {
|
||||
|
||||
vec3 fragmentColor = vec3(texture(u_skybox, v_texCoord));
|
||||
|
||||
f_color = vec4(fragmentColor, 1.0f);
|
||||
|
||||
}
|
||||
17
data/shaders/skybox.vert
Normal file
17
data/shaders/skybox.vert
Normal file
@@ -0,0 +1,17 @@
|
||||
#version 330 core
|
||||
|
||||
layout(location = 0) in vec3 a_position;
|
||||
|
||||
out vec3 v_texCoord;
|
||||
|
||||
uniform mat4 projection;
|
||||
uniform mat4 view;
|
||||
uniform mat4 u_viewProjectionMatrix;
|
||||
|
||||
void main() {
|
||||
|
||||
gl_Position = u_viewProjectionMatrix * vec4(a_position, 1.0);
|
||||
|
||||
v_texCoord = a_position;
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user