1
0
Fork 0

WS30 HDR: Use interface blocks

This commit is contained in:
Stuart Buchanan 2023-05-08 19:44:37 +01:00
parent 53866c24b1
commit ea982e075c

View file

@ -1,7 +1,10 @@
#version 330 core
in vec3 vN;
in vec2 texcoord;
in VS_OUT {
vec2 texcoord;
vec2 orthophoto_texcoord;
vec3 vertex_normal;
} fs_in;
uniform sampler2D landclass;
uniform sampler2DArray atlas;
@ -35,12 +38,12 @@ void main()
vec4 specular = vec4(0.1, 0.1, 0.1, 1.0);
if (fg_photoScenery) {
texel = texture(landclass, vec2(texcoord.s, 1.0 - texcoord.t)).rgb;
texel = texture(landclass, vec2(fs_in.texcoord.s, 1.0 - fs_in.texcoord.t)).rgb;
} else {
// The Landclass for this particular fragment. This can be used to
// index into the atlas textures.
int lc = int(texture2D(landclass, texcoord).g * 255.0 + 0.5);
int lc = int(texture2D(landclass, fs_in.texcoord).g * 255.0 + 0.5);
uint tex1 = uint(fg_textureLookup1[lc].r * 255.0 + 0.5);
//color = ambientArray[lc] + diffuseArray[lc] * NdotL * gl_LightSource[0].diffuse;
@ -49,14 +52,14 @@ void main()
// Different textures have different have different dimensions.
vec2 atlas_dimensions = fg_dimensionsArray[lc].st;
vec2 atlas_scale = vec2(fg_tileWidth / atlas_dimensions.s, fg_tileHeight / atlas_dimensions.t );
vec2 st = atlas_scale * texcoord;
vec2 st = atlas_scale * fs_in.texcoord;
// Rotate texture using the perlin texture as a mask to reduce tiling
if (step(0.5, texture(perlin, atlas_scale * texcoord / 8.0).r) == 1.0) {
st = vec2(atlas_scale.s * texcoord.t, atlas_scale.t * texcoord);
if (step(0.5, texture(perlin, atlas_scale * fs_in.texcoord / 8.0).r) == 1.0) {
st = vec2(atlas_scale.s * fs_in.texcoord.t, atlas_scale.t * fs_in.texcoord);
}
if (step(0.5, texture(perlin, - atlas_scale * texcoord / 16.0).r) == 1.0) {
if (step(0.5, texture(perlin, - atlas_scale * fs_in.texcoord / 16.0).r) == 1.0) {
st = -st;
}
@ -65,6 +68,7 @@ void main()
vec3 color = eotf_inverse_sRGB(texel);
vec3 N = normalize(fs_in.vertex_normal);
gbuffer_pack(vN, color, TERRAIN_METALLIC, TERRAIN_ROUGHNESS, 1.0, vec3(0.0), 3u);
gbuffer_pack(N, color, TERRAIN_METALLIC, TERRAIN_ROUGHNESS, 1.0, vec3(0.0), 3u);
}