Skip to content

Commit

Permalink
Merge pull request #127 from OpenSauce04/Better-Sun-Moon-Textures
Browse files Browse the repository at this point in the history
Improved Sun and Moon texture handling + Realistic textures
  • Loading branch information
jebbyk authored Apr 28, 2021
2 parents 82d1f0c + 7cf0157 commit f3b470a
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 3 deletions.
9 changes: 7 additions & 2 deletions shaders/glsl/sun_and_moon.fragment
Original file line number Diff line number Diff line change
Expand Up @@ -76,10 +76,15 @@ void main()
highp vec3 dp1 = dFdx(worldPosition.xyz);
highp vec3 dp2 = dFdy(worldPosition.xyz);

vec3 normal = (normalize(cross(dp1, dp2)) + 1.0) / 2.0;
vec3 normal = (normalize(cross(dp1, dp2)) + 1.0) / 2.0;


gl_FragColor = CURRENT_COLOR * diffuse * length(diffuse.rgb);
gl_FragColor += halo * haloTint /*+ sun * sunTint*/;
gl_FragColor.a *= 1.0 - isRain;

float sunHaloIntensity = 0.6;
float moonHaloIntensity = 0.4;
float haloIntensity = sunHaloIntensity + abs((isDay * moonHaloIntensity) - moonHaloIntensity);

gl_FragColor.a *= haloIntensity - (isRain * haloIntensity);
}
2 changes: 1 addition & 1 deletion shaders/glsl/sun_and_moon.vertex
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ varying vec3 viewPosition;

void main()
{
gl_Position = WORLDVIEWPROJ * (POSITION * vec4(8.0, 8.0, 8.0, 1.0));
gl_Position = WORLDVIEWPROJ * (POSITION * vec4(16.0, 16.0, 16.0, 8.0)); // <-- The sun's visual position

position = POSITION.xyz * vec3(8.0);
worldPosition = POSITION * vec4(8.0, 8.0, 8.0, 1.0) * WORLD;
Expand Down
Binary file modified textures/environment/moon_phases.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified textures/environment/sun.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit f3b470a

Please sign in to comment.