Creating a rusted metal effect
This recipe combines a noise texture with the reflection effect covered in Chapter 5, Using Textures to create a simple rusted metal effect.
This technique is very similar to the previous recipe, Creating a paint-spatter effect. We'll use our noise texture to modulate the reflection from the teapot. If the noise is above a certain threshold, we'll use the rust color, otherwise, we'll use the reflected color.
Getting ready
We'll combine the technique described in the Simulating reflection with cube maps recipe in Chapter 5, Using Textures, with a noise texture. Start with the shaders from that recipe.
How to do it...
In the fragment shader, we'll access our noise texture and if the value is below the threshold value Threshold
, we'll use the reflected color (from the cube map), otherwise, we'll use a rust color:
in vec3 ReflectDir; in vec2 TexCoord; uniform samplerCube CubeMapTex; uniform sampler2D NoiseTex; uniform float ReflectFactor; uniform vec4 MaterialColor...