mirror of
https://gitlab.com/veloren/veloren.git
synced 2024-08-30 18:12:32 +00:00
Merge branch 'intel-gpu-fix' into 'master'
Fix a crash and model/shadow issues on Intel Gen7/7.5 GPUs. See merge request veloren/veloren!1349
This commit is contained in:
commit
e512578ef5
@ -73,8 +73,9 @@ void main() {
|
||||
// Pre-calculate bone matrix
|
||||
/* uint bone_idx = (v_ao_bone >> 2) & 0x3Fu; */
|
||||
uint bone_idx = (v_pos_norm >> 27) & 0xFu;
|
||||
BoneData bone_data = bones[bone_idx];
|
||||
mat4 bone_mat = bone_data.bone_mat;
|
||||
|
||||
mat4 bone_mat = bones[bone_idx].bone_mat;
|
||||
mat4 normals_mat = bones[bone_idx].normals_mat;
|
||||
mat4 combined_mat = /*model_mat * */bone_mat;
|
||||
|
||||
vec3 pos = (vec3((uvec3(v_pos_norm) >> uvec3(0, 9, 18)) & uvec3(0x1FFu)) - 256.0) / 2.0;
|
||||
@ -105,7 +106,7 @@ void main() {
|
||||
// vec3 norm = normals[normal_idx];
|
||||
uint axis_idx = v_atlas_pos & 3u;
|
||||
|
||||
vec3 norm = bone_data.normals_mat[axis_idx].xyz;
|
||||
vec3 norm = normals_mat[axis_idx].xyz;
|
||||
// norm = normalize(norm);
|
||||
// vec3 norm = norm_mat * vec4(uvec3(1 << axis_idx) & uvec3(0x1u, 0x3u, 0x7u), 1);
|
||||
|
||||
|
@ -154,8 +154,8 @@ float ShadowCalculationDirected(in vec3 fragPos)//in vec4 /*light_pos[2]*/sun_po
|
||||
} */
|
||||
// vec3 fragPos = sun_pos.xyz;// / sun_pos.w;//light_pos[lightIndex].xyz;
|
||||
// sun_pos.z += sun_pos.w * bias;
|
||||
ShadowLocals sun_shadow = shadowMats[0];
|
||||
vec4 sun_pos = sun_shadow.texture_mat * vec4(fragPos, 1.0);
|
||||
mat4 texture_mat = shadowMats[0].texture_mat;
|
||||
vec4 sun_pos = texture_mat * vec4(fragPos, 1.0);
|
||||
// sun_pos.z -= sun_pos.w * bias;
|
||||
float visibility = textureProj(t_directed_shadow_maps, sun_pos);
|
||||
/* float visibilityLeft = textureProj(t_directed_shadow_maps, sun_shadow.texture_mat * vec4(fragPos + vec3(0.0, -diskRadius, 0.0), 1.0));
|
||||
|
@ -470,21 +470,21 @@ vec3 get_sky_color(vec3 dir, float time_of_day, vec3 origin, vec3 f_pos, float q
|
||||
float fog(vec3 f_pos, vec3 focus_pos, uint medium) {
|
||||
return max(1.0 - 5000.0 / (1.0 + distance(f_pos.xy, focus_pos.xy)), 0.0);
|
||||
|
||||
float fog_radius = view_distance.x;
|
||||
float mist_radius = 10000000.0;
|
||||
// float fog_radius = view_distance.x;
|
||||
// float mist_radius = 10000000.0;
|
||||
|
||||
float min_fog = 0.5;
|
||||
float max_fog = 1.0;
|
||||
// float min_fog = 0.5;
|
||||
// float max_fog = 1.0;
|
||||
|
||||
if (medium == 1u) {
|
||||
mist_radius = UNDERWATER_MIST_DIST;
|
||||
min_fog = 0.0;
|
||||
}
|
||||
// if (medium == 1u) {
|
||||
// mist_radius = UNDERWATER_MIST_DIST;
|
||||
// min_fog = 0.0;
|
||||
// }
|
||||
|
||||
float fog = distance(f_pos.xy, focus_pos.xy) / fog_radius;
|
||||
float mist = distance(f_pos, focus_pos) / mist_radius;
|
||||
// float fog = distance(f_pos.xy, focus_pos.xy) / fog_radius;
|
||||
// float mist = distance(f_pos, focus_pos) / mist_radius;
|
||||
|
||||
return pow(clamp((max(fog, mist) - min_fog) / (max_fog - min_fog), 0.0, 1.0), 1.7);
|
||||
// return pow(clamp((max(fog, mist) - min_fog) / (max_fog - min_fog), 0.0, 1.0), 1.7);
|
||||
}
|
||||
|
||||
/* vec3 illuminate(vec3 color, vec3 light, vec3 diffuse, vec3 ambience) {
|
||||
@ -493,55 +493,55 @@ float fog(vec3 f_pos, vec3 focus_pos, uint medium) {
|
||||
} */
|
||||
vec3 illuminate(float max_light, vec3 view_dir, /*vec3 max_light, */vec3 emitted, vec3 reflected) {
|
||||
return emitted + reflected;
|
||||
const float NIGHT_EXPOSURE = 10.0;
|
||||
const float DUSK_EXPOSURE = 2.0;//0.8;
|
||||
const float DAY_EXPOSURE = 1.0;//0.7;
|
||||
// const float NIGHT_EXPOSURE = 10.0;
|
||||
// const float DUSK_EXPOSURE = 2.0;//0.8;
|
||||
// const float DAY_EXPOSURE = 1.0;//0.7;
|
||||
|
||||
#if (LIGHTING_ALGORITHM == LIGHTING_ALGORITHM_ASHIKHMIN)
|
||||
const float DAY_SATURATION = 1.1;
|
||||
#else
|
||||
const float DAY_SATURATION = 1.0;
|
||||
#endif
|
||||
const float DUSK_SATURATION = 0.6;
|
||||
const float NIGHT_SATURATION = 0.1;
|
||||
// #if (LIGHTING_ALGORITHM == LIGHTING_ALGORITHM_ASHIKHMIN)
|
||||
// const float DAY_SATURATION = 1.1;
|
||||
// #else
|
||||
// const float DAY_SATURATION = 1.0;
|
||||
// #endif
|
||||
// const float DUSK_SATURATION = 0.6;
|
||||
// const float NIGHT_SATURATION = 0.1;
|
||||
|
||||
const float gamma = /*0.5*//*1.*0*/1.0;//1.0;
|
||||
// const float gamma = /*0.5*//*1.*0*/1.0;//1.0;
|
||||
/* float light = length(emitted + reflected);
|
||||
float color = srgb_to_linear(emitted + reflected);
|
||||
float avg_col = (color.r + color.g + color.b) / 3.0;
|
||||
return ((color - avg_col) * light + reflected * avg_col) * (emitted + reflected); */
|
||||
// float max_intensity = vec3(1.0);
|
||||
vec3 color = emitted + reflected;
|
||||
float lum = rel_luminance(color);
|
||||
// vec3 color = emitted + reflected;
|
||||
// float lum = rel_luminance(color);
|
||||
// float lum_sky = lum - max_light;
|
||||
|
||||
/* vec3 sun_dir = get_sun_dir(time_of_day.x);
|
||||
vec3 moon_dir = get_moon_dir(time_of_day.x); */
|
||||
float sky_light = rel_luminance(
|
||||
get_sun_color(/*sun_dir*/) * get_sun_brightness(/*sun_dir*/) * SUN_COLOR_FACTOR +
|
||||
get_moon_color(/*moon_dir*/) * get_moon_brightness(/*moon_dir*/));
|
||||
// float sky_light = rel_luminance(
|
||||
// get_sun_color(/*sun_dir*/) * get_sun_brightness(/*sun_dir*/) * SUN_COLOR_FACTOR +
|
||||
// get_moon_color(/*moon_dir*/) * get_moon_brightness(/*moon_dir*/));
|
||||
|
||||
// Tone mapped value.
|
||||
// vec3 T = /*color*//*lum*/color;//normalize(color) * lum / (1.0 + lum);
|
||||
// float alpha = 0.5;//2.0;
|
||||
float alpha = mix(
|
||||
mix(
|
||||
DUSK_EXPOSURE,
|
||||
NIGHT_EXPOSURE,
|
||||
max(sun_dir.z, 0)
|
||||
),
|
||||
DAY_EXPOSURE,
|
||||
max(-sun_dir.z, 0)
|
||||
);
|
||||
vec3 now_light = moon_dir.z < 0 ? moon_dir.xyz : sun_dir.xyz;
|
||||
float cos_view_light = dot(-now_light, view_dir);
|
||||
// float alpha = mix(
|
||||
// mix(
|
||||
// DUSK_EXPOSURE,
|
||||
// NIGHT_EXPOSURE,
|
||||
// max(sun_dir.z, 0)
|
||||
// ),
|
||||
// DAY_EXPOSURE,
|
||||
// max(-sun_dir.z, 0)
|
||||
// );
|
||||
// vec3 now_light = moon_dir.z < 0 ? moon_dir.xyz : sun_dir.xyz;
|
||||
// float cos_view_light = dot(-now_light, view_dir);
|
||||
// alpha *= exp(1.0 - cos_view_light);
|
||||
// sky_light *= 1.0 - log(1.0 + view_dir.z);
|
||||
float alph = sky_light > 0.0 && max_light > 0.0 ? mix(1.0 / log(/*1.0*//*1.0 + *//*lum_sky + */1.0 + max_light / (0.0 + sky_light)), 1.0, clamp(max_light - sky_light, 0.0, 1.0)) : 1.0;
|
||||
alpha = alpha * min(alph, 1.0);//((max_light > 0.0 && max_light > sky_light /* && sky_light > 0.0*/) ? /*1.0*/1.0 / log(/*1.0*//*1.0 + *//*lum_sky + */1.0 + max_light - (0.0 + sky_light)) : 1.0);
|
||||
// float alph = sky_light > 0.0 && max_light > 0.0 ? mix(1.0 / log(/*1.0*//*1.0 + *//*lum_sky + */1.0 + max_light / (0.0 + sky_light)), 1.0, clamp(max_light - sky_light, 0.0, 1.0)) : 1.0;
|
||||
// alpha = alpha * min(alph, 1.0);//((max_light > 0.0 && max_light > sky_light /* && sky_light > 0.0*/) ? /*1.0*/1.0 / log(/*1.0*//*1.0 + *//*lum_sky + */1.0 + max_light - (0.0 + sky_light)) : 1.0);
|
||||
// alpha = alpha * min(1.0, (max_light == 0.0 ? 1.0 : (1.0 + abs(lum_sky)) / /*(1.0 + max_light)*/max_light));
|
||||
|
||||
vec3 col_adjusted = lum == 0.0 ? vec3(0.0) : color / lum;
|
||||
// vec3 col_adjusted = lum == 0.0 ? vec3(0.0) : color / lum;
|
||||
|
||||
// float L = lum == 0.0 ? 0.0 : log(lum);
|
||||
|
||||
@ -560,30 +560,30 @@ vec3 illuminate(float max_light, vec3 view_dir, /*vec3 max_light, */vec3 emitted
|
||||
// // float T = lum;
|
||||
// float O = exp(B_ + D);
|
||||
|
||||
float T = 1.0 - exp(-alpha * lum);//lum / (1.0 + lum);
|
||||
// float T = 1.0 - exp(-alpha * lum);//lum / (1.0 + lum);
|
||||
// float T = lum;
|
||||
|
||||
// Heuristic desaturation
|
||||
// const float s = 0.8;
|
||||
float s = mix(
|
||||
mix(
|
||||
DUSK_SATURATION,
|
||||
NIGHT_SATURATION,
|
||||
max(sun_dir.z, 0)
|
||||
),
|
||||
DAY_SATURATION,
|
||||
max(-sun_dir.z, 0)
|
||||
);
|
||||
// float s = mix(
|
||||
// mix(
|
||||
// DUSK_SATURATION,
|
||||
// NIGHT_SATURATION,
|
||||
// max(sun_dir.z, 0)
|
||||
// ),
|
||||
// DAY_SATURATION,
|
||||
// max(-sun_dir.z, 0)
|
||||
// );
|
||||
// s = max(s, (max_light) / (1.0 + s));
|
||||
s = max(s, max_light / (1.0 + max_light));
|
||||
// s = max(s, max_light / (1.0 + max_light));
|
||||
|
||||
vec3 c = pow(col_adjusted, vec3(s)) * T;
|
||||
// vec3 c = pow(col_adjusted, vec3(s)) * T;
|
||||
// vec3 c = col_adjusted * T;
|
||||
// vec3 c = sqrt(col_adjusted) * T;
|
||||
// vec3 c = /*col_adjusted * */col_adjusted * T;
|
||||
|
||||
// return color;
|
||||
return c;
|
||||
// return c;
|
||||
// float sum_col = color.r + color.g + color.b;
|
||||
// return /*srgb_to_linear*/(/*0.5*//*0.125 * */vec3(pow(color.x, gamma), pow(color.y, gamma), pow(color.z, gamma)));
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user