# Day11 - Procedural Textures Primitives glsl has some...

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

Procedural Textures

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

View Full Document
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
Primitives a 0 1 float f = smoothstep(a, b, x); f b

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

View Full Document
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
Primitives clamp restricts a value to lie within a range a 0 1 float f = clamp(x, a, b); f b a b

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

View Full Document
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)
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. ); }

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

View Full Document
Primitives N=2 N=3 N=4 N=16
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. );

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

View Full Document
Primitives N=2 N=3 N=4 N=16
This is the end of the preview. Sign up to access the rest of the document.

{[ snackBarMessage ]}

### 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
Ask a homework question - tutors are online