Skip to main content
GameDev.net gamedev.net
🔒 Locked

Noise filter

Started by XiotexStudios Apr 20, 2006 at 7:14 AM 4 replies 600+ views
Original Post
XiotexStudios
XiotexStudios
Hi, I want to apply a noise filter as a post-process effect to my scenes. The shader version is fine but I was wondering if anyone had a good technique of a shader-less noise filter that doesn't involve locking a texture and filling it with noise :) I experimented for a while with shifting a 'noise' texture but maybe I am being too perfectionist but I began to notice the repeating patterns.
Byron Atkinson-JonesXiotex Studioswww.xiotex.com
Evil Steve
Evil Steve
What I'd do is create a 512x512 texture and fill it with noise once. Then render a grid of triangles across the screen, each one being something like 64x64. Every frame, change the texture coordinates of the top left vertex to a random value, and set the others to fit properly - so you get a 1:1 mapping of texels to pixels.

The larger your texture and the smaller the size of the grid, the more noise-like it'll look. Since you're changing the texture coordinates to a random value, there shouldn't be any noticiable patterns.
XiotexStudios
XiotexStudios
I may be mis-reading you here..

Are you saying that you set each 64x64 section to a random offset or just apply the offset once to the top left tri/quad and bubble the offset to the rest of the tri/quad's (with their relative position in mind?).

Byron Atkinson-JonesXiotex Studioswww.xiotex.com
Evil Steve
Evil Steve
Sorry, I'm useless at explaining things [smile]

If you have a scene that's 1024x768, then you'd get 16x12 "tiles" of 64x64. Each of those tiles would be made from 4 vertices, and the top left vertex in that tile has a random UV offset.

Something like:
for(int y=0; y<12; ++y){   Vertex* pFirstVert;   for(int x=0; x<16; ++x)   {      pVertex->u = random_float();   // 0..1      pVertex->v = random_float();   // 0..1      pFirstVert = pVertex;      ++pVertex;      pVertex->u = pFirstVert->u + 64.0f/512.0f;      pVertex->v = pFirstVert->v;      ++pVertex;      pVertex->u = pFirstVert->u;      pVertex->v = pFirstVert->v + 64.0f/512.0f;      ++pVertex;      pVertex->u = pFirstVert->u + 64.0f/512.0f;      pVertex->v = pFirstVert->v + 64.0f/512.0f;      ++pVertex;   }}

Or something like that anyway.
XiotexStudios
XiotexStudios
thats olay - I am useless at understanding them :)

I'll give that a go - cheers!

Its one of those problems that seems insignificant when compared to all of the other features of an engine and yet proved difficult to get a 'good' result.

Byron Atkinson-JonesXiotex Studioswww.xiotex.com
XiotexStudios
XiotexStudios
'thats olay' - and typing too it seems :(
Byron Atkinson-JonesXiotex Studioswww.xiotex.com

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.