mirror of
https://gitlab.com/veloren/veloren.git
synced 2024-08-30 18:12:32 +00:00
Use tilted origin for rain
This commit is contained in:
parent
d5c0e878d7
commit
32fe997506
@ -89,6 +89,7 @@ void main() {
|
||||
vec3 adjusted_dir = (vec4(dir, 0) * rain_dir_mat).xyz;
|
||||
|
||||
vec2 dir2d = adjusted_dir.xy;
|
||||
vec3 rorigin = (vec4(cam_wpos, 0) * rain_dir_mat).xyz;
|
||||
vec3 rpos = vec3(0.0);
|
||||
float t = 0.0;
|
||||
for (int i = 0; i < 10; i ++) {//t * (length(dir2d) + 0.25) < 30.0) {
|
||||
@ -97,7 +98,7 @@ void main() {
|
||||
vec2 deltas = (step(vec2(0), dir2d) - fract(rpos.xy / scale)) / dir2d;
|
||||
float jump = max(min(deltas.x, deltas.y) * scale, PLANCK);
|
||||
t += jump;
|
||||
rpos = cam_wpos + adjusted_dir * t;
|
||||
rpos = rorigin + adjusted_dir * t;
|
||||
|
||||
vec2 diff = abs(round(rpos.xy) - rpos.xy);
|
||||
vec3 wall_pos = vec3((diff.x > diff.y) ? rpos.xy : rpos.yx, rpos.z + integrated_rain_vel * 0.5);
|
||||
|
@ -164,6 +164,17 @@ void main() {
|
||||
vec3 surf_color = /*srgb_to_linear*/f_col;
|
||||
float alpha = 1.0;
|
||||
const float n2 = 1.5;
|
||||
|
||||
|
||||
// This is a silly hack. It's not true reflectance (see below for that), but gives the desired
|
||||
// effect without breaking the entire lighting model until we come up with a better way of doing
|
||||
// reflectivity that accounts for physical surroundings like the ground
|
||||
if ((material & (1u << 1u)) > 0u) {
|
||||
vec3 reflect_ray_dir = reflect(cam_to_frag, f_norm);
|
||||
surf_color *= dot(vec3(1.0) - abs(fract(reflect_ray_dir * 1.5) * 2.0 - 1.0) * 0.85, vec3(1));
|
||||
alpha = 0.1;
|
||||
}
|
||||
|
||||
const float R_s2s0 = pow((1.0 - n2) / (1.0 + n2), 2);
|
||||
const float R_s1s0 = pow((1.3325 - n2) / (1.3325 + n2), 2);
|
||||
const float R_s2s1 = pow((1.0 - 1.3325) / (1.0 + 1.3325), 2);
|
||||
@ -174,14 +185,6 @@ void main() {
|
||||
vec3 k_d = vec3(1.0);
|
||||
vec3 k_s = vec3(R_s);
|
||||
|
||||
// This is a silly hack. It's not true reflectance (see below for that), but gives the desired
|
||||
// effect without breaking the entire lighting model until we come up with a better way of doing
|
||||
// reflectivity that accounts for physical surroundings like the ground
|
||||
if ((material & (1u << 1u)) > 0u) {
|
||||
vec3 reflect_ray_dir = reflect(cam_to_frag, f_norm);
|
||||
surf_color *= dot(vec3(1.0) - abs(fract(reflect_ray_dir * 1.5) * 2.0 - 1.0) * 0.85, vec3(1));
|
||||
}
|
||||
|
||||
vec3 emitted_light, reflected_light;
|
||||
|
||||
// Make voxel shadows block the sun and moon
|
||||
|
@ -300,7 +300,7 @@ void main() {
|
||||
vec3 two_down = f_pos - offset_two;
|
||||
|
||||
// Adjust this to change the size of the grid cells relative to the
|
||||
// number of shadow texels
|
||||
// number of shadow texels
|
||||
float grid_cell_to_texel_ratio = 32.0;
|
||||
|
||||
vec2 shadowTexSize = textureSize(sampler2D(t_directed_shadow_maps, s_directed_shadow_maps), 0) / grid_cell_to_texel_ratio;
|
||||
@ -320,7 +320,7 @@ void main() {
|
||||
return;
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
float max_light = 0.0;
|
||||
|
||||
// After shadows are computed, we use a refracted sun and moon direction.
|
||||
|
Loading…
Reference in New Issue
Block a user