Skip to content

Commit 8c2c05c

Browse files
authored
Fix missing clouds_height in compute shader (#3)
1 parent e17dcdc commit 8c2c05c

File tree

1 file changed

+1
-2
lines changed

1 file changed

+1
-2
lines changed

assets/shaders/clouds_compute.wgsl

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -103,14 +103,14 @@ fn get_cloud_map_density(pos: vec3f, normalized_height: f32) -> f32 {
103103
}
104104

105105
fn get_normalized_height(pos: vec3f) -> f32 {
106+
let clouds_height = config.clouds_top_height - config.clouds_bottom_height;
106107
return (length(pos) - (config.planet_radius + config.clouds_bottom_height)) / clouds_height;
107108
}
108109

109110
fn volumetric_shadow(origin: vec3f, ray_dot_sun: f32) -> f32 {
110111
var ray_step_size = config.clouds_shadow_raymarch_step_size;
111112
var distance_along_ray = ray_step_size * 0.5;
112113
var transmittance = 1.0;
113-
let clouds_height = config.clouds_top_height - config.clouds_bottom_height;
114114

115115
for (var step: u32 = 0; step < config.clouds_shadow_raymarch_steps_count; step++) {
116116
let pos = origin + config.sun_dir.xyz * distance_along_ray;
@@ -178,7 +178,6 @@ fn raymarch(_ray_origin: vec3f, ray_dir: vec3f, max_dist: f32) -> RaymarchResult
178178
var transmittance = 1.0;
179179

180180
var dist = config.planet_radius;
181-
let clouds_height = config.clouds_top_height - config.clouds_bottom_height;
182181

183182
for (var step: u32 = 0; step < config.clouds_raymarch_steps_count; step++) {
184183
let world_position = ray_origin + dir_length * ray_dir;

0 commit comments

Comments
 (0)