Better tether pattern, account for mass

This commit is contained in:
Joshua Barretto 2023-06-06 21:42:10 +01:00
parent deca7ae258
commit a5ec81a2ab
3 changed files with 22 additions and 23 deletions

View File

@ -72,11 +72,10 @@ void main() {
// float f_ao = f_col_light.a;
float f_ao = 1.0;
uint material = 0xFFu;
vec3 f_col = mix(
vec3(0.035, 0.02, 0.01),
vec3(0.06, 0.05, 0.03),
floor(abs(fract(m_pos.z * 10.0) - 0.5) * 6.0) / 3.0
vec3(0.05, 0.03, 0.01),
vec3(0.1, 0.07, 0.05),
floor(abs(fract(m_pos.z * 10.0 + atan(m_pos.x, m_pos.y) * 0.159) - 0.5) * 6.0) / 3.0
);
#ifdef EXPERIMENTAL_BAREMINIMUM
@ -201,13 +200,6 @@ void main() {
reflected_light *= point_shadow;
emitted_light *= point_shadow;
// Apply emissive glow
// For now, just make glowing material light be the same colour as the surface
// TODO: Add a way to control this better outside the shaders
if ((material & (1u << 0u)) > 0u) {
emitted_light += 20 * surf_color;
}
/* reflected_light *= cloud_shadow(f_pos); */
/* vec3 point_light = light_at(f_pos, f_norm);
emitted_light += point_light;
@ -226,14 +218,6 @@ void main() {
float reflectance = 0.0;
// TODO: Do reflectance properly like this later
vec3 reflect_color = vec3(0);
/*
if ((material & (1u << 1u)) > 0u && false) {
vec3 reflect_ray_dir = reflect(cam_to_frag, f_norm);
reflect_color = get_sky_color(reflect_ray_dir, time_of_day.x, f_pos, vec3(-100000), 0.125, true);
reflect_color = get_cloud_color(reflect_color, reflect_ray_dir, cam_pos.xyz, time_of_day.x, 100000.0, 0.25);
reflectance = 1.0;
}
*/
surf_color = illuminate(max_light, view_dir, mix(surf_color * emitted_light, reflect_color, reflectance), mix(surf_color * reflected_light, reflect_color, reflectance));

View File

@ -40,8 +40,8 @@ void main() {
float dist = distance(pos_a.xyz, pos_b.xyz);
vec3 pos = pos_a.xyz + (rx * v_pos.x + ry * v_pos.y) * 0.1 + rz * v_pos.z * dist;
vec2 ideal_wind_sway = wind_vel * vec2(
wind_wave(pos.y * 1.5, 2.9, wind_vel.x, wind_vel.y),
wind_wave(pos.x * 1.5, 3.1, wind_vel.y, wind_vel.x)
wind_wave(pos.y * 1.5, 1.9, wind_vel.x, wind_vel.y),
wind_wave(pos.x * 1.5, 2.1, wind_vel.y, wind_vel.x)
);
float dip = (1 - pow(abs(v_pos.z - 0.5) * 2.0, 2)) * max(tether_length - dist, 0.0);
pos += vec3(ideal_wind_sway * min(pow(dip, 2), 0.005), -0.5 * dip);

View File

@ -104,12 +104,27 @@ impl<'a> System<'a> for Sys {
if let Some(follower_ori) = orientations.get_mut(follower) {
let turn_strength = pull_factor
* (tether_offset.magnitude() * (attach_pos - tether_pos).magnitude()
* (tether_offset.magnitude() * tether_pos.distance(attach_pos)
- tether_offset.dot(attach_pos - tether_pos).abs())
* 2.0;
// TODO: proper moment of inertia
* 500.0
/ follower_mass.0;
// TODO: Should consider the offset
let target_ori = follower_ori.yawed_towards(Dir::new(pull_dir));
*follower_ori = follower_ori.slerped_towards(target_ori, turn_strength * dt.0);
}
if let Some(leader_ori) = orientations.get_mut(leader) {
let turn_strength = pull_factor
* (attach_offset.magnitude() * tether_pos.distance(attach_pos)
- attach_offset.dot(tether_pos - attach_pos).abs())
// TODO: proper moment of inertia
* 500.0
/ leader_mass.0;
// TODO: Should consider the offset
let target_ori = leader_ori.yawed_towards(Dir::new(pull_dir));
*leader_ori = leader_ori.slerped_towards(target_ori, turn_strength * dt.0);
}
}
}
}