16
0
mirror of https://github.com/MaSzyna-EU07/maszyna.git synced 2026-07-18 03:09:18 +02:00
This commit is contained in:
milek7
2018-07-11 19:25:04 +02:00
parent 7299fc866e
commit 29167ed459
10 changed files with 72 additions and 38 deletions

View File

@@ -1,8 +1,8 @@
#version 330
in vec3 v_vert;
in vec3 v_normal;
in vec2 v_coord;
layout(location = 0) in vec3 v_vert;
layout(location = 1) in vec3 v_normal;
layout(location = 2) in vec2 v_coord;
#include <common>

View File

@@ -3,10 +3,23 @@
in vec3 f_normal;
in vec2 f_coord;
in vec3 f_pos;
in vec4 f_light_pos;
#include <common>
uniform sampler2D tex1;
uniform sampler2DShadow shadowmap;
float calc_shadow()
{
vec3 coords = f_light_pos.xyz;
//float bias = clamp(0.0025*tan(acos(clamp(dot(f_normal, -lights[0].dir), 0.0, 1.0))), 0, 0.01);
float bias = 0.0f;
float shadow = texture(shadowmap, vec3(coords.xy, coords.z - bias));
return shadow;
}
vec3 apply_fog(vec3 color)
{
@@ -61,6 +74,7 @@ float calc_dir_light(light_s light)
void main()
{
float shadow = calc_shadow();
vec3 result = ambient * 0.3 + param[0].rgb * emission;
for (uint i = 0U; i < lights_count; i++)
{
@@ -74,6 +88,8 @@ void main()
else if (light.type == LIGHT_DIR)
part = calc_dir_light(light);
if (i == 0U)
part *= shadow;
result += light.color * part;
}

View File

@@ -47,11 +47,11 @@ void main()
vec3 hdr_color = texture(tex1, texcoord).xyz;
vec3 mapped;
if (texcoord.x < 0.33f)
mapped = reinhard(hdr_color);
else if (texcoord.x < 0.66f)
mapped = filmic(hdr_color);
else
//if (texcoord.x < 0.33f)
// mapped = reinhard(hdr_color);
//else if (texcoord.x < 0.66f)
// mapped = filmic(hdr_color);
//else
mapped = ACESFilm(hdr_color);
gl_FragColor = vec4(mapped, 1.0);
}

View File

@@ -2,9 +2,11 @@
in vec2 f_coord;
uniform sampler2D tex;
//uniform sampler2D tex;
void main()
{
gl_FragDepth = gl_FragCoord.z + (1.0 - texture(tex, f_coord).w);
//gl_FragColor = texture(tex, f_coord);
gl_FragDepth = gl_FragCoord.z;
//gl_FragDepth = gl_FragCoord.z + (1.0 - texture(tex, f_coord).w);
}

View File

@@ -1,7 +1,7 @@
#version 330
layout (location = 0) in vec3 v_vert;
layout (location = 2) in vec2 v_coord;
layout(location = 0) in vec3 v_vert;
layout(location = 2) in vec2 v_coord;
out vec2 f_coord;

View File

@@ -1,15 +1,16 @@
#version 330
in vec3 v_vert;
in vec3 v_normal;
in vec2 v_coord;
in vec4 v_tangent;
layout(location = 0) in vec3 v_vert;
layout(location = 1) in vec3 v_normal;
layout(location = 2) in vec2 v_coord;
layout(location = 3) in vec4 v_tangent;
out vec3 f_normal;
out vec2 f_coord;
out vec3 f_pos;
out mat3 f_tbn;
out vec4 f_tangent;
out vec4 f_light_pos;
#include <common>
@@ -20,6 +21,7 @@ void main()
f_coord = v_coord;
f_tangent = v_tangent;
f_pos = vec3(modelview * vec4(v_vert, 1.0f));
f_light_pos = lightview * vec4(f_pos, 1.0f);
vec3 T = normalize(modelviewnormal * v_tangent.xyz);
vec3 B = normalize(modelviewnormal * cross(v_normal, v_tangent.xyz) * v_tangent.w);

View File

@@ -1,8 +1,8 @@
#version 330
in vec3 v_vert;
in vec3 v_normal;
in vec2 v_coord;
layout(location = 0) in vec3 v_vert;
layout(location = 1) in vec3 v_normal;
layout(location = 2) in vec2 v_coord;
#include <common>

View File

@@ -1,7 +1,7 @@
#version 330
in vec3 v_vert;
in vec3 v_color;
layout(location = 0) in vec3 v_vert;
layout(location = 1) in vec3 v_color;
out vec3 f_color;