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:
- Find rotation matrix which would rotate plane normal to (0, 1, 0)
- Use this matrix to rotate current vertex position.
- 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?