Graphics Reference
In-Depth Information
value. Figure 14-11 shows a 2D slice of the gradient noise using the
preceding algorithm.
Figure 14-11
2D Slice of Gradient Noise
Using Noise
Once we have created a 3D noise volume, it is very easy to use it to
produce a variety of effects. In the case of the wispy fog effect, the idea is
simple: Scroll the 3D noise texture in all three dimensions based on time
and use the value from the texture to distort the fog factor. Let's take a
look at the fragment shader in Example 14-17.
Example 14-17
Noise-Distorted Fog Fragment Shader
#version 300 es
precision mediump float;
uniform sampler3D s_noiseTex;
uniform float u_fogMaxDist;
uniform float u_fogMinDist;
uniform vec4 u_fogColor;
uniform float u_time;
in vec4 v_color;
in vec2 v_texCoord;
in vec4 v_eyePos;
layout(location = 0) out vec4 outColor;
float computeLinearFogFactor()
 
 
 
Search WWH ::




Custom Search