Attention | Topic was automatically imported from the old Question2Answer platform. | |
Asked By | Macryc |
Hi. Does anyone know how to write a simple noise-based volumetric fog shader (ie, the fog() function)??
Attention | Topic was automatically imported from the old Question2Answer platform. | |
Asked By | Macryc |
Hi. Does anyone know how to write a simple noise-based volumetric fog shader (ie, the fog() function)??
Reply From: | omggomb |
For 3D there is a built in volumetric fog in the Environment
settings, for 2D I can’t help, sorry.
Reply From: | horsecar123 |
float noise(vec2 coord){
vec2 i = floor(coord);
vec2 f = fract(coord);
// 4 corners of a rectangle surrounding our point
float a = rand(i);
float b = rand(i + vec2(1.0, 0.0));
float c = rand(i + vec2(0.0, 1.0));
float d = rand(i + vec2(1.0, 1.0));
vec2 cubic = f * f * (3.0 - 2.0 * f);
return mix(a, b, cubic.x) + (c - a) * cubic.y * (1.0 - cubic.x) + (d - b) * cubic.x * cubic.y;
}