0
\$\begingroup\$

I want to apply kind of noise/dust texture to objects so it would look good, and make it without having UV mapping in models. This is because I want to have a possibility to apply this to any objects, despite them having some other textures already. Just to have a way to make anything look little dirty.

It doesn't have to seam well between faces as this is noise type texture. The priority is that the texture scale is preserved.

In the vertex shader I have vertex coordinates as well as normal, binormal and tangent. I thought about projecting 3d vertex coordinates onto a plane defined by the normal and getting 2d coordinates from there, then use them as UV. But either I can't get the equations right, or it's not going to work. I check results on a sphere and I always get places where texture is stretching.

Is there any way to achieve good results?

I'm using XNA/Monogame, C#, HLSL if this matters.

UPDATE: I have found this:

Calculate Rotation Matrix to align Vector A to Vector B in 3d? https://math.stackexchange.com/questions/180418/calculate-rotation-matrix-to-align-vector-a-to-vector-b-in-3d/897677#897677

And I thought this could work:

  1. Find rotation matrix which would rotate plane normal to (0, 1, 0)
  2. Use this matrix to rotate current vertex position.
  3. Take (x, z) from the rotated position as (u, v).

However my math skills are not enough to make algorithms out if these equations. Would this work at all?

\$\endgroup\$
2
  • \$\begingroup\$ Have you considered volume texturing? \$\endgroup\$
    – DMGregory
    Commented Jan 1, 2016 at 14:07
  • \$\begingroup\$ As I wrote below, need to have some real image, maybe even a photo. Can I build a 3D texture fro image? \$\endgroup\$
    – Arek
    Commented Jan 1, 2016 at 19:37

1 Answer 1

1
\$\begingroup\$

You can use a small 3D texture for the noise and just use the model's vertex coordinates as texture coordinates.

https://msdn.microsoft.com/en-us/library/microsoft.xna.framework.graphics.texture3d.aspx

\$\endgroup\$
2
  • \$\begingroup\$ Can I build such a 3D texture from 2D image? My noise is going to be some dirt, so it is somewhat random but it's not generated. I might even have to get a real photo of it. \$\endgroup\$
    – Arek
    Commented Jan 1, 2016 at 19:36
  • \$\begingroup\$ It's extremely difficult to generate such 3D texture by hand. You're better off writing a procedural generator. The solution generally used in the industry (which was rejected in your question) is to pre-UV map the models with multiple texture layers: use a 2D dirt texture layer made by the artist and use a 3rd texture as an alpha mask to "apply" the dirt making it visible procedurally. It's also used for blood splatters and other similar effects. \$\endgroup\$ Commented Jan 2, 2016 at 5:15

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .