0

I have an issue with applying noise over the surface of a non-trivial mesh (well any mesh) in OpenGL without texture coordinates. I basically want to have a noise texture applied over the surface but since I don't have texture coordinates I can't just apply a noise texture. Generating texture coordinates in the vertex shader works to an extent however whether it is cube, sphere or object planar coordinates there is always some texture smearing.

smearing with cube map http://img811.imageshack.us/img811/3923/0ouu.png

Smearing with cube map coordinates across surface changes

smearing with object planar http://img195.imageshack.us/img195/987/c3cz.png

Smearing with object planar (xy) coordinates along z plane

I've done random noise generation in the fragment shader however as this changes every frame it is not what i need (and not computationally cheap either).

I just need a static uniform distribution of noise across the mesh surface.

Anybody got any ideas on how this could be done?

genpfault
  • 51,148
  • 11
  • 85
  • 139
Stinomus
  • 113
  • 7

1 Answers1

1

You could acquire 3d model space coordinates for each pixel in fragment shader and use some 3d noise based on those values.

Vasaka
  • 1,953
  • 1
  • 19
  • 30
  • Model space fragment coordinates is fine, and writing them to a Texture3D render target should be fine but can I just then sample that texture in another pass using the model space fragment coordinates? – Stinomus Jun 29 '13 at 01:26
  • 1
    My comment above may be a misunderstanding of what you meant in your answer. I think I understand what you mean now, instead of baking any of these values into a texture you mean calculating model space coordinates of each fragment and using a deterministic noise function each frame, that makes more sense, i'll give that a shot. – Stinomus Jun 30 '13 at 23:00
  • @Stinomus yes, that is what I was talking about. – Vasaka Jul 01 '13 at 07:54