I'll help you create a GLSL shader for cloud particles with normal mapping. This shader will create a soft, volumetric appearance while using normal mapping for detail.
glsl Copy code
// Vertex Shader
varying vec2 vUv;
varying vec3 vViewPosition;
varying vec3 vNormal;
void main() {
vUv = uv;
vec4 mvPosition = modelViewMatrix * vec4(position, 1.0);
vViewPosition = -mvPosition.xyz;
vNormal = normalMatrix * normal;
gl_Position = projectionMatrix * mvPosition;
}
// Fragment Shader
uniform sampler2D cloudTexture;
uniform sampler2D normalMap;
uniform float time;
uniform vec3 lightPosition;
varying vec2 vUv;
varying vec3 vViewPosition;
varying vec3 vNormal;
void main() {
// Sample the normal map and transform to world space
vec3 normalMap = texture2D(normalMap, vUv).rgb * 2.0 - 1.0;
vec3 N = normalize(vNormal + normalMap);
// Calculate view and light direction
vec3 V = normalize(vViewPosition);
vec3 L = normalize(lightPosition - vViewPosition);
// Basic lighting calculations
float diffuse = max(dot(N, L), 0.0);
float fresnel = pow(1.0 - max(dot(N, V), 0.0), 4.0);
// Sample cloud texture with time-based movement
vec2 moveUV = vUv + time * 0.1;
vec4 cloudColor = texture2D(cloudTexture, moveUV);
// Combine lighting with cloud color
vec3 finalColor = cloudColor.rgb * (diffuse * 0.7 + 0.3);
// Add fresnel effect for edge highlighting
finalColor += vec3(fresnel) * 0.3;
// Soft alpha for cloud-like appearance
float alpha = cloudColor.a * (0.8 - fresnel * 0.3);
gl_FragColor = vec4(finalColor, alpha);
}
This shader includes:
Normal mapping for surface detail
Soft particle effects using fresnel
Time-based UV movement for animation
Diffuse lighting
Alpha blending for cloud-like transparency
To use this shader, you'll need to provide:
A cloud texture (cloudTexture)
A normal map (normalMap)
Time uniform for animation
Light position uniform
For best results, you should:
Enable alpha blending in your rendering setup
Use a cloud texture with alpha channel
Adjust the fresnel and diffuse parameters to match your desired look
Would you like me to explain any part in more detail or help you with implementing specific effects?