To build a shader program that uses a noise texture to create a cloud-like effect, perform the following steps:
- Set up your vertex shader to pass the texture coordinates to the fragment shader via the TexCoord variable.
- Use the following code for the fragment shader:
#define PI 3.14159265 layout( binding=0 ) uniform sampler2D NoiseTex; uniform vec4 SkyColor = vec4( 0.3, 0.3, 0.9, 1.0 ); uniform vec4 CloudColor = vec4( 1.0, 1.0, 1.0, 1.0 ); in vec2 TexCoord; layout ( location = 0 ) out vec4 FragColor; void main() { vec4 noise = texture(NoiseTex, TexCoord); float t = (cos( noise.g * PI ) + 1.0) / 2.0; vec4 color = mix( SkyColor, CloudColor, t ); FragColor = vec4( color.rgb , 1.0 ); }