I struggled a bit to find the relevant math to do this, so I’m going to post it here just in case somebody needs it.
This shader allows you to quickly create a Sky background with a noise texture that won’t be deformed at its poles. It might save you space, time, and make procedural generation easier.
shader_type sky;
uniform sampler3D noise;
void sky() {
if (AT_CUBEMAP_PASS) {
COLOR = vec3(0.0);
ALPHA = 1.0;
} else {
vec2 norm = (SKY_COORDS * 2.0) - vec2(-1.0, -1.0);
float long = norm.x * PI;
float lat = norm.y * (PI/2.0);
vec3 projected = vec3(cos(lat) * sin(long), cos(lat) * cos(long), sin(lat));
vec3 color = texture(noise, projected).rgb;
COLOR = color;
}
}
Steps to implement:
- Create your WorldEnvironment
- Set ‘background’ to ‘Sky’
- Sky to New Sky
- Sky Material to New ShaderMaterial
- Copypaste this sahder code
- In Shader parameters, create a New NoiseTexture3D
- Set to seamless
- You might need to increase Seamless Blend or the resolution