Getting ready

Start with a basic setup for rendering using the Phong shading model (or whatever model you prefer). Include texture coordinates and pass them along to the fragment shader.

There are a couple of uniform variables that define the parameters of the paint spatters:

  • PaintColor: The color of the paint spatters
  • Threshold: The minimum noise value where a spatter will appear

Create a noise texture with high-frequency noise.

Make your noise texture available to the fragment shader via the NoiseTex uniform sampler variable.

Get OpenGL 4 Shading Language Cookbook - Third Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.