X Tutup
Skip to content

Commit e4acba7

Browse files
committed
bug fixes
hopefully fixed a bug where some planets display incorrectly on different platofrms by changing seeds and alpha calculation.
1 parent bad0a4b commit e4acba7

File tree

18 files changed

+162
-449
lines changed

18 files changed

+162
-449
lines changed

Planets/Asteroids/Asteroids.shader

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ uniform int OCTAVES : hint_range(0, 20, 1);
1313
uniform float seed: hint_range(1, 10);
1414

1515
float rand(vec2 coord) {
16-
return fract(sin(dot(coord.xy ,vec2(12.9898,78.233))) * 43758.5453 * seed);
16+
return fract(sin(dot(coord.xy ,vec2(12.9898,78.233))) * 15.5453 * seed);
1717
}
1818

1919
float noise(vec2 coord){

Planets/DryTerran/DryTerran.tscn

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -78,17 +78,17 @@ void fragment() {
7878
vec2 uv = floor(UV*pixels)/pixels;
7979
bool dith = dither(uv, UV);
8080

81+
// cut out a circle
82+
float d_circle = distance(uv, vec2(0.5));
83+
float a = step(d_circle, 0.5);
84+
8185
uv = spherify(uv);
8286

83-
// check distance from center & distance to light
84-
float d_circle = distance(uv, vec2(0.5));
87+
// check distance distance to light
8588
float d_light = distance(uv , vec2(light_origin));
8689

8790
uv = rotate(uv, rotation);
8891

89-
// cut out a circle
90-
float a = step(d_circle, 0.5);
91-
9292
// noise
9393
float f = fbm(uv*size+vec2(time*time_speed, 0.0));
9494

Planets/GasPlanet/GasPlanet.shader

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ uniform float time = 0.0;
2323

2424
float rand(vec2 coord) {
2525
coord = mod(coord, vec2(1.0,1.0)*round(size));
26-
return fract(sin(dot(coord.xy ,vec2(12.9898,78.233))) * 43758.5453 * seed);
26+
return fract(sin(dot(coord.xy ,vec2(12.9898,78.233))) * 15.5453 * seed);
2727
}
2828

2929
float noise(vec2 coord){
@@ -96,13 +96,18 @@ void fragment() {
9696
// pixelize uv
9797
vec2 uv = floor(UV*pixels)/pixels;
9898

99-
// distance to light source
100-
float d_light = distance(uv , light_origin);
99+
// cut out a circle
100+
float d_circle = distance(uv, vec2(0.5));
101+
float a = step(d_circle, 0.5);
101102

102103
uv = rotate(uv, rotation);
103104

104105
// map to sphere
105106
uv = spherify(uv);
107+
108+
// distance to light source
109+
float d_light = distance(uv , light_origin);
110+
106111
// slightly make uv go down on the right, and up in the left
107112
uv.y += smoothstep(0.0, cloud_curve, abs(uv.x-0.4));
108113

@@ -124,5 +129,5 @@ void fragment() {
124129

125130

126131

127-
COLOR = vec4(col, step(cloud_cover, c));
132+
COLOR = vec4(col, step(cloud_cover, c) * a);
128133
}

Planets/GasPlanet/GasPlanet.tscn

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -102,6 +102,8 @@ void fragment() {
102102
// pixelize uv
103103
vec2 uv = floor(UV*pixels)/pixels;
104104

105+
106+
105107
// distance to light source
106108
float d_light = distance(uv , light_origin);
107109

@@ -128,8 +130,6 @@ void fragment() {
128130
col = shadow_outline_color.rgb;
129131
}
130132

131-
132-
133133
COLOR = vec4(col, step(cloud_cover, c));
134134
}
135135
"

Planets/GasPlanetLayers/GasLayers.shader

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ uniform float time = 0.0;
2222

2323
float rand(vec2 coord) {
2424
coord = mod(coord, vec2(2.0,1.0)*round(size));
25-
return fract(sin(dot(coord.xy ,vec2(12.9898,78.233))) * 43758.5453 * seed);
25+
return fract(sin(dot(coord.xy ,vec2(12.9898,78.233))) * 15.5453 * seed);
2626
}
2727

2828
float noise(vec2 coord){

Planets/GasPlanetLayers/Ring.shader

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ uniform float time = 0.0;
2121

2222
float rand(vec2 coord) {
2323
coord = mod(coord, vec2(2.0,1.0)*round(size));
24-
return fract(sin(dot(coord.xy ,vec2(12.9898,78.233))) * 43758.5453 * seed);
24+
return fract(sin(dot(coord.xy ,vec2(12.9898,78.233))) * 15.5453 * seed);
2525
}
2626

2727
float noise(vec2 coord){

Planets/LandMasses/Clouds.shader

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ uniform float time = 0.0;
2424

2525
float rand(vec2 coord) {
2626
coord = mod(coord, vec2(1.0,1.0)*round(size));
27-
return fract(sin(dot(coord.xy ,vec2(12.9898,78.233))) * 43758.5453 * seed);
27+
return fract(sin(dot(coord.xy ,vec2(12.9898,78.233))) * 15.5453 * seed);
2828
}
2929

3030
float noise(vec2 coord){
@@ -101,6 +101,10 @@ void fragment() {
101101
// distance to light source
102102
float d_light = distance(uv , light_origin);
103103

104+
// cut out a circle
105+
float d_circle = distance(uv, vec2(0.5));
106+
float a = step(d_circle, 0.5);
107+
104108
float d_to_center = distance(uv, vec2(0.5));
105109

106110
uv = rotate(uv, rotation);
@@ -127,5 +131,5 @@ void fragment() {
127131
}
128132

129133
c *= step(d_to_center, 0.5);
130-
COLOR = vec4(col, step(cloud_cover, c));
134+
COLOR = vec4(col, step(cloud_cover, c) * a);
131135
}

Planets/LandMasses/PlanetLandmass.shader

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ float rand(vec2 coord) {
2727
// it would probably be better to only allow integer sizes
2828
// multiply by vec2(2,1) to simulate planet having another side
2929
coord = mod(coord, vec2(2.0,1.0)*round(size));
30-
return fract(sin(dot(coord.xy ,vec2(12.9898,78.233))) * 43758.5453 * seed);
30+
return fract(sin(dot(coord.xy ,vec2(12.9898,78.233))) * 15.5453 * seed);
3131
}
3232

3333

@@ -75,6 +75,9 @@ void fragment() {
7575
vec2 uv = floor(UV*pixels)/pixels;
7676

7777
float d_light = distance(uv , light_origin);
78+
// cut out a circle
79+
float d_circle = distance(uv, vec2(0.5));
80+
float a = step(d_circle, 0.5);
7881

7982
// give planet a tilt
8083
uv = rotate(uv, rotation);
@@ -122,5 +125,5 @@ void fragment() {
122125
col = col1.rgb;
123126
}
124127

125-
COLOR = vec4(col, step(land_cutoff, fbm1));
128+
COLOR = vec4(col, step(land_cutoff, fbm1) * a);
126129
}

Planets/LandMasses/PlanetUnder.shader

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ float rand(vec2 coord) {
2222
// it would probably be better to only allow integer sizes
2323
// multiply by vec2(2,1) to simulate planet having another side
2424
coord = mod(coord, vec2(2.0,1.0)*round(size));
25-
return fract(sin(dot(coord.xy ,vec2(12.9898,78.233))) * 43758.5453 * seed);
25+
return fract(sin(dot(coord.xy ,vec2(12.9898,78.233))) * 15.5453 * seed);
2626
}
2727

2828
float noise(vec2 coord){
@@ -75,15 +75,19 @@ void fragment() {
7575

7676
bool dith = dither(uv, UV);
7777

78-
uv = spherify(uv);
79-
uv = rotate(uv, rotation);
80-
// check distance from center & distance to light
81-
float d_circle = distance(uv, vec2(0.5));
78+
// check distance distance to light
8279
float d_light = distance(uv , vec2(light_origin));
8380

8481
// cut out a circle
82+
float d_circle = distance(uv, vec2(0.5));
8583
float a = step(d_circle, 0.5);
8684

85+
uv = spherify(uv);
86+
uv = rotate(uv, rotation);
87+
88+
89+
90+
8791
// get a noise value with light distance added
8892
d_light += fbm(uv*size+vec2(time*time_speed, 0.0))*0.3; // change the magic 0.3 here for different light strengths
8993

Planets/LavaWorld/Rivers.shader

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ uniform float time = 0.0;
2121

2222
float rand(vec2 coord) {
2323
coord = mod(coord, vec2(2.0,1.0)*round(size));
24-
return fract(sin(dot(coord.xy ,vec2(12.9898,78.233))) * 43758.5453 * seed);
24+
return fract(sin(dot(coord.xy ,vec2(12.9898,78.233))) * 15.5453 * seed);
2525
}
2626

2727
float noise(vec2 coord){
@@ -73,10 +73,14 @@ void fragment() {
7373

7474
float d_light = distance(uv , light_origin);
7575

76+
// cut out a circle
77+
float d_circle = distance(uv, vec2(0.5));
78+
float a = step(d_circle, 0.5);
79+
7680
// give planet a tilt
7781
uv = rotate(uv, rotation);
78-
79-
// // map to sphere
82+
83+
// map to sphere
8084
uv = spherify(uv);
8185

8286
// some scrolling noise for landmasses
@@ -98,7 +102,6 @@ void fragment() {
98102
col = color3.rgb;
99103
}
100104

101-
float a = step(river_cutoff, river_fbm);
102-
a*= step(distance(vec2(0.5), uv), 0.5);
105+
a *= step(river_cutoff, river_fbm);
103106
COLOR = vec4(col, a);
104107
}

0 commit comments

Comments
 (0)
X Tutup