@@ -3,14 +3,12 @@ render_mode unshaded, cull_front, depth_draw_never, blend_add;
33
44uniform float planet_radius : hint_range (0.0 , 1e9 ) = 200000.0 ;
55uniform float atmosphere_height : hint_range (0.0 , 1e8 ) = 6000.0 ;
6- uniform float outer_radius : hint_range (0.0 , 1e9 ) = 206000.0 ;
76
8- uniform float intensity_rayleigh : hint_range (0.0 , 2.0 ) = 0.25 ;
9- uniform float intensity_mie : hint_range (0.0 , 2.0 ) = 0.05 ;
10- uniform float g : hint_range (- 0.99 , 0.99 ) = 0.8 ;
11-
12- uniform vec3 rayleigh_color : source_color = vec3 (0.55 , 0.75 , 1.0 );
13- uniform vec3 mie_color : source_color = vec3 (1.0 , 0.95 , 0.9 );
7+ // Simplified atmosphere controls
8+ uniform float intensity : hint_range (0.0 , 2.0 ) = 0.5 ;
9+ uniform vec3 atmosphere_color : source_color = vec3 (0.55 , 0.75 , 1.0 );
10+ uniform float density_falloff : hint_range (0.1 , 2.0 ) = 0.8 ;
11+ uniform float horizon_power : hint_range (1.0 , 4.0 ) = 2.0 ;
1412
1513// Sun light direction in planet object-space (points from planet towards sun)
1614uniform vec3 sun_dir_object = vec3 (0.0 , - 1.0 , 0.0 );
@@ -19,22 +17,11 @@ uniform vec3 camera_pos_object = vec3(0.0);
1917
2018varying vec3 v_pos_obj ;
2119
22- float rayleigh_phase (float cosTheta ) {
23- return 3.0 / (16.0 * PI ) * (1.0 + cosTheta * cosTheta );
24- }
25-
26- float hg_phase (float cosTheta , float g_val ) {
27- float g2 = g_val * g_val ;
28- float denom = pow (max (1.0 + g2 - 2.0 * g_val * cosTheta , 1e-3 ), 1.5 );
29- return (1.0 / (4.0 * PI )) * (1.0 - g2 ) / denom ;
30- }
31-
3220void vertex () {
3321 v_pos_obj = VERTEX ;
3422}
3523
3624void fragment () {
37- // Camera position in planet object-space passed from script
3825 vec3 cam_pos_obj = camera_pos_object ;
3926 vec3 view_dir = normalize (cam_pos_obj - v_pos_obj );
4027 vec3 up_from_center = normalize (v_pos_obj );
@@ -43,24 +30,24 @@ void fragment() {
4330 // Exponential density falloff with height above surface
4431 float h = max (r - planet_radius , 0.0 );
4532 float H = max (atmosphere_height , 1.0 );
46- float density = exp (- h / (0.5 * H ));
47-
48- // Thicker towards horizon for visual oomph
49- float horizon = pow (1.0 - clamp (dot (up_from_center , view_dir ), 0.0 , 1.0 ), 1.25 );
50- float thickness = density * (0.6 + 1.6 * horizon );
33+ float density = exp (- h / (density_falloff * H ));
5134
52- // Phase functions based on sun-view angle
35+ // Enhanced horizon effect for more atmospheric depth
36+ float horizon = 1.0 - clamp (dot (up_from_center , view_dir ), 0.0 , 1.0 );
37+ horizon = pow (horizon , horizon_power );
38+
39+ // Sun direction influence for simple scattering
5340 vec3 sun_dir = normalize (sun_dir_object );
54- float cosTheta = clamp (dot (view_dir , sun_dir ), - 1.0 , 1.0 );
55- float pr = rayleigh_phase (cosTheta );
56- float pm = hg_phase (cosTheta , g );
41+ float sun_alignment = clamp (dot (view_dir , sun_dir ), 0.0 , 1.0 );
42+ float scattering = 0.6 + 0.4 * sun_alignment ;
5743
58- vec3 scatter = rayleigh_color * intensity_rayleigh * pr + mie_color * intensity_mie * pm ;
59- vec3 col = scatter * thickness ;
44+ // Final atmospheric glow
45+ float thickness = density * horizon * scattering ;
46+ vec3 final_color = atmosphere_color * intensity * thickness ;
6047
61- EMISSION = col ;
48+ EMISSION = final_color ;
6249 ALBEDO = vec3 (0.0 );
6350 ROUGHNESS = 1.0 ;
6451 SPECULAR = 0.0 ;
65- ALPHA = clamp (length (col ), 0.0 , 1.0 );
52+ ALPHA = clamp (length (final_color ), 0.0 , 1.0 );
6653}
0 commit comments