Day11 - Procedural Textures Primitives glsl has some...

Info iconThis preview shows pages 1–11. Sign up to view the full content.

View Full Document Right Arrow Icon
Procedural Textures
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Primitives glsl has some built-in functions that can be used to generate simple textures returns 0.0 if x < a, 1.0 otherwise a 0 1 float f = step(a, x); f
Background image of page 2
Primitives a 0 1 float f = smoothstep(a, b, x); f b
Background image of page 3

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Primitives a pulse can be formed using two steps can also use smoothstep to generate a smooth pulse (p189) a 0 1 float f = step(a, x) – step(b, x); f b
Background image of page 4
Primitives clamp restricts a value to lie within a range a 0 1 float f = clamp(x, a, b); f b a b
Background image of page 5

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Primitives mod is useful for generating periodic functions for any function f(x) where 0 <= x < 1 f( mod(x, a) / a) is periodic works best if f(0) = f(1) and f’(0) = f’(1)
Background image of page 6
Primitives consider the following fragment shader in vec2 vST; out vec4 fFragColor; void main( ) { const float N = 16; const float F = 1.0 / N; float x = mod(vST.s, F) / F; float r = smoothstep(0.4, 0.6, x); fFragColor = vec4( r, 1., 0., 1. ); }
Background image of page 7

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Primitives N=2 N=3 N=4 N=16
Background image of page 8
Primitives somewhat better using a smooth pulse in vec2 vST; out vec4 fFragColor; void main( ) { const float N = 16; const float F = 1.0 / N; float x = mod(vST.s, F) / F; float r = smoothstep(0.0, 0.2, x) – smoothstep(0.5, 0.7, x); fFragColor = vec4( r, 1., 0., 1. );
Background image of page 9

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Primitives N=2 N=3 N=4 N=16
Background image of page 10
Image of page 11
This is the end of the preview. Sign up to access the rest of the document.

Page1 / 28

Day11 - Procedural Textures Primitives glsl has some...

This preview shows document pages 1 - 11. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online