mirror of
https://gitlab.com/veloren/veloren.git
synced 2024-08-30 18:12:32 +00:00
Fix dx12 shader issues
This commit is contained in:
parent
97359042db
commit
f09f515db2
@ -34,7 +34,7 @@ vec4 cloud_at(vec3 pos, float dist, out vec3 emission) {
|
|||||||
// Mist sits close to the ground in valleys (TODO: use base_alt to put it closer to water)
|
// Mist sits close to the ground in valleys (TODO: use base_alt to put it closer to water)
|
||||||
float mist_min_alt = 0.5;
|
float mist_min_alt = 0.5;
|
||||||
#if (CLOUD_MODE >= CLOUD_MODE_MEDIUM)
|
#if (CLOUD_MODE >= CLOUD_MODE_MEDIUM)
|
||||||
mist_min_alt = (texture(sampler2D(t_noise, s_noise), pos.xy / 50000.0).x - 0.5) * 1.5 + 0.5;
|
mist_min_alt = (textureLod(sampler2D(t_noise, s_noise), pos.xy / 50000.0, 0).x - 0.5) * 1.5 + 0.5;
|
||||||
#endif
|
#endif
|
||||||
mist_min_alt = view_distance.z * 1.5 * (1.0 + mist_min_alt * 0.5) + alt * 0.5 + 250;
|
mist_min_alt = view_distance.z * 1.5 * (1.0 + mist_min_alt * 0.5) + alt * 0.5 + 250;
|
||||||
const float MIST_FADE_HEIGHT = 1000;
|
const float MIST_FADE_HEIGHT = 1000;
|
||||||
@ -146,9 +146,9 @@ vec4 cloud_at(vec3 pos, float dist, out vec3 emission) {
|
|||||||
#if (CLOUD_MODE >= CLOUD_MODE_MEDIUM)
|
#if (CLOUD_MODE >= CLOUD_MODE_MEDIUM)
|
||||||
emission_alt += (noise_3d(vec3(wind_pos.xy * 0.0005 + cloud_tendency * 0.2, emission_alt * 0.0001 + time_of_day.x * 0.001)) - 0.5) * 1000;
|
emission_alt += (noise_3d(vec3(wind_pos.xy * 0.0005 + cloud_tendency * 0.2, emission_alt * 0.0001 + time_of_day.x * 0.001)) - 0.5) * 1000;
|
||||||
#endif
|
#endif
|
||||||
float tail = (texture(t_noise, wind_pos.xy * 0.00005).x - 0.5) * 4 + (pos.z - emission_alt) * 0.0001;
|
float tail = (textureLod(t_noise, wind_pos.xy * 0.00005).x - 0.5, 0) * 4 + (pos.z - emission_alt) * 0.0001;
|
||||||
vec3 emission_col = vec3(0.8 + tail * 1.5, 0.5 - tail * 0.2, 0.3 + tail * 0.2);
|
vec3 emission_col = vec3(0.8 + tail * 1.5, 0.5 - tail * 0.2, 0.3 + tail * 0.2);
|
||||||
float emission_nz = max(pow(texture(t_noise, wind_pos.xy * 0.000015).x, 8), 0.01) * 0.25 / (10.0 + abs(pos.z - emission_alt) / 80);
|
float emission_nz = max(pow(textureLod(t_noise, wind_pos.xy * 0.000015, 0).x, 8), 0.01) * 0.25 / (10.0 + abs(pos.z - emission_alt) / 80);
|
||||||
emission = emission_col * emission_nz * emission_strength * max(sun_dir.z, 0) * 500000 / (1000.0 + abs(pos.z - emission_alt) * 0.1);
|
emission = emission_col * emission_nz * emission_strength * max(sun_dir.z, 0) * 500000 / (1000.0 + abs(pos.z - emission_alt) * 0.1);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -196,7 +196,7 @@ vec3 get_cloud_color(vec3 surf_color, vec3 dir, vec3 origin, const float time_of
|
|||||||
// improves visual quality for low cloud settings
|
// improves visual quality for low cloud settings
|
||||||
float splay = 1.0;
|
float splay = 1.0;
|
||||||
#if (CLOUD_MODE == CLOUD_MODE_MINIMAL)
|
#if (CLOUD_MODE == CLOUD_MODE_MINIMAL)
|
||||||
splay += (texture(sampler2D(t_noise, s_noise), vec2(atan2(dir.x, dir.y) * 2 / PI, dir.z) * 5.0 - time_of_day * 0.00005).x - 0.5) * 0.025 / (1.0 + pow(dir.z, 2) * 10);
|
splay += (textureLod(sampler2D(t_noise, s_noise), vec2(atan2(dir.x, dir.y) * 2 / PI, dir.z) * 5.0 - time_of_day * 0.00005, 0).x - 0.5) * 0.025 / (1.0 + pow(dir.z, 2) * 10);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* const float RAYLEIGH = 0.25; */
|
/* const float RAYLEIGH = 0.25; */
|
||||||
|
@ -127,7 +127,7 @@ vec2 textureBicubic16(texture2D tex, sampler sampl, vec2 texCoords) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
float alt_at(vec2 pos) {
|
float alt_at(vec2 pos) {
|
||||||
vec4 alt_sample = texture/*textureBicubic16*/(sampler2D(t_alt, s_alt), pos_to_uv(t_alt, s_alt, pos));
|
vec4 alt_sample = textureLod/*textureBicubic16*/(sampler2D(t_alt, s_alt), pos_to_uv(t_alt, s_alt, pos), 0);
|
||||||
return (/*round*/((alt_sample.r / 256.0 + alt_sample.g) * (/*1300.0*//*1278.7266845703125*/view_distance.w)) + /*140.0*/view_distance.z - focus_off.z);
|
return (/*round*/((alt_sample.r / 256.0 + alt_sample.g) * (/*1300.0*//*1278.7266845703125*/view_distance.w)) + /*140.0*/view_distance.z - focus_off.z);
|
||||||
//+ (texture(t_noise, pos * 0.002).x - 0.5) * 64.0;
|
//+ (texture(t_noise, pos * 0.002).x - 0.5) * 64.0;
|
||||||
|
|
||||||
|
@ -32,7 +32,7 @@ float hash_fast(uvec3 q)
|
|||||||
|
|
||||||
// 2D, but using shifted 2D textures
|
// 2D, but using shifted 2D textures
|
||||||
float noise_2d(vec2 pos) {
|
float noise_2d(vec2 pos) {
|
||||||
return texture(sampler2D(t_noise, s_noise), pos).x;
|
return textureLod(sampler2D(t_noise, s_noise), pos, 0).x;
|
||||||
}
|
}
|
||||||
|
|
||||||
// 3D, but using shifted 2D textures
|
// 3D, but using shifted 2D textures
|
||||||
@ -41,7 +41,7 @@ float noise_3d(vec3 pos) {
|
|||||||
uint z = uint(trunc(pos.z));
|
uint z = uint(trunc(pos.z));
|
||||||
vec2 offs0 = vec2(hash_one(z), hash_one(z + 73u));
|
vec2 offs0 = vec2(hash_one(z), hash_one(z + 73u));
|
||||||
vec2 offs1 = vec2(hash_one(z + 1u), hash_one(z + 1u + 73u));
|
vec2 offs1 = vec2(hash_one(z + 1u), hash_one(z + 1u + 73u));
|
||||||
return mix(texture(sampler2D(t_noise, s_noise), pos.xy + offs0).x, texture(sampler2D(t_noise, s_noise), pos.xy + offs1).x, fract(pos.z));
|
return mix(textureLod(sampler2D(t_noise, s_noise), pos.xy + offs0, 0).x, textureLod(sampler2D(t_noise, s_noise), pos.xy + offs1, 0).x, fract(pos.z));
|
||||||
}
|
}
|
||||||
|
|
||||||
// 3D version of `snoise`
|
// 3D version of `snoise`
|
||||||
|
@ -87,7 +87,7 @@ vec2 wind_offset = vec2(time_of_day.x * wind_speed);
|
|||||||
float cloud_scale = view_distance.z / 150.0;
|
float cloud_scale = view_distance.z / 150.0;
|
||||||
|
|
||||||
float cloud_tendency_at(vec2 pos) {
|
float cloud_tendency_at(vec2 pos) {
|
||||||
float nz = texture(sampler2D(t_noise, s_nosie), (pos + wind_offset) / 60000.0 / cloud_scale).x - 0.3;
|
float nz = textureLod(sampler2D(t_noise, s_nosie), (pos + wind_offset) / 60000.0 / cloud_scale, 0).x - 0.3;
|
||||||
nz = pow(clamp(nz, 0, 1), 3);
|
nz = pow(clamp(nz, 0, 1), 3);
|
||||||
return nz;
|
return nz;
|
||||||
}
|
}
|
||||||
|
@ -55,7 +55,7 @@ const float SCALE_FACTOR = pow(SCALE, 1.3) * 0.2;
|
|||||||
|
|
||||||
const int EXTRA_NEG_Z = 32768;
|
const int EXTRA_NEG_Z = 32768;
|
||||||
const int VERT_EXTRA_NEG_Z = 128;
|
const int VERT_EXTRA_NEG_Z = 128;
|
||||||
const int VERT_PAGE_SIZE = 256;
|
const uint VERT_PAGE_SIZE = 256;
|
||||||
|
|
||||||
void main() {
|
void main() {
|
||||||
// Matrix to transform this sprite instance from model space to chunk space
|
// Matrix to transform this sprite instance from model space to chunk space
|
||||||
@ -71,7 +71,8 @@ void main() {
|
|||||||
f_inst_light = vec2(inst_light, inst_glow);
|
f_inst_light = vec2(inst_light, inst_glow);
|
||||||
|
|
||||||
// Index of the vertex data in the 1D vertex texture
|
// Index of the vertex data in the 1D vertex texture
|
||||||
int vertex_index = int(gl_VertexIndex % VERT_PAGE_SIZE + inst_vert_page * VERT_PAGE_SIZE);
|
// TODO: dx12 warning to switch to uint for modulus here (test if it got speedup?)
|
||||||
|
int vertex_index = int(uint(gl_VertexIndex) % VERT_PAGE_SIZE + inst_vert_page * VERT_PAGE_SIZE);
|
||||||
//const int WIDTH = 8192; // TODO: temp
|
//const int WIDTH = 8192; // TODO: temp
|
||||||
//ivec2 tex_coords = ivec2(vertex_index % WIDTH, vertex_index / WIDTH);
|
//ivec2 tex_coords = ivec2(vertex_index % WIDTH, vertex_index / WIDTH);
|
||||||
//uvec2 pos_atlas_pos_norm_ao = texelFetch(usampler2D(t_sprite_verts, s_sprite_verts), tex_coords, 0).xy;
|
//uvec2 pos_atlas_pos_norm_ao = texelFetch(usampler2D(t_sprite_verts, s_sprite_verts), tex_coords, 0).xy;
|
||||||
@ -100,7 +101,21 @@ void main() {
|
|||||||
) * v_pos.z * model_z_scale * SCALE_FACTOR;
|
) * v_pos.z * model_z_scale * SCALE_FACTOR;
|
||||||
|
|
||||||
// Determine normal
|
// Determine normal
|
||||||
vec3 norm = (inst_mat[(v_pos_norm >> 30u) & 3u].xyz);
|
// TODO: do changes here effect perf on vulkan
|
||||||
|
// TODO: dx12 doesn't like dynamic index
|
||||||
|
// TODO: use mix?
|
||||||
|
// Shader@0x000001AABD89BEE0(112,43-53): error X4576: Input array signature parameter cannot be indexed dynamically.
|
||||||
|
//vec3 norm = (inst_mat[(v_pos_norm >> 30u) & 3u].xyz);
|
||||||
|
uint index = v_pos_norm >> 30u & 3u;
|
||||||
|
vec3 norm;
|
||||||
|
if (index == 0) {
|
||||||
|
norm = (inst_mat[0].xyz);
|
||||||
|
} else if (index == 1) {
|
||||||
|
norm = (inst_mat[1].xyz);
|
||||||
|
} else {
|
||||||
|
norm = (inst_mat[2].xyz);
|
||||||
|
}
|
||||||
|
|
||||||
f_norm = normalize(mix(-norm, norm, v_pos_norm >> 29u & 1u));
|
f_norm = normalize(mix(-norm, norm, v_pos_norm >> 29u & 1u));
|
||||||
|
|
||||||
// Expand atlas tex coords to floats
|
// Expand atlas tex coords to floats
|
||||||
|
@ -59,5 +59,6 @@ void main() {
|
|||||||
f_uv = v_uv;
|
f_uv = v_uv;
|
||||||
gl_Position = vec4(v_pos, 0.5, 1.0);
|
gl_Position = vec4(v_pos, 0.5, 1.0);
|
||||||
}
|
}
|
||||||
|
|
||||||
f_mode = v_mode;
|
f_mode = v_mode;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user