book
OpenGL Programming Guide: The Official Guide to Learning OpenGL, Version 4.3, Eighth Edition
by Dave Shreiner, Graham Sellers, John M. Kessenich, Bill M. Licea-Kane
March 2013
Intermediate to advanced
984 pages
26h 18m
English
Content preview from OpenGL Programming Guide: The Official Guide to Learning OpenGL, Version 4.3, Eighth EditionBecome an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
Start your free trial



Granite
With noise, it’s also easy just to try to make stuff up. In this example, we want to simulate a grayish rocky material with small black specks. To generate a relatively high-frequency noise texture, we use only the fourth component (the highest frequency one). We scale it by an arbitrary amount to provide an appropriate intensity level and then use this value for each of the red, green, and blue components. The shader in Example 8.20 generates an appearance similar to granite, as shown in Figure 8.27.
Example 8.20. Granite Fragment Shader
#version 330 coreuniform sampler3D Noise;uniform float NoiseScale;in float LightIntensity;in vec3 MCposition;out vec4 FragColor;void main(){ vec4 noisevec = texture(Noise, ...