[Add] Implement tileable and pile-corrected clouds.
This commit is contained in:
parent
a1c214caec
commit
19a431ccc8
@ -24,6 +24,10 @@ void main() {
|
||||
float diffuse = max(dot(normal, -u_LightDir), 0.0);
|
||||
vec3 cloudColor = vec3(1.0) * (diffuse * 0.5 + 0.5); /* Add some ambient light. */
|
||||
|
||||
/* Fade out clouds at the poles to hide pinching. */
|
||||
float poleFade = 1.0 - abs(TexCoords.y);
|
||||
cloudAlpha *= smoothstep(0.0, 0.2, poleFade);
|
||||
|
||||
/* Cloud colour is white. it's transparency is determined by alpha. */
|
||||
FragColor = vec4(cloudColor, cloudAlpha);
|
||||
}
|
||||
|
||||
@ -226,7 +226,18 @@ unsigned int Renderer::_generate_cloud_texture(void) {
|
||||
|
||||
for(int y = 0; y < height; y++) {
|
||||
for(int x = 0; x < width; x++) {
|
||||
float noise_val = noise.GetNoise((float)x, (float)y);
|
||||
const float R = 1.0f; /* Major radius of the torus. */
|
||||
const float r = 0.5f; /* Minor radius of the torus. */
|
||||
|
||||
float u = (float)x / width * 2.0f * M_PI;
|
||||
float v = (float)y / height * 2.0f * M_PI;
|
||||
|
||||
float nx = (R + r * cos(v)) * cos(u);
|
||||
float ny = (R + r * cos(v)) * sin(u);
|
||||
float nz = r * sin(v);
|
||||
|
||||
const float noise_scale = 45.0f;
|
||||
float noise_val = noise.GetNoise(nx * noise_scale, ny * noise_scale, nz * noise_scale);
|
||||
buffer[y*width+x] = (noise_val + 1.0f) / 2.0f;
|
||||
}
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user