Skip to content

Commit

Permalink
Fix grain noise
Browse files Browse the repository at this point in the history
Faruk Eroğlu committed Aug 16, 2020
1 parent 700fafb commit 06857d5
Showing 2 changed files with 12 additions and 5 deletions.
9 changes: 8 additions & 1 deletion Enhanced Cloudscapes/shaders/rendering/fragment_shader.glsl
Original file line number Diff line number Diff line change
@@ -253,7 +253,14 @@ vec4 sample_ray_march(in vec4 input_color, in int cloud_layer_index)

while (current_ray_distance <= layer_intersections.y)
{
float current_step_size = step_size * map(texture(blue_noise_texture, current_ray_position.xz * blue_noise_scale).x, 0.0, 1.0, 0.75, 1.0) * map(current_ray_distance, 0.0, layer_intersections.y, 1.0, 8.0);
float current_step_size = step_size * map(texture(blue_noise_texture, current_ray_position.xz * blue_noise_scale).x, 0.0, 1.0, 0.75, 1.0);

float distance_multiplier;

if (current_ray_distance < 40000.0) distance_multiplier = map(current_ray_distance, 0.0, 40000.0, 1.0, 4.0);
else distance_multiplier = map(current_ray_distance, 40000.0, layer_intersections.y, 4.0, 16.0);

current_step_size *= distance_multiplier;

float cloud_sample = sample_clouds(current_ray_position, cloud_layer_index);

8 changes: 4 additions & 4 deletions src/simulator_objects.cpp
Original file line number Diff line number Diff line change
@@ -150,8 +150,8 @@ namespace simulator_objects
viewport_dataref = XPLMFindDataRef("sim/graphics/view/viewport");
current_eye_dataref = XPLMFindDataRef("sim/graphics/view/draw_call_type");

rendering_resolution_ratio_dataref = export_float_dataref("enhanced_cloudscapes/rendering_resolution_ratio", 0.7);
skip_fragments_dataref = export_int_dataref("enhanced_cloudscapes/skip_fragments", 1);
rendering_resolution_ratio_dataref = export_float_dataref("enhanced_cloudscapes/rendering_resolution_ratio", 0.5);
skip_fragments_dataref = export_int_dataref("enhanced_cloudscapes/skip_fragments", 0);

reverse_z_dataref = XPLMFindDataRef("sim/graphics/view/is_reverse_float_z");

@@ -177,13 +177,13 @@ namespace simulator_objects
cloud_top_datarefs[1] = XPLMFindDataRef("sim/weather/cloud_tops_msl_m[1]");
cloud_top_datarefs[2] = XPLMFindDataRef("sim/weather/cloud_tops_msl_m[2]");

cloud_coverage_datarefs[0] = export_float_dataref("enhanced_cloudscapes/cirrus/coverage", 1.0f);
cloud_coverage_datarefs[0] = export_float_dataref("enhanced_cloudscapes/cirrus/coverage", 0.85f);
cloud_coverage_datarefs[1] = export_float_dataref("enhanced_cloudscapes/scattered/coverage", 0.75f);
cloud_coverage_datarefs[2] = export_float_dataref("enhanced_cloudscapes/broken/coverage", 0.85f);
cloud_coverage_datarefs[3] = export_float_dataref("enhanced_cloudscapes/overcast/coverage", 0.95f);
cloud_coverage_datarefs[4] = export_float_dataref("enhanced_cloudscapes/stratus/coverage", 1.0f);

cloud_density_datarefs[0] = export_float_dataref("enhanced_cloudscapes/cirrus/density_multiplier", 0.00065);
cloud_density_datarefs[0] = export_float_dataref("enhanced_cloudscapes/cirrus/density_multiplier", 0.00055);
cloud_density_datarefs[1] = export_float_dataref("enhanced_cloudscapes/scattered/density_multiplier", 0.0035);
cloud_density_datarefs[2] = export_float_dataref("enhanced_cloudscapes/broken/density_multiplier", 0.004);
cloud_density_datarefs[3] = export_float_dataref("enhanced_cloudscapes/overcast/density_multiplier", 0.004);

0 comments on commit 06857d5

Please sign in to comment.