Remove all unused shaders
This commit is contained in:
parent
b1f1afb9c5
commit
68e8da2353
@ -1,142 +0,0 @@
|
||||
uniform sampler2D depth;
|
||||
uniform float split0;
|
||||
uniform float split1;
|
||||
uniform float split2;
|
||||
uniform float splitmax;
|
||||
uniform mat4 SunCamMatrix;
|
||||
|
||||
layout (local_size_x = 8, local_size_y = 8) in;
|
||||
|
||||
struct CascadeBoundingBox
|
||||
{
|
||||
int xmin;
|
||||
int xmax;
|
||||
int ymin;
|
||||
int ymax;
|
||||
int zmin;
|
||||
int zmax;
|
||||
};
|
||||
|
||||
layout (std430) buffer BoundingBoxes
|
||||
{
|
||||
CascadeBoundingBox BB[4];
|
||||
};
|
||||
|
||||
#stk_include "utils/getPosFromUVDepth.frag"
|
||||
|
||||
shared int xmin[4];
|
||||
shared int xmax[4];
|
||||
shared int ymin[4];
|
||||
shared int ymax[4];
|
||||
shared int zmin[4];
|
||||
shared int zmax[4];
|
||||
|
||||
void main()
|
||||
{
|
||||
if (gl_LocalInvocationIndex < 4) {
|
||||
xmin[gl_LocalInvocationIndex] = ymin[gl_LocalInvocationIndex] = zmin[gl_LocalInvocationIndex] = 1000;
|
||||
xmax[gl_LocalInvocationIndex] = ymax[gl_LocalInvocationIndex] = zmax[gl_LocalInvocationIndex] = -1000;
|
||||
}
|
||||
|
||||
barrier();
|
||||
|
||||
ivec3 lmax0 = ivec3(-1000);
|
||||
ivec3 lmin0 = ivec3(1000);
|
||||
ivec3 lmax1 = ivec3(-1000);
|
||||
ivec3 lmin1 = ivec3(1000);
|
||||
ivec3 lmax2 = ivec3(-1000);
|
||||
ivec3 lmin2 = ivec3(1000);
|
||||
ivec3 lmax3 = ivec3(-1000);
|
||||
ivec3 lmin3 = ivec3(1000);
|
||||
|
||||
vec2 start_xy = gl_LocalInvocationID.xy + gl_WorkGroupID.xy * gl_WorkGroupSize.xy * 8;
|
||||
for (int i = 0; i < 8; i++) {
|
||||
for (int j = 0; j < 8; j++) {
|
||||
|
||||
|
||||
vec2 uv = (start_xy + vec2(i, j) * gl_WorkGroupID.xy) / u_screen;
|
||||
float z = texture(depth, uv).x;
|
||||
vec4 xpos = getPosFromUVDepth(vec3(uv, z), u_inverse_projection_matrix);
|
||||
vec4 lightcoord = u_inverse_view_matrix * xpos;
|
||||
lightcoord /= lightcoord.w;
|
||||
lightcoord = SunCamMatrix * lightcoord;
|
||||
lightcoord /= lightcoord.w;
|
||||
ivec3 lc = ivec3(lightcoord.xyz) * 4;
|
||||
|
||||
if (xpos.z < split0) {
|
||||
lmax0 = max(lmax0, lc);
|
||||
lmin0 = min(lmin0, lc);
|
||||
} else if (xpos.z < split1) {
|
||||
lmax1 = max(lmax1, lc);
|
||||
lmin1 = min(lmin1, lc);
|
||||
} else if (xpos.z < split2) {
|
||||
lmax2 = max(lmax2, lc);
|
||||
lmin2 = min(lmin2, lc);
|
||||
} else if (xpos.z < splitmax) {
|
||||
lmax3 = max(lmax3, lc);
|
||||
lmin3 = min(lmin3, lc);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
atomicMax(xmax[0], lmax0.x);
|
||||
atomicMax(ymax[0], lmax0.y);
|
||||
atomicMax(zmax[0], lmax0.z);
|
||||
atomicMin(xmin[0], lmin0.x);
|
||||
atomicMin(ymin[0], lmin0.y);
|
||||
atomicMin(zmin[0], lmin0.z);
|
||||
|
||||
atomicMax(xmax[1], lmax1.x);
|
||||
atomicMax(ymax[1], lmax1.y);
|
||||
atomicMax(zmax[1], lmax1.z);
|
||||
atomicMin(xmin[1], lmin1.x);
|
||||
atomicMin(ymin[1], lmin1.y);
|
||||
atomicMin(zmin[1], lmin1.z);
|
||||
|
||||
atomicMax(xmax[2], lmax2.x);
|
||||
atomicMax(ymax[2], lmax2.y);
|
||||
atomicMax(zmax[2], lmax2.z);
|
||||
atomicMin(xmin[2], lmin2.x);
|
||||
atomicMin(ymin[2], lmin2.y);
|
||||
atomicMin(zmin[2], lmin2.z);
|
||||
|
||||
atomicMax(xmax[3], lmax3.x);
|
||||
atomicMax(ymax[3], lmax3.y);
|
||||
atomicMax(zmax[3], lmax3.z);
|
||||
atomicMin(xmin[3], lmin3.x);
|
||||
atomicMin(ymin[3], lmin3.y);
|
||||
atomicMin(zmin[3], lmin3.z);
|
||||
|
||||
barrier();
|
||||
|
||||
if (gl_LocalInvocationIndex == 0) {
|
||||
atomicMax(BB[0].xmax, xmax[0]);
|
||||
atomicMax(BB[0].ymax, ymax[0]);
|
||||
atomicMax(BB[0].zmax, zmax[0]);
|
||||
atomicMin(BB[0].xmin, xmin[0]);
|
||||
atomicMin(BB[0].ymin, ymin[0]);
|
||||
atomicMin(BB[0].zmin, zmin[0]);
|
||||
|
||||
atomicMax(BB[1].xmax, xmax[1]);
|
||||
atomicMax(BB[1].ymax, ymax[1]);
|
||||
atomicMax(BB[1].zmax, zmax[1]);
|
||||
atomicMin(BB[1].xmin, xmin[1]);
|
||||
atomicMin(BB[1].ymin, ymin[1]);
|
||||
atomicMin(BB[1].zmin, zmin[1]);
|
||||
|
||||
atomicMax(BB[2].xmax, xmax[2]);
|
||||
atomicMax(BB[2].ymax, ymax[2]);
|
||||
atomicMax(BB[2].zmax, zmax[2]);
|
||||
atomicMin(BB[2].xmin, xmin[2]);
|
||||
atomicMin(BB[2].ymin, ymin[2]);
|
||||
atomicMin(BB[2].zmin, zmin[2]);
|
||||
|
||||
atomicMax(BB[3].xmax, xmax[3]);
|
||||
atomicMax(BB[3].ymax, ymax[3]);
|
||||
atomicMax(BB[3].zmax, zmax[3]);
|
||||
atomicMin(BB[3].xmin, xmin[3]);
|
||||
atomicMin(BB[3].ymin, ymin[3]);
|
||||
atomicMin(BB[3].zmin, zmin[3]);
|
||||
}
|
||||
}
|
||||
|
@ -1,30 +0,0 @@
|
||||
#ifdef Use_Bindless_Texture
|
||||
layout(bindless_sampler) uniform sampler2D Albedo;
|
||||
layout(bindless_sampler) uniform sampler2D Detail;
|
||||
layout(bindless_sampler) uniform sampler2D SpecMap;
|
||||
#else
|
||||
uniform sampler2D Albedo;
|
||||
uniform sampler2D Detail;
|
||||
uniform sampler2D SpecMap;
|
||||
#endif
|
||||
|
||||
in vec2 uv;
|
||||
in vec2 uv_bis;
|
||||
out vec4 FragColor;
|
||||
|
||||
#stk_include "utils/getLightFactor.frag"
|
||||
|
||||
void main(void)
|
||||
{
|
||||
vec4 color = texture(Albedo, uv);
|
||||
#ifdef Use_Bindless_Texture
|
||||
#ifdef SRGBBindlessFix
|
||||
color.xyz = pow(color.xyz, vec3(2.2));
|
||||
#endif
|
||||
#endif
|
||||
vec4 detail = texture(Detail, uv_bis);
|
||||
detail.rgb = detail.a * detail.rgb;
|
||||
color.rgb = detail.rgb + color.rgb * (1. - detail.a);
|
||||
float specmap = texture(SpecMap, uv).g;
|
||||
FragColor = vec4(getLightFactor(color.xyz, vec3(1.), specmap, 0.), 1.);
|
||||
}
|
@ -1,46 +0,0 @@
|
||||
uniform sampler2D displacement_tex;
|
||||
uniform sampler2D mask_tex;
|
||||
uniform sampler2D color_tex;
|
||||
uniform sampler2D tex;
|
||||
uniform vec2 dir;
|
||||
uniform vec2 dir2;
|
||||
|
||||
in vec2 uv;
|
||||
in float camdist;
|
||||
|
||||
out vec4 FragColor;
|
||||
|
||||
const float maxlen = 0.02;
|
||||
|
||||
void main()
|
||||
{
|
||||
float horiz = texture(displacement_tex, uv + dir).x;
|
||||
float vert = texture(displacement_tex, (uv.yx + dir2) * vec2(0.9)).x;
|
||||
|
||||
vec2 offset = vec2(horiz, vert);
|
||||
offset *= 2.0;
|
||||
offset -= 1.0;
|
||||
|
||||
// Fade according to distance to cam
|
||||
float fade = 1.0 - smoothstep(1.0, 100.0, camdist);
|
||||
|
||||
vec4 shiftval;
|
||||
shiftval.r = step(offset.x, 0.0) * -offset.x;
|
||||
shiftval.g = step(0.0, offset.x) * offset.x;
|
||||
shiftval.b = step(offset.y, 0.0) * -offset.y;
|
||||
shiftval.a = step(0.0, offset.y) * offset.y;
|
||||
|
||||
vec2 shift;
|
||||
shift.x = -shiftval.x + shiftval.y;
|
||||
shift.y = -shiftval.z + shiftval.w;
|
||||
shift /= 50.;
|
||||
|
||||
vec2 tc = gl_FragCoord.xy / u_screen;
|
||||
float mask = texture(mask_tex, tc + shift).x;
|
||||
tc += (mask < 1.) ? vec2(0.) : shift;
|
||||
|
||||
vec4 col = texture(color_tex, tc);
|
||||
vec4 blend_tex = texture(tex, uv);
|
||||
col.rgb = blend_tex.rgb * blend_tex.a + (1. - blend_tex.a) * col.rgb;
|
||||
FragColor = vec4(col.rgb, 1.);
|
||||
}
|
@ -1,23 +0,0 @@
|
||||
uniform sampler2D tex;
|
||||
|
||||
uniform float density;
|
||||
uniform vec3 col;
|
||||
|
||||
out vec4 FragColor;
|
||||
|
||||
|
||||
#stk_include "utils/getPosFromUVDepth.frag"
|
||||
|
||||
void main()
|
||||
{
|
||||
vec2 uv = gl_FragCoord.xy / screen;
|
||||
float z = texture(tex, uv).x;
|
||||
vec4 xpos = getPosFromUVDepth(vec3(uv, z), InverseProjectionMatrix);
|
||||
|
||||
float dist = length(xpos.xyz);
|
||||
float factor = (1. - exp(- density * dist));
|
||||
vec3 fog = col * factor;
|
||||
|
||||
// fog is scattering component, factor is the beer lambert absorption
|
||||
FragColor = vec4(fog, factor);
|
||||
}
|
@ -1,89 +0,0 @@
|
||||
// From http://graphics.cs.aueb.gr/graphics/research_illumination.html
|
||||
// "Real-Time Diffuse Global Illumination Using Radiance Hints"
|
||||
// paper and shader code
|
||||
|
||||
uniform sampler2D ntex;
|
||||
uniform sampler2D dtex;
|
||||
|
||||
uniform sampler3D SHR;
|
||||
uniform sampler3D SHG;
|
||||
uniform sampler3D SHB;
|
||||
|
||||
uniform vec3 extents;
|
||||
uniform mat4 RHMatrix;
|
||||
uniform mat4 InvRHMatrix;
|
||||
|
||||
vec4 SHBasis (const in vec3 dir)
|
||||
{
|
||||
float L00 = 0.282095;
|
||||
float L1_1 = 0.488603 * dir.y;
|
||||
float L10 = 0.488603 * dir.z;
|
||||
float L11 = 0.488603 * dir.x;
|
||||
return vec4 (L11, L1_1, L10, L00);
|
||||
}
|
||||
|
||||
vec3 SH2RGB (in vec4 sh_r, in vec4 sh_g, in vec4 sh_b, in vec3 dir)
|
||||
{
|
||||
vec4 Y = vec4(1.023326*dir.x, 1.023326*dir.y, 1.023326*dir.z, 0.886226);
|
||||
return vec3 (dot(Y,sh_r), dot(Y,sh_g), dot(Y,sh_b));
|
||||
}
|
||||
|
||||
out vec4 Diffuse;
|
||||
|
||||
#stk_include "utils/decodeNormal.frag"
|
||||
#stk_include "utils/getPosFromUVDepth.frag"
|
||||
|
||||
vec3 resolution = vec3(32, 16, 32);
|
||||
|
||||
void main()
|
||||
{
|
||||
vec2 uv = gl_FragCoord.xy / u_screen;
|
||||
vec3 GI = vec3(0.);
|
||||
|
||||
float depth = texture2D(dtex, uv).x;
|
||||
// Discard background fragments
|
||||
if (depth==1.0) discard;
|
||||
|
||||
vec4 pos_screen_space = getPosFromUVDepth(vec3(uv, depth), u_inverse_projection_matrix);
|
||||
vec4 tmp = (InvRHMatrix * u_inverse_view_matrix * pos_screen_space);
|
||||
vec3 pos = tmp.xyz / tmp.w;
|
||||
vec3 normal_screen_space = normalize(DecodeNormal(2. * texture(ntex, uv).xy - 1.));
|
||||
vec3 normal = (transpose(u_view_matrix) * vec4(normal_screen_space, 0.)).xyz;
|
||||
|
||||
// Convert to grid coordinates
|
||||
vec3 uvw = .5 + 0.5 * pos / extents;
|
||||
if (uvw.x < 0. || uvw.x > 1. || uvw.y < 0. || uvw.y > 1. || uvw.z < 0. || uvw.z > 1.) discard;
|
||||
|
||||
// Sample the RH volume at 4 locations, one directly above the shaded point,
|
||||
// three on a ring 80degs away from the normal direction.
|
||||
vec3 rnd = vec3(0,0,0);
|
||||
|
||||
// Generate the sample locations
|
||||
vec3 v_rand = vec3(0.5);
|
||||
vec3 tangent = normalize(cross(normal, v_rand));
|
||||
vec3 bitangent = cross(normal, tangent);
|
||||
vec3 D[4];
|
||||
D[0] = vec3(1.0,0.0,0.0);
|
||||
int i;
|
||||
for (i=1; i<4; i++)
|
||||
{
|
||||
D[i] = vec3(0.1, 0.8*cos((rnd.x*1.5+i)*6.2832/3.0), 0.8*sin((rnd.x*1.5+i)*6.2832/3.0));
|
||||
D[i] = normalize(D[i]);
|
||||
}
|
||||
|
||||
for (i=0; i<4; i++)
|
||||
{
|
||||
vec3 SampleDir = normal * D[i].x + tangent * D[i].y + bitangent *D[i].z;
|
||||
vec3 SampleOffset = (0.5 * normal + SampleDir) / resolution;
|
||||
vec3 uvw_new = uvw + SampleOffset;
|
||||
|
||||
vec4 IncidentSHR = texture(SHR, uvw_new);
|
||||
vec4 IncidentSHG = texture(SHG, uvw_new);
|
||||
vec4 IncidentSHB = texture(SHB, uvw_new);
|
||||
|
||||
GI += SH2RGB(IncidentSHR, IncidentSHG, IncidentSHB, -normal);
|
||||
}
|
||||
GI /= 4;
|
||||
|
||||
Diffuse = max(16. * vec4(GI, 1.), vec4(0.));
|
||||
}
|
@ -1,24 +0,0 @@
|
||||
#ifdef Explicit_Attrib_Location_Usable
|
||||
layout(location = 0) in vec3 Position;
|
||||
layout(location = 7) in vec3 Origin;
|
||||
layout(location = 8) in vec3 Orientation;
|
||||
layout(location = 9) in vec3 Scale;
|
||||
layout(location = 10) in vec4 misc_data;
|
||||
#else
|
||||
in vec3 Position;
|
||||
in vec3 Origin;
|
||||
in vec3 Orientation;
|
||||
in vec3 Scale;
|
||||
in vec4 misc_data;
|
||||
#endif
|
||||
flat out vec4 glowColor;
|
||||
|
||||
#stk_include "utils/getworldmatrix.vert"
|
||||
|
||||
void main(void)
|
||||
{
|
||||
mat4 ModelMatrix = getWorldMatrix(Origin, Orientation, Scale);
|
||||
mat4 TransposeInverseModelView = transpose(getInverseWorldMatrix(Origin, Orientation, Scale) * u_inverse_view_matrix);
|
||||
gl_Position = u_projection_view_matrix * ModelMatrix * vec4(Position, 1.);
|
||||
glowColor = misc_data;
|
||||
}
|
@ -1,39 +0,0 @@
|
||||
uniform vec3 windDir;
|
||||
uniform mat4 ModelMatrix;
|
||||
uniform mat4 InverseModelMatrix;
|
||||
|
||||
#ifdef Explicit_Attrib_Location_Usable
|
||||
layout(location = 0) in vec3 Position;
|
||||
layout(location = 1) in vec3 Normal;
|
||||
layout(location = 2) in vec4 Color;
|
||||
layout(location = 3) in vec2 Texcoord;
|
||||
#else
|
||||
in vec3 Position;
|
||||
in vec3 Normal;
|
||||
in vec4 Color;
|
||||
in vec2 Texcoord;
|
||||
#endif
|
||||
|
||||
out vec3 nor;
|
||||
out vec2 uv;
|
||||
|
||||
void main()
|
||||
{
|
||||
|
||||
vec3 test = sin(windDir * (Position.y * 0.1)) * 1.;
|
||||
test += cos(windDir) * 0.7;
|
||||
|
||||
mat4 new_model_matrix = ModelMatrix;
|
||||
mat4 new_inverse_model_matrix = InverseModelMatrix;
|
||||
new_model_matrix[3].xyz += test * Color.r;
|
||||
|
||||
// FIXME doesn't seem to make too much difference in pass 2, because this
|
||||
// affects "nor" which is later only * 0.1 by scattering
|
||||
new_inverse_model_matrix[3].xyz -= test * Color.r;
|
||||
|
||||
mat4 ModelViewProjectionMatrix = u_projection_view_matrix * new_model_matrix;
|
||||
mat4 TransposeInverseModelView = transpose(u_inverse_view_matrix * new_inverse_model_matrix);
|
||||
gl_Position = ModelViewProjectionMatrix * vec4(Position, 1.);
|
||||
nor = (TransposeInverseModelView * vec4(Normal, 0.)).xyz;
|
||||
uv = Texcoord;
|
||||
}
|
@ -1,41 +0,0 @@
|
||||
#ifdef Use_Bindless_Texture
|
||||
layout(bindless_sampler) uniform sampler2D Albedo;
|
||||
layout(bindless_sampler) uniform sampler2D SpecMap;
|
||||
layout(bindless_sampler) uniform sampler2D colorization_mask;
|
||||
#else
|
||||
uniform sampler2D Albedo;
|
||||
uniform sampler2D SpecMap;
|
||||
uniform sampler2D colorization_mask;
|
||||
#endif
|
||||
|
||||
in vec3 nor;
|
||||
in vec2 uv;
|
||||
uniform vec2 color_change;
|
||||
out vec4 FragColor;
|
||||
|
||||
#stk_include "utils/getLightFactor.frag"
|
||||
#stk_include "utils/rgb_conversion.frag"
|
||||
|
||||
void main(void)
|
||||
{
|
||||
vec4 color = texture(Albedo, uv);
|
||||
#ifdef Use_Bindless_Texture
|
||||
#ifdef SRGBBindlessFix
|
||||
color.xyz = pow(color.xyz, vec3(2.2));
|
||||
#endif
|
||||
#endif
|
||||
if (color.a < 0.5) discard;
|
||||
|
||||
float mask = texture(colorization_mask, uv).a;
|
||||
if (color_change.x > 0.0)
|
||||
{
|
||||
vec3 old_hsv = rgbToHsv(color.rgb);
|
||||
float mask_step = step(mask, 0.5);
|
||||
vec2 new_xy = mix(vec2(old_hsv.x, old_hsv.y), vec2(color_change.x, max(old_hsv.y, color_change.y)), vec2(mask_step, mask_step));
|
||||
color.xyz = hsvToRgb(vec3(new_xy.x, new_xy.y, old_hsv.z));
|
||||
}
|
||||
float specmap = texture(SpecMap, uv).g;
|
||||
float emitmap = texture(SpecMap, uv).b;
|
||||
vec3 LightFactor = getLightFactor(color.xyz, vec3(1.), specmap, emitmap);
|
||||
FragColor = vec4(LightFactor, 1.);
|
||||
}
|
@ -1,35 +0,0 @@
|
||||
#ifndef Use_Bindless_Texture
|
||||
uniform sampler2D Albedo;
|
||||
uniform sampler2D Detail;
|
||||
uniform sampler2D SpecMap;
|
||||
#endif
|
||||
|
||||
#ifdef Use_Bindless_Texture
|
||||
flat in sampler2D handle;
|
||||
flat in sampler2D secondhandle;
|
||||
flat in sampler2D fourthhandle;
|
||||
#endif
|
||||
in vec2 uv;
|
||||
in vec2 uv_bis;
|
||||
out vec4 FragColor;
|
||||
|
||||
#stk_include "utils/getLightFactor.frag"
|
||||
|
||||
void main(void)
|
||||
{
|
||||
#ifdef Use_Bindless_Texture
|
||||
vec4 color = texture(handle, uv);
|
||||
float specmap = texture(secondhandle, uv).g;
|
||||
#ifdef SRGBBindlessFix
|
||||
color.xyz = pow(color.xyz, vec3(2.2));
|
||||
#endif
|
||||
vec4 detail = texture(fourthhandle, uv_bis);
|
||||
#else
|
||||
vec4 color = texture(Albedo, uv);
|
||||
vec4 detail = texture(Detail, uv_bis);
|
||||
float specmap = texture(SpecMap, uv).g;
|
||||
#endif
|
||||
detail.rgb = detail.a * detail.rgb;
|
||||
color.rgb = detail.rgb + color.rgb * (1. - detail.a);
|
||||
FragColor = vec4(getLightFactor(color.xyz, vec3(1.), specmap, 0.), 1.);
|
||||
}
|
@ -1,57 +0,0 @@
|
||||
uniform vec3 windDir;
|
||||
|
||||
#ifdef Explicit_Attrib_Location_Usable
|
||||
layout(location = 0) in vec3 Position;
|
||||
layout(location = 1) in vec3 Normal;
|
||||
layout(location = 2) in vec4 Color;
|
||||
layout(location = 3) in vec2 Texcoord;
|
||||
|
||||
layout(location = 7) in vec3 Origin;
|
||||
layout(location = 8) in vec3 Orientation;
|
||||
layout(location = 9) in vec3 Scale;
|
||||
layout(location = 10) in vec4 misc_data;
|
||||
#ifdef Use_Bindless_Texture
|
||||
layout(location = 11) in sampler2D Handle;
|
||||
layout(location = 12) in sampler2D SecondHandle;
|
||||
layout(location = 13) in sampler2D ThirdHandle;
|
||||
#endif
|
||||
|
||||
#else
|
||||
in vec3 Position;
|
||||
in vec3 Normal;
|
||||
in vec4 Color;
|
||||
in vec2 Texcoord;
|
||||
|
||||
in vec3 Origin;
|
||||
in vec3 Orientation;
|
||||
in vec3 Scale;
|
||||
in vec4 misc_data;
|
||||
#endif
|
||||
|
||||
out vec3 nor;
|
||||
out vec2 uv;
|
||||
flat out vec2 color_change;
|
||||
#ifdef Use_Bindless_Texture
|
||||
flat out sampler2D handle;
|
||||
flat out sampler2D secondhandle;
|
||||
flat out sampler2D thirdhandle;
|
||||
#endif
|
||||
|
||||
#stk_include "utils/getworldmatrix.vert"
|
||||
|
||||
void main()
|
||||
{
|
||||
vec3 test = sin(windDir * (Position.y * 0.1)) * 1.;
|
||||
test += cos(windDir) * 0.7;
|
||||
mat4 ModelMatrix = getWorldMatrix(Origin + test * Color.r, Orientation, Scale);
|
||||
mat4 TransposeInverseModelView = transpose(getInverseWorldMatrix(Origin + test * Color.r, Orientation, Scale) * u_inverse_view_matrix);
|
||||
gl_Position = u_projection_view_matrix * ModelMatrix * vec4(Position, 1.);
|
||||
nor = (TransposeInverseModelView * vec4(Normal, 0.)).xyz;
|
||||
uv = Texcoord;
|
||||
color_change = misc_data.zw;
|
||||
#ifdef Use_Bindless_Texture
|
||||
handle = Handle;
|
||||
secondhandle = SecondHandle;
|
||||
thirdhandle = ThirdHandle;
|
||||
#endif
|
||||
}
|
@ -1,47 +0,0 @@
|
||||
#ifndef Use_Bindless_Texture
|
||||
uniform sampler2D Albedo;
|
||||
uniform sampler2D SpecMap;
|
||||
uniform sampler2D colorization_mask;
|
||||
#endif
|
||||
|
||||
#ifdef Use_Bindless_Texture
|
||||
flat in sampler2D handle;
|
||||
flat in sampler2D secondhandle;
|
||||
flat in sampler2D thirdhandle;
|
||||
#endif
|
||||
in vec3 nor;
|
||||
in vec2 uv;
|
||||
flat in vec2 color_change;
|
||||
out vec4 FragColor;
|
||||
|
||||
#stk_include "utils/getLightFactor.frag"
|
||||
#stk_include "utils/rgb_conversion.frag"
|
||||
|
||||
void main(void)
|
||||
{
|
||||
#ifdef Use_Bindless_Texture
|
||||
vec4 color = texture(handle, uv);
|
||||
float specmap = texture(secondhandle, uv).g;
|
||||
float emitmap = texture(secondhandle, uv).b;
|
||||
float mask = texture(thirdhandle, uv).a;
|
||||
#ifdef SRGBBindlessFix
|
||||
color.xyz = pow(color.xyz, vec3(2.2));
|
||||
#endif
|
||||
#else
|
||||
vec4 color = texture(Albedo, uv);
|
||||
float specmap = texture(SpecMap, uv).g;
|
||||
float emitmap = texture(SpecMap, uv).b;
|
||||
float mask = texture(colorization_mask, uv).a;
|
||||
#endif
|
||||
if (color.a < 0.5) discard;
|
||||
|
||||
if (color_change.x > 0.0)
|
||||
{
|
||||
vec3 old_hsv = rgbToHsv(color.rgb);
|
||||
float mask_step = step(mask, 0.5);
|
||||
vec2 new_xy = mix(vec2(old_hsv.x, old_hsv.y), vec2(color_change.x, max(old_hsv.y, color_change.y)), vec2(mask_step, mask_step));
|
||||
color.xyz = hsvToRgb(vec3(new_xy.x, new_xy.y, old_hsv.z));
|
||||
}
|
||||
vec3 LightFactor = getLightFactor(color.xyz, vec3(1.), specmap, emitmap);
|
||||
FragColor = vec4(LightFactor, 1.);
|
||||
}
|
@ -1,62 +0,0 @@
|
||||
uniform int layer;
|
||||
|
||||
uniform vec3 windDir;
|
||||
#ifdef Explicit_Attrib_Location_Usable
|
||||
layout(location = 0) in vec3 Position;
|
||||
layout(location = 2) in vec4 Color;
|
||||
layout(location = 3) in vec2 Texcoord;
|
||||
|
||||
layout(location = 7) in vec3 Origin;
|
||||
layout(location = 8) in vec3 Orientation;
|
||||
layout(location = 9) in vec3 Scale;
|
||||
#ifdef Use_Bindless_Texture
|
||||
layout(location = 11) in uvec2 Handle;
|
||||
#endif
|
||||
|
||||
#else
|
||||
in vec3 Position;
|
||||
in vec4 Color;
|
||||
in vec2 Texcoord;
|
||||
|
||||
in vec3 Origin;
|
||||
in vec3 Orientation;
|
||||
in vec3 Scale;
|
||||
#endif
|
||||
|
||||
#ifdef VSLayer
|
||||
out vec2 uv;
|
||||
#ifdef Use_Bindless_Texture
|
||||
flat out uvec2 handle;
|
||||
#endif
|
||||
#else
|
||||
out vec2 tc;
|
||||
out int layerId;
|
||||
#ifdef Use_Bindless_Texture
|
||||
flat out uvec2 hdle;
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#stk_include "utils/getworldmatrix.vert"
|
||||
|
||||
void main(void)
|
||||
{
|
||||
|
||||
vec3 test = sin(windDir * (Position.y* 0.5)) * 0.5;
|
||||
test += cos(windDir) * 0.7;
|
||||
mat4 ModelMatrix = getWorldMatrix(Origin, Orientation, Scale);
|
||||
#ifdef VSLayer
|
||||
gl_Layer = layer;
|
||||
gl_Position = u_shadow_projection_view_matrices[gl_Layer] * ModelMatrix * vec4(Position + test * Color.r, 1.);
|
||||
uv = Texcoord;
|
||||
#ifdef Use_Bindless_Texture
|
||||
handle = Handle;
|
||||
#endif
|
||||
#else
|
||||
layerId = layer;
|
||||
gl_Position = u_shadow_projection_view_matrices[layerId] * ModelMatrix * vec4(Position + test * Color.r, 1.);
|
||||
tc = Texcoord;
|
||||
#ifdef Use_Bindless_Texture
|
||||
hdle = Handle;
|
||||
#endif
|
||||
#endif
|
||||
}
|
@ -1,36 +0,0 @@
|
||||
#ifndef Use_Bindless_Texture
|
||||
uniform sampler2D normalMap;
|
||||
uniform sampler2D glossMap;
|
||||
#endif
|
||||
|
||||
#ifdef Use_Bindless_Texture
|
||||
flat in sampler2D secondhandle;
|
||||
flat in sampler2D fourthhandle;
|
||||
#endif
|
||||
in vec3 tangent;
|
||||
in vec3 bitangent;
|
||||
in vec3 nor;
|
||||
flat in float bitangent_sign;
|
||||
in vec2 uv;
|
||||
out vec3 EncodedNormal;
|
||||
|
||||
#stk_include "utils/encode_normal.frag"
|
||||
|
||||
void main()
|
||||
{
|
||||
// normal in Tangent Space
|
||||
#ifdef Use_Bindless_Texture
|
||||
vec3 TS_normal = 2.0 * texture(fourthhandle, uv).rgb - 1.0;
|
||||
float gloss = texture(secondhandle, uv).x;
|
||||
#else
|
||||
vec3 TS_normal = 2.0 * texture(normalMap, uv).rgb - 1.0;
|
||||
float gloss = texture(glossMap, uv).x;
|
||||
#endif
|
||||
// Because of interpolation, we need to renormalize
|
||||
vec3 Frag_tangent = normalize(tangent);
|
||||
vec3 Frag_normal = normalize(nor);
|
||||
vec3 Frag_bitangent = normalize(cross(Frag_normal, tangent) * bitangent_sign);
|
||||
vec3 FragmentNormal = mat3(Frag_tangent, Frag_bitangent, Frag_normal) * TS_normal;
|
||||
EncodedNormal.xy = 0.5 * EncodeNormal(normalize(FragmentNormal)) + 0.5;
|
||||
EncodedNormal.z = gloss;
|
||||
}
|
@ -1,76 +0,0 @@
|
||||
#ifdef Explicit_Attrib_Location_Usable
|
||||
layout(location = 0) in vec3 Position;
|
||||
layout(location = 1) in vec3 Normal;
|
||||
layout(location = 2) in vec4 Color;
|
||||
layout(location = 3) in vec2 Texcoord;
|
||||
layout(location = 4) in vec2 SecondTexcoord;
|
||||
layout(location = 5) in vec3 Tangent;
|
||||
layout(location = 6) in vec4 Bitangent;
|
||||
|
||||
layout(location = 7) in vec3 Origin;
|
||||
layout(location = 8) in vec3 Orientation;
|
||||
layout(location = 9) in vec3 Scale;
|
||||
layout(location = 10) in vec4 misc_data;
|
||||
#ifdef Use_Bindless_Texture
|
||||
layout(location = 11) in sampler2D Handle;
|
||||
layout(location = 12) in sampler2D SecondHandle;
|
||||
layout(location = 13) in sampler2D ThirdHandle;
|
||||
layout(location = 14) in sampler2D FourthHandle;
|
||||
#endif
|
||||
|
||||
#else
|
||||
in vec3 Position;
|
||||
in vec3 Normal;
|
||||
in vec4 Color;
|
||||
in vec2 Texcoord;
|
||||
in vec2 SecondTexcoord;
|
||||
in vec3 Tangent;
|
||||
in vec3 Bitangent;
|
||||
|
||||
in vec3 Origin;
|
||||
in vec3 Orientation;
|
||||
in vec3 Scale;
|
||||
in vec4 misc_data;
|
||||
#endif
|
||||
|
||||
out vec3 nort;
|
||||
out vec3 nor;
|
||||
out vec3 tangent;
|
||||
out vec3 bitangent;
|
||||
flat out float bitangent_sign;
|
||||
out vec2 uv;
|
||||
out vec2 uv_bis;
|
||||
out vec4 color;
|
||||
flat out vec2 color_change;
|
||||
#ifdef Use_Bindless_Texture
|
||||
flat out sampler2D handle;
|
||||
flat out sampler2D secondhandle;
|
||||
flat out sampler2D thirdhandle;
|
||||
flat out sampler2D fourthhandle;
|
||||
#endif
|
||||
|
||||
#stk_include "utils/getworldmatrix.vert"
|
||||
|
||||
void main(void)
|
||||
{
|
||||
mat4 ModelMatrix = getWorldMatrix(Origin, Orientation, Scale);
|
||||
mat4 TransposeInverseModelView = transpose(getInverseWorldMatrix(Origin, Orientation, Scale) * u_inverse_view_matrix);
|
||||
gl_Position = u_projection_view_matrix * ModelMatrix * vec4(Position, 1.);
|
||||
// Keep orthogonality
|
||||
nor = (TransposeInverseModelView * vec4(Normal, 0.)).xyz;
|
||||
// Keep direction
|
||||
tangent = (TransposeInverseModelView * vec4(Tangent, 0.)).xyz;
|
||||
bitangent = (TransposeInverseModelView * vec4(Bitangent.xyz, 0.)).xyz;
|
||||
bitangent_sign = Bitangent.w;
|
||||
uv = vec2(Texcoord.x + misc_data.x, Texcoord.y + misc_data.y);
|
||||
uv_bis = SecondTexcoord;
|
||||
color = Color.zyxw;
|
||||
color_change = misc_data.zw;
|
||||
#ifdef Use_Bindless_Texture
|
||||
handle = Handle;
|
||||
secondhandle = SecondHandle;
|
||||
thirdhandle = ThirdHandle;
|
||||
fourthhandle = FourthHandle;
|
||||
#endif
|
||||
//bitangent = Bitangent;
|
||||
}
|
@ -1,23 +0,0 @@
|
||||
#ifndef Use_Bindless_Texture
|
||||
uniform sampler2D glosstex;
|
||||
#endif
|
||||
|
||||
#ifdef Use_Bindless_Texture
|
||||
flat in sampler2D secondhandle;
|
||||
#endif
|
||||
in vec3 nor;
|
||||
in vec2 uv;
|
||||
out vec3 EncodedNormal;
|
||||
|
||||
#stk_include "utils/encode_normal.frag"
|
||||
|
||||
void main(void)
|
||||
{
|
||||
#ifdef Use_Bindless_Texture
|
||||
float glossmap = texture(secondhandle, uv).x;
|
||||
#else
|
||||
float glossmap = texture(glosstex, uv).x;
|
||||
#endif
|
||||
EncodedNormal.xy = 0.5 * EncodeNormal(normalize(nor)) + 0.5;
|
||||
EncodedNormal.z = glossmap;
|
||||
}
|
@ -1,54 +0,0 @@
|
||||
#ifndef Use_Bindless_Texture
|
||||
uniform sampler2D Albedo;
|
||||
uniform sampler2D SpecMap;
|
||||
uniform sampler2D colorization_mask;
|
||||
#endif
|
||||
|
||||
#ifdef Use_Bindless_Texture
|
||||
flat in sampler2D handle;
|
||||
flat in sampler2D secondhandle;
|
||||
flat in sampler2D thirdhandle;
|
||||
#endif
|
||||
|
||||
in vec2 uv;
|
||||
in vec4 color;
|
||||
flat in vec2 color_change;
|
||||
out vec4 FragColor;
|
||||
|
||||
#stk_include "utils/getLightFactor.frag"
|
||||
#stk_include "utils/rgb_conversion.frag"
|
||||
|
||||
void main(void)
|
||||
{
|
||||
#ifdef Use_Bindless_Texture
|
||||
vec4 col = texture(handle, uv);
|
||||
float specmap = texture(secondhandle, uv).g;
|
||||
float emitmap = texture(secondhandle, uv).b;
|
||||
float mask = texture(thirdhandle, uv).a;
|
||||
#ifdef SRGBBindlessFix
|
||||
col.xyz = pow(col.xyz, vec3(2.2));
|
||||
#endif
|
||||
#else
|
||||
vec4 col = texture(Albedo, uv);
|
||||
float specmap = texture(SpecMap, uv).g;
|
||||
float emitmap = texture(SpecMap, uv).b;
|
||||
float mask = texture(colorization_mask, uv).a;
|
||||
#endif
|
||||
|
||||
if (color_change.x > 0.0)
|
||||
{
|
||||
vec3 old_hsv = rgbToHsv(col.rgb);
|
||||
float mask_step = step(mask, 0.5);
|
||||
vec2 new_xy = mix(vec2(old_hsv.x, old_hsv.y), vec2(color_change.x, max(old_hsv.y, color_change.y)), vec2(mask_step, mask_step));
|
||||
vec3 new_color = hsvToRgb(vec3(new_xy.x, new_xy.y, old_hsv.z));
|
||||
col = vec4(new_color.r, new_color.g, new_color.b, col.a);
|
||||
}
|
||||
|
||||
#if defined(sRGB_Framebuffer_Usable) || defined(Advanced_Lighting_Enabled)
|
||||
col.xyz *= pow(color.xyz, vec3(2.2));
|
||||
#else
|
||||
col.xyz *= color.xyz;
|
||||
#endif
|
||||
|
||||
FragColor = vec4(getLightFactor(col.xyz, vec3(1.), specmap, emitmap) , 1.);
|
||||
}
|
@ -1,32 +0,0 @@
|
||||
#ifndef Use_Bindless_Texture
|
||||
uniform sampler2D tex;
|
||||
#endif
|
||||
|
||||
#ifdef Use_Bindless_Texture
|
||||
flat in sampler2D handle;
|
||||
#endif
|
||||
|
||||
in vec2 uv;
|
||||
in vec4 color;
|
||||
out vec4 FragColor;
|
||||
|
||||
void main(void)
|
||||
{
|
||||
#ifdef Use_Bindless_Texture
|
||||
vec4 col = texture(handle, uv);
|
||||
#ifdef SRGBBindlessFix
|
||||
col.xyz = pow(col.xyz, vec3(2.2));
|
||||
#endif
|
||||
#else
|
||||
vec4 col = texture(tex, uv);
|
||||
#endif
|
||||
if (col.a < 0.5) discard;
|
||||
|
||||
#if defined(sRGB_Framebuffer_Usable) || defined(Advanced_Lighting_Enabled)
|
||||
col.xyz *= pow(color.xyz, vec3(2.2));
|
||||
#else
|
||||
col.xyz *= color.xyz;
|
||||
#endif
|
||||
|
||||
FragColor = vec4(col.xyz, 1.);
|
||||
}
|
@ -1,33 +0,0 @@
|
||||
// See http://www.ozone3d.net/tutorials/glsl_texturing_p04.php for ref
|
||||
|
||||
#ifndef Use_Bindless_Texture
|
||||
uniform sampler2D tex;
|
||||
#endif
|
||||
|
||||
#ifdef Use_Bindless_Texture
|
||||
flat in sampler2D handle;
|
||||
#endif
|
||||
in vec3 nor;
|
||||
out vec4 FragColor;
|
||||
|
||||
#stk_include "utils/getPosFromUVDepth.frag"
|
||||
#stk_include "utils/getLightFactor.frag"
|
||||
|
||||
void main() {
|
||||
vec3 texc = gl_FragCoord.xyz / vec3(u_screen, 1.);
|
||||
vec3 u = getPosFromUVDepth(texc, u_inverse_projection_matrix).xyz;
|
||||
vec3 r = reflect(u, nor);
|
||||
|
||||
float m = 2.0 * sqrt(r.x * r.x + r.y * r.y + (r.z + 1.0) * (r.z + 1.0));
|
||||
r.y = - r.y;
|
||||
#ifdef Use_Bindless_Texture
|
||||
vec4 detail0 = texture(handle, r.xy / m + .5);
|
||||
#ifdef SRGBBindlessFix
|
||||
detail0.xyz = pow(detail0.xyz, vec3(2.2));
|
||||
#endif
|
||||
#else
|
||||
vec4 detail0 = texture(tex, r.xy / m + .5);
|
||||
#endif
|
||||
|
||||
FragColor = vec4(getLightFactor(detail0.xyz, vec3(1.), 0., 0.), 1.);
|
||||
}
|
@ -1,29 +0,0 @@
|
||||
#ifndef Use_Bindless_Texture
|
||||
uniform sampler2D tex;
|
||||
uniform sampler2D glosstex;
|
||||
#endif
|
||||
|
||||
#ifdef Use_Bindless_Texture
|
||||
flat in sampler2D handle;
|
||||
flat in sampler2D secondhandle;
|
||||
#endif
|
||||
in vec3 nor;
|
||||
in vec2 uv;
|
||||
out vec3 EncodedNormal;
|
||||
|
||||
#stk_include "utils/encode_normal.frag"
|
||||
|
||||
void main() {
|
||||
#ifdef Use_Bindless_Texture
|
||||
vec4 col = texture(handle, uv);
|
||||
float glossmap = texture(secondhandle, uv).x;
|
||||
#else
|
||||
vec4 col = texture(tex, uv);
|
||||
float glossmap = texture(glosstex, uv).x;
|
||||
#endif
|
||||
if (col.a < 0.5)
|
||||
discard;
|
||||
EncodedNormal.xy = 0.5 * EncodeNormal(normalize(nor)) + 0.5;
|
||||
EncodedNormal.z = glossmap;
|
||||
}
|
||||
|
@ -1,54 +0,0 @@
|
||||
#ifndef Use_Bindless_Texture
|
||||
uniform sampler2D Albedo;
|
||||
uniform sampler2D SpecMap;
|
||||
uniform sampler2D colorization_mask;
|
||||
#endif
|
||||
|
||||
#ifdef Use_Bindless_Texture
|
||||
flat in sampler2D handle;
|
||||
flat in sampler2D secondhandle;
|
||||
flat in sampler2D thirdhandle;
|
||||
#endif
|
||||
in vec2 uv;
|
||||
in vec4 color;
|
||||
flat in vec2 color_change;
|
||||
out vec4 FragColor;
|
||||
|
||||
#stk_include "utils/getLightFactor.frag"
|
||||
#stk_include "utils/rgb_conversion.frag"
|
||||
|
||||
void main(void)
|
||||
{
|
||||
#ifdef Use_Bindless_Texture
|
||||
vec4 col = texture(handle, uv);
|
||||
float specmap = texture(secondhandle, uv).g;
|
||||
float emitmap = texture(secondhandle, uv).b;
|
||||
float mask = texture(thirdhandle, uv).a;
|
||||
#ifdef SRGBBindlessFix
|
||||
col.xyz = pow(col.xyz, vec3(2.2));
|
||||
#endif
|
||||
#else
|
||||
vec4 col = texture(Albedo, uv);
|
||||
float specmap = texture(SpecMap, uv).g;
|
||||
float emitmap = texture(SpecMap, uv).b;
|
||||
float mask = texture(colorization_mask, uv).a;
|
||||
#endif
|
||||
if (col.a * color.a < 0.5) discard;
|
||||
|
||||
#if defined(sRGB_Framebuffer_Usable) || defined(Advanced_Lighting_Enabled)
|
||||
col.xyz *= pow(color.xyz, vec3(2.2));
|
||||
#else
|
||||
col.xyz *= color.xyz;
|
||||
#endif
|
||||
|
||||
if (color_change.x > 0.0)
|
||||
{
|
||||
vec3 old_hsv = rgbToHsv(col.rgb);
|
||||
float mask_step = step(mask, 0.5);
|
||||
vec2 new_xy = mix(vec2(old_hsv.x, old_hsv.y), vec2(color_change.x, max(old_hsv.y, color_change.y)), vec2(mask_step, mask_step));
|
||||
vec3 new_color = hsvToRgb(vec3(new_xy.x, new_xy.y, old_hsv.z));
|
||||
col = vec4(new_color.r, new_color.g, new_color.b, col.a);
|
||||
}
|
||||
|
||||
FragColor = vec4(getLightFactor(col.xyz, vec3(1.), specmap, emitmap), 1.);
|
||||
}
|
@ -1,27 +0,0 @@
|
||||
#ifndef Use_Bindless_Texture
|
||||
uniform sampler2D tex;
|
||||
#endif
|
||||
|
||||
in vec2 uv;
|
||||
in vec3 nor;
|
||||
in vec4 color;
|
||||
#ifdef Use_Bindless_Texture
|
||||
flat in uvec2 handle;
|
||||
#endif
|
||||
layout (location = 0) out vec3 RSMColor;
|
||||
layout (location = 1) out vec3 RSMNormals;
|
||||
|
||||
void main()
|
||||
{
|
||||
#ifdef Use_Bindless_Texture
|
||||
vec4 col = texture(sampler2D(handle), uv);
|
||||
#ifdef SRGBBindlessFix
|
||||
col.xyz = pow(col.xyz, vec3(2.2));
|
||||
#endif
|
||||
#else
|
||||
vec4 col = texture(tex, uv);
|
||||
#endif
|
||||
if (col.a < .5) discard;
|
||||
RSMColor = col.xyz * color.rgb;
|
||||
RSMNormals = .5 * normalize(nor) + .5;
|
||||
}
|
@ -1,38 +0,0 @@
|
||||
uniform mat4 RSMMatrix;
|
||||
|
||||
layout(location = 0) in vec3 Position;
|
||||
layout(location = 1) in vec3 Normal;
|
||||
layout(location = 2) in vec4 Color;
|
||||
layout(location = 3) in vec2 Texcoord;
|
||||
layout(location = 4) in vec2 SecondTexcoord;
|
||||
layout(location = 7) in vec3 Origin;
|
||||
layout(location = 8) in vec3 Orientation;
|
||||
layout(location = 9) in vec3 Scale;
|
||||
#ifdef Use_Bindless_Texture
|
||||
layout(location = 11) in uvec2 Handle;
|
||||
#endif
|
||||
|
||||
out vec3 nor;
|
||||
out vec2 uv;
|
||||
out vec2 uv_bis;
|
||||
out vec4 color;
|
||||
#ifdef Use_Bindless_Texture
|
||||
flat out uvec2 handle;
|
||||
#endif
|
||||
|
||||
|
||||
#stk_include "utils/getworldmatrix.vert"
|
||||
|
||||
void main(void)
|
||||
{
|
||||
mat4 ModelMatrix = getWorldMatrix(Origin, Orientation, Scale);
|
||||
mat4 ModelViewProjectionMatrix = RSMMatrix * ModelMatrix;
|
||||
mat4 TransposeInverseModel = transpose(inverse(ModelMatrix));
|
||||
gl_Position = ModelViewProjectionMatrix * vec4(Position, 1.);
|
||||
nor = (TransposeInverseModel * vec4(Normal, 0.)).xyz;
|
||||
uv = Texcoord;
|
||||
color = Color.zyxw;
|
||||
#ifdef Use_Bindless_Texture
|
||||
handle = Handle;
|
||||
#endif
|
||||
}
|
@ -1,28 +0,0 @@
|
||||
layout(triangles) in;
|
||||
layout(triangle_strip, max_vertices=3) out;
|
||||
|
||||
#ifdef Use_Bindless_Texture
|
||||
flat in uvec2 hdle[3];
|
||||
#endif
|
||||
in vec2 tc[3];
|
||||
in int layerId[3];
|
||||
|
||||
out vec2 uv;
|
||||
#ifdef Use_Bindless_Texture
|
||||
out flat uvec2 handle;
|
||||
#endif
|
||||
|
||||
void main(void)
|
||||
{
|
||||
gl_Layer = layerId[0];
|
||||
#ifdef Use_Bindless_Texture
|
||||
handle = hdle[0];
|
||||
#endif
|
||||
for(int i=0; i<3; i++)
|
||||
{
|
||||
uv = tc[i];
|
||||
gl_Position = gl_in[i].gl_Position;
|
||||
EmitVertex();
|
||||
}
|
||||
EndPrimitive();
|
||||
}
|
@ -1,56 +0,0 @@
|
||||
uniform int layer;
|
||||
|
||||
#ifdef Explicit_Attrib_Location_Usable
|
||||
layout(location = 0) in vec3 Position;
|
||||
layout(location = 3) in vec2 Texcoord;
|
||||
|
||||
layout(location = 7) in vec3 Origin;
|
||||
layout(location = 8) in vec3 Orientation;
|
||||
layout(location = 9) in vec3 Scale;
|
||||
#ifdef Use_Bindless_Texture
|
||||
layout(location = 11) in uvec2 Handle;
|
||||
#endif
|
||||
|
||||
#else
|
||||
in vec3 Position;
|
||||
in vec2 Texcoord;
|
||||
|
||||
in vec3 Origin;
|
||||
in vec3 Orientation;
|
||||
in vec3 Scale;
|
||||
#endif
|
||||
|
||||
#ifdef VSLayer
|
||||
out vec2 uv;
|
||||
#ifdef Use_Bindless_Texture
|
||||
flat out uvec2 handle;
|
||||
#endif
|
||||
#else
|
||||
out vec2 tc;
|
||||
out int layerId;
|
||||
#ifdef Use_Bindless_Texture
|
||||
flat out uvec2 hdle;
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#stk_include "utils/getworldmatrix.vert"
|
||||
|
||||
void main(void)
|
||||
{
|
||||
mat4 ModelMatrix = getWorldMatrix(Origin, Orientation, Scale);
|
||||
#ifdef VSLayer
|
||||
gl_Layer = layer;
|
||||
gl_Position = u_shadow_projection_view_matrices[gl_Layer] * ModelMatrix * vec4(Position, 1.);
|
||||
uv = Texcoord;
|
||||
#ifdef Use_Bindless_Texture
|
||||
handle = Handle;
|
||||
#endif
|
||||
#else
|
||||
layerId = layer;
|
||||
gl_Position = u_shadow_projection_view_matrices[layerId] * ModelMatrix * vec4(Position, 1.);
|
||||
tc = Texcoord;
|
||||
#ifdef Use_Bindless_Texture
|
||||
hdle = Handle;
|
||||
#endif
|
||||
#endif
|
||||
}
|
@ -1,21 +0,0 @@
|
||||
#ifndef Use_Bindless_Texture
|
||||
uniform sampler2D tex;
|
||||
#endif
|
||||
|
||||
#ifdef Use_Bindless_Texture
|
||||
flat in uvec2 handle;
|
||||
#endif
|
||||
in vec2 uv;
|
||||
in vec4 color;
|
||||
out vec4 FragColor;
|
||||
|
||||
void main(void)
|
||||
{
|
||||
#ifdef Use_Bindless_Texture
|
||||
vec4 col = texture(sampler2D(handle), uv);
|
||||
#else
|
||||
vec4 col = texture(tex, uv);
|
||||
#endif
|
||||
if (col.a < 0.5) discard;
|
||||
FragColor = vec4(exp(32. * (2. * gl_FragCoord.z - 1.) / gl_FragCoord.w));
|
||||
}
|
@ -1,99 +0,0 @@
|
||||
#ifdef Explicit_Attrib_Location_Usable
|
||||
layout(location = 0) in vec3 Position;
|
||||
layout(location = 1) in vec3 Normal;
|
||||
layout(location = 2) in vec4 Color;
|
||||
layout(location = 3) in vec2 Texcoord;
|
||||
layout(location = 4) in vec3 Tangent;
|
||||
layout(location = 11) in vec4 Bitangent;
|
||||
layout(location = 5) in ivec4 Joint;
|
||||
layout(location = 6) in vec4 Weight;
|
||||
|
||||
layout(location = 7) in vec3 Origin;
|
||||
layout(location = 8) in vec3 Orientation;
|
||||
layout(location = 9) in vec3 Scale;
|
||||
layout(location = 10) in vec4 misc_data;
|
||||
#ifdef Use_Bindless_Texture
|
||||
layout(location = 11) in sampler2D Handle;
|
||||
layout(location = 12) in sampler2D SecondHandle;
|
||||
layout(location = 13) in sampler2D ThirdHandle;
|
||||
layout(location = 14) in sampler2D FourthHandle;
|
||||
#endif
|
||||
layout(location = 15) in int skinning_offset;
|
||||
#else
|
||||
in vec3 Position;
|
||||
in vec3 Normal;
|
||||
in vec4 Color;
|
||||
in vec4 Data1;
|
||||
in vec4 Data2;
|
||||
in ivec4 Joint;
|
||||
in vec4 Weight;
|
||||
|
||||
in vec3 Origin;
|
||||
in vec3 Orientation;
|
||||
in vec3 Scale;
|
||||
in vec4 misc_data;
|
||||
in int skinning_offset;
|
||||
#endif
|
||||
|
||||
out vec3 nor;
|
||||
out vec3 nort;
|
||||
out vec3 tangent;
|
||||
out vec3 bitangent;
|
||||
flat out float bitangent_sign;
|
||||
out vec2 uv;
|
||||
out vec4 color;
|
||||
flat out vec2 color_change;
|
||||
#ifdef Use_Bindless_Texture
|
||||
flat out sampler2D handle;
|
||||
flat out sampler2D secondhandle;
|
||||
flat out sampler2D thirdhandle;
|
||||
flat out sampler2D fourthhandle;
|
||||
#endif
|
||||
|
||||
#stk_include "utils/getworldmatrix.vert"
|
||||
|
||||
uniform samplerBuffer skinning_tex;
|
||||
|
||||
void main(void)
|
||||
{
|
||||
mat4 ModelMatrix = getWorldMatrix(Origin, Orientation, Scale);
|
||||
mat4 TransposeInverseModelView = transpose(getInverseWorldMatrix(Origin, Orientation, Scale) * u_inverse_view_matrix);
|
||||
vec4 idle_position = vec4(Position, 1.);
|
||||
vec4 idle_normal = vec4(Normal, 0.);
|
||||
vec4 idle_tangent = vec4(Tangent, 0.);
|
||||
vec4 idle_bitangent = vec4(Bitangent.xyz, 0.);
|
||||
vec4 skinned_position = vec4(0.);
|
||||
vec4 skinned_normal = vec4(0.);
|
||||
vec4 skinned_tangent = vec4(0.);
|
||||
vec4 skinned_bitangent = vec4(0.);
|
||||
for (int i = 0; i < 4; i++)
|
||||
{
|
||||
mat4 joint_matrix = mat4(
|
||||
texelFetch(skinning_tex, clamp(Joint[i] + skinning_offset, 0, MAX_BONES) * 4),
|
||||
texelFetch(skinning_tex, clamp(Joint[i] + skinning_offset, 0, MAX_BONES) * 4 + 1),
|
||||
texelFetch(skinning_tex, clamp(Joint[i] + skinning_offset, 0, MAX_BONES) * 4 + 2),
|
||||
texelFetch(skinning_tex, clamp(Joint[i] + skinning_offset, 0, MAX_BONES) * 4 + 3));
|
||||
skinned_position += Weight[i] * joint_matrix * idle_position;
|
||||
skinned_normal += Weight[i] * joint_matrix * idle_normal;
|
||||
skinned_tangent += Weight[i] * joint_matrix * idle_tangent;
|
||||
skinned_bitangent += Weight[i] * joint_matrix * idle_bitangent;
|
||||
}
|
||||
|
||||
gl_Position = u_projection_view_matrix * ModelMatrix * skinned_position;
|
||||
// Keep orthogonality
|
||||
nor = (TransposeInverseModelView * skinned_normal).xyz;
|
||||
// Keep direction
|
||||
tangent = (TransposeInverseModelView * skinned_tangent).xyz;
|
||||
bitangent = (TransposeInverseModelView * skinned_bitangent).xyz;
|
||||
bitangent_sign = Bitangent.w;
|
||||
uv = vec2(Texcoord.x + misc_data.x, Texcoord.y + misc_data.y);
|
||||
color = Color.zyxw;
|
||||
color_change = misc_data.zw;
|
||||
#ifdef Use_Bindless_Texture
|
||||
handle = Handle;
|
||||
secondhandle = SecondHandle;
|
||||
thirdhandle = ThirdHandle;
|
||||
fourthhandle = FourthHandle;
|
||||
#endif
|
||||
//bitangent = skinned_bitangent.xyz;
|
||||
}
|
@ -1,73 +0,0 @@
|
||||
uniform int layer;
|
||||
|
||||
#ifdef Explicit_Attrib_Location_Usable
|
||||
layout(location = 0) in vec3 Position;
|
||||
layout(location = 3) in vec4 Data1;
|
||||
layout(location = 5) in ivec4 Joint;
|
||||
layout(location = 6) in vec4 Weight;
|
||||
layout(location = 7) in vec3 Origin;
|
||||
layout(location = 8) in vec3 Orientation;
|
||||
layout(location = 9) in vec3 Scale;
|
||||
#ifdef Use_Bindless_Texture
|
||||
layout(location = 11) in uvec2 Handle;
|
||||
#endif
|
||||
layout(location = 15) in int skinning_offset;
|
||||
#else
|
||||
in vec3 Position;
|
||||
in vec4 Data1;
|
||||
in ivec4 Joint;
|
||||
in vec4 Weight;
|
||||
in vec3 Origin;
|
||||
in vec3 Orientation;
|
||||
in vec3 Scale;
|
||||
in int skinning_offset;
|
||||
#endif
|
||||
|
||||
#ifdef VSLayer
|
||||
out vec2 uv;
|
||||
#ifdef Use_Bindless_Texture
|
||||
flat out uvec2 handle;
|
||||
#endif
|
||||
#else
|
||||
out vec2 tc;
|
||||
out int layerId;
|
||||
#ifdef Use_Bindless_Texture
|
||||
flat out uvec2 hdle;
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#stk_include "utils/getworldmatrix.vert"
|
||||
|
||||
uniform samplerBuffer skinning_tex;
|
||||
|
||||
void main(void)
|
||||
{
|
||||
mat4 ModelMatrix = getWorldMatrix(Origin, Orientation, Scale);
|
||||
vec4 idle_position = vec4(Position, 1.);
|
||||
vec4 skinned_position = vec4(0.);
|
||||
for (int i = 0; i < 4; i++)
|
||||
{
|
||||
mat4 joint_matrix = mat4(
|
||||
texelFetch(skinning_tex, clamp(Joint[i] + skinning_offset, 0, MAX_BONES) * 4),
|
||||
texelFetch(skinning_tex, clamp(Joint[i] + skinning_offset, 0, MAX_BONES) * 4 + 1),
|
||||
texelFetch(skinning_tex, clamp(Joint[i] + skinning_offset, 0, MAX_BONES) * 4 + 2),
|
||||
texelFetch(skinning_tex, clamp(Joint[i] + skinning_offset, 0, MAX_BONES) * 4 + 3));
|
||||
skinned_position += Weight[i] * joint_matrix * idle_position;
|
||||
}
|
||||
|
||||
#ifdef VSLayer
|
||||
gl_Layer = layer;
|
||||
gl_Position = u_shadow_projection_view_matrices[gl_Layer] * ModelMatrix * skinned_position;
|
||||
uv = Data1.xy;
|
||||
#ifdef Use_Bindless_Texture
|
||||
handle = Handle;
|
||||
#endif
|
||||
#else
|
||||
layerId = layer;
|
||||
gl_Position = u_shadow_projection_view_matrices[layerId] * ModelMatrix * skinned_position;
|
||||
tc = Data1.xy;
|
||||
#ifdef Use_Bindless_Texture
|
||||
hdle = Handle;
|
||||
#endif
|
||||
#endif
|
||||
}
|
@ -1,22 +0,0 @@
|
||||
layout(triangles) in;
|
||||
layout(line_strip, max_vertices = 6) out;
|
||||
|
||||
in vec3 nor[];
|
||||
|
||||
void main()
|
||||
{
|
||||
for(int i=0; i < gl_in.length(); i++)
|
||||
{
|
||||
vec4 pos = gl_in[i].gl_Position;
|
||||
gl_Position = pos;
|
||||
EmitVertex();
|
||||
|
||||
vec3 normal = normalize(nor[i]);
|
||||
pos = inverse(ProjectionMatrix) * pos;
|
||||
pos /= pos.w;
|
||||
gl_Position = ProjectionMatrix * (pos + .2 * vec4(normal, 0.));
|
||||
EmitVertex();
|
||||
|
||||
EndPrimitive();
|
||||
}
|
||||
}
|
@ -1,29 +0,0 @@
|
||||
#ifdef Use_Bindless_Texture
|
||||
layout(bindless_sampler) uniform sampler2D normalMap;
|
||||
layout(bindless_sampler) uniform sampler2D glossMap;
|
||||
#else
|
||||
uniform sampler2D normalMap;
|
||||
uniform sampler2D glossMap;
|
||||
#endif
|
||||
|
||||
in vec3 tangent;
|
||||
in vec3 bitangent;
|
||||
in vec2 uv;
|
||||
out vec3 EncodedNormal;
|
||||
|
||||
#stk_include "utils/encode_normal.frag"
|
||||
|
||||
void main()
|
||||
{
|
||||
// normal in Tangent Space
|
||||
vec3 TS_normal = 2.0 * texture(normalMap, uv).rgb - 1.0;
|
||||
float gloss = texture(glossMap, uv).x;
|
||||
// Because of interpolation, we need to renormalize
|
||||
vec3 Frag_tangent = normalize(tangent);
|
||||
vec3 Frag_normal = normalize(cross(Frag_tangent, bitangent));
|
||||
vec3 Frag_bitangent = cross(Frag_normal, Frag_tangent);
|
||||
|
||||
vec3 FragmentNormal = TS_normal.x * Frag_tangent + TS_normal.y * Frag_bitangent - TS_normal.z * Frag_normal;
|
||||
EncodedNormal.xy = 0.5 * EncodeNormal(normalize(FragmentNormal)) + 0.5;
|
||||
EncodedNormal.z = gloss;
|
||||
}
|
@ -1,60 +0,0 @@
|
||||
#ifdef GL_ES
|
||||
uniform mat4 ModelMatrix;
|
||||
uniform mat4 InverseModelMatrix;
|
||||
uniform vec2 texture_trans;
|
||||
#else
|
||||
uniform mat4 ModelMatrix =
|
||||
mat4(1., 0., 0., 0.,
|
||||
0., 1., 0., 0.,
|
||||
0., 0., 1., 0.,
|
||||
0., 0., 0., 1.);
|
||||
uniform mat4 InverseModelMatrix =
|
||||
mat4(1., 0., 0., 0.,
|
||||
0., 1., 0., 0.,
|
||||
0., 0., 1., 0.,
|
||||
0., 0., 0., 1.);
|
||||
|
||||
uniform vec2 texture_trans = vec2(0., 0.);
|
||||
#endif
|
||||
|
||||
#ifdef Explicit_Attrib_Location_Usable
|
||||
layout(location = 0) in vec3 Position;
|
||||
layout(location = 1) in vec3 Normal;
|
||||
layout(location = 2) in vec4 Color;
|
||||
layout(location = 3) in vec2 Texcoord;
|
||||
layout(location = 4) in vec2 SecondTexcoord;
|
||||
layout(location = 5) in vec3 Tangent;
|
||||
layout(location = 6) in vec3 Bitangent;
|
||||
#else
|
||||
in vec3 Position;
|
||||
in vec3 Normal;
|
||||
in vec4 Color;
|
||||
in vec2 Texcoord;
|
||||
in vec2 SecondTexcoord;
|
||||
in vec3 Tangent;
|
||||
in vec3 Bitangent;
|
||||
#endif
|
||||
|
||||
out vec3 nor;
|
||||
out vec3 tangent;
|
||||
out vec3 bitangent;
|
||||
out vec2 uv;
|
||||
out vec2 uv_bis;
|
||||
out vec4 color;
|
||||
out float camdist;
|
||||
|
||||
void main(void)
|
||||
{
|
||||
color = Color.zyxw;
|
||||
mat4 ModelViewProjectionMatrix = u_projection_view_matrix * ModelMatrix;
|
||||
mat4 TransposeInverseModelView = transpose(InverseModelMatrix * u_inverse_view_matrix);
|
||||
gl_Position = ModelViewProjectionMatrix * vec4(Position, 1.);
|
||||
// Keep orthogonality
|
||||
nor = (TransposeInverseModelView * vec4(Normal, 0.)).xyz;
|
||||
// Keep direction
|
||||
tangent = (u_view_matrix * ModelMatrix * vec4(Tangent, 0.)).xyz;
|
||||
bitangent = (u_view_matrix * ModelMatrix * vec4(Bitangent, 0.)).xyz;
|
||||
uv = vec2(Texcoord.x + texture_trans.x, Texcoord.y + texture_trans.y);
|
||||
uv_bis = SecondTexcoord;
|
||||
camdist = length(u_view_matrix * ModelMatrix * vec4(Position, 1.));
|
||||
}
|
@ -1,18 +0,0 @@
|
||||
#ifdef Use_Bindless_Texture
|
||||
layout(bindless_sampler) uniform sampler2D tex;
|
||||
#else
|
||||
uniform sampler2D tex;
|
||||
#endif
|
||||
|
||||
in vec3 nor;
|
||||
in vec2 uv;
|
||||
out vec3 EncodedNormal;
|
||||
|
||||
#stk_include "utils/encode_normal.frag"
|
||||
|
||||
void main(void)
|
||||
{
|
||||
float glossmap = texture(tex, uv).x;
|
||||
EncodedNormal.xy = 0.5 * EncodeNormal(normalize(nor)) + 0.5;
|
||||
EncodedNormal.z = glossmap;
|
||||
}
|
@ -1,52 +0,0 @@
|
||||
#ifdef Use_Bindless_Texture
|
||||
layout(bindless_sampler) uniform sampler2D Albedo;
|
||||
layout(bindless_sampler) uniform sampler2D SpecMap;
|
||||
layout(bindless_sampler) uniform sampler2D colorization_mask;
|
||||
|
||||
#else
|
||||
uniform sampler2D Albedo;
|
||||
uniform sampler2D SpecMap;
|
||||
uniform sampler2D colorization_mask;
|
||||
#endif
|
||||
|
||||
uniform vec2 color_change;
|
||||
|
||||
in vec2 uv;
|
||||
in vec4 color;
|
||||
out vec4 FragColor;
|
||||
|
||||
#stk_include "utils/getLightFactor.frag"
|
||||
#stk_include "utils/rgb_conversion.frag"
|
||||
|
||||
void main(void)
|
||||
{
|
||||
#ifdef Use_Bindless_Texture
|
||||
vec4 col = texture(Albedo, uv);
|
||||
float mask = texture(colorization_mask, uv).a;
|
||||
#ifdef SRGBBindlessFix
|
||||
col.xyz = pow(col.xyz, vec3(2.2));
|
||||
#endif
|
||||
#else
|
||||
vec4 col = texture(Albedo, uv);
|
||||
float mask = texture(colorization_mask, uv).a;
|
||||
#endif
|
||||
|
||||
if (color_change.x > 0.0)
|
||||
{
|
||||
vec3 old_hsv = rgbToHsv(col.rgb);
|
||||
float mask_step = step(mask, 0.5);
|
||||
vec2 new_xy = mix(vec2(old_hsv.x, old_hsv.y), vec2(color_change.x, max(old_hsv.y, color_change.y)), vec2(mask_step, mask_step));
|
||||
vec3 new_color = hsvToRgb(vec3(new_xy.x, new_xy.y, old_hsv.z));
|
||||
col = vec4(new_color.r, new_color.g, new_color.b, col.a);
|
||||
}
|
||||
|
||||
#if defined(sRGB_Framebuffer_Usable) || defined(Advanced_Lighting_Enabled)
|
||||
col.xyz *= pow(color.xyz, vec3(2.2));
|
||||
#else
|
||||
col.xyz *= color.xyz;
|
||||
#endif
|
||||
|
||||
float specmap = texture(SpecMap, uv).g;
|
||||
float emitmap = texture(SpecMap, uv).b;
|
||||
FragColor = vec4(getLightFactor(col.xyz, vec3(1.), specmap, emitmap), 1.);
|
||||
}
|
@ -1,28 +0,0 @@
|
||||
#ifdef Use_Bindless_Texture
|
||||
layout(bindless_sampler) uniform sampler2D tex;
|
||||
#else
|
||||
uniform sampler2D tex;
|
||||
#endif
|
||||
|
||||
in vec2 uv;
|
||||
in vec4 color;
|
||||
out vec4 FragColor;
|
||||
|
||||
void main(void)
|
||||
{
|
||||
vec4 col = texture(tex, uv);
|
||||
#ifdef Use_Bindless_Texture
|
||||
#ifdef SRGBBindlessFix
|
||||
col.xyz = pow(col.xyz, vec3(2.2));
|
||||
#endif
|
||||
#endif
|
||||
if (col.a < 0.5) discard;
|
||||
|
||||
#if defined(sRGB_Framebuffer_Usable) || defined(Advanced_Lighting_Enabled)
|
||||
col.xyz *= pow(color.xyz, vec3(2.2));
|
||||
#else
|
||||
col.xyz *= color.xyz;
|
||||
#endif
|
||||
|
||||
FragColor = vec4(col.xyz, 1.);
|
||||
}
|
@ -1,30 +0,0 @@
|
||||
// See http://www.ozone3d.net/tutorials/glsl_texturing_p04.php for ref
|
||||
|
||||
#ifdef Use_Bindless_Texture
|
||||
layout(bindless_sampler) uniform sampler2D tex;
|
||||
#else
|
||||
uniform sampler2D tex;
|
||||
#endif
|
||||
|
||||
in vec3 nor;
|
||||
out vec4 FragColor;
|
||||
|
||||
#stk_include "utils/getPosFromUVDepth.frag"
|
||||
#stk_include "utils/getLightFactor.frag"
|
||||
|
||||
void main() {
|
||||
vec3 texc = gl_FragCoord.xyz / vec3(u_screen, 1.);
|
||||
vec3 u = getPosFromUVDepth(texc, u_inverse_projection_matrix).xyz;
|
||||
vec3 r = reflect(u, nor);
|
||||
|
||||
float m = 2.0 * sqrt(r.x * r.x + r.y * r.y + (r.z + 1.0) * (r.z + 1.0));
|
||||
r.y = - r.y;
|
||||
vec4 detail0 = texture(tex, r.xy / m + .5);
|
||||
#ifdef Use_Bindless_Texture
|
||||
#ifdef SRGBBindlessFix
|
||||
detail0.xyz = pow(detail0.xyz, vec3(2.2));
|
||||
#endif
|
||||
#endif
|
||||
|
||||
FragColor = vec4(getLightFactor(detail0.xyz, vec3(1.), 0., 0.), 1.);
|
||||
}
|
@ -1,23 +0,0 @@
|
||||
#ifdef Use_Bindless_Texture
|
||||
layout(bindless_sampler) uniform sampler2D tex;
|
||||
layout(bindless_sampler) uniform sampler2D glosstex;
|
||||
#else
|
||||
uniform sampler2D tex;
|
||||
uniform sampler2D glosstex;
|
||||
#endif
|
||||
|
||||
in vec3 nor;
|
||||
in vec2 uv;
|
||||
out vec3 EncodedNormal;
|
||||
|
||||
#stk_include "utils/encode_normal.frag"
|
||||
|
||||
void main() {
|
||||
vec4 col = texture(tex, uv);
|
||||
if (col.a < 0.5)
|
||||
discard;
|
||||
float glossmap = texture(glosstex, uv).x;
|
||||
EncodedNormal.xy = 0.5 * EncodeNormal(normalize(nor)) + 0.5;
|
||||
EncodedNormal.z = glossmap;
|
||||
}
|
||||
|
@ -1,49 +0,0 @@
|
||||
#ifdef Use_Bindless_Texture
|
||||
layout(bindless_sampler) uniform sampler2D Albedo;
|
||||
layout(bindless_sampler) uniform sampler2D SpecMap;
|
||||
layout(bindless_sampler) uniform sampler2D colorization_mask;
|
||||
#else
|
||||
uniform sampler2D Albedo;
|
||||
uniform sampler2D SpecMap;
|
||||
uniform sampler2D colorization_mask;
|
||||
#endif
|
||||
|
||||
uniform vec2 color_change;
|
||||
|
||||
in vec2 uv;
|
||||
in vec4 color;
|
||||
out vec4 FragColor;
|
||||
|
||||
#stk_include "utils/getLightFactor.frag"
|
||||
#stk_include "utils/rgb_conversion.frag"
|
||||
|
||||
void main(void)
|
||||
{
|
||||
vec4 col = texture(Albedo, uv);
|
||||
#ifdef Use_Bindless_Texture
|
||||
#ifdef SRGBBindlessFix
|
||||
col.xyz = pow(col.xyz, vec3(2.2));
|
||||
#endif
|
||||
#endif
|
||||
if (col.a * color.a < 0.5) discard;
|
||||
|
||||
#if defined(sRGB_Framebuffer_Usable) || defined(Advanced_Lighting_Enabled)
|
||||
col.xyz *= pow(color.xyz, vec3(2.2));
|
||||
#else
|
||||
col.xyz *= color.xyz;
|
||||
#endif
|
||||
|
||||
float mask = texture(colorization_mask, uv).a;
|
||||
if (color_change.x > 0.0)
|
||||
{
|
||||
vec3 old_hsv = rgbToHsv(col.rgb);
|
||||
float mask_step = step(mask, 0.5);
|
||||
vec2 new_xy = mix(vec2(old_hsv.x, old_hsv.y), vec2(color_change.x, max(old_hsv.y, color_change.y)), vec2(mask_step, mask_step));
|
||||
col.xyz = hsvToRgb(vec3(new_xy.x, new_xy.y, old_hsv.z));
|
||||
}
|
||||
|
||||
float specmap = texture(SpecMap, uv).g;
|
||||
float emitmap = texture(SpecMap, uv).b;
|
||||
|
||||
FragColor = vec4(getLightFactor(col.xyz, vec3(1.), specmap, emitmap), 1.);
|
||||
}
|
@ -1,10 +0,0 @@
|
||||
#version 140
|
||||
uniform sampler2D tex;
|
||||
|
||||
in vec2 uv;
|
||||
out vec4 FragColor;
|
||||
|
||||
void main()
|
||||
{
|
||||
FragColor = texture(tex, uv);
|
||||
}
|
@ -1,11 +0,0 @@
|
||||
// Passthrough shader for drawQuad()
|
||||
#version 140
|
||||
|
||||
in vec3 Position;
|
||||
in vec2 Texcoord;
|
||||
out vec2 uv;
|
||||
|
||||
void main() {
|
||||
uv = Texcoord;
|
||||
gl_Position = vec4(Position, 1.);
|
||||
}
|
@ -1,13 +0,0 @@
|
||||
#version 300 es
|
||||
|
||||
precision mediump float;
|
||||
|
||||
uniform sampler2D tex;
|
||||
|
||||
in vec2 uv;
|
||||
out vec4 FragColor;
|
||||
|
||||
void main()
|
||||
{
|
||||
FragColor = texture(tex, uv);
|
||||
}
|
@ -1,12 +0,0 @@
|
||||
#version 300 es
|
||||
|
||||
precision mediump float;
|
||||
|
||||
in vec3 Position;
|
||||
in vec2 Texcoord;
|
||||
out vec2 uv;
|
||||
|
||||
void main() {
|
||||
uv = Texcoord;
|
||||
gl_Position = vec4(Position, 1.);
|
||||
}
|
@ -1,116 +0,0 @@
|
||||
// From http://graphics.cs.aueb.gr/graphics/research_illumination.html
|
||||
// "Real-Time Diffuse Global Illumination Using Radiance Hints"
|
||||
// paper and shader code
|
||||
|
||||
uniform float R_wcs = 10.; // Rmax: maximum sampling distance (in WCS units)
|
||||
uniform vec3 extents;
|
||||
uniform mat4 RHMatrix;
|
||||
uniform mat4 RSMMatrix;
|
||||
uniform sampler2D dtex;
|
||||
uniform sampler2D ctex;
|
||||
uniform sampler2D ntex;
|
||||
uniform vec3 suncol;
|
||||
|
||||
flat in int slice;
|
||||
layout (location = 0) out vec4 SHRed;
|
||||
layout (location = 1) out vec4 SHGreen;
|
||||
layout (location = 2) out vec4 SHBlue;
|
||||
|
||||
vec3 resolution = vec3(32, 16, 32);
|
||||
#define SAMPLES 16
|
||||
|
||||
vec4 SHBasis (const in vec3 dir)
|
||||
{
|
||||
float L00 = 0.282095;
|
||||
float L1_1 = 0.488603 * dir.y;
|
||||
float L10 = 0.488603 * dir.z;
|
||||
float L11 = 0.488603 * dir.x;
|
||||
return vec4 (L11, L1_1, L10, L00);
|
||||
}
|
||||
|
||||
vec4 DirToSh(vec3 dir, float flux)
|
||||
{
|
||||
return SHBasis (dir) * flux;
|
||||
}
|
||||
|
||||
// We need to manually unroll the loop, otherwise Nvidia driver crashes.
|
||||
void loop(in int i,
|
||||
in vec3 RHcenter,in vec3 RHCellSize, in vec2 RHuv, in float RHdepth,
|
||||
inout vec4 SHr, inout vec4 SHg, inout vec4 SHb)
|
||||
{
|
||||
// produce a new sample location on the RSM texture
|
||||
float alpha = (i + .5) / SAMPLES;
|
||||
float theta = 2. * 3.14 * 7. * alpha;
|
||||
float h = alpha;
|
||||
vec2 offset = h * vec2(cos(theta), sin(theta));
|
||||
vec2 uv = RHuv + offset * 0.01;
|
||||
|
||||
// Get world position and normal from the RSM sample
|
||||
float depth = texture(dtex, uv).x;
|
||||
vec4 RSMPos = inverse(RSMMatrix) * (2. * vec4(uv, depth, 1.) - 1.);
|
||||
RSMPos /= RSMPos.w;
|
||||
vec3 RSMAlbedo = texture(ctex, uv).xyz;
|
||||
vec3 normal = normalize(2. * texture(ntex, uv).xyz - 1.);
|
||||
|
||||
// Sampled location inside the RH cell
|
||||
vec3 offset3d = vec3(uv, 0);
|
||||
vec3 SamplePos = RHcenter + .5 * offset3d.xzy * RHCellSize;
|
||||
|
||||
// Normalize distance to RSM sample
|
||||
float dist = distance(SamplePos, RSMPos.xyz) / R_wcs;
|
||||
// Determine the incident direction.
|
||||
// Avoid very close samples (and numerical instability problems)
|
||||
vec3 RSM_to_RH_dir = (dist <= 0.1) ? vec3(0.) : normalize(SamplePos - RSMPos.xyz);
|
||||
float dotprod = max(dot(RSM_to_RH_dir, normal.xyz), 0.);
|
||||
float factor = dotprod / (0.1 + dist * dist);
|
||||
|
||||
vec3 color = RSMAlbedo.rgb * factor * suncol.rgb;
|
||||
|
||||
SHr += DirToSh(RSM_to_RH_dir, color.r);
|
||||
SHg += DirToSh(RSM_to_RH_dir, color.g);
|
||||
SHb += DirToSh(RSM_to_RH_dir, color.b);
|
||||
}
|
||||
|
||||
void main(void)
|
||||
{
|
||||
vec3 normalizedRHCenter = 2. * vec3(gl_FragCoord.xy, slice) / resolution - 1.;
|
||||
vec3 RHcenter = (RHMatrix * vec4(normalizedRHCenter * extents, 1.)).xyz;
|
||||
|
||||
vec4 ShadowProjectedRH = RSMMatrix * vec4(RHcenter, 1.);
|
||||
|
||||
vec3 RHCellSize = extents / resolution;
|
||||
vec2 RHuv = .5 * ShadowProjectedRH.xy / ShadowProjectedRH.w + .5;
|
||||
float RHdepth = .5 * ShadowProjectedRH.z / ShadowProjectedRH.w + .5;
|
||||
|
||||
vec4 SHr = vec4(0.);
|
||||
vec4 SHg = vec4(0.);
|
||||
vec4 SHb = vec4(0.);
|
||||
|
||||
int x = int(gl_FragCoord.x), y = int(gl_FragCoord.y);
|
||||
float phi = 30. * (x ^ y) + 10. * x * y;
|
||||
|
||||
loop(0, RHcenter, RHCellSize, RHuv, RHdepth, SHr, SHg, SHb);
|
||||
loop(1, RHcenter, RHCellSize, RHuv, RHdepth, SHr, SHg, SHb);
|
||||
loop(2, RHcenter, RHCellSize, RHuv, RHdepth, SHr, SHg, SHb);
|
||||
loop(3, RHcenter, RHCellSize, RHuv, RHdepth, SHr, SHg, SHb);
|
||||
loop(4, RHcenter, RHCellSize, RHuv, RHdepth, SHr, SHg, SHb);
|
||||
loop(5, RHcenter, RHCellSize, RHuv, RHdepth, SHr, SHg, SHb);
|
||||
loop(6, RHcenter, RHCellSize, RHuv, RHdepth, SHr, SHg, SHb);
|
||||
loop(7, RHcenter, RHCellSize, RHuv, RHdepth, SHr, SHg, SHb);
|
||||
loop(8, RHcenter, RHCellSize, RHuv, RHdepth, SHr, SHg, SHb);
|
||||
loop(9, RHcenter, RHCellSize, RHuv, RHdepth, SHr, SHg, SHb);
|
||||
loop(10, RHcenter, RHCellSize, RHuv, RHdepth, SHr, SHg, SHb);
|
||||
loop(11, RHcenter, RHCellSize, RHuv, RHdepth, SHr, SHg, SHb);
|
||||
loop(12, RHcenter, RHCellSize, RHuv, RHdepth, SHr, SHg, SHb);
|
||||
loop(13, RHcenter, RHCellSize, RHuv, RHdepth, SHr, SHg, SHb);
|
||||
loop(14, RHcenter, RHCellSize, RHuv, RHdepth, SHr, SHg, SHb);
|
||||
loop(15, RHcenter, RHCellSize, RHuv, RHdepth, SHr, SHg, SHb);
|
||||
|
||||
SHr /= 3.14159 * SAMPLES;
|
||||
SHg /= 3.14159 * SAMPLES;
|
||||
SHb /= 3.14159 * SAMPLES;
|
||||
|
||||
SHRed = SHr;
|
||||
SHGreen = SHg;
|
||||
SHBlue = SHb;
|
||||
}
|
@ -1,14 +0,0 @@
|
||||
uniform sampler3D SHR;
|
||||
uniform sampler3D SHG;
|
||||
uniform sampler3D SHB;
|
||||
|
||||
in vec3 uvw;
|
||||
out vec4 FragColor;
|
||||
|
||||
void main()
|
||||
{
|
||||
float r = texture(SHR, uvw).w;
|
||||
float g = texture(SHG, uvw).w;
|
||||
float b = texture(SHB, uvw).w;
|
||||
FragColor = max(10. * vec4(r, g, b, 1.0), vec4(0.));
|
||||
}
|
@ -1,20 +0,0 @@
|
||||
uniform vec3 extents;
|
||||
|
||||
uniform mat4 RHMatrix;
|
||||
|
||||
ivec3 resolution = ivec3(32, 16, 32);
|
||||
|
||||
out vec3 uvw;
|
||||
|
||||
void main(void)
|
||||
{
|
||||
// Determine the RH center
|
||||
float gx = int(gl_VertexID) & (resolution.x - 1);
|
||||
float gy = int(gl_VertexID >> 5) & (resolution.y - 1);
|
||||
float gz = int(gl_VertexID >> 9) & (resolution.z - 1);
|
||||
uvw = vec3(gx, gy, gz) / vec3(resolution);
|
||||
vec3 WorldPos = (2. * uvw - 1.) * extents;
|
||||
gl_Position = u_projection_view_matrix * RHMatrix * vec4(WorldPos, 1.);
|
||||
gl_PointSize = 500. / gl_Position.w;
|
||||
|
||||
}
|
@ -1,17 +0,0 @@
|
||||
layout(triangles) in;
|
||||
layout(triangle_strip, max_vertices=3) out;
|
||||
|
||||
in int layer[3];
|
||||
flat out int slice;
|
||||
|
||||
void main(void)
|
||||
{
|
||||
gl_Layer = layer[0];
|
||||
for(int i=0; i<3; i++)
|
||||
{
|
||||
slice = layer[0];
|
||||
gl_Position = gl_in[i].gl_Position;
|
||||
EmitVertex();
|
||||
}
|
||||
EndPrimitive();
|
||||
}
|
@ -1,14 +0,0 @@
|
||||
uniform sampler2D tex;
|
||||
|
||||
in vec2 uv;
|
||||
in vec3 nor;
|
||||
in vec4 color;
|
||||
layout (location = 0) out vec3 RSMColor;
|
||||
layout (location = 1) out vec3 RSMNormals;
|
||||
|
||||
void main()
|
||||
{
|
||||
if (texture(tex, uv).a < .5) discard;
|
||||
RSMColor = texture(tex, uv).xyz * color.rgb;
|
||||
RSMNormals = .5 * normalize(nor) + .5;
|
||||
}
|
@ -1,34 +0,0 @@
|
||||
uniform mat4 ModelMatrix;
|
||||
uniform mat4 RSMMatrix;
|
||||
uniform vec2 texture_trans = vec2(0., 0.);
|
||||
|
||||
#ifdef Explicit_Attrib_Location_Usable
|
||||
layout(location = 0) in vec3 Position;
|
||||
layout(location = 1) in vec3 Normal;
|
||||
layout(location = 2) in vec4 Color;
|
||||
layout(location = 3) in vec2 Texcoord;
|
||||
layout(location = 4) in vec2 SecondTexcoord;
|
||||
#else
|
||||
in vec3 Position;
|
||||
in vec3 Normal;
|
||||
in vec4 Color;
|
||||
in vec2 Texcoord;
|
||||
in vec2 SecondTexcoord;
|
||||
#endif
|
||||
|
||||
out vec3 nor;
|
||||
out vec2 uv;
|
||||
out vec2 uv_bis;
|
||||
out vec4 color;
|
||||
|
||||
|
||||
void main(void)
|
||||
{
|
||||
mat4 ModelViewProjectionMatrix = RSMMatrix * ModelMatrix;
|
||||
mat4 TransposeInverseModel = transpose(inverse(ModelMatrix));
|
||||
gl_Position = ModelViewProjectionMatrix * vec4(Position, 1.);
|
||||
nor = (TransposeInverseModel * vec4(Normal, 0.)).xyz;
|
||||
uv = vec2(Texcoord.x + texture_trans.x, Texcoord.y + texture_trans.y);
|
||||
uv_bis = SecondTexcoord;
|
||||
color = Color.zyxw;
|
||||
}
|
@ -1,6 +0,0 @@
|
||||
out vec4 FragColor;
|
||||
|
||||
void main()
|
||||
{
|
||||
FragColor = vec4(exp(32. * (2. * gl_FragCoord.z - 1.) / gl_FragCoord.w));
|
||||
}
|
@ -1,19 +0,0 @@
|
||||
layout(triangles) in;
|
||||
layout(triangle_strip, max_vertices=3) out;
|
||||
|
||||
in vec2 tc[3];
|
||||
in int layerId[3];
|
||||
|
||||
out vec2 uv;
|
||||
|
||||
void main(void)
|
||||
{
|
||||
gl_Layer = layerId[0];
|
||||
for(int i=0; i<3; i++)
|
||||
{
|
||||
uv = tc[i];
|
||||
gl_Position = gl_in[i].gl_Position;
|
||||
EmitVertex();
|
||||
}
|
||||
EndPrimitive();
|
||||
}
|
@ -1,30 +0,0 @@
|
||||
uniform int layer;
|
||||
uniform mat4 ModelMatrix;
|
||||
|
||||
#ifdef Explicit_Attrib_Location_Usable
|
||||
layout(location = 0) in vec3 Position;
|
||||
layout(location = 3) in vec2 Texcoord;
|
||||
#else
|
||||
in vec3 Position;
|
||||
in vec2 Texcoord;
|
||||
#endif
|
||||
|
||||
#ifdef VSLayer
|
||||
out vec2 uv;
|
||||
#else
|
||||
out vec2 tc;
|
||||
out int layerId;
|
||||
#endif
|
||||
|
||||
void main(void)
|
||||
{
|
||||
#ifdef VSLayer
|
||||
gl_Layer = layer;
|
||||
uv = Texcoord;
|
||||
gl_Position = u_shadow_projection_view_matrices[gl_Layer] * ModelMatrix * vec4(Position, 1.);
|
||||
#else
|
||||
layerId = layer;
|
||||
tc = Texcoord;
|
||||
gl_Position = u_shadow_projection_view_matrices[layerId] * ModelMatrix * vec4(Position, 1.);
|
||||
#endif
|
||||
}
|
@ -1,37 +0,0 @@
|
||||
uniform int layer;
|
||||
uniform mat4 ModelMatrix;
|
||||
uniform vec3 windDir;
|
||||
|
||||
#ifdef Explicit_Attrib_Location_Usable
|
||||
layout(location = 0) in vec3 Position;
|
||||
layout(location = 2) in vec4 Color;
|
||||
layout(location = 3) in vec2 Texcoord;
|
||||
#else
|
||||
in vec3 Position;
|
||||
in vec4 Color;
|
||||
in vec2 Texcoord;
|
||||
#endif
|
||||
|
||||
#ifdef VSLayer
|
||||
out vec2 uv;
|
||||
#else
|
||||
out vec2 tc;
|
||||
out int layerId;
|
||||
#endif
|
||||
|
||||
void main(void)
|
||||
{
|
||||
|
||||
vec3 test = sin(windDir * (Position.y* 0.5)) * 0.5;
|
||||
test += cos(windDir) * 0.7;
|
||||
|
||||
#ifdef VSLayer
|
||||
gl_Layer = layer;
|
||||
uv = Texcoord;
|
||||
gl_Position = u_shadow_projection_view_matrices[gl_Layer] * ModelMatrix * vec4(Position + test * Color.r, 1.);
|
||||
#else
|
||||
layerId = layer;
|
||||
tc = Texcoord;
|
||||
gl_Position = u_shadow_projection_view_matrices[layerId] * ModelMatrix * vec4(Position + test * Color.r, 1.);
|
||||
#endif
|
||||
}
|
@ -1,52 +0,0 @@
|
||||
uniform mat4 SunCamMatrix;
|
||||
|
||||
layout (local_size_x = 4) in;
|
||||
|
||||
struct CascadeBoundingBox
|
||||
{
|
||||
int xmin;
|
||||
int xmax;
|
||||
int ymin;
|
||||
int ymax;
|
||||
int zmin;
|
||||
int zmax;
|
||||
};
|
||||
|
||||
layout (std430) buffer BoundingBoxes
|
||||
{
|
||||
CascadeBoundingBox BB[4];
|
||||
};
|
||||
|
||||
layout (std140) buffer NewMatrixData
|
||||
{
|
||||
mat4 ShadowMatrixes[4];
|
||||
};
|
||||
|
||||
mat4 buildProjectionMatrixOrthoLH(float left, float right, float up, float down, float zNear, float zFar)
|
||||
{
|
||||
mat4 M;
|
||||
M[0] = vec4(2. / (right - left), 0., 0., 0.);
|
||||
|
||||
M[1] = vec4(0., 2. / (up - down), 0., 0.);
|
||||
|
||||
M[2] = vec4(0., 0., 1. / (zFar - zNear), 0.);
|
||||
|
||||
M[3].x = - (right + left) / (right - left);
|
||||
M[3].y = - (up + down) / (up - down);
|
||||
M[3].z = zNear / (zNear - zFar);
|
||||
M[3].w = 1.;
|
||||
|
||||
return M;
|
||||
}
|
||||
|
||||
void main()
|
||||
{
|
||||
if (gl_LocalInvocationIndex > 3)
|
||||
return;
|
||||
|
||||
ShadowMatrixes[gl_LocalInvocationIndex] = buildProjectionMatrixOrthoLH(
|
||||
BB[gl_LocalInvocationIndex].xmin / 4. - 1., BB[gl_LocalInvocationIndex].xmax / 4. + 1.,
|
||||
BB[gl_LocalInvocationIndex].ymax / 4. + 1., BB[gl_LocalInvocationIndex].ymin / 4. - 1.,
|
||||
BB[gl_LocalInvocationIndex].zmin / 4. - 100., BB[gl_LocalInvocationIndex].zmax / 4. + 1.) * SunCamMatrix;
|
||||
}
|
||||
|
@ -1,16 +0,0 @@
|
||||
#ifdef Use_Bindless_Texture
|
||||
layout(bindless_sampler) uniform sampler2D tex;
|
||||
#else
|
||||
uniform sampler2D tex;
|
||||
#endif
|
||||
|
||||
in vec2 uv;
|
||||
in vec4 color;
|
||||
out vec4 FragColor;
|
||||
|
||||
void main(void)
|
||||
{
|
||||
vec4 col = texture(tex, uv);
|
||||
if (col.a < 0.5) discard;
|
||||
FragColor = vec4(exp(32. * (2. * gl_FragCoord.z - 1.) / gl_FragCoord.w));
|
||||
}
|
@ -1,93 +0,0 @@
|
||||
#ifdef GL_ES
|
||||
uniform mat4 ModelMatrix;
|
||||
uniform mat4 InverseModelMatrix;
|
||||
uniform vec2 texture_trans;
|
||||
#else
|
||||
uniform mat4 ModelMatrix =
|
||||
mat4(1., 0., 0., 0.,
|
||||
0., 1., 0., 0.,
|
||||
0., 0., 1., 0.,
|
||||
0., 0., 0., 1.);
|
||||
uniform mat4 InverseModelMatrix =
|
||||
mat4(1., 0., 0., 0.,
|
||||
0., 1., 0., 0.,
|
||||
0., 0., 1., 0.,
|
||||
0., 0., 0., 1.);
|
||||
|
||||
uniform vec2 texture_trans = vec2(0., 0.);
|
||||
#endif
|
||||
uniform int skinning_offset;
|
||||
#ifdef GL_ES
|
||||
uniform sampler2D skinning_tex;
|
||||
#else
|
||||
uniform samplerBuffer skinning_tex;
|
||||
#endif
|
||||
|
||||
#ifdef Explicit_Attrib_Location_Usable
|
||||
layout(location = 0) in vec3 Position;
|
||||
layout(location = 1) in vec3 Normal;
|
||||
layout(location = 2) in vec4 Color;
|
||||
layout(location = 3) in vec4 Data1;
|
||||
layout(location = 4) in vec4 Data2;
|
||||
layout(location = 5) in ivec4 Joint;
|
||||
layout(location = 6) in vec4 Weight;
|
||||
#else
|
||||
in vec3 Position;
|
||||
in vec3 Normal;
|
||||
in vec4 Color;
|
||||
in vec4 Data1;
|
||||
in vec4 Data2;
|
||||
in ivec4 Joint;
|
||||
in vec4 Weight;
|
||||
#endif
|
||||
|
||||
out vec3 nor;
|
||||
out vec3 tangent;
|
||||
out vec3 bitangent;
|
||||
out vec2 uv;
|
||||
out vec4 color;
|
||||
|
||||
#stk_include "utils/getworldmatrix.vert"
|
||||
|
||||
void main(void)
|
||||
{
|
||||
mat4 TransposeInverseModelView = transpose(InverseModelMatrix * u_inverse_view_matrix);
|
||||
vec4 idle_position = vec4(Position, 1.);
|
||||
vec4 idle_normal = vec4(Normal, 0.);
|
||||
vec4 idle_tangent = vec4(Data1.z, Data1.w, Data2.x, 0.);
|
||||
vec4 idle_bitangent = vec4(Data2.y, Data2.z, Data2.w, 0.);
|
||||
vec4 skinned_position = vec4(0.);
|
||||
vec4 skinned_normal = vec4(0.);
|
||||
vec4 skinned_tangent = vec4(0.);
|
||||
vec4 skinned_bitangent = vec4(0.);
|
||||
|
||||
for (int i = 0; i < 4; i++)
|
||||
{
|
||||
#ifdef GL_ES
|
||||
mat4 joint_matrix = mat4(
|
||||
texelFetch(skinning_tex, ivec2(0, clamp(Joint[i] + skinning_offset, 0, MAX_BONES)), 0),
|
||||
texelFetch(skinning_tex, ivec2(1, clamp(Joint[i] + skinning_offset, 0, MAX_BONES)), 0),
|
||||
texelFetch(skinning_tex, ivec2(2, clamp(Joint[i] + skinning_offset, 0, MAX_BONES)), 0),
|
||||
texelFetch(skinning_tex, ivec2(3, clamp(Joint[i] + skinning_offset, 0, MAX_BONES)), 0));
|
||||
#else
|
||||
mat4 joint_matrix = mat4(
|
||||
texelFetch(skinning_tex, clamp(Joint[i] + skinning_offset, 0, MAX_BONES) * 4),
|
||||
texelFetch(skinning_tex, clamp(Joint[i] + skinning_offset, 0, MAX_BONES) * 4 + 1),
|
||||
texelFetch(skinning_tex, clamp(Joint[i] + skinning_offset, 0, MAX_BONES) * 4 + 2),
|
||||
texelFetch(skinning_tex, clamp(Joint[i] + skinning_offset, 0, MAX_BONES) * 4 + 3));
|
||||
#endif
|
||||
skinned_position += Weight[i] * joint_matrix * idle_position;
|
||||
skinned_normal += Weight[i] * joint_matrix * idle_normal;
|
||||
skinned_tangent += Weight[i] * joint_matrix * idle_tangent;
|
||||
skinned_bitangent += Weight[i] * joint_matrix * idle_bitangent;
|
||||
}
|
||||
|
||||
gl_Position = u_projection_view_matrix * ModelMatrix * skinned_position;
|
||||
// Keep orthogonality
|
||||
nor = (TransposeInverseModelView * skinned_normal).xyz;
|
||||
// Keep direction
|
||||
tangent = (u_view_matrix * ModelMatrix * skinned_tangent).xyz;
|
||||
bitangent = (u_view_matrix * ModelMatrix * skinned_bitangent).xyz;
|
||||
uv = vec2(Data1.x + texture_trans.x, Data1.y + texture_trans.y);
|
||||
color = Color.zyxw;
|
||||
}
|
@ -1,61 +0,0 @@
|
||||
uniform mat4 ModelMatrix;
|
||||
uniform int skinning_offset;
|
||||
uniform int layer;
|
||||
#ifdef GL_ES
|
||||
uniform sampler2D skinning_tex;
|
||||
#else
|
||||
uniform samplerBuffer skinning_tex;
|
||||
#endif
|
||||
|
||||
#ifdef Explicit_Attrib_Location_Usable
|
||||
layout(location = 0) in vec3 Position;
|
||||
layout(location = 3) in vec4 Data1;
|
||||
layout(location = 5) in ivec4 Joint;
|
||||
layout(location = 6) in vec4 Weight;
|
||||
#else
|
||||
in vec3 Position;
|
||||
in vec4 Data1;
|
||||
in ivec4 Joint;
|
||||
in vec4 Weight;
|
||||
#endif
|
||||
|
||||
#ifdef VSLayer
|
||||
out vec2 uv;
|
||||
#else
|
||||
out vec2 tc;
|
||||
out int layerId;
|
||||
#endif
|
||||
|
||||
void main(void)
|
||||
{
|
||||
vec4 idle_position = vec4(Position, 1.);
|
||||
vec4 skinned_position = vec4(0.);
|
||||
|
||||
for (int i = 0; i < 4; i++)
|
||||
{
|
||||
#ifdef GL_ES
|
||||
mat4 joint_matrix = mat4(
|
||||
texelFetch(skinning_tex, ivec2(0, clamp(Joint[i] + skinning_offset, 0, MAX_BONES)), 0),
|
||||
texelFetch(skinning_tex, ivec2(1, clamp(Joint[i] + skinning_offset, 0, MAX_BONES)), 0),
|
||||
texelFetch(skinning_tex, ivec2(2, clamp(Joint[i] + skinning_offset, 0, MAX_BONES)), 0),
|
||||
texelFetch(skinning_tex, ivec2(3, clamp(Joint[i] + skinning_offset, 0, MAX_BONES)), 0));
|
||||
#else
|
||||
mat4 joint_matrix = mat4(
|
||||
texelFetch(skinning_tex, clamp(Joint[i] + skinning_offset, 0, MAX_BONES) * 4),
|
||||
texelFetch(skinning_tex, clamp(Joint[i] + skinning_offset, 0, MAX_BONES) * 4 + 1),
|
||||
texelFetch(skinning_tex, clamp(Joint[i] + skinning_offset, 0, MAX_BONES) * 4 + 2),
|
||||
texelFetch(skinning_tex, clamp(Joint[i] + skinning_offset, 0, MAX_BONES) * 4 + 3));
|
||||
#endif
|
||||
skinned_position += Weight[i] * joint_matrix * idle_position;
|
||||
}
|
||||
|
||||
#ifdef VSLayer
|
||||
gl_Layer = layer;
|
||||
uv = Data1.xy;
|
||||
gl_Position = u_shadow_projection_view_matrices[gl_Layer] * ModelMatrix * skinned_position;
|
||||
#else
|
||||
layerId = layer;
|
||||
tc = Data1.xy;
|
||||
gl_Position = u_shadow_projection_view_matrices[layerId] * ModelMatrix * skinned_position;
|
||||
#endif
|
||||
}
|
@ -1,18 +0,0 @@
|
||||
in vec2 Position;
|
||||
in vec2 Texcoord;
|
||||
|
||||
#ifndef VSLayer
|
||||
out int layer;
|
||||
#else
|
||||
flat out int slice;
|
||||
#endif
|
||||
|
||||
void main() {
|
||||
#ifdef VSLayer
|
||||
gl_Layer = gl_InstanceID;
|
||||
slice = gl_InstanceID;
|
||||
#else
|
||||
layer = gl_InstanceID;
|
||||
#endif
|
||||
gl_Position = vec4(Position, 0., 1.);
|
||||
}
|
@ -1,11 +0,0 @@
|
||||
uniform int slice;
|
||||
|
||||
in vec2 Position;
|
||||
in vec2 Texcoord;
|
||||
|
||||
out int layer;
|
||||
|
||||
void main() {
|
||||
layer = slice;
|
||||
gl_Position = vec4(Position, 0., 1.);
|
||||
}
|
@ -1,44 +0,0 @@
|
||||
#ifdef Use_Bindless_Texture
|
||||
layout(bindless_sampler) uniform sampler2D tex_layout;
|
||||
layout(bindless_sampler) uniform sampler2D tex_detail0;
|
||||
layout(bindless_sampler) uniform sampler2D tex_detail1;
|
||||
layout(bindless_sampler) uniform sampler2D tex_detail2;
|
||||
layout(bindless_sampler) uniform sampler2D tex_detail3;
|
||||
#else
|
||||
uniform sampler2D tex_layout;
|
||||
uniform sampler2D tex_detail0;
|
||||
uniform sampler2D tex_detail1;
|
||||
uniform sampler2D tex_detail2;
|
||||
uniform sampler2D tex_detail3;
|
||||
#endif
|
||||
|
||||
in vec2 uv;
|
||||
in vec2 uv_bis;
|
||||
out vec4 FragColor;
|
||||
|
||||
#stk_include "utils/getLightFactor.frag"
|
||||
|
||||
void main() {
|
||||
// Splatting part
|
||||
vec4 splatting = texture(tex_layout, uv_bis);
|
||||
vec4 detail0 = texture(tex_detail0, uv);
|
||||
vec4 detail1 = texture(tex_detail1, uv);
|
||||
vec4 detail2 = texture(tex_detail2, uv);
|
||||
vec4 detail3 = texture(tex_detail3, uv);
|
||||
vec4 detail4 = vec4(0.0);
|
||||
#ifdef Use_Bindless_Texture
|
||||
#ifdef SRGBBindlessFix
|
||||
detail0.xyz = pow(detail0.xyz, vec3(2.2));
|
||||
detail1.xyz = pow(detail1.xyz, vec3(2.2));
|
||||
detail2.xyz = pow(detail2.xyz, vec3(2.2));
|
||||
detail3.xyz = pow(detail3.xyz, vec3(2.2));
|
||||
#endif
|
||||
#endif
|
||||
|
||||
vec4 splatted = splatting.r * detail0 +
|
||||
splatting.g * detail1 +
|
||||
splatting.b * detail2 +
|
||||
max(0., (1.0 - splatting.r - splatting.g - splatting.b)) * detail3;
|
||||
|
||||
FragColor = vec4(getLightFactor(splatted.xyz, vec3(1.), 0., 0.), 1.);
|
||||
}
|
@ -1,27 +0,0 @@
|
||||
uniform sampler2D tex_layout;
|
||||
uniform sampler2D tex_detail0;
|
||||
uniform sampler2D tex_detail1;
|
||||
uniform sampler2D tex_detail2;
|
||||
uniform sampler2D tex_detail3;
|
||||
|
||||
in vec2 uv;
|
||||
in vec2 uv_bis;
|
||||
in vec3 nor;
|
||||
layout (location = 0) out vec3 RSMColor;
|
||||
layout (location = 1) out vec3 RSMNormals;
|
||||
|
||||
void main()
|
||||
{
|
||||
vec4 splatting = texture(tex_layout, uv_bis);
|
||||
vec4 detail0 = texture(tex_detail0, uv);
|
||||
vec4 detail1 = texture(tex_detail1, uv);
|
||||
vec4 detail2 = texture(tex_detail2, uv);
|
||||
vec4 detail3 = texture(tex_detail3, uv);
|
||||
|
||||
vec4 splatted = splatting.r * detail0 +
|
||||
splatting.g * detail1 +
|
||||
splatting.b * detail2 +
|
||||
max(0., (1.0 - splatting.r - splatting.g - splatting.b)) * detail3;
|
||||
RSMColor = splatted.rgb;
|
||||
RSMNormals = .5 * normalize(nor) + .5;
|
||||
}
|
@ -1,66 +0,0 @@
|
||||
uniform sampler2D ntex;
|
||||
uniform sampler2D dtex;
|
||||
uniform sampler2DArray shadowtex;
|
||||
|
||||
uniform float split0;
|
||||
uniform float split1;
|
||||
uniform float split2;
|
||||
uniform float splitmax;
|
||||
|
||||
in vec2 uv;
|
||||
#ifdef GL_ES
|
||||
layout (location = 0) out vec4 Diff;
|
||||
layout (location = 1) out vec4 Spec;
|
||||
#else
|
||||
out vec4 Diff;
|
||||
out vec4 Spec;
|
||||
#endif
|
||||
|
||||
#stk_include "utils/decodeNormal.frag"
|
||||
#stk_include "utils/SpecularBRDF.frag"
|
||||
#stk_include "utils/DiffuseBRDF.frag"
|
||||
#stk_include "utils/getPosFromUVDepth.frag"
|
||||
#stk_include "utils/SunMRP.frag"
|
||||
|
||||
float getShadowFactor(vec3 pos, int index)
|
||||
{
|
||||
vec4 shadowcoord = (u_shadow_projection_view_matrices[index] * u_inverse_view_matrix * vec4(pos, 1.0));
|
||||
shadowcoord.xy /= shadowcoord.w;
|
||||
vec2 shadowtexcoord = shadowcoord.xy * 0.5 + 0.5;
|
||||
|
||||
float z = texture(shadowtex, vec3(shadowtexcoord, float(index))).x;
|
||||
float d = shadowcoord.z;
|
||||
return min(pow(exp(-32. * d) * z, 8.), 1.);
|
||||
}
|
||||
|
||||
void main() {
|
||||
vec2 uv = gl_FragCoord.xy / u_screen;
|
||||
float z = texture(dtex, uv).x;
|
||||
vec4 xpos = getPosFromUVDepth(vec3(uv, z), u_inverse_projection_matrix);
|
||||
|
||||
vec3 norm = normalize(DecodeNormal(2. * texture(ntex, uv).xy - 1.));
|
||||
float roughness =texture(ntex, uv).z;
|
||||
vec3 eyedir = -normalize(xpos.xyz);
|
||||
|
||||
vec3 Lightdir = SunMRP(norm, eyedir);
|
||||
float NdotL = clamp(dot(norm, Lightdir), 0., 1.);
|
||||
|
||||
vec3 Specular = SpecularBRDF(norm, eyedir, Lightdir, vec3(1.), roughness);
|
||||
vec3 Diffuse = DiffuseBRDF(norm, eyedir, Lightdir, vec3(1.), roughness);
|
||||
|
||||
// Shadows
|
||||
float factor;
|
||||
if (xpos.z < split0)
|
||||
factor = getShadowFactor(xpos.xyz, 0);
|
||||
else if (xpos.z < split1)
|
||||
factor = getShadowFactor(xpos.xyz, 1);
|
||||
else if (xpos.z < split2)
|
||||
factor = getShadowFactor(xpos.xyz, 2);
|
||||
else if (xpos.z < splitmax)
|
||||
factor = getShadowFactor(xpos.xyz, 3);
|
||||
else
|
||||
factor = 1.;
|
||||
|
||||
Diff = vec4(factor * NdotL * Diffuse * sun_col, 1.);
|
||||
Spec = vec4(factor * NdotL * Specular * sun_col, 1.);
|
||||
}
|
@ -1,6 +0,0 @@
|
||||
out vec4 FragColor;
|
||||
|
||||
void main(void)
|
||||
{
|
||||
FragColor = vec4(1.0);
|
||||
}
|
@ -1,44 +0,0 @@
|
||||
#ifdef Use_Bindless_Texture
|
||||
layout(bindless_sampler) uniform sampler2D tex;
|
||||
#else
|
||||
uniform sampler2D tex;
|
||||
#endif
|
||||
|
||||
|
||||
uniform float fogmax;
|
||||
uniform float startH;
|
||||
uniform float endH;
|
||||
uniform float start;
|
||||
uniform float end;
|
||||
uniform vec3 col;
|
||||
|
||||
in vec2 uv;
|
||||
in vec4 color;
|
||||
out vec4 FragColor;
|
||||
|
||||
|
||||
void main()
|
||||
{
|
||||
vec4 diffusecolor = texture(tex, uv);
|
||||
#ifdef Use_Bindless_Texture
|
||||
#ifdef SRGBBindlessFix
|
||||
diffusecolor.xyz = pow(diffusecolor.xyz, vec3(2.2));
|
||||
#endif
|
||||
#endif
|
||||
diffusecolor.xyz *= pow(color.xyz, vec3(2.2));
|
||||
diffusecolor.a *= color.a;
|
||||
vec3 tmp = vec3(gl_FragCoord.xy / u_screen, gl_FragCoord.z);
|
||||
tmp = 2. * tmp - 1.;
|
||||
|
||||
vec4 xpos = vec4(tmp, 1.0);
|
||||
xpos = u_inverse_projection_matrix * xpos;
|
||||
xpos.xyz /= xpos.w;
|
||||
|
||||
float dist = length(xpos.xyz);
|
||||
float fog = smoothstep(start, end, dist);
|
||||
|
||||
fog = min(fog, fogmax);
|
||||
|
||||
vec4 finalcolor = vec4(col, 0.) * fog + diffusecolor *(1. - fog);
|
||||
FragColor = vec4(finalcolor.rgb * finalcolor.a, finalcolor.a);
|
||||
}
|
@ -1,11 +0,0 @@
|
||||
|
||||
in vec4 color;
|
||||
out vec4 FragColor;
|
||||
|
||||
#stk_include "utils/getLightFactor.frag"
|
||||
|
||||
void main(void)
|
||||
{
|
||||
vec3 LightFactor = getLightFactor(1.);
|
||||
FragColor = vec4(color.xyz * LightFactor, 1.);
|
||||
}
|
@ -1,50 +0,0 @@
|
||||
const float DEG2GRAD = 3.14 / 180.;
|
||||
|
||||
|
||||
mat4 getMatrixFromRotation(vec3 rotation)
|
||||
{
|
||||
|
||||
// from irrlicht
|
||||
float cr = cos(DEG2GRAD * rotation.x );
|
||||
float sr = sin(DEG2GRAD * rotation.x );
|
||||
float cp = cos(DEG2GRAD * rotation.y );
|
||||
float sp = sin(DEG2GRAD * rotation.y );
|
||||
float cy = cos(DEG2GRAD * rotation.z );
|
||||
float sy = sin(DEG2GRAD * rotation.z );
|
||||
|
||||
float srsp = sr*sp;
|
||||
float crsp = cr*sp;
|
||||
|
||||
return transpose(mat4(
|
||||
vec4(cp * cy, srsp * cy - cr * sy, crsp * cy + sr * sy, 0.),
|
||||
vec4(cp * sy, srsp * sy + cr * cy, crsp * sy - sr * cy, 0.),
|
||||
vec4(-sp, sr * cp, cr * cp, 0.),
|
||||
vec4(0., 0., 0., 1.)));
|
||||
}
|
||||
|
||||
mat4 getScaleMatrix(vec3 scale)
|
||||
{
|
||||
mat4 result = mat4(
|
||||
vec4(scale.x, 0., 0., 0.),
|
||||
vec4(0., scale.y, 0., 0.),
|
||||
vec4(0., 0., scale.z, 0.),
|
||||
vec4(0., 0., 0., 1.)
|
||||
);
|
||||
return result;
|
||||
}
|
||||
|
||||
mat4 getWorldMatrix(vec3 translation, vec3 rotation, vec3 scale)
|
||||
{
|
||||
mat4 result = getMatrixFromRotation(rotation);
|
||||
// translation
|
||||
result[3].xyz += translation;
|
||||
return result * getScaleMatrix(scale);
|
||||
}
|
||||
|
||||
mat4 getInverseWorldMatrix(vec3 translation, vec3 rotation, vec3 scale)
|
||||
{
|
||||
mat4 result = transpose(getMatrixFromRotation(rotation));
|
||||
// FIXME: it's wrong but the fourth column is not used
|
||||
// result[3].xyz -= translation;
|
||||
return getScaleMatrix(1. / scale) * result;
|
||||
}
|
@ -1,45 +0,0 @@
|
||||
#ifdef Use_Bindless_Texture
|
||||
layout(bindless_sampler) uniform sampler2D tex;
|
||||
#else
|
||||
uniform sampler2D tex;
|
||||
#endif
|
||||
|
||||
|
||||
uniform float fogmax;
|
||||
uniform float startH;
|
||||
uniform float endH;
|
||||
uniform float start;
|
||||
uniform float end;
|
||||
uniform vec3 col;
|
||||
|
||||
in vec2 uv;
|
||||
in vec4 color;
|
||||
out vec4 FragColor;
|
||||
|
||||
|
||||
void main()
|
||||
{
|
||||
vec4 diffusecolor = texture(tex, uv);
|
||||
#ifdef Use_Bindless_Texture
|
||||
#ifdef SRGBBindlessFix
|
||||
diffusecolor.xyz = pow(diffusecolor.xyz, vec3(2.2));
|
||||
#endif
|
||||
#endif
|
||||
diffusecolor.xyz *= pow(color.xyz, vec3(2.2));
|
||||
diffusecolor.a *= color.a;
|
||||
vec3 tmp = vec3(gl_FragCoord.xy / u_screen, gl_FragCoord.z);
|
||||
tmp = 2. * tmp - 1.;
|
||||
|
||||
vec4 xpos = vec4(tmp, 1.0);
|
||||
xpos = u_inverse_projection_matrix * xpos;
|
||||
xpos.xyz /= xpos.w;
|
||||
|
||||
float dist = length(xpos.xyz);
|
||||
float fog = smoothstep(start, end, dist);
|
||||
|
||||
fog = min(fog, fogmax);
|
||||
|
||||
vec4 finalcolor = vec4(col, 0.) * fog + diffusecolor *(1. - fog);
|
||||
FragColor = vec4(finalcolor.rgb * finalcolor.a, finalcolor.a);
|
||||
//FragColor = vec4(1.0, 0.0, 0.0, finalcolor.a);
|
||||
}
|
@ -1,6 +1,6 @@
|
||||
out vec4 FragColor;
|
||||
|
||||
void main()
|
||||
void main(void)
|
||||
{
|
||||
FragColor = vec4(1.0);
|
||||
}
|
||||
|
@ -62,7 +62,6 @@ public:
|
||||
unsigned getGLSLVersion() const;
|
||||
|
||||
// Needs special handle ?
|
||||
bool needRHWorkaround() const;
|
||||
bool needsVertexIdWorkaround() const;
|
||||
|
||||
// Extension is available and safe to use
|
||||
|
@ -226,40 +226,6 @@ public:
|
||||
} // render
|
||||
}; // ShadowedSunLightShaderPCF
|
||||
|
||||
// ============================================================================
|
||||
class ShadowedSunLightShaderESM : public TextureShader<ShadowedSunLightShaderESM,
|
||||
3, float, float, float,
|
||||
float>
|
||||
{
|
||||
public:
|
||||
ShadowedSunLightShaderESM()
|
||||
{
|
||||
loadProgram(OBJECT, GL_VERTEX_SHADER, "screenquad.vert",
|
||||
GL_FRAGMENT_SHADER, "sunlightshadowesm.frag");
|
||||
|
||||
// Use 8 to circumvent a catalyst bug when binding sampler
|
||||
assignSamplerNames(0, "ntex", ST_NEAREST_FILTERED,
|
||||
1, "dtex", ST_NEAREST_FILTERED,
|
||||
8, "shadowtex", ST_TRILINEAR_CLAMPED_ARRAY2D);
|
||||
|
||||
assignUniforms("split0", "split1", "split2", "splitmax");
|
||||
} // ShadowedSunLightShaderESM
|
||||
// ------------------------------------------------------------------------
|
||||
void render(GLuint normal_depth_texture,
|
||||
GLuint depth_stencil_texture,
|
||||
const FrameBuffer& shadow_framebuffer)
|
||||
{
|
||||
setTextureUnits(normal_depth_texture,
|
||||
depth_stencil_texture,
|
||||
shadow_framebuffer.getRTT()[0]);
|
||||
drawFullScreenEffect(ShadowMatrices::m_shadow_split[1],
|
||||
ShadowMatrices::m_shadow_split[2],
|
||||
ShadowMatrices::m_shadow_split[3],
|
||||
ShadowMatrices::m_shadow_split[4]);
|
||||
} // render
|
||||
}; // ShadowedSunLightShaderESM
|
||||
|
||||
|
||||
// ============================================================================
|
||||
class SunLightShader : public TextureShader<SunLightShader, 2,
|
||||
core::vector3df, video::SColorf>
|
||||
|
@ -459,25 +459,6 @@ public:
|
||||
} // render
|
||||
}; // DepthOfFieldShader
|
||||
|
||||
// ============================================================================
|
||||
class RHDebug : public Shader<RHDebug, core::matrix4, core::vector3df>
|
||||
{
|
||||
public:
|
||||
GLuint m_tu_shr, m_tu_shg, m_tu_shb;
|
||||
|
||||
RHDebug()
|
||||
{
|
||||
loadProgram(OBJECT, GL_VERTEX_SHADER, "rhdebug.vert",
|
||||
GL_FRAGMENT_SHADER, "rhdebug.frag");
|
||||
assignUniforms("rh_matrix", "extents");
|
||||
m_tu_shr = 0;
|
||||
m_tu_shg = 1;
|
||||
m_tu_shb = 2;
|
||||
assignTextureUnit(m_tu_shr, "SHR", m_tu_shg, "SHG",
|
||||
m_tu_shb, "SHB");
|
||||
} // RHDebug
|
||||
}; // RHDebug
|
||||
|
||||
// ============================================================================
|
||||
class PassThroughShader : public TextureShader<PassThroughShader, 1, int, int>
|
||||
{
|
||||
@ -868,26 +849,6 @@ void PostProcessing::renderBloom(GLuint in)
|
||||
BloomShader::getInstance()->render(in);
|
||||
} // renderBloom
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
void PostProcessing::renderRHDebug(unsigned SHR, unsigned SHG, unsigned SHB,
|
||||
const core::matrix4 &rh_matrix,
|
||||
const core::vector3df &rh_extend)
|
||||
{
|
||||
#if !defined(USE_GLES2)
|
||||
glEnable(GL_PROGRAM_POINT_SIZE);
|
||||
RHDebug::getInstance()->use();
|
||||
glActiveTexture(GL_TEXTURE0 + RHDebug::getInstance()->m_tu_shr);
|
||||
glBindTexture(GL_TEXTURE_3D, SHR);
|
||||
glActiveTexture(GL_TEXTURE0 + RHDebug::getInstance()->m_tu_shg);
|
||||
glBindTexture(GL_TEXTURE_3D, SHG);
|
||||
glActiveTexture(GL_TEXTURE0 + RHDebug::getInstance()->m_tu_shb);
|
||||
glBindTexture(GL_TEXTURE_3D, SHB);
|
||||
RHDebug::getInstance()->setUniforms(rh_matrix, rh_extend);
|
||||
glDrawArrays(GL_POINTS, 0, 32 * 16 * 32);
|
||||
glDisable(GL_PROGRAM_POINT_SIZE);
|
||||
#endif
|
||||
} // renderRHDebug
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
static std::vector<float> getGaussianWeight(float sigma, size_t count)
|
||||
{
|
||||
|
@ -70,9 +70,6 @@ public:
|
||||
void renderSSAO(const FrameBuffer& linear_depth_framebuffer,
|
||||
const FrameBuffer& ssao_framebuffer,
|
||||
GLuint depth_stencil_texture);
|
||||
void renderRHDebug(unsigned SHR, unsigned SHG, unsigned SHB,
|
||||
const core::matrix4 &rh_matrix,
|
||||
const core::vector3df &rh_extend);
|
||||
/** Blur the in texture */
|
||||
void renderGaussian3Blur(const FrameBuffer &in_fbo, const FrameBuffer &auxiliary) const;
|
||||
|
||||
|
@ -41,7 +41,7 @@ int ShaderBase::loadTFBProgram(const std::string &shader_name,
|
||||
m_program = glCreateProgram();
|
||||
loadAndAttachShader(GL_VERTEX_SHADER, shader_name);
|
||||
#ifdef USE_GLES2
|
||||
loadAndAttachShader(GL_FRAGMENT_SHADER, "tfb_dummy.frag");
|
||||
loadAndAttachShader(GL_FRAGMENT_SHADER, "white.frag");
|
||||
#endif
|
||||
|
||||
glTransformFeedbackVaryings(m_program, varying_count, varyings,
|
||||
|
@ -291,45 +291,6 @@ void ShadowMatrices::computeMatrixesAndCameras(scene::ICameraSceneNode *const ca
|
||||
irr_driver->getVideoDriver()->getTransform(video::ETS_PROJECTION)
|
||||
* irr_driver->getVideoDriver()->getTransform(video::ETS_VIEW) );
|
||||
}
|
||||
|
||||
// Rsm Matrix and camera
|
||||
if (!m_rsm_matrix_initialized && track->getPtrTriangleMesh())
|
||||
{
|
||||
// Compute track extent
|
||||
Vec3 vmin, vmax;
|
||||
track->getTriangleMesh().getCollisionShape()
|
||||
.getAabb(btTransform::getIdentity(), vmin, vmax);
|
||||
core::aabbox3df trackbox(vmin.toIrrVector(), vmax.toIrrVector() -
|
||||
core::vector3df(0, 30, 0));
|
||||
|
||||
if (trackbox.MinEdge.X != trackbox.MaxEdge.X &&
|
||||
trackbox.MinEdge.Y != trackbox.MaxEdge.Y &&
|
||||
// Cover the case where sun_cam_view_matrix is null
|
||||
sun_cam_view_matrix.getScale() != core::vector3df(0., 0., 0.))
|
||||
{
|
||||
sun_cam_view_matrix.transformBoxEx(trackbox);
|
||||
core::matrix4 tmp_matrix;
|
||||
tmp_matrix.buildProjectionMatrixOrthoLH(trackbox.MinEdge.X,
|
||||
trackbox.MaxEdge.X,
|
||||
trackbox.MaxEdge.Y,
|
||||
trackbox.MinEdge.Y,
|
||||
30, trackbox.MaxEdge.Z);
|
||||
m_sun_cam->setProjectionMatrix(tmp_matrix, true);
|
||||
m_sun_cam->render();
|
||||
}
|
||||
m_rsm_matrix = irr_driver->getVideoDriver()->getTransform(video::ETS_PROJECTION)
|
||||
* irr_driver->getVideoDriver()->getTransform(video::ETS_VIEW);
|
||||
m_rsm_matrix_initialized = true;
|
||||
m_rsm_map_available = false;
|
||||
}
|
||||
m_rh_extend = core::vector3df(128, 64, 128);
|
||||
core::vector3df campos = camnode->getAbsolutePosition();
|
||||
core::vector3df translation(8 * floor(campos.X / 8),
|
||||
8 * floor(campos.Y / 8),
|
||||
8 * floor(campos.Z / 8));
|
||||
m_rh_matrix.setTranslation(translation);
|
||||
|
||||
|
||||
assert(m_sun_ortho_matrices.size() == 4);
|
||||
// reset normal camera
|
||||
camnode->setNearValue(oldnear);
|
||||
|
@ -50,8 +50,6 @@ private:
|
||||
bool m_rsm_matrix_initialized;
|
||||
float m_shadows_cam[4][24];
|
||||
bool m_rsm_map_available;
|
||||
core::vector3df m_rh_extend;
|
||||
core::matrix4 m_rh_matrix;
|
||||
float m_mat_ubo[16 * 9 + 2];
|
||||
|
||||
core::matrix4 getTighestFitOrthoProj(const core::matrix4 &transform,
|
||||
@ -81,21 +79,11 @@ public:
|
||||
// ------------------------------------------------------------------------
|
||||
scene::ICameraSceneNode* getSunCam() { return m_sun_cam; }
|
||||
// ------------------------------------------------------------------------
|
||||
const core::matrix4& getRHMatrix() const { return m_rh_matrix; }
|
||||
// ------------------------------------------------------------------------
|
||||
const core::vector3df& getRHExtend() const { return m_rh_extend; }
|
||||
// ------------------------------------------------------------------------
|
||||
const core::matrix4& getRSMMatrix() const { return m_rsm_matrix; }
|
||||
// ------------------------------------------------------------------------
|
||||
std::vector<core::matrix4>& getSunOrthoMatrices()
|
||||
{
|
||||
return m_sun_ortho_matrices;
|
||||
}
|
||||
// ------------------------------------------------------------------------
|
||||
void setRSMMapAvail(bool b) { m_rsm_map_available = b; }
|
||||
// ------------------------------------------------------------------------
|
||||
bool isRSMMapAvail() const { return m_rsm_map_available; }
|
||||
// ------------------------------------------------------------------------
|
||||
const std::pair<float, float>* getShadowScales() const
|
||||
{
|
||||
return m_shadow_scales;
|
||||
|
@ -24,16 +24,12 @@
|
||||
|
||||
#include "irrString.h"
|
||||
#include "ITexture.h"
|
||||
#include <pthread.h>
|
||||
|
||||
#include <cassert>
|
||||
#include <string>
|
||||
#include <queue>
|
||||
#include <unordered_map>
|
||||
#include <vector>
|
||||
|
||||
class STKTexture;
|
||||
class ThreadedTexLoader;
|
||||
namespace irr
|
||||
{
|
||||
namespace video { class SColor; }
|
||||
|
Loading…
x
Reference in New Issue
Block a user