mirror of
https://github.com/MaSzyna-EU07/maszyna.git
synced 2026-03-22 15:05:03 +01:00
Merge remote-tracking branch 'tmj/master' into sim
This commit is contained in:
@@ -1,9 +1,30 @@
|
||||
vec3 apply_fog(vec3 color)
|
||||
{
|
||||
float sun_amount = 0.0;
|
||||
if (lights_count >= 1U && lights[0].type == LIGHT_DIR)
|
||||
sun_amount = max(dot(normalize(f_pos.xyz), normalize(-lights[0].dir)), 0.0);
|
||||
vec3 fog_color_v = mix(fog_color, lights[0].color, pow(sun_amount, 30.0));
|
||||
float fog_amount_v = 1.0 - min(1.0, exp(-length(f_pos.xyz) * fog_density));
|
||||
return mix(color, fog_color_v, fog_amount_v);
|
||||
}
|
||||
vec3 get_fog_color()
|
||||
{
|
||||
vec3 fog_color_v = fog_color;
|
||||
if (lights_count >= 1U && lights[0].type == LIGHT_DIR) {
|
||||
float sun_amount = max(dot(normalize(f_pos.xyz), normalize(-lights[0].dir)), 0.0);
|
||||
fog_color_v += lights[0].color * pow(sun_amount, 30.0);
|
||||
}
|
||||
return fog_color_v;
|
||||
}
|
||||
|
||||
float get_fog_amount()
|
||||
{
|
||||
float z = length(f_pos.xyz);
|
||||
// float fog_amount_v = 1.0 - z * fog_density; // linear
|
||||
// float fog_amount_v = exp( -fog_density * z ); // exp
|
||||
float fog_amount_v = exp2( -fog_density * fog_density * z * z * 1.442695 ); // exp2
|
||||
|
||||
fog_amount_v = 1.0 - clamp(fog_amount_v, 0.0, 1.0);
|
||||
return fog_amount_v;
|
||||
}
|
||||
|
||||
vec3 apply_fog(vec3 color)
|
||||
{
|
||||
return mix(color, get_fog_color(), get_fog_amount());
|
||||
}
|
||||
|
||||
vec3 add_fog(vec3 color, float amount)
|
||||
{
|
||||
return color + get_fog_color() * get_fog_amount() * amount;
|
||||
}
|
||||
|
||||
@@ -1,6 +1,8 @@
|
||||
in vec3 f_color;
|
||||
in vec4 f_pos;
|
||||
|
||||
#include <common>
|
||||
#include <apply_fog.glsl>
|
||||
#include <tonemapping.glsl>
|
||||
|
||||
layout(location = 0) out vec4 out_color;
|
||||
@@ -11,9 +13,9 @@ layout(location = 1) out vec4 out_motion;
|
||||
void main()
|
||||
{
|
||||
#if POSTFX_ENABLED
|
||||
out_color = vec4(f_color, 1.0f);
|
||||
out_color = vec4(apply_fog(f_color), 1.0f);
|
||||
#else
|
||||
out_color = tonemap(vec4(f_color, 1.0f));
|
||||
out_color = tonemap(vec4(apply_fog(f_color), 1.0f));
|
||||
#endif
|
||||
#if MOTIONBLUR_ENABLED
|
||||
out_motion = vec4(0.0f);
|
||||
|
||||
108
shaders/conversion.glsl
Normal file
108
shaders/conversion.glsl
Normal file
@@ -0,0 +1,108 @@
|
||||
vec3 rgb2yuv(vec3 val)
|
||||
{
|
||||
return
|
||||
clamp(
|
||||
vec3(
|
||||
(0.257 * val.r) + (0.504 * val.g) + (0.098 * val.b) + 0.0625,
|
||||
-(0.148 * val.r) - (0.291 * val.g) + (0.439 * val.b) + 0.5,
|
||||
(0.439 * val.r) - (0.368 * val.g) - (0.071 * val.b) + 0.5 ),
|
||||
0.0, 1.0);
|
||||
}
|
||||
|
||||
vec3 yuv2rgb(vec3 val)
|
||||
{
|
||||
val -= vec3(0.0625, 0.5, 0.5);
|
||||
return
|
||||
clamp(
|
||||
vec3(
|
||||
(1.164 * val.r) + (1.596 * val.b),
|
||||
(1.164 * val.r) - (0.391 * val.g) - (0.813 * val.b),
|
||||
(1.164 * val.r) + (2.018 * val.g) ),
|
||||
0.0, 1.0);
|
||||
}
|
||||
|
||||
vec3 rgb2hsl( vec3 col )
|
||||
{
|
||||
float red = col.r;
|
||||
float green = col.g;
|
||||
float blue = col.b;
|
||||
|
||||
float minc = min( col.r, min( col.g, col.b ));
|
||||
float maxc = max( col.r, max( col.g, col.b ));
|
||||
float delta = maxc - minc;
|
||||
|
||||
float lum = (minc + maxc) * 0.5;
|
||||
float sat = 0.0;
|
||||
float hue = 0.0;
|
||||
|
||||
if (lum > 0.0 && lum < 1.0) {
|
||||
float mul = (lum < 0.5) ? (lum) : (1.0-lum);
|
||||
sat = delta / (mul * 2.0);
|
||||
}
|
||||
|
||||
vec3 masks = vec3(
|
||||
(maxc == red && maxc != green) ? 1.0 : 0.0,
|
||||
(maxc == green && maxc != blue) ? 1.0 : 0.0,
|
||||
(maxc == blue && maxc != red) ? 1.0 : 0.0
|
||||
);
|
||||
|
||||
vec3 adds = vec3(
|
||||
((green - blue ) / delta),
|
||||
2.0 + ((blue - red ) / delta),
|
||||
4.0 + ((red - green) / delta)
|
||||
);
|
||||
|
||||
float deltaGtz = (delta > 0.0) ? 1.0 : 0.0;
|
||||
|
||||
hue += dot( adds, masks );
|
||||
hue *= deltaGtz;
|
||||
hue /= 6.0;
|
||||
|
||||
if (hue < 0.0)
|
||||
hue += 1.0;
|
||||
|
||||
return vec3( hue, sat, lum );
|
||||
}
|
||||
|
||||
vec3 hsl2rgb( vec3 col )
|
||||
{
|
||||
const float onethird = 1.0 / 3.0;
|
||||
const float twothird = 2.0 / 3.0;
|
||||
const float rcpsixth = 6.0;
|
||||
|
||||
float hue = col.x;
|
||||
float sat = col.y;
|
||||
float lum = col.z;
|
||||
|
||||
vec3 xt = vec3(
|
||||
rcpsixth * (hue - twothird),
|
||||
0.0,
|
||||
rcpsixth * (1.0 - hue)
|
||||
);
|
||||
|
||||
if (hue < twothird) {
|
||||
xt.r = 0.0;
|
||||
xt.g = rcpsixth * (twothird - hue);
|
||||
xt.b = rcpsixth * (hue - onethird);
|
||||
}
|
||||
|
||||
if (hue < onethird) {
|
||||
xt.r = rcpsixth * (onethird - hue);
|
||||
xt.g = rcpsixth * hue;
|
||||
xt.b = 0.0;
|
||||
}
|
||||
|
||||
xt = min( xt, 1.0 );
|
||||
|
||||
float sat2 = 2.0 * sat;
|
||||
float satinv = 1.0 - sat;
|
||||
float luminv = 1.0 - lum;
|
||||
float lum2m1 = (2.0 * lum) - 1.0;
|
||||
vec3 ct = (sat2 * xt) + satinv;
|
||||
|
||||
vec3 rgb;
|
||||
if (lum >= 0.5) { rgb = (luminv * ct) + lum2m1; }
|
||||
else { rgb = lum * ct; }
|
||||
|
||||
return rgb;
|
||||
}
|
||||
15
shaders/envmapping.glsl
Normal file
15
shaders/envmapping.glsl
Normal file
@@ -0,0 +1,15 @@
|
||||
#if ENVMAP_ENABLED
|
||||
uniform samplerCube envmap;
|
||||
#endif
|
||||
|
||||
vec3 envmap_color( vec3 normal )
|
||||
{
|
||||
#if ENVMAP_ENABLED
|
||||
vec3 refvec = reflect(f_pos.xyz, normal); // view space
|
||||
refvec = vec3(inv_view * vec4(refvec, 0.0)); // world space
|
||||
vec3 envcolor = texture(envmap, refvec).rgb;
|
||||
#else
|
||||
vec3 envcolor = vec3(0.5);
|
||||
#endif
|
||||
return envcolor;
|
||||
}
|
||||
@@ -1,14 +1,17 @@
|
||||
#include <common>
|
||||
#include <tonemapping.glsl>
|
||||
|
||||
in vec4 f_pos;
|
||||
in vec4 f_clip_pos;
|
||||
in vec4 f_clip_future_pos;
|
||||
|
||||
#include <common>
|
||||
|
||||
layout(location = 0) out vec4 out_color;
|
||||
#if MOTIONBLUR_ENABLED
|
||||
layout(location = 1) out vec4 out_motion;
|
||||
#endif
|
||||
|
||||
#include <tonemapping.glsl>
|
||||
#include <apply_fog.glsl>
|
||||
|
||||
void main()
|
||||
{
|
||||
float x = (gl_PointCoord.x - 0.5f) * 2.0f;
|
||||
@@ -16,12 +19,10 @@ void main()
|
||||
float dist = sqrt(x * x + y * y);
|
||||
if (dist > 0.5f)
|
||||
discard;
|
||||
vec4 color = vec4(param[0].rgb * emission, mix(param[0].a, 0.0f, dist * 2.0f));
|
||||
#if POSTFX_ENABLED
|
||||
out_color = color;
|
||||
#else
|
||||
out_color = tonemap(color);
|
||||
#endif
|
||||
// vec4 color = vec4(param[0].rgb * emission, mix(param[0].a, 0.0f, dist * 2.0f));
|
||||
vec4 color = vec4(apply_fog(pow(param[0].rgb, vec3(2.2)) * emission), mix(param[0].a, 0.0f, dist * 2.0f));
|
||||
// vec4 color = vec4(add_fog(param[0].rgb * emission * (1.0 - get_fog_amount()), 1.0), mix(param[0].a, 0.0f, dist * 2.0f));
|
||||
out_color = FBOUT(color);
|
||||
#if MOTIONBLUR_ENABLED
|
||||
{
|
||||
vec2 a = (f_clip_future_pos.xy / f_clip_future_pos.w) * 0.5 + 0.5;;
|
||||
|
||||
@@ -4,11 +4,13 @@ layout(location = 2) in vec2 v_coord;
|
||||
|
||||
#include <common>
|
||||
|
||||
out vec4 f_pos;
|
||||
out vec4 f_clip_pos;
|
||||
out vec4 f_clip_future_pos;
|
||||
|
||||
void main()
|
||||
{
|
||||
f_pos = modelview * vec4(v_vert, 1.0);
|
||||
f_clip_pos = (projection * modelview) * vec4(v_vert, 1.0f);
|
||||
f_clip_future_pos = (projection * future * modelview) * vec4(v_vert, 1.0f);
|
||||
|
||||
|
||||
@@ -1,58 +1,66 @@
|
||||
#include <apply_fog.glsl>
|
||||
#if SHADOWMAP_ENABLED
|
||||
in vec4 f_light_pos[MAX_CASCADES];
|
||||
uniform sampler2DArrayShadow shadowmap;
|
||||
#endif
|
||||
uniform sampler2D headlightmap;
|
||||
|
||||
#include <envmapping.glsl>
|
||||
#include <conversion.glsl>
|
||||
|
||||
float glossiness = 1.0;
|
||||
bool metalic = false;
|
||||
|
||||
float length2(vec3 v)
|
||||
{
|
||||
return dot(v, v);
|
||||
}
|
||||
|
||||
float calc_shadow()
|
||||
{
|
||||
#if SHADOWMAP_ENABLED
|
||||
vec3 coords = f_light_pos.xyz / f_light_pos.w;
|
||||
|
||||
float distance = dot(f_pos.xyz, f_pos.xyz);
|
||||
uint cascade;
|
||||
for (cascade = 0U; cascade < MAX_CASCADES; cascade++)
|
||||
if (distance <= cascade_end[cascade])
|
||||
break;
|
||||
|
||||
vec3 coords = f_light_pos[cascade].xyz / f_light_pos[cascade].w;
|
||||
if (coords.z < 0.0f)
|
||||
return 1.0f;
|
||||
return 0.0f;
|
||||
|
||||
float bias = 0.0004f;
|
||||
|
||||
//sampler PCF
|
||||
//float shadow = texture(shadowmap, coords.xyz + vec3(0.0, 0.0, bias));
|
||||
|
||||
//sampler PCF + PCF
|
||||
float shadow = 0.0;
|
||||
//basic
|
||||
// shadow = texture(shadowmap, coords.xyz + vec3(0.0, 0.0, bias));
|
||||
//PCF
|
||||
float bias = 0.00005f * (cascade + 1U);
|
||||
vec2 texel = vec2(1.0) / vec2(textureSize(shadowmap, 0));
|
||||
float radius = 1.0;
|
||||
for (float y = -1.5; y <= 1.5; y += 1.0)
|
||||
for (float x = -1.5; x <= 1.5; x += 1.0)
|
||||
shadow += texture(shadowmap, coords.xyz + vec3(vec2(x, y) * texel, bias));
|
||||
shadow += texture( shadowmap, vec4(coords.xy + vec2(x, y) * radius * texel, cascade, coords.z + bias) );
|
||||
shadow /= 16.0;
|
||||
|
||||
return 1.0 - shadow;
|
||||
return shadow;
|
||||
#else
|
||||
return 1.0;
|
||||
return 0.0;
|
||||
#endif
|
||||
}
|
||||
|
||||
// [0] - diffuse, [1] - specular
|
||||
// do magic here
|
||||
vec2 calc_light(vec3 light_dir)
|
||||
vec2 calc_light(vec3 light_dir, vec3 fragnormal)
|
||||
{
|
||||
#ifdef NORMALMAP
|
||||
vec3 normal = normal;
|
||||
#elif defined(WATER)
|
||||
vec3 normal = normal_d;
|
||||
#elif defined(PARALLAX)
|
||||
vec3 normal = normal_p;
|
||||
#else
|
||||
vec3 normal = normalize(f_normal);
|
||||
#endif
|
||||
vec3 view_dir = normalize(vec3(0.0f, 0.0f, 0.0f) - f_pos.xyz);
|
||||
vec3 halfway_dir = normalize(light_dir + view_dir);
|
||||
|
||||
float diffuse_v = max(dot(normal, light_dir), 0.0);
|
||||
float specular_v = pow(max(dot(normal, halfway_dir), 0.0), 15.0);
|
||||
float diffuse_v = max(dot(fragnormal, light_dir), 0.0);
|
||||
float specular_v = pow(max(dot(fragnormal, halfway_dir), 0.0), max(glossiness, 0.01)) * diffuse_v;
|
||||
|
||||
return vec2(diffuse_v, specular_v);
|
||||
}
|
||||
|
||||
vec2 calc_point_light(light_s light)
|
||||
vec2 calc_point_light(light_s light, vec3 fragnormal)
|
||||
{
|
||||
vec3 light_dir = normalize(light.pos - f_pos.xyz);
|
||||
vec2 val = calc_light(light_dir);
|
||||
vec2 val = calc_light(light_dir, fragnormal);
|
||||
val.x += light.ambient;
|
||||
val *= light.intensity;
|
||||
|
||||
@@ -62,7 +70,7 @@ vec2 calc_point_light(light_s light)
|
||||
return val * atten;
|
||||
}
|
||||
|
||||
vec2 calc_spot_light(light_s light)
|
||||
vec2 calc_spot_light(light_s light, vec3 fragnormal)
|
||||
{
|
||||
vec3 light_dir = normalize(light.pos - f_pos.xyz);
|
||||
|
||||
@@ -70,12 +78,105 @@ vec2 calc_spot_light(light_s light)
|
||||
float epsilon = light.in_cutoff - light.out_cutoff;
|
||||
float intensity = clamp((theta - light.out_cutoff) / epsilon, 0.0, 1.0);
|
||||
|
||||
vec2 point = calc_point_light(light);
|
||||
vec2 point = calc_point_light(light, fragnormal);
|
||||
return point * intensity;
|
||||
}
|
||||
|
||||
vec2 calc_dir_light(light_s light)
|
||||
vec2 calc_dir_light(light_s light, vec3 fragnormal)
|
||||
{
|
||||
vec3 light_dir = normalize(-light.dir);
|
||||
return calc_light(light_dir);
|
||||
return calc_light(light_dir, fragnormal);
|
||||
}
|
||||
|
||||
vec2 calc_headlights(light_s light, vec3 fragnormal)
|
||||
{
|
||||
vec4 headlightpos = light.headlight_projection * f_pos;
|
||||
vec3 coords = headlightpos.xyz / headlightpos.w;
|
||||
|
||||
if (coords.z > 1.0)
|
||||
return vec2(0.0);
|
||||
if (coords.z < 0.0)
|
||||
return vec2(0.0);
|
||||
|
||||
vec3 light_dir = normalize(light.pos - f_pos.xyz);
|
||||
vec2 part = vec2(1.0) * clamp(dot(fragnormal, light_dir) + 0.25, 0.0, 1.0);
|
||||
float distance = length(light.pos - f_pos.xyz);
|
||||
float atten = 1.0f / (1.0f + light.linear * distance + light.quadratic * (distance * distance));
|
||||
atten *= mix(1.0, 0.0, clamp((coords.z - 0.998) * 500.0, 0.0, 1.0));
|
||||
vec3 lights = textureProj(headlightmap, headlightpos).rgb * light.headlight_weights.rgb;
|
||||
float lightintensity = max(max(lights.r, lights.g), lights.b);
|
||||
return part * atten * lightintensity;
|
||||
}
|
||||
|
||||
// [0] - diffuse, [1] - specular
|
||||
// do magic here
|
||||
vec3 apply_lights(vec3 fragcolor, vec3 fragnormal, vec3 texturecolor, float reflectivity, float specularity, float shadowtone)
|
||||
{
|
||||
vec3 basecolor = param[0].rgb;
|
||||
|
||||
fragcolor *= basecolor;
|
||||
|
||||
vec3 emissioncolor = basecolor * emission;
|
||||
vec3 envcolor = envmap_color(fragnormal);
|
||||
|
||||
// yuv path
|
||||
vec3 texturecoloryuv = rgb2yuv(texturecolor);
|
||||
vec3 texturecolorfullv = yuv2rgb(vec3(0.2176, texturecoloryuv.gb));
|
||||
// hsl path
|
||||
// vec3 texturecolorhsl = rgb2hsl(texturecolor);
|
||||
// vec3 texturecolorfullv = hsl2rgb(vec3(texturecolorhsl.rg, 0.5));
|
||||
|
||||
vec3 envyuv = rgb2yuv(envcolor);
|
||||
texturecolor = mix(texturecolor, texturecolorfullv, envyuv.r * reflectivity);
|
||||
|
||||
if(lights_count == 0U)
|
||||
return (fragcolor + emissioncolor + envcolor * reflectivity) * texturecolor;
|
||||
|
||||
// fragcolor *= lights[0].intensity;
|
||||
vec2 sunlight = calc_dir_light(lights[0], fragnormal);
|
||||
|
||||
float diffuseamount = (sunlight.x * param[1].x) * lights[0].intensity;
|
||||
// fragcolor += mix(lights[0].color * diffuseamount, envcolor, reflectivity);
|
||||
fragcolor += lights[0].color * diffuseamount;
|
||||
fragcolor = mix(fragcolor, envcolor, reflectivity);
|
||||
|
||||
for (uint i = 1U; i < lights_count; i++)
|
||||
{
|
||||
light_s light = lights[i];
|
||||
vec2 part = vec2(0.0);
|
||||
|
||||
// if (light.type == LIGHT_SPOT)
|
||||
// part = calc_spot_light(light, fragnormal);
|
||||
// else if (light.type == LIGHT_POINT)
|
||||
// part = calc_point_light(light, fragnormal);
|
||||
// else if (light.type == LIGHT_DIR)
|
||||
// part = calc_dir_light(light, fragnormal);
|
||||
// else if (light.type == LIGHT_HEADLIGHTS)
|
||||
part = calc_headlights(light, fragnormal);
|
||||
|
||||
fragcolor += light.color * (part.x * param[1].x + part.y * param[1].y) * light.intensity;
|
||||
}
|
||||
|
||||
float specularamount = (sunlight.y * param[1].y * specularity) * lights[0].intensity * clamp(1.0 - shadowtone, 0.0, 1.0);
|
||||
if (shadowtone < 1.0)
|
||||
{
|
||||
float shadow = calc_shadow();
|
||||
specularamount *= clamp(1.0 - shadow, 0.0, 1.0);
|
||||
fragcolor = mix(fragcolor, fragcolor * shadowtone, clamp(diffuseamount * shadow + specularamount, 0.0, 1.0));
|
||||
}
|
||||
fragcolor += emissioncolor;
|
||||
vec3 specularcolor = specularamount * lights[0].color;
|
||||
|
||||
if ((param[1].w < 0.0) || (metalic == true))
|
||||
{
|
||||
fragcolor += specularcolor;
|
||||
fragcolor *= texturecolor;
|
||||
}
|
||||
else
|
||||
{
|
||||
fragcolor *= texturecolor;
|
||||
fragcolor += specularcolor;
|
||||
}
|
||||
|
||||
return fragcolor;
|
||||
}
|
||||
|
||||
@@ -4,5 +4,5 @@ layout(location = 0) out vec4 out_color;
|
||||
|
||||
void main()
|
||||
{
|
||||
out_color = vec4(scene_extra, 1.0f);
|
||||
out_color = vec4(vec3(cascade_end), 1.0f);
|
||||
}
|
||||
|
||||
@@ -8,7 +8,7 @@ out vec2 f_coords;
|
||||
|
||||
void main() {
|
||||
vec4 position = gl_in[0].gl_Position;
|
||||
vec2 size = vec2(0.1) * scene_extra.xy;
|
||||
vec2 size = vec2(0.1) * cascade_end.xy;
|
||||
|
||||
gl_Position = position + vec4(-size.x, -size.y, 0.0, 0.0);
|
||||
f_coords = vec2(g_coords[0].s, 0.0);
|
||||
|
||||
@@ -2,25 +2,59 @@ in vec3 f_normal;
|
||||
in vec2 f_coord;
|
||||
in vec4 f_pos;
|
||||
|
||||
#texture (tex1, 0, sRGB_A)
|
||||
uniform sampler2D tex1;
|
||||
in vec4 f_clip_pos;
|
||||
in vec4 f_clip_future_pos;
|
||||
|
||||
#include <common>
|
||||
#include <tonemapping.glsl>
|
||||
|
||||
#param (diffuse, 1, 0, 1, diffuse)
|
||||
|
||||
#texture (diffuse, 0, sRGB_A)
|
||||
uniform sampler2D diffuse;
|
||||
|
||||
layout(location = 0) out vec4 out_color;
|
||||
#if MOTIONBLUR_ENABLED
|
||||
layout(location = 1) out vec4 out_motion;
|
||||
#endif
|
||||
|
||||
#include <apply_fog.glsl>
|
||||
#include <tonemapping.glsl>
|
||||
|
||||
vec3 apply_lights_clouds(vec3 fragcolor, vec3 fragnormal, vec3 texturecolor)
|
||||
{
|
||||
if(lights_count == 0U)
|
||||
return fragcolor * texturecolor;
|
||||
|
||||
vec3 light_dir = normalize(-lights[0].dir);
|
||||
vec3 view_dir = normalize(vec3(0.0) - f_pos.xyz);
|
||||
vec3 halfway_dir = normalize(light_dir + view_dir);
|
||||
float diffuse_v = max(dot(fragnormal, light_dir), 0.0);
|
||||
float diffuseamount = (diffuse_v * param[1].x) * lights[0].intensity;
|
||||
fragcolor += lights[0].color * diffuseamount;
|
||||
fragcolor *= texturecolor;
|
||||
|
||||
return fragcolor;
|
||||
}
|
||||
|
||||
void main()
|
||||
{
|
||||
vec4 tex_color = texture(tex1, f_coord);
|
||||
vec4 tex_color = texture(diffuse, f_coord);
|
||||
tex_color.a = clamp(tex_color.a * 1.25, 0.0, 1.0);
|
||||
if(tex_color.a < 0.01)
|
||||
discard;
|
||||
|
||||
vec3 fragcolor = param[0].rgb;
|
||||
vec3 fragnormal = normalize(f_normal);
|
||||
|
||||
fragcolor = apply_lights_clouds(fragcolor, fragnormal, tex_color.rgb);
|
||||
vec4 color = vec4(apply_fog(fragcolor), tex_color.a);
|
||||
|
||||
#if POSTFX_ENABLED
|
||||
out_color = tex_color * param[0];
|
||||
out_color = color;
|
||||
#else
|
||||
out_color = tonemap(tex_color * param[0]);
|
||||
out_color = tonemap(color);
|
||||
#endif
|
||||
|
||||
#if MOTIONBLUR_ENABLED
|
||||
out_motion = vec4(0.0f);
|
||||
#endif
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
in vec3 f_normal;
|
||||
in vec2 f_coord;
|
||||
in vec4 f_pos;
|
||||
in vec4 f_light_pos;
|
||||
|
||||
in vec4 f_clip_pos;
|
||||
in vec4 f_clip_future_pos;
|
||||
@@ -12,60 +11,33 @@ in vec4 f_clip_future_pos;
|
||||
#param (diffuse, 1, 0, 1, diffuse)
|
||||
#param (specular, 1, 1, 1, specular)
|
||||
#param (reflection, 1, 2, 1, zero)
|
||||
|
||||
#if SHADOWMAP_ENABLED
|
||||
uniform sampler2DShadow shadowmap;
|
||||
#endif
|
||||
|
||||
#if ENVMAP_ENABLED
|
||||
uniform samplerCube envmap;
|
||||
#endif
|
||||
|
||||
#include <light_common.glsl>
|
||||
#include <tonemapping.glsl>
|
||||
#param (glossiness, 1, 3, 1, glossiness)
|
||||
|
||||
layout(location = 0) out vec4 out_color;
|
||||
#if MOTIONBLUR_ENABLED
|
||||
layout(location = 1) out vec4 out_motion;
|
||||
#endif
|
||||
|
||||
#include <light_common.glsl>
|
||||
#include <apply_fog.glsl>
|
||||
#include <tonemapping.glsl>
|
||||
|
||||
void main()
|
||||
{
|
||||
vec4 tex_color = vec4(pow(param[0].rgb, vec3(2.2)), param[0].a);
|
||||
|
||||
vec3 normal = normalize(f_normal);
|
||||
vec3 refvec = reflect(f_pos.xyz, normal);
|
||||
#if ENVMAP_ENABLED
|
||||
vec3 envcolor = texture(envmap, refvec).rgb;
|
||||
#else
|
||||
vec3 envcolor = vec3(0.5);
|
||||
#endif
|
||||
// if (tex_color.a < opacity)
|
||||
// discard;
|
||||
|
||||
vec3 result = ambient * 0.5 + param[0].rgb * emission;
|
||||
vec3 fragcolor = ambient;
|
||||
vec3 fragnormal = normalize(f_normal);
|
||||
float reflectivity = param[1].z;
|
||||
float specularity = (tex_color.r + tex_color.g + tex_color.b) * 0.5;
|
||||
glossiness = abs(param[1].w);
|
||||
|
||||
fragcolor = apply_lights(fragcolor, fragnormal, tex_color.rgb, reflectivity, specularity, shadow_tone);
|
||||
|
||||
if (lights_count > 0U)
|
||||
{
|
||||
vec2 part = calc_dir_light(lights[0]);
|
||||
vec3 c = (part.x * param[1].x + part.y * param[1].y) * calc_shadow() * lights[0].color;
|
||||
result += mix(c, envcolor, param[1].z);
|
||||
}
|
||||
|
||||
for (uint i = 1U; i < lights_count; i++)
|
||||
{
|
||||
light_s light = lights[i];
|
||||
vec2 part = vec2(0.0);
|
||||
|
||||
if (light.type == LIGHT_SPOT)
|
||||
part = calc_spot_light(light);
|
||||
else if (light.type == LIGHT_POINT)
|
||||
part = calc_point_light(light);
|
||||
else if (light.type == LIGHT_DIR)
|
||||
part = calc_dir_light(light);
|
||||
|
||||
result += light.color * (part.x * param[1].x + part.y * param[1].y);
|
||||
}
|
||||
|
||||
vec4 color = vec4(apply_fog(result * tex_color.rgb), tex_color.a * alpha_mult);
|
||||
vec4 color = vec4(apply_fog(fragcolor), tex_color.a * alpha_mult);
|
||||
#if POSTFX_ENABLED
|
||||
out_color = color;
|
||||
#else
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
in vec3 f_normal;
|
||||
in vec2 f_coord;
|
||||
in vec4 f_pos;
|
||||
in vec4 f_light_pos;
|
||||
|
||||
in vec4 f_clip_pos;
|
||||
in vec4 f_clip_future_pos;
|
||||
@@ -12,72 +11,50 @@ in vec4 f_clip_future_pos;
|
||||
#param (diffuse, 1, 0, 1, diffuse)
|
||||
#param (specular, 1, 1, 1, specular)
|
||||
#param (reflection, 1, 2, 1, zero)
|
||||
#param (glossiness, 1, 3, 1, glossiness)
|
||||
|
||||
#texture (diffuse, 0, sRGB_A)
|
||||
uniform sampler2D diffuse;
|
||||
|
||||
#if SHADOWMAP_ENABLED
|
||||
uniform sampler2DShadow shadowmap;
|
||||
#endif
|
||||
|
||||
#if ENVMAP_ENABLED
|
||||
uniform samplerCube envmap;
|
||||
#endif
|
||||
|
||||
layout(location = 0) out vec4 out_color;
|
||||
#if MOTIONBLUR_ENABLED
|
||||
layout(location = 1) out vec4 out_motion;
|
||||
#endif
|
||||
|
||||
#include <light_common.glsl>
|
||||
#include <apply_fog.glsl>
|
||||
#include <tonemapping.glsl>
|
||||
|
||||
void main()
|
||||
{
|
||||
vec4 tex_color = texture(diffuse, f_coord);
|
||||
|
||||
if (tex_color.a < opacity)
|
||||
bool alphatestfail = ( opacity >= 0.0 ? (tex_color.a < opacity) : (tex_color.a >= -opacity) );
|
||||
if(alphatestfail)
|
||||
discard;
|
||||
// if (tex_color.a < opacity)
|
||||
// discard;
|
||||
|
||||
vec3 normal = normalize(f_normal);
|
||||
vec3 refvec = reflect(f_pos.xyz, normal);
|
||||
#if ENVMAP_ENABLED
|
||||
vec3 envcolor = texture(envmap, refvec).rgb;
|
||||
#else
|
||||
vec3 envcolor = vec3(0.5);
|
||||
#endif
|
||||
|
||||
vec3 result = ambient * 0.5 + param[0].rgb * emission;
|
||||
|
||||
if (lights_count > 0U)
|
||||
{
|
||||
vec2 part = calc_dir_light(lights[0]);
|
||||
vec3 c = (part.x * param[1].x + part.y * param[1].y) * calc_shadow() * lights[0].color;
|
||||
result += mix(c, envcolor, param[1].z);
|
||||
}
|
||||
|
||||
for (uint i = 1U; i < lights_count; i++)
|
||||
{
|
||||
light_s light = lights[i];
|
||||
vec2 part = vec2(0.0);
|
||||
|
||||
if (light.type == LIGHT_SPOT)
|
||||
part = calc_spot_light(light);
|
||||
else if (light.type == LIGHT_POINT)
|
||||
part = calc_point_light(light);
|
||||
else if (light.type == LIGHT_DIR)
|
||||
part = calc_dir_light(light);
|
||||
|
||||
result += light.color * (part.x * param[1].x + part.y * param[1].y);
|
||||
}
|
||||
|
||||
vec4 color = vec4(apply_fog(result * tex_color.rgb), tex_color.a * alpha_mult);
|
||||
vec3 fragcolor = ambient;
|
||||
vec3 fragnormal = normalize(f_normal);
|
||||
float reflectivity = param[1].z;
|
||||
float specularity = (tex_color.r + tex_color.g + tex_color.b) * 0.5;
|
||||
glossiness = abs(param[1].w);
|
||||
|
||||
fragcolor = apply_lights(fragcolor, fragnormal, tex_color.rgb, reflectivity, specularity, shadow_tone);
|
||||
vec4 color = vec4(apply_fog(fragcolor), tex_color.a * alpha_mult);
|
||||
/*
|
||||
float distance = dot(f_pos.xyz, f_pos.xyz);
|
||||
if( distance <= cascade_end.x ) { color.r += 0.25; }
|
||||
else if( distance <= cascade_end.y ) { color.g += 0.25; }
|
||||
else if( distance <= cascade_end.z ) { color.b += 0.25; }
|
||||
*/
|
||||
#if POSTFX_ENABLED
|
||||
out_color = color;
|
||||
#else
|
||||
out_color = tonemap(color);
|
||||
#endif
|
||||
|
||||
|
||||
#if MOTIONBLUR_ENABLED
|
||||
{
|
||||
vec2 a = (f_clip_future_pos.xy / f_clip_future_pos.w) * 0.5 + 0.5;;
|
||||
|
||||
70
shaders/mat_default_specgloss.frag
Normal file
70
shaders/mat_default_specgloss.frag
Normal file
@@ -0,0 +1,70 @@
|
||||
in vec3 f_normal;
|
||||
in vec2 f_coord;
|
||||
in vec4 f_pos;
|
||||
|
||||
in vec4 f_clip_pos;
|
||||
in vec4 f_clip_future_pos;
|
||||
|
||||
#include <common>
|
||||
|
||||
#param (color, 0, 0, 4, diffuse)
|
||||
#param (diffuse, 1, 0, 1, diffuse)
|
||||
#param (specular, 1, 1, 1, specular)
|
||||
#param (reflection, 1, 2, 1, zero)
|
||||
#param (glossiness, 1, 3, 1, glossiness)
|
||||
|
||||
#texture (diffuse, 0, sRGB_A)
|
||||
uniform sampler2D diffuse;
|
||||
|
||||
#texture (specgloss, 1, RGBA)
|
||||
uniform sampler2D specgloss;
|
||||
|
||||
layout(location = 0) out vec4 out_color;
|
||||
#if MOTIONBLUR_ENABLED
|
||||
layout(location = 1) out vec4 out_motion;
|
||||
#endif
|
||||
|
||||
#include <light_common.glsl>
|
||||
#include <apply_fog.glsl>
|
||||
#include <tonemapping.glsl>
|
||||
|
||||
void main()
|
||||
{
|
||||
vec4 tex_color = texture(diffuse, f_coord);
|
||||
|
||||
bool alphatestfail = ( opacity >= 0.0 ? (tex_color.a < opacity) : (tex_color.a >= -opacity) );
|
||||
if(alphatestfail)
|
||||
discard;
|
||||
// if (tex_color.a < opacity)
|
||||
// discard;
|
||||
|
||||
vec3 fragcolor = ambient;
|
||||
vec3 fragnormal = normalize(f_normal);
|
||||
float reflectivity = param[1].z;
|
||||
float specularity = texture(specgloss, f_coord).r;
|
||||
glossiness = texture(specgloss, f_coord).g * abs(param[1].w);
|
||||
metalic = (texture(specgloss, f_coord).b > 0.5) ? true : false;
|
||||
|
||||
fragcolor = apply_lights(fragcolor, fragnormal, tex_color.rgb, reflectivity, specularity, shadow_tone);
|
||||
vec4 color = vec4(apply_fog(fragcolor), tex_color.a * alpha_mult);
|
||||
/*
|
||||
float distance = dot(f_pos.xyz, f_pos.xyz);
|
||||
if( distance <= cascade_end.x ) { color.r += 0.25; }
|
||||
else if( distance <= cascade_end.y ) { color.g += 0.25; }
|
||||
else if( distance <= cascade_end.z ) { color.b += 0.25; }
|
||||
*/
|
||||
#if POSTFX_ENABLED
|
||||
out_color = color;
|
||||
#else
|
||||
out_color = tonemap(color);
|
||||
#endif
|
||||
|
||||
#if MOTIONBLUR_ENABLED
|
||||
{
|
||||
vec2 a = (f_clip_future_pos.xy / f_clip_future_pos.w) * 0.5 + 0.5;;
|
||||
vec2 b = (f_clip_pos.xy / f_clip_pos.w) * 0.5 + 0.5;;
|
||||
|
||||
out_motion = vec4(a - b, 0.0f, tex_color.a * alpha_mult);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
@@ -2,7 +2,6 @@ in vec3 f_normal;
|
||||
in vec2 f_coord;
|
||||
in vec4 f_pos;
|
||||
in mat3 f_tbn;
|
||||
in vec4 f_light_pos;
|
||||
|
||||
in vec4 f_clip_pos;
|
||||
in vec4 f_clip_future_pos;
|
||||
@@ -17,7 +16,8 @@ layout(location = 1) out vec4 out_motion;
|
||||
#param (color, 0, 0, 4, diffuse)
|
||||
#param (diffuse, 1, 0, 1, diffuse)
|
||||
#param (specular, 1, 1, 1, specular)
|
||||
#param (reflection, 1, 2, 1, zero)
|
||||
#param (reflection, 1, 2, 1, one)
|
||||
#param (glossiness, 1, 3, 1, glossiness)
|
||||
|
||||
#texture (diffuse, 0, sRGB_A)
|
||||
uniform sampler2D diffuse;
|
||||
@@ -25,63 +25,33 @@ uniform sampler2D diffuse;
|
||||
#texture (normalmap, 1, RGBA)
|
||||
uniform sampler2D normalmap;
|
||||
|
||||
#if SHADOWMAP_ENABLED
|
||||
uniform sampler2DShadow shadowmap;
|
||||
#endif
|
||||
|
||||
#if ENVMAP_ENABLED
|
||||
uniform samplerCube envmap;
|
||||
#endif
|
||||
|
||||
vec3 normal;
|
||||
|
||||
#define NORMALMAP
|
||||
#include <light_common.glsl>
|
||||
#include <apply_fog.glsl>
|
||||
#include <tonemapping.glsl>
|
||||
|
||||
void main()
|
||||
{
|
||||
vec4 tex_color = texture(diffuse, f_coord);
|
||||
|
||||
if (tex_color.a < opacity)
|
||||
bool alphatestfail = ( opacity >= 0.0 ? (tex_color.a < opacity) : (tex_color.a >= -opacity) );
|
||||
if(alphatestfail)
|
||||
discard;
|
||||
// if (tex_color.a < opacity)
|
||||
// discard;
|
||||
|
||||
vec3 fragcolor = ambient;
|
||||
|
||||
vec3 normal;
|
||||
normal.xy = (texture(normalmap, f_coord).rg * 2.0 - 1.0);
|
||||
normal.z = sqrt(1.0 - clamp((dot(normal.xy, normal.xy)), 0.0, 1.0));
|
||||
normal = normalize(f_tbn * normalize(normal.xyz));
|
||||
//vec3 normal = normalize(f_tbn * normalize(texture(normalmap, f_coord).rgb * 2.0 - 1.0));
|
||||
vec3 refvec = reflect(f_pos.xyz, normal);
|
||||
#if ENVMAP_ENABLED
|
||||
vec3 envcolor = texture(envmap, refvec).rgb;
|
||||
#else
|
||||
vec3 envcolor = vec3(0.5);
|
||||
#endif
|
||||
vec3 fragnormal = normalize(f_tbn * normalize(normal.xyz));
|
||||
float reflectivity = param[1].z * texture(normalmap, f_coord).a;
|
||||
float specularity = (tex_color.r + tex_color.g + tex_color.b) * 0.5;
|
||||
|
||||
vec3 result = ambient * 0.5 + param[0].rgb * emission;
|
||||
fragcolor = apply_lights(fragcolor, fragnormal, tex_color.rgb, reflectivity, specularity, shadow_tone);
|
||||
|
||||
if (lights_count > 0U)
|
||||
{
|
||||
vec2 part = calc_dir_light(lights[0]);
|
||||
vec3 c = (part.x * param[1].x + part.y * param[1].y) * calc_shadow() * lights[0].color;
|
||||
result += mix(c, envcolor, param[1].z * texture(normalmap, f_coord).a);
|
||||
}
|
||||
|
||||
for (uint i = 1U; i < lights_count; i++)
|
||||
{
|
||||
light_s light = lights[i];
|
||||
vec2 part = vec2(0.0);
|
||||
|
||||
if (light.type == LIGHT_SPOT)
|
||||
part = calc_spot_light(light);
|
||||
else if (light.type == LIGHT_POINT)
|
||||
part = calc_point_light(light);
|
||||
else if (light.type == LIGHT_DIR)
|
||||
part = calc_dir_light(light);
|
||||
|
||||
result += light.color * (part.x * param[1].x + part.y * param[1].y);
|
||||
}
|
||||
|
||||
vec4 color = vec4(apply_fog(result * tex_color.rgb), tex_color.a * alpha_mult);
|
||||
vec4 color = vec4(apply_fog(fragcolor), tex_color.a * alpha_mult);
|
||||
#if POSTFX_ENABLED
|
||||
out_color = color;
|
||||
#else
|
||||
|
||||
74
shaders/mat_normalmap_specgloss.frag
Normal file
74
shaders/mat_normalmap_specgloss.frag
Normal file
@@ -0,0 +1,74 @@
|
||||
in vec3 f_normal;
|
||||
in vec2 f_coord;
|
||||
in vec4 f_pos;
|
||||
in mat3 f_tbn;
|
||||
|
||||
in vec4 f_clip_pos;
|
||||
in vec4 f_clip_future_pos;
|
||||
|
||||
#include <common>
|
||||
|
||||
layout(location = 0) out vec4 out_color;
|
||||
#if MOTIONBLUR_ENABLED
|
||||
layout(location = 1) out vec4 out_motion;
|
||||
#endif
|
||||
|
||||
#param (color, 0, 0, 4, diffuse)
|
||||
#param (diffuse, 1, 0, 1, diffuse)
|
||||
#param (specular, 1, 1, 1, specular)
|
||||
#param (reflection, 1, 2, 1, one)
|
||||
#param (glossiness, 1, 3, 1, glossiness)
|
||||
|
||||
#texture (diffuse, 0, sRGB_A)
|
||||
uniform sampler2D diffuse;
|
||||
|
||||
#texture (normalmap, 1, RGBA)
|
||||
uniform sampler2D normalmap;
|
||||
|
||||
#texture (specgloss, 2, RGBA)
|
||||
uniform sampler2D specgloss;
|
||||
|
||||
|
||||
#define NORMALMAP
|
||||
#include <light_common.glsl>
|
||||
#include <apply_fog.glsl>
|
||||
#include <tonemapping.glsl>
|
||||
|
||||
void main()
|
||||
{
|
||||
vec4 tex_color = texture(diffuse, f_coord);
|
||||
|
||||
bool alphatestfail = ( opacity >= 0.0 ? (tex_color.a < opacity) : (tex_color.a >= -opacity) );
|
||||
if(alphatestfail)
|
||||
discard;
|
||||
// if (tex_color.a < opacity)
|
||||
// discard;
|
||||
|
||||
vec3 fragcolor = ambient;
|
||||
|
||||
vec3 normal;
|
||||
normal.xy = (texture(normalmap, f_coord).rg * 2.0 - 1.0);
|
||||
normal.z = sqrt(1.0 - clamp((dot(normal.xy, normal.xy)), 0.0, 1.0));
|
||||
vec3 fragnormal = normalize(f_tbn * normalize(normal.xyz));
|
||||
float reflectivity = param[1].z * texture(normalmap, f_coord).a;
|
||||
float specularity = texture(specgloss, f_coord).r;
|
||||
glossiness = texture(specgloss, f_coord).g * abs(param[1].w);
|
||||
metalic = (texture(specgloss, f_coord).b > 0.5) ? true : false;
|
||||
|
||||
fragcolor = apply_lights(fragcolor, fragnormal, tex_color.rgb, reflectivity, specularity, shadow_tone);
|
||||
|
||||
vec4 color = vec4(apply_fog(fragcolor), tex_color.a * alpha_mult);
|
||||
#if POSTFX_ENABLED
|
||||
out_color = color;
|
||||
#else
|
||||
out_color = tonemap(color);
|
||||
#endif
|
||||
#if MOTIONBLUR_ENABLED
|
||||
{
|
||||
vec2 a = (f_clip_future_pos.xy / f_clip_future_pos.w) * 0.5 + 0.5;;
|
||||
vec2 b = (f_clip_pos.xy / f_clip_pos.w) * 0.5 + 0.5;;
|
||||
|
||||
out_motion = vec4(a - b, 0.0f, 0.0f);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
@@ -2,7 +2,6 @@ in vec3 f_normal;
|
||||
in vec2 f_coord;
|
||||
in vec4 f_pos;
|
||||
in mat3 f_tbn; //tangent matrix nietransponowany; mnożyć przez f_tbn dla TangentLightPos; TangentViewPos; TangentFragPos;
|
||||
in vec4 f_light_pos;
|
||||
in vec4 f_clip_pos;
|
||||
in vec4 f_clip_future_pos;
|
||||
in vec3 TangentFragPos;
|
||||
@@ -17,7 +16,8 @@ layout(location = 1) out vec4 out_motion;
|
||||
#param (color, 0, 0, 4, diffuse)
|
||||
#param (diffuse, 1, 0, 1, diffuse)
|
||||
#param (specular, 1, 1, 1, specular)
|
||||
#param (reflection, 1, 2, 1, zero)
|
||||
#param (reflection, 1, 2, 1, one)
|
||||
#param (glossiness, 1, 3, 1, glossiness)
|
||||
#param (height_scale, 2, 1, 1, zero)
|
||||
#param (height_offset, 2, 2, 1, zero)
|
||||
|
||||
@@ -27,67 +27,39 @@ uniform sampler2D diffuse;
|
||||
#texture (normalmap, 1, RGBA)
|
||||
uniform sampler2D normalmap;
|
||||
|
||||
#if SHADOWMAP_ENABLED
|
||||
uniform sampler2DShadow shadowmap;
|
||||
#endif
|
||||
|
||||
#if ENVMAP_ENABLED
|
||||
uniform samplerCube envmap;
|
||||
#endif
|
||||
|
||||
vec3 normal_p;
|
||||
#define PARALLAX
|
||||
#include <light_common.glsl>
|
||||
#include <apply_fog.glsl>
|
||||
#include <tonemapping.glsl>
|
||||
|
||||
vec2 ParallaxMapping(vec2 f_coord, vec3 viewDir);
|
||||
|
||||
void main()
|
||||
{
|
||||
//parallex mapping
|
||||
//parallax mapping
|
||||
vec3 viewDir = normalize(vec3(0.0f, 0.0f, 0.0f) - TangentFragPos); //tangent view pos - tangent frag pos
|
||||
vec2 f_coord_p = ParallaxMapping(f_coord, viewDir);
|
||||
|
||||
vec4 tex_color = texture(diffuse, f_coord_p);
|
||||
|
||||
if (tex_color.a < opacity)
|
||||
bool alphatestfail = ( opacity >= 0.0 ? (tex_color.a < opacity) : (tex_color.a >= -opacity) );
|
||||
if(alphatestfail)
|
||||
discard;
|
||||
// if (tex_color.a < opacity)
|
||||
// discard;
|
||||
|
||||
vec3 fragcolor = ambient;
|
||||
|
||||
vec3 normal;
|
||||
normal.xy = (texture(normalmap, f_coord_p).rg * 2.0 - 1.0);
|
||||
normal.z = sqrt(1.0 - clamp((dot(normal.xy, normal.xy)), 0.0, 1.0));
|
||||
normal_p = normalize(f_tbn * normalize(normal.xyz));
|
||||
vec3 refvec = reflect(f_pos.xyz, normal_p);
|
||||
#if ENVMAP_ENABLED
|
||||
vec3 envcolor = texture(envmap, refvec).rgb;
|
||||
#else
|
||||
vec3 envcolor = vec3(0.5);
|
||||
#endif
|
||||
vec3 fragnormal = normalize(f_tbn * normalize(normal.xyz));
|
||||
float reflectivity = param[1].z * texture(normalmap, f_coord_p).a;
|
||||
float specularity = (tex_color.r + tex_color.g + tex_color.b) * 0.5;
|
||||
|
||||
fragcolor = apply_lights(fragcolor, fragnormal, tex_color.rgb, reflectivity, specularity, shadow_tone);
|
||||
|
||||
vec3 result = ambient * 0.5 + param[0].rgb * emission;
|
||||
|
||||
if (lights_count > 0U)
|
||||
{
|
||||
vec2 part = calc_dir_light(lights[0]);
|
||||
vec3 c = (part.x * param[1].x + part.y * param[1].y) * calc_shadow() * lights[0].color;
|
||||
result += mix(c, envcolor, param[1].z * texture(normalmap, f_coord_p).a);
|
||||
}
|
||||
|
||||
for (uint i = 1U; i < lights_count; i++)
|
||||
{
|
||||
light_s light = lights[i];
|
||||
vec2 part = vec2(0.0);
|
||||
|
||||
if (light.type == LIGHT_SPOT)
|
||||
part = calc_spot_light(light);
|
||||
else if (light.type == LIGHT_POINT)
|
||||
part = calc_point_light(light);
|
||||
else if (light.type == LIGHT_DIR)
|
||||
part = calc_dir_light(light);
|
||||
|
||||
result += light.color * (part.x * param[1].x + part.y * param[1].y);
|
||||
}
|
||||
|
||||
vec4 color = vec4(apply_fog(result * tex_color.rgb), tex_color.a * alpha_mult);
|
||||
vec4 color = vec4(apply_fog(fragcolor), tex_color.a * alpha_mult);
|
||||
#if POSTFX_ENABLED
|
||||
out_color = color;
|
||||
#else
|
||||
@@ -102,6 +74,7 @@ void main()
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
vec2 ParallaxMapping(vec2 f_coord, vec3 viewDir)
|
||||
{
|
||||
float pos_len = length(f_pos.xyz);
|
||||
@@ -134,7 +107,7 @@ vec2 ParallaxMapping(vec2 f_coord, vec3 viewDir)
|
||||
vec2 prevTexCoords = currentTexCoords + deltaTexCoords; // get texture coordinates before collision (reverse operations)
|
||||
|
||||
float afterDepth = currentDepthMapValue - currentLayerDepth; // get depth after and before collision for linear interpolation
|
||||
float beforeDepth = texture(normalmap, currentTexCoords).b - currentLayerDepth + layerDepth;
|
||||
float beforeDepth = texture(normalmap, prevTexCoords).b - currentLayerDepth + layerDepth;
|
||||
|
||||
float weight = afterDepth / (afterDepth - beforeDepth); // interpolation of texture coordinates
|
||||
vec2 finalTexCoords = prevTexCoords * weight + currentTexCoords * (1.0 - weight);
|
||||
|
||||
127
shaders/mat_parallax_specgloss.frag
Normal file
127
shaders/mat_parallax_specgloss.frag
Normal file
@@ -0,0 +1,127 @@
|
||||
in vec3 f_normal;
|
||||
in vec2 f_coord;
|
||||
in vec4 f_pos;
|
||||
in mat3 f_tbn; //tangent matrix nietransponowany; mnożyć przez f_tbn dla TangentLightPos; TangentViewPos; TangentFragPos;
|
||||
in vec4 f_clip_pos;
|
||||
in vec4 f_clip_future_pos;
|
||||
in vec3 TangentFragPos;
|
||||
|
||||
#include <common>
|
||||
|
||||
layout(location = 0) out vec4 out_color;
|
||||
#if MOTIONBLUR_ENABLED
|
||||
layout(location = 1) out vec4 out_motion;
|
||||
#endif
|
||||
|
||||
#param (color, 0, 0, 4, diffuse)
|
||||
#param (diffuse, 1, 0, 1, diffuse)
|
||||
#param (specular, 1, 1, 1, specular)
|
||||
#param (reflection, 1, 2, 1, one)
|
||||
#param (glossiness, 1, 3, 1, glossiness)
|
||||
#param (height_scale, 2, 1, 1, zero)
|
||||
#param (height_offset, 2, 2, 1, zero)
|
||||
|
||||
#texture (diffuse, 0, sRGB_A)
|
||||
uniform sampler2D diffuse;
|
||||
|
||||
#texture (normalmap, 1, RGBA)
|
||||
uniform sampler2D normalmap;
|
||||
|
||||
#texture (specgloss, 2, RGBA)
|
||||
uniform sampler2D specgloss;
|
||||
|
||||
|
||||
#define PARALLAX
|
||||
#include <light_common.glsl>
|
||||
#include <apply_fog.glsl>
|
||||
#include <tonemapping.glsl>
|
||||
|
||||
vec2 ParallaxMapping(vec2 f_coord, vec3 viewDir);
|
||||
|
||||
void main()
|
||||
{
|
||||
//parallax mapping
|
||||
vec3 viewDir = normalize(vec3(0.0f, 0.0f, 0.0f) - TangentFragPos); //tangent view pos - tangent frag pos
|
||||
vec2 f_coord_p = ParallaxMapping(f_coord, viewDir);
|
||||
|
||||
vec4 tex_color = texture(diffuse, f_coord_p);
|
||||
|
||||
bool alphatestfail = ( opacity >= 0.0 ? (tex_color.a < opacity) : (tex_color.a >= -opacity) );
|
||||
if(alphatestfail)
|
||||
discard;
|
||||
// if (tex_color.a < opacity)
|
||||
// discard;
|
||||
|
||||
vec3 fragcolor = ambient;
|
||||
|
||||
vec3 normal;
|
||||
normal.xy = (texture(normalmap, f_coord_p).rg * 2.0 - 1.0);
|
||||
normal.z = sqrt(1.0 - clamp((dot(normal.xy, normal.xy)), 0.0, 1.0));
|
||||
vec3 fragnormal = normalize(f_tbn * normalize(normal.xyz));
|
||||
float reflectivity = param[1].z * texture(normalmap, f_coord_p).a;
|
||||
float specularity = texture(specgloss, f_coord).r;
|
||||
glossiness = texture(specgloss, f_coord).g * abs(param[1].w);
|
||||
metalic = (texture(specgloss, f_coord).b > 0.5) ? true : false;
|
||||
|
||||
fragcolor = apply_lights(fragcolor, fragnormal, tex_color.rgb, reflectivity, specularity, shadow_tone);
|
||||
|
||||
vec4 color = vec4(apply_fog(fragcolor), tex_color.a * alpha_mult);
|
||||
#if POSTFX_ENABLED
|
||||
out_color = color;
|
||||
#else
|
||||
out_color = tonemap(color);
|
||||
#endif
|
||||
#if MOTIONBLUR_ENABLED
|
||||
{
|
||||
vec2 a = (f_clip_future_pos.xy / f_clip_future_pos.w) * 0.5 + 0.5;;
|
||||
vec2 b = (f_clip_pos.xy / f_clip_pos.w) * 0.5 + 0.5;;
|
||||
|
||||
out_motion = vec4(a - b, 0.0f, 0.0f);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
vec2 ParallaxMapping(vec2 f_coord, vec3 viewDir)
|
||||
{
|
||||
float pos_len = length(f_pos.xyz);
|
||||
|
||||
if (pos_len > 100.0) {
|
||||
return f_coord;
|
||||
}
|
||||
|
||||
#if EXTRAEFFECTS_ENABLED
|
||||
const float minLayers = 8.0;
|
||||
const float maxLayers = 32.0;
|
||||
float LayersWeight = pos_len / 20.0;
|
||||
vec2 currentTexCoords = f_coord;
|
||||
float currentDepthMapValue = texture(normalmap, currentTexCoords).b;
|
||||
LayersWeight = min(abs(dot(vec3(0.0, 0.0, 1.0), viewDir)),LayersWeight);
|
||||
float numLayers = mix(maxLayers, minLayers, clamp(LayersWeight, 0.0, 1.0)); // number of depth layers
|
||||
float layerDepth = 1.0 / numLayers; // calculate the size of each layer
|
||||
float currentLayerDepth = 0.0; // depth of current layer
|
||||
vec2 P = viewDir.xy * param[2].y; // the amount to shift the texture coordinates per layer (from vector P)
|
||||
vec2 deltaTexCoords = P / numLayers;
|
||||
|
||||
|
||||
while(currentLayerDepth < currentDepthMapValue)
|
||||
{
|
||||
currentTexCoords -= deltaTexCoords; // shift texture coordinates along direction of P
|
||||
currentDepthMapValue = texture(normalmap, currentTexCoords).b; // get depthmap value at current texture coordinates
|
||||
currentLayerDepth += layerDepth; // get depth of next layer
|
||||
}
|
||||
|
||||
vec2 prevTexCoords = currentTexCoords + deltaTexCoords; // get texture coordinates before collision (reverse operations)
|
||||
|
||||
float afterDepth = currentDepthMapValue - currentLayerDepth; // get depth after and before collision for linear interpolation
|
||||
float beforeDepth = texture(normalmap, prevTexCoords).b - currentLayerDepth + layerDepth;
|
||||
|
||||
float weight = afterDepth / (afterDepth - beforeDepth); // interpolation of texture coordinates
|
||||
vec2 finalTexCoords = prevTexCoords * weight + currentTexCoords * (1.0 - weight);
|
||||
|
||||
return finalTexCoords;
|
||||
#else
|
||||
float height = texture(normalmap, f_coord).b;
|
||||
vec2 p = viewDir.xy / viewDir.z * (height * (param[2].y - param[2].z) * 0.2);
|
||||
return f_coord - p;
|
||||
#endif
|
||||
}
|
||||
@@ -1,7 +1,6 @@
|
||||
in vec3 f_normal;
|
||||
in vec2 f_coord;
|
||||
in vec4 f_pos;
|
||||
in vec4 f_light_pos;
|
||||
|
||||
in vec4 f_clip_pos;
|
||||
in vec4 f_clip_future_pos;
|
||||
@@ -17,6 +16,7 @@ layout(location = 1) out vec4 out_motion;
|
||||
#param (diffuse, 1, 0, 1, diffuse)
|
||||
#param (specular, 1, 1, 1, specular)
|
||||
#param (reflection, 1, 2, 1, one)
|
||||
#param (glossiness, 1, 3, 1, glossiness)
|
||||
|
||||
#texture (diffuse, 0, sRGB_A)
|
||||
uniform sampler2D diffuse;
|
||||
@@ -24,57 +24,33 @@ uniform sampler2D diffuse;
|
||||
#texture (reflmap, 1, RGBA)
|
||||
uniform sampler2D reflmap;
|
||||
|
||||
#if SHADOWMAP_ENABLED
|
||||
uniform sampler2DShadow shadowmap;
|
||||
#endif
|
||||
|
||||
#if ENVMAP_ENABLED
|
||||
uniform samplerCube envmap;
|
||||
#endif
|
||||
|
||||
#include <light_common.glsl>
|
||||
#include <apply_fog.glsl>
|
||||
#include <tonemapping.glsl>
|
||||
|
||||
void main()
|
||||
{
|
||||
vec4 tex_color = texture(diffuse, f_coord);
|
||||
|
||||
if (tex_color.a < opacity)
|
||||
bool alphatestfail = ( opacity >= 0.0 ? (tex_color.a < opacity) : (tex_color.a >= -opacity) );
|
||||
if(alphatestfail)
|
||||
discard;
|
||||
// if (tex_color.a < opacity)
|
||||
// discard;
|
||||
|
||||
vec3 normal = normalize(f_normal);
|
||||
vec3 refvec = reflect(f_pos.xyz, normal);
|
||||
#if ENVMAP_ENABLED
|
||||
vec3 envcolor = texture(envmap, refvec).rgb;
|
||||
#else
|
||||
vec3 envcolor = vec3(0.5);
|
||||
#endif
|
||||
vec3 fragcolor = ambient;
|
||||
vec3 fragnormal = normalize(f_normal);
|
||||
float reflectivity = param[1].z * texture(reflmap, f_coord).a;
|
||||
float specularity = (tex_color.r + tex_color.g + tex_color.b) * 0.5;
|
||||
glossiness = abs(param[1].w);
|
||||
|
||||
fragcolor = apply_lights(fragcolor, fragnormal, tex_color.rgb, reflectivity, specularity, shadow_tone);
|
||||
|
||||
vec3 result = ambient * 0.5 + param[0].rgb * emission;
|
||||
if(alphatestfail)
|
||||
fragcolor.r = 1.0;
|
||||
|
||||
if (lights_count > 0U)
|
||||
{
|
||||
vec2 part = calc_dir_light(lights[0]);
|
||||
vec3 c = (part.x * param[1].x + part.y * param[1].y) * calc_shadow() * lights[0].color;
|
||||
result += mix(c, envcolor, param[1].z * texture(reflmap, f_coord).a);
|
||||
}
|
||||
vec4 color = vec4(apply_fog(fragcolor), tex_color.a * alpha_mult);
|
||||
|
||||
for (uint i = 1U; i < lights_count; i++)
|
||||
{
|
||||
light_s light = lights[i];
|
||||
vec2 part = vec2(0.0);
|
||||
|
||||
if (light.type == LIGHT_SPOT)
|
||||
part = calc_spot_light(light);
|
||||
else if (light.type == LIGHT_POINT)
|
||||
part = calc_point_light(light);
|
||||
else if (light.type == LIGHT_DIR)
|
||||
part = calc_dir_light(light);
|
||||
|
||||
result += light.color * (part.x * param[1].x + part.y * param[1].y);
|
||||
}
|
||||
|
||||
vec4 color = vec4(apply_fog(result * tex_color.rgb), tex_color.a * alpha_mult);
|
||||
#if POSTFX_ENABLED
|
||||
out_color = color;
|
||||
#else
|
||||
|
||||
72
shaders/mat_reflmap_specgloss.frag
Normal file
72
shaders/mat_reflmap_specgloss.frag
Normal file
@@ -0,0 +1,72 @@
|
||||
in vec3 f_normal;
|
||||
in vec2 f_coord;
|
||||
in vec4 f_pos;
|
||||
|
||||
in vec4 f_clip_pos;
|
||||
in vec4 f_clip_future_pos;
|
||||
|
||||
#include <common>
|
||||
|
||||
layout(location = 0) out vec4 out_color;
|
||||
#if MOTIONBLUR_ENABLED
|
||||
layout(location = 1) out vec4 out_motion;
|
||||
#endif
|
||||
|
||||
#param (color, 0, 0, 4, diffuse)
|
||||
#param (diffuse, 1, 0, 1, diffuse)
|
||||
#param (specular, 1, 1, 1, specular)
|
||||
#param (reflection, 1, 2, 1, one)
|
||||
#param (glossiness, 1, 3, 1, glossiness)
|
||||
|
||||
#texture (diffuse, 0, sRGB_A)
|
||||
uniform sampler2D diffuse;
|
||||
|
||||
#texture (reflmap, 1, RGBA)
|
||||
uniform sampler2D reflmap;
|
||||
|
||||
#texture (specgloss, 2, RGBA)
|
||||
uniform sampler2D specgloss;
|
||||
|
||||
|
||||
#include <light_common.glsl>
|
||||
#include <apply_fog.glsl>
|
||||
#include <tonemapping.glsl>
|
||||
|
||||
void main()
|
||||
{
|
||||
vec4 tex_color = texture(diffuse, f_coord);
|
||||
|
||||
bool alphatestfail = ( opacity >= 0.0 ? (tex_color.a < opacity) : (tex_color.a >= -opacity) );
|
||||
if(alphatestfail)
|
||||
discard;
|
||||
// if (tex_color.a < opacity)
|
||||
// discard;
|
||||
|
||||
vec3 fragcolor = ambient;
|
||||
vec3 fragnormal = normalize(f_normal);
|
||||
float reflectivity = param[1].z * texture(reflmap, f_coord).a;
|
||||
float specularity = texture(specgloss, f_coord).r;
|
||||
glossiness = texture(specgloss, f_coord).g * abs(param[1].w);
|
||||
metalic = (texture(specgloss, f_coord).b > 0.5) ? true : false;
|
||||
|
||||
fragcolor = apply_lights(fragcolor, fragnormal, tex_color.rgb, reflectivity, specularity, shadow_tone);
|
||||
|
||||
if(alphatestfail)
|
||||
fragcolor.r = 1.0;
|
||||
|
||||
vec4 color = vec4(apply_fog(fragcolor), tex_color.a * alpha_mult);
|
||||
|
||||
#if POSTFX_ENABLED
|
||||
out_color = color;
|
||||
#else
|
||||
out_color = tonemap(color);
|
||||
#endif
|
||||
#if MOTIONBLUR_ENABLED
|
||||
{
|
||||
vec2 a = (f_clip_future_pos.xy / f_clip_future_pos.w) * 0.5 + 0.5;;
|
||||
vec2 b = (f_clip_pos.xy / f_clip_pos.w) * 0.5 + 0.5;;
|
||||
|
||||
out_motion = vec4(a - b, 0.0f, 0.0f);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
68
shaders/mat_shadowlessnormalmap.frag
Normal file
68
shaders/mat_shadowlessnormalmap.frag
Normal file
@@ -0,0 +1,68 @@
|
||||
in vec3 f_normal;
|
||||
in vec2 f_coord;
|
||||
in vec4 f_pos;
|
||||
in mat3 f_tbn;
|
||||
|
||||
in vec4 f_clip_pos;
|
||||
in vec4 f_clip_future_pos;
|
||||
|
||||
#include <common>
|
||||
|
||||
layout(location = 0) out vec4 out_color;
|
||||
#if MOTIONBLUR_ENABLED
|
||||
layout(location = 1) out vec4 out_motion;
|
||||
#endif
|
||||
|
||||
#param (color, 0, 0, 4, diffuse)
|
||||
#param (diffuse, 1, 0, 1, diffuse)
|
||||
#param (specular, 1, 1, 1, specular)
|
||||
#param (reflection, 1, 2, 1, zero)
|
||||
#param (glossiness, 1, 3, 1, glossiness)
|
||||
|
||||
#texture (diffuse, 0, sRGB_A)
|
||||
uniform sampler2D diffuse;
|
||||
|
||||
#texture (normalmap, 1, RGBA)
|
||||
uniform sampler2D normalmap;
|
||||
|
||||
#define NORMALMAP
|
||||
#include <light_common.glsl>
|
||||
#include <apply_fog.glsl>
|
||||
#include <tonemapping.glsl>
|
||||
|
||||
void main()
|
||||
{
|
||||
vec4 tex_color = texture(diffuse, f_coord);
|
||||
|
||||
bool alphatestfail = ( opacity >= 0.0 ? (tex_color.a < opacity) : (tex_color.a >= -opacity) );
|
||||
if(alphatestfail)
|
||||
discard;
|
||||
// if (tex_color.a < opacity)
|
||||
// discard;
|
||||
|
||||
vec3 fragcolor = ambient;
|
||||
|
||||
vec3 normal;
|
||||
normal.xy = (texture(normalmap, f_coord).rg * 2.0 - 1.0);
|
||||
normal.z = sqrt(1.0 - clamp((dot(normal.xy, normal.xy)), 0.0, 1.0));
|
||||
vec3 fragnormal = normalize(f_tbn * normalize(normal.xyz));
|
||||
float reflectivity = param[1].z * texture(normalmap, f_coord).a;
|
||||
float specularity = (tex_color.r + tex_color.g + tex_color.b) * 0.5;
|
||||
glossiness = abs(param[1].w);
|
||||
|
||||
fragcolor = apply_lights(fragcolor, fragnormal, tex_color.rgb, reflectivity, specularity, 1.0);
|
||||
vec4 color = vec4(apply_fog(fragcolor), tex_color.a * alpha_mult);
|
||||
#if POSTFX_ENABLED
|
||||
out_color = color;
|
||||
#else
|
||||
out_color = tonemap(color);
|
||||
#endif
|
||||
#if MOTIONBLUR_ENABLED
|
||||
{
|
||||
vec2 a = (f_clip_future_pos.xy / f_clip_future_pos.w) * 0.5 + 0.5;;
|
||||
vec2 b = (f_clip_pos.xy / f_clip_pos.w) * 0.5 + 0.5;;
|
||||
|
||||
out_motion = vec4(a - b, 0.0f, 0.0f);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
73
shaders/mat_shadowlessnormalmap_specgloss.frag
Normal file
73
shaders/mat_shadowlessnormalmap_specgloss.frag
Normal file
@@ -0,0 +1,73 @@
|
||||
in vec3 f_normal;
|
||||
in vec2 f_coord;
|
||||
in vec4 f_pos;
|
||||
in mat3 f_tbn;
|
||||
|
||||
in vec4 f_clip_pos;
|
||||
in vec4 f_clip_future_pos;
|
||||
|
||||
#include <common>
|
||||
|
||||
layout(location = 0) out vec4 out_color;
|
||||
#if MOTIONBLUR_ENABLED
|
||||
layout(location = 1) out vec4 out_motion;
|
||||
#endif
|
||||
|
||||
#param (color, 0, 0, 4, diffuse)
|
||||
#param (diffuse, 1, 0, 1, diffuse)
|
||||
#param (specular, 1, 1, 1, specular)
|
||||
#param (reflection, 1, 2, 1, zero)
|
||||
#param (glossiness, 1, 3, 1, glossiness)
|
||||
|
||||
#texture (diffuse, 0, sRGB_A)
|
||||
uniform sampler2D diffuse;
|
||||
|
||||
#texture (normalmap, 1, RGBA)
|
||||
uniform sampler2D normalmap;
|
||||
|
||||
#texture (specgloss, 2, RGBA)
|
||||
uniform sampler2D specgloss;
|
||||
|
||||
|
||||
#define NORMALMAP
|
||||
#include <light_common.glsl>
|
||||
#include <apply_fog.glsl>
|
||||
#include <tonemapping.glsl>
|
||||
|
||||
void main()
|
||||
{
|
||||
vec4 tex_color = texture(diffuse, f_coord);
|
||||
|
||||
bool alphatestfail = ( opacity >= 0.0 ? (tex_color.a < opacity) : (tex_color.a >= -opacity) );
|
||||
if(alphatestfail)
|
||||
discard;
|
||||
// if (tex_color.a < opacity)
|
||||
// discard;
|
||||
|
||||
vec3 fragcolor = ambient;
|
||||
|
||||
vec3 normal;
|
||||
normal.xy = (texture(normalmap, f_coord).rg * 2.0 - 1.0);
|
||||
normal.z = sqrt(1.0 - clamp((dot(normal.xy, normal.xy)), 0.0, 1.0));
|
||||
vec3 fragnormal = normalize(f_tbn * normalize(normal.xyz));
|
||||
float reflectivity = param[1].z * texture(normalmap, f_coord).a;
|
||||
float specularity = texture(specgloss, f_coord).r;
|
||||
glossiness = texture(specgloss, f_coord).g * abs(param[1].w);
|
||||
metalic = (texture(specgloss, f_coord).b > 0.5) ? true : false;
|
||||
|
||||
fragcolor = apply_lights(fragcolor, fragnormal, tex_color.rgb, reflectivity, specularity, 1.0);
|
||||
vec4 color = vec4(apply_fog(fragcolor), tex_color.a * alpha_mult);
|
||||
#if POSTFX_ENABLED
|
||||
out_color = color;
|
||||
#else
|
||||
out_color = tonemap(color);
|
||||
#endif
|
||||
#if MOTIONBLUR_ENABLED
|
||||
{
|
||||
vec2 a = (f_clip_future_pos.xy / f_clip_future_pos.w) * 0.5 + 0.5;;
|
||||
vec2 b = (f_clip_pos.xy / f_clip_pos.w) * 0.5 + 0.5;;
|
||||
|
||||
out_motion = vec4(a - b, 0.0f, 0.0f);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
125
shaders/mat_sunlessnormalmap.frag
Normal file
125
shaders/mat_sunlessnormalmap.frag
Normal file
@@ -0,0 +1,125 @@
|
||||
in vec3 f_normal;
|
||||
in vec2 f_coord;
|
||||
in vec4 f_pos;
|
||||
in mat3 f_tbn;
|
||||
|
||||
in vec4 f_clip_pos;
|
||||
in vec4 f_clip_future_pos;
|
||||
|
||||
#include <common>
|
||||
|
||||
layout(location = 0) out vec4 out_color;
|
||||
#if MOTIONBLUR_ENABLED
|
||||
layout(location = 1) out vec4 out_motion;
|
||||
#endif
|
||||
|
||||
#param (color, 0, 0, 4, diffuse)
|
||||
#param (diffuse, 1, 0, 1, diffuse)
|
||||
#param (specular, 1, 1, 1, specular)
|
||||
#param (reflection, 1, 2, 1, zero)
|
||||
#param (glossiness, 1, 3, 1, glossiness)
|
||||
|
||||
#texture (diffuse, 0, sRGB_A)
|
||||
uniform sampler2D diffuse;
|
||||
|
||||
#texture (normalmap, 1, RGBA)
|
||||
uniform sampler2D normalmap;
|
||||
|
||||
#define NORMALMAP
|
||||
#include <light_common.glsl>
|
||||
#include <apply_fog.glsl>
|
||||
#include <tonemapping.glsl>
|
||||
|
||||
vec3 apply_lights_sunless(vec3 fragcolor, vec3 fragnormal, vec3 texturecolor, float reflectivity, float specularity, float shadowtone)
|
||||
{
|
||||
vec3 basecolor = param[0].rgb;
|
||||
|
||||
fragcolor *= basecolor;
|
||||
|
||||
vec3 emissioncolor = basecolor * emission;
|
||||
vec3 envcolor = envmap_color(fragnormal);
|
||||
|
||||
// yuv path
|
||||
vec3 texturecoloryuv = rgb2yuv(texturecolor);
|
||||
vec3 texturecolorfullv = yuv2rgb(vec3(0.2176, texturecoloryuv.gb));
|
||||
// hsl path
|
||||
// vec3 texturecolorhsl = rgb2hsl(texturecolor);
|
||||
// vec3 texturecolorfullv = hsl2rgb(vec3(texturecolorhsl.rg, 0.5));
|
||||
|
||||
vec3 envyuv = rgb2yuv(envcolor);
|
||||
texturecolor = mix(texturecolor, texturecolorfullv, envyuv.r * reflectivity);
|
||||
|
||||
if(lights_count == 0U)
|
||||
return (fragcolor + emissioncolor + envcolor * reflectivity) * texturecolor;
|
||||
|
||||
vec2 sunlight = calc_dir_light(lights[0], fragnormal);
|
||||
|
||||
float diffuseamount = (sunlight.x * param[1].x) * lights[0].intensity;
|
||||
fragcolor += envcolor * reflectivity;
|
||||
float specularamount = (sunlight.y * param[1].y * specularity) * lights[0].intensity;
|
||||
glossiness = abs(param[1].w);
|
||||
|
||||
for (uint i = 1U; i < lights_count; i++)
|
||||
{
|
||||
light_s light = lights[i];
|
||||
vec2 part = vec2(0.0);
|
||||
|
||||
// if (light.type == LIGHT_SPOT)
|
||||
// part = calc_spot_light(light, fragnormal);
|
||||
// else if (light.type == LIGHT_POINT)
|
||||
// part = calc_point_light(light, fragnormal);
|
||||
// else if (light.type == LIGHT_DIR)
|
||||
// part = calc_dir_light(light, fragnormal);
|
||||
// else if (light.type == LIGHT_HEADLIGHTS)
|
||||
part = calc_headlights(light, fragnormal);
|
||||
|
||||
fragcolor += light.color * (part.x * param[1].x + part.y * param[1].y) * light.intensity;
|
||||
}
|
||||
|
||||
if (shadowtone < 1.0)
|
||||
{
|
||||
float shadow = calc_shadow();
|
||||
specularamount *= clamp(1.0 - shadow, 0.0, 1.0);
|
||||
fragcolor = mix(fragcolor, fragcolor * shadowtone, clamp(diffuseamount * shadow + specularamount, 0.0, 1.0));
|
||||
}
|
||||
fragcolor += emissioncolor;
|
||||
fragcolor *= texturecolor;
|
||||
|
||||
return fragcolor;
|
||||
}
|
||||
|
||||
void main()
|
||||
{
|
||||
vec4 tex_color = texture(diffuse, f_coord);
|
||||
|
||||
bool alphatestfail = ( opacity >= 0.0 ? (tex_color.a < opacity) : (tex_color.a >= -opacity) );
|
||||
if(alphatestfail)
|
||||
discard;
|
||||
// if (tex_color.a < opacity)
|
||||
// discard;
|
||||
|
||||
vec3 fragcolor = ambient;
|
||||
|
||||
vec3 normal;
|
||||
normal.xy = (texture(normalmap, f_coord).rg * 2.0 - 1.0);
|
||||
normal.z = sqrt(1.0 - clamp((dot(normal.xy, normal.xy)), 0.0, 1.0));
|
||||
vec3 fragnormal = normalize(f_tbn * normalize(normal.xyz));
|
||||
float reflectivity = param[1].z * texture(normalmap, f_coord).a;
|
||||
float specularity = (tex_color.r + tex_color.g + tex_color.b) * 0.5;
|
||||
|
||||
fragcolor = apply_lights_sunless(fragcolor, fragnormal, tex_color.rgb, reflectivity, specularity, shadow_tone);
|
||||
vec4 color = vec4(apply_fog(fragcolor), tex_color.a * alpha_mult);
|
||||
#if POSTFX_ENABLED
|
||||
out_color = color;
|
||||
#else
|
||||
out_color = tonemap(color);
|
||||
#endif
|
||||
#if MOTIONBLUR_ENABLED
|
||||
{
|
||||
vec2 a = (f_clip_future_pos.xy / f_clip_future_pos.w) * 0.5 + 0.5;;
|
||||
vec2 b = (f_clip_pos.xy / f_clip_pos.w) * 0.5 + 0.5;;
|
||||
|
||||
out_motion = vec4(a - b, 0.0f, 0.0f);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
130
shaders/mat_sunlessnormalmap_specgloss.frag
Normal file
130
shaders/mat_sunlessnormalmap_specgloss.frag
Normal file
@@ -0,0 +1,130 @@
|
||||
in vec3 f_normal;
|
||||
in vec2 f_coord;
|
||||
in vec4 f_pos;
|
||||
in mat3 f_tbn;
|
||||
|
||||
in vec4 f_clip_pos;
|
||||
in vec4 f_clip_future_pos;
|
||||
|
||||
#include <common>
|
||||
|
||||
layout(location = 0) out vec4 out_color;
|
||||
#if MOTIONBLUR_ENABLED
|
||||
layout(location = 1) out vec4 out_motion;
|
||||
#endif
|
||||
|
||||
#param (color, 0, 0, 4, diffuse)
|
||||
#param (diffuse, 1, 0, 1, diffuse)
|
||||
#param (specular, 1, 1, 1, specular)
|
||||
#param (reflection, 1, 2, 1, zero)
|
||||
#param (glossiness, 1, 3, 1, glossiness)
|
||||
|
||||
#texture (diffuse, 0, sRGB_A)
|
||||
uniform sampler2D diffuse;
|
||||
|
||||
#texture (normalmap, 1, RGBA)
|
||||
uniform sampler2D normalmap;
|
||||
|
||||
#texture (specgloss, 2, RGBA)
|
||||
uniform sampler2D specgloss;
|
||||
|
||||
|
||||
#define NORMALMAP
|
||||
#include <light_common.glsl>
|
||||
#include <apply_fog.glsl>
|
||||
#include <tonemapping.glsl>
|
||||
|
||||
vec3 apply_lights_sunless(vec3 fragcolor, vec3 fragnormal, vec3 texturecolor, float reflectivity, float specularity, float shadowtone)
|
||||
{
|
||||
vec3 basecolor = param[0].rgb;
|
||||
|
||||
fragcolor *= basecolor;
|
||||
|
||||
vec3 emissioncolor = basecolor * emission;
|
||||
vec3 envcolor = envmap_color(fragnormal);
|
||||
|
||||
// yuv path
|
||||
vec3 texturecoloryuv = rgb2yuv(texturecolor);
|
||||
vec3 texturecolorfullv = yuv2rgb(vec3(0.2176, texturecoloryuv.gb));
|
||||
// hsl path
|
||||
// vec3 texturecolorhsl = rgb2hsl(texturecolor);
|
||||
// vec3 texturecolorfullv = hsl2rgb(vec3(texturecolorhsl.rg, 0.5));
|
||||
|
||||
vec3 envyuv = rgb2yuv(envcolor);
|
||||
texturecolor = mix(texturecolor, texturecolorfullv, envyuv.r * reflectivity);
|
||||
|
||||
if(lights_count == 0U)
|
||||
return (fragcolor + emissioncolor + envcolor * reflectivity) * texturecolor;
|
||||
|
||||
vec2 sunlight = calc_dir_light(lights[0], fragnormal);
|
||||
|
||||
float diffuseamount = (sunlight.x * param[1].x) * lights[0].intensity;
|
||||
fragcolor += envcolor * reflectivity;
|
||||
float specularamount = (sunlight.y * param[1].y * specularity) * lights[0].intensity;
|
||||
|
||||
for (uint i = 1U; i < lights_count; i++)
|
||||
{
|
||||
light_s light = lights[i];
|
||||
vec2 part = vec2(0.0);
|
||||
|
||||
// if (light.type == LIGHT_SPOT)
|
||||
// part = calc_spot_light(light, fragnormal);
|
||||
// else if (light.type == LIGHT_POINT)
|
||||
// part = calc_point_light(light, fragnormal);
|
||||
// else if (light.type == LIGHT_DIR)
|
||||
// part = calc_dir_light(light, fragnormal);
|
||||
// else if (light.type == LIGHT_HEADLIGHTS)
|
||||
part = calc_headlights(light, fragnormal);
|
||||
|
||||
fragcolor += light.color * (part.x * param[1].x + part.y * param[1].y) * light.intensity;
|
||||
}
|
||||
|
||||
if (shadowtone < 1.0)
|
||||
{
|
||||
float shadow = calc_shadow();
|
||||
specularamount *= clamp(1.0 - shadow, 0.0, 1.0);
|
||||
fragcolor = mix(fragcolor, fragcolor * shadowtone, clamp(diffuseamount * shadow + specularamount, 0.0, 1.0));
|
||||
}
|
||||
fragcolor += emissioncolor;
|
||||
fragcolor *= texturecolor;
|
||||
|
||||
return fragcolor;
|
||||
}
|
||||
|
||||
void main()
|
||||
{
|
||||
vec4 tex_color = texture(diffuse, f_coord);
|
||||
|
||||
bool alphatestfail = ( opacity >= 0.0 ? (tex_color.a < opacity) : (tex_color.a >= -opacity) );
|
||||
if(alphatestfail)
|
||||
discard;
|
||||
// if (tex_color.a < opacity)
|
||||
// discard;
|
||||
|
||||
vec3 fragcolor = ambient;
|
||||
|
||||
vec3 normal;
|
||||
normal.xy = (texture(normalmap, f_coord).rg * 2.0 - 1.0);
|
||||
normal.z = sqrt(1.0 - clamp((dot(normal.xy, normal.xy)), 0.0, 1.0));
|
||||
vec3 fragnormal = normalize(f_tbn * normalize(normal.xyz));
|
||||
float reflectivity = param[1].z * texture(normalmap, f_coord).a;
|
||||
float specularity = texture(specgloss, f_coord).r;
|
||||
glossiness = texture(specgloss, f_coord).g * abs(param[1].w);
|
||||
metalic = (texture(specgloss, f_coord).b > 0.5) ? true : false;
|
||||
|
||||
fragcolor = apply_lights_sunless(fragcolor, fragnormal, tex_color.rgb, reflectivity, specularity, shadow_tone);
|
||||
vec4 color = vec4(apply_fog(fragcolor), tex_color.a * alpha_mult);
|
||||
#if POSTFX_ENABLED
|
||||
out_color = color;
|
||||
#else
|
||||
out_color = tonemap(color);
|
||||
#endif
|
||||
#if MOTIONBLUR_ENABLED
|
||||
{
|
||||
vec2 a = (f_clip_future_pos.xy / f_clip_future_pos.w) * 0.5 + 0.5;;
|
||||
vec2 b = (f_clip_pos.xy / f_clip_pos.w) * 0.5 + 0.5;;
|
||||
|
||||
out_motion = vec4(a - b, 0.0f, 0.0f);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
@@ -2,7 +2,6 @@ in vec3 f_normal;
|
||||
in vec2 f_coord;
|
||||
in vec4 f_pos;
|
||||
in mat3 f_tbn;
|
||||
in vec4 f_light_pos;
|
||||
|
||||
in vec4 f_clip_pos;
|
||||
in vec4 f_clip_future_pos;
|
||||
@@ -18,6 +17,7 @@ layout(location = 1) out vec4 out_motion;
|
||||
#param (diffuse, 1, 0, 1, diffuse)
|
||||
#param (specular, 1, 1, 1, specular)
|
||||
#param (reflection, 1, 2, 1, one)
|
||||
#param (glossiness, 1, 3, 1, glossiness)
|
||||
#param (wave_strength, 2, 1, 1, one)
|
||||
#param (wave_speed, 2, 2, 1, one)
|
||||
|
||||
@@ -30,24 +30,17 @@ uniform sampler2D dudvmap;
|
||||
#texture (diffuse, 2, sRGB_A)
|
||||
uniform sampler2D diffuse;
|
||||
|
||||
#if SHADOWMAP_ENABLED
|
||||
uniform sampler2DShadow shadowmap;
|
||||
#endif
|
||||
#if ENVMAP_ENABLED
|
||||
uniform samplerCube envmap;
|
||||
#endif
|
||||
|
||||
//wave distortion variables
|
||||
float move_factor = 0.0;
|
||||
vec3 normal_d;
|
||||
|
||||
#define WATER
|
||||
#include <light_common.glsl>
|
||||
#include <apply_fog.glsl>
|
||||
#include <tonemapping.glsl>
|
||||
|
||||
void main()
|
||||
{
|
||||
//wave distortion
|
||||
//wave distortion
|
||||
move_factor += (param[2].z * time);
|
||||
move_factor = mod(move_factor, 1.0);
|
||||
vec2 texture_coords = f_coord;
|
||||
@@ -56,51 +49,31 @@ void main()
|
||||
vec2 total_distorted_tex_coord = (texture(dudvmap, distorted_tex_coord).rg * 2.0 - 1.0 ) * param[2].y;
|
||||
texture_coords += total_distorted_tex_coord;
|
||||
|
||||
vec4 tex_color = texture(diffuse, texture_coords);
|
||||
|
||||
vec3 fragcolor = ambient * 0.25;
|
||||
|
||||
vec3 normal;
|
||||
normal.xy = (texture(normalmap, texture_coords).rg * 2.0 - 1.0);
|
||||
normal.z = sqrt(1.0 - clamp((dot(normal.xy, normal.xy)), 0.0, 1.0));
|
||||
normal_d = normalize(f_tbn * normalize(normal.xyz));
|
||||
vec3 refvec = reflect(f_pos.xyz, normal_d);
|
||||
#if ENVMAP_ENABLED
|
||||
vec3 envcolor = texture(envmap, refvec).rgb;
|
||||
#else
|
||||
vec3 envcolor = vec3(0.5);
|
||||
#endif
|
||||
vec4 tex_color = texture(diffuse, texture_coords);
|
||||
//Fresnel effect
|
||||
vec3 fragnormal = normalize(f_tbn * normalize(normal.xyz));
|
||||
float reflectivity = param[1].z * texture(normalmap, texture_coords ).a;
|
||||
float specularity = 1.0;
|
||||
glossiness = abs(param[1].w);
|
||||
|
||||
fragcolor = apply_lights(fragcolor, fragnormal, tex_color.rgb, reflectivity, specularity, shadow_tone);
|
||||
|
||||
//fragcolor = mix(fragcolor, param[0].rgb, param[1].z);
|
||||
// fragcolor = (fragcolor * tex_color.rgb * param[1].z) + (fragcolor * (1.0 - param[1].z)); //multiply
|
||||
//fragcolor = ( max(fragcolor + param[0].rgb -1.0,0.0) * param[1].z + fragcolor * (1.0 - param[1].z)); //linear burn
|
||||
//fragcolor = ( min(param[0].rgb,fragcolor) * param[1].z + fragcolor * (1.0 - param[1].z)); //darken
|
||||
|
||||
// fresnel effect
|
||||
vec3 view_dir = normalize(vec3(0.0f, 0.0f, 0.0f) - f_pos.xyz);
|
||||
float fresnel = pow ( dot (f_normal, view_dir), 0.2 );
|
||||
float fresnel_inv = ((fresnel - 1.0 ) * -1.0 );
|
||||
|
||||
vec3 result = ambient * 0.5 + param[0].rgb * emission;
|
||||
|
||||
if (lights_count > 0U)
|
||||
{
|
||||
vec2 part = calc_dir_light(lights[0]);
|
||||
vec3 c = (part.x * param[1].x + part.y * param[1].y) * calc_shadow() * lights[0].color;
|
||||
result += mix(c, envcolor, param[1].z * texture(normalmap, texture_coords ).a);
|
||||
}
|
||||
//result = mix(result, param[0].rgb, param[1].z);
|
||||
result = (result * tex_color.rgb * param[1].z) + (result * (1.0 - param[1].z)); //multiply
|
||||
//result = ( max(result + param[0].rgb -1.0,0.0) * param[1].z + result * (1.0 - param[1].z)); //linear burn
|
||||
//result = ( min(param[0].rgb,result) * param[1].z + result * (1.0 - param[1].z)); //darken
|
||||
|
||||
for (uint i = 1U; i < lights_count; i++)
|
||||
{
|
||||
light_s light = lights[i];
|
||||
vec2 part = vec2(0.0);
|
||||
|
||||
if (light.type == LIGHT_SPOT)
|
||||
part = calc_spot_light(light);
|
||||
else if (light.type == LIGHT_POINT)
|
||||
part = calc_point_light(light);
|
||||
else if (light.type == LIGHT_DIR)
|
||||
part = calc_dir_light(light);
|
||||
result += light.color * (part.x * param[1].x + part.y * param[1].y);
|
||||
}
|
||||
|
||||
vec4 color = vec4(apply_fog(clamp(result,0.0,1.0)), clamp((fresnel_inv + param[0].a),0.0,1.0));
|
||||
|
||||
vec4 color = vec4(apply_fog(clamp(fragcolor, 0.0, 1.0)), clamp((fresnel_inv + param[0].a), 0.0, 1.0));
|
||||
#if POSTFX_ENABLED
|
||||
out_color = color;
|
||||
#else
|
||||
|
||||
95
shaders/mat_water_specgloss.frag
Normal file
95
shaders/mat_water_specgloss.frag
Normal file
@@ -0,0 +1,95 @@
|
||||
in vec3 f_normal;
|
||||
in vec2 f_coord;
|
||||
in vec4 f_pos;
|
||||
in mat3 f_tbn;
|
||||
|
||||
in vec4 f_clip_pos;
|
||||
in vec4 f_clip_future_pos;
|
||||
|
||||
#include <common>
|
||||
|
||||
layout(location = 0) out vec4 out_color;
|
||||
#if MOTIONBLUR_ENABLED
|
||||
layout(location = 1) out vec4 out_motion;
|
||||
#endif
|
||||
|
||||
#param (color, 0, 0, 4, diffuse)
|
||||
#param (diffuse, 1, 0, 1, diffuse)
|
||||
#param (specular, 1, 1, 1, specular)
|
||||
#param (reflection, 1, 2, 1, one)
|
||||
#param (glossiness, 1, 3, 1, glossiness)
|
||||
#param (wave_strength, 2, 1, 1, one)
|
||||
#param (wave_speed, 2, 2, 1, one)
|
||||
|
||||
#texture (normalmap, 0, RGBA)
|
||||
uniform sampler2D normalmap;
|
||||
|
||||
#texture (dudvmap, 1, RGB)
|
||||
uniform sampler2D dudvmap;
|
||||
|
||||
#texture (diffuse, 2, sRGB_A)
|
||||
uniform sampler2D diffuse;
|
||||
|
||||
#texture (specgloss, 3, RGBA)
|
||||
uniform sampler2D specgloss;
|
||||
|
||||
|
||||
//wave distortion variables
|
||||
float move_factor = 0.0;
|
||||
|
||||
#define WATER
|
||||
#include <light_common.glsl>
|
||||
#include <apply_fog.glsl>
|
||||
#include <tonemapping.glsl>
|
||||
|
||||
void main()
|
||||
{
|
||||
//wave distortion
|
||||
move_factor += (param[2].z * time);
|
||||
move_factor = mod(move_factor, 1.0);
|
||||
vec2 texture_coords = f_coord;
|
||||
vec2 distorted_tex_coord = texture(dudvmap, vec2(texture_coords.x + move_factor, texture_coords.y)).rg * 0.1;
|
||||
distorted_tex_coord = texture_coords + vec2(distorted_tex_coord.x , distorted_tex_coord.y + move_factor);
|
||||
vec2 total_distorted_tex_coord = (texture(dudvmap, distorted_tex_coord).rg * 2.0 - 1.0 ) * param[2].y;
|
||||
texture_coords += total_distorted_tex_coord;
|
||||
|
||||
vec4 tex_color = texture(diffuse, texture_coords);
|
||||
|
||||
vec3 fragcolor = ambient * 0.25;
|
||||
|
||||
vec3 normal;
|
||||
normal.xy = (texture(normalmap, texture_coords).rg * 2.0 - 1.0);
|
||||
normal.z = sqrt(1.0 - clamp((dot(normal.xy, normal.xy)), 0.0, 1.0));
|
||||
vec3 fragnormal = normalize(f_tbn * normalize(normal.xyz));
|
||||
float reflectivity = param[1].z * texture(normalmap, texture_coords ).a;
|
||||
float specularity = texture(specgloss, f_coord).r;
|
||||
glossiness = texture(specgloss, f_coord).g * abs(param[1].w);
|
||||
metalic = (texture(specgloss, f_coord).b > 0.5) ? true : false;
|
||||
|
||||
fragcolor = apply_lights(fragcolor, fragnormal, tex_color.rgb, reflectivity, specularity, shadow_tone);
|
||||
|
||||
//fragcolor = mix(fragcolor, param[0].rgb, param[1].z);
|
||||
// fragcolor = (fragcolor * tex_color.rgb * param[1].z) + (fragcolor * (1.0 - param[1].z)); //multiply
|
||||
//fragcolor = ( max(fragcolor + param[0].rgb -1.0,0.0) * param[1].z + fragcolor * (1.0 - param[1].z)); //linear burn
|
||||
//fragcolor = ( min(param[0].rgb,fragcolor) * param[1].z + fragcolor * (1.0 - param[1].z)); //darken
|
||||
|
||||
// fresnel effect
|
||||
vec3 view_dir = normalize(vec3(0.0f, 0.0f, 0.0f) - f_pos.xyz);
|
||||
float fresnel = pow ( dot (f_normal, view_dir), 0.2 );
|
||||
float fresnel_inv = ((fresnel - 1.0 ) * -1.0 );
|
||||
|
||||
vec4 color = vec4(apply_fog(clamp(fragcolor, 0.0, 1.0)), clamp((fresnel_inv + param[0].a), 0.0, 1.0));
|
||||
#if POSTFX_ENABLED
|
||||
out_color = color;
|
||||
#else
|
||||
out_color = tonemap(color);
|
||||
#endif
|
||||
#if MOTIONBLUR_ENABLED
|
||||
{
|
||||
vec2 a = (f_clip_future_pos.xy / f_clip_future_pos.w) * 0.5 + 0.5;;
|
||||
vec2 b = (f_clip_pos.xy / f_clip_pos.w) * 0.5 + 0.5;;
|
||||
|
||||
out_motion = vec4(a - b, 0.0f, 0.0f);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
21
shaders/postfx_chromaticaberration.frag
Normal file
21
shaders/postfx_chromaticaberration.frag
Normal file
@@ -0,0 +1,21 @@
|
||||
in vec2 f_coords;
|
||||
|
||||
layout(location = 0) out vec4 out_color;
|
||||
|
||||
#texture (color_tex, 0, RGB)
|
||||
uniform sampler2D iChannel0;
|
||||
|
||||
void main()
|
||||
{
|
||||
float amount = 0.001;
|
||||
|
||||
vec2 uv = f_coords;
|
||||
vec3 col;
|
||||
col.r = texture( iChannel0, vec2(uv.x+amount,uv.y) ).r;
|
||||
col.g = texture( iChannel0, uv ).g;
|
||||
col.b = texture( iChannel0, vec2(uv.x-amount,uv.y) ).b;
|
||||
|
||||
col *= (1.0 - amount * 0.5);
|
||||
|
||||
out_color = vec4(col,1.0);
|
||||
}
|
||||
@@ -11,6 +11,5 @@ void main()
|
||||
{
|
||||
vec2 texcoord = f_coords;
|
||||
vec3 hdr_color = texture(tex1, texcoord).xyz;
|
||||
|
||||
out_color = tonemap(vec4(hdr_color, 1.0));
|
||||
}
|
||||
|
||||
@@ -21,4 +21,3 @@ void main()
|
||||
gl_Position = vec4(vert[gl_VertexID], 0.0, 1.0);
|
||||
f_coords = uv[gl_VertexID];
|
||||
}
|
||||
|
||||
|
||||
@@ -1,6 +1,15 @@
|
||||
const float pureWhite = 1.0;
|
||||
|
||||
vec3 reinhard(vec3 x)
|
||||
{
|
||||
return x / (x + vec3(1.0));
|
||||
// return x / (x + vec3(1.0));
|
||||
|
||||
// Reinhard tonemapping operator.
|
||||
// see: "Photographic Tone Reproduction for Digital Images", eq. 4
|
||||
float luminance = dot(x, vec3(0.2126, 0.7152, 0.0722));
|
||||
float mappedLuminance = (luminance * (1.0 + luminance/(pureWhite*pureWhite))) / (1.0 + luminance);
|
||||
// Scale color by ratio of average luminances.
|
||||
return (mappedLuminance / luminance) * x;
|
||||
}
|
||||
|
||||
// https://knarkowicz.wordpress.com/2016/01/06/aces-filmic-tone-mapping-curve/
|
||||
@@ -33,5 +42,6 @@ vec3 filmic(vec3 x)
|
||||
|
||||
vec4 tonemap(vec4 x)
|
||||
{
|
||||
return FBOUT(vec4(ACESFilm(x.rgb), x.a));
|
||||
// return FBOUT(vec4(ACESFilm(x.rgb), x.a));
|
||||
return FBOUT(vec4(reinhard(x.rgb), x.a));
|
||||
}
|
||||
|
||||
@@ -2,11 +2,16 @@ layout(location = 0) in vec3 v_vert;
|
||||
layout(location = 1) in vec3 v_color;
|
||||
|
||||
out vec3 f_color;
|
||||
out vec4 f_pos;
|
||||
out vec4 f_clip_pos;
|
||||
|
||||
#include <common>
|
||||
|
||||
void main()
|
||||
{
|
||||
gl_Position = projection * modelview * vec4(v_vert, 1.0f);
|
||||
f_color = v_color;
|
||||
f_pos = modelview * vec4(v_vert, 1.0);
|
||||
f_clip_pos = (projection * modelview) * vec4(v_vert, 1.0);
|
||||
f_color = pow(v_color, vec3(1.0));
|
||||
|
||||
gl_Position = f_clip_pos;
|
||||
}
|
||||
|
||||
@@ -3,13 +3,14 @@ layout(location = 1) in vec3 v_normal;
|
||||
layout(location = 2) in vec2 v_coord;
|
||||
layout(location = 3) in vec4 v_tangent;
|
||||
|
||||
#include <common>
|
||||
|
||||
out vec3 f_normal;
|
||||
flat out vec3 f_normal_raw;
|
||||
out vec2 f_coord;
|
||||
out vec4 f_pos;
|
||||
out mat3 f_tbn;
|
||||
//out vec4 f_tangent;
|
||||
out vec4 f_light_pos;
|
||||
out vec4 f_light_pos[MAX_CASCADES];
|
||||
|
||||
out vec4 f_clip_pos;
|
||||
out vec4 f_clip_future_pos;
|
||||
@@ -18,19 +19,17 @@ out vec4 f_clip_future_pos;
|
||||
//out vec3 TangentViewPos;
|
||||
out vec3 TangentFragPos;
|
||||
|
||||
#include <common>
|
||||
|
||||
void main()
|
||||
{
|
||||
f_normal = normalize(modelviewnormal * v_normal);
|
||||
f_normal_raw = v_normal;
|
||||
f_coord = v_coord;
|
||||
// f_tangent = v_tangent;
|
||||
f_pos = modelview * vec4(v_vert, 1.0f);
|
||||
f_light_pos = lightview * f_pos;
|
||||
|
||||
f_clip_pos = (projection * modelview) * vec4(v_vert, 1.0f);
|
||||
f_clip_future_pos = (projection * future * modelview) * vec4(v_vert, 1.0f);
|
||||
f_pos = modelview * vec4(v_vert, 1.0);
|
||||
for (uint idx = 0U ; idx < MAX_CASCADES ; ++idx) {
|
||||
f_light_pos[idx] = lightview[idx] * f_pos;
|
||||
}
|
||||
f_clip_pos = (projection * modelview) * vec4(v_vert, 1.0);
|
||||
f_clip_future_pos = (projection * future * modelview) * vec4(v_vert, 1.0);
|
||||
|
||||
gl_Position = f_clip_pos;
|
||||
gl_PointSize = param[1].x;
|
||||
@@ -42,6 +41,6 @@ void main()
|
||||
|
||||
mat3 TBN = transpose(f_tbn);
|
||||
// TangentLightPos = TBN * f_light_pos.xyz;
|
||||
// TangentViewPos = TBN * vec3(0.0f, 0.0f, 0.0f);
|
||||
// TangentViewPos = TBN * vec3(0.0, 0.0, 0.0);
|
||||
TangentFragPos = TBN * f_pos.xyz;
|
||||
}
|
||||
|
||||
@@ -4,5 +4,5 @@ layout(location = 0) in vec3 v_vert;
|
||||
|
||||
void main()
|
||||
{
|
||||
gl_Position = (projection * modelview) * vec4(v_vert, 1.0f);
|
||||
gl_Position = (projection * modelview) * vec4(v_vert, 1.0);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user