I’ve been thinking how to paint a 3d model texture in 3d.
I am thinking of actually how a modelling program would do it not a game. So it needs to modify the texture.
I have failed to find anything on this topic from my searches. That is probably more to do with having the right terminology.
My current thought is rendering to texture the uv coordinates so you have the uv locations in screen space. Though the texture could be more detailed than the screen space and would miss some pixels. Also I am not sure what would be the best way. using cpu to manually edit these values into the texture or using a shader.
I’m hoping there is simpler way that also hopefully works across seams.
Any help or ideas are much appreciated.
Blender has this feature, calling it texture painting.
Indeed a shader could output as color the current uv coords, and a simple readpixels under mouse cursor would give you the texcoord. Then go the the texture and paint a circle, done.
Of course plenty of subtle precision issues can arise. Going across seams for example, could be solved by reading not only a single pixel but a few that cover the brush, so that it will detect that the brush must be painting at 2 (or more) different parts of the texture.
I was hoping there would be more solutions.
reading and writing pixels sounds pain-full and not efficient.
I can not think of any glsl solution that could write to a texture in this situation.
I am thinking that when I click I do a render to texture that is just as wide as the brush. The resolution can be ramped up aswell. and render the texture uv to r,g and the brush uv to b,alpha(in-case it is rotated or part of a bigger image).
problem is more when writing the texture. I essentially need to re upload the entire texture after editing as it is not just editing a small rectangular area of a texture. I suppose I could loop through and work out the smallest area. I suppose i’ll just need to try it.
WHAT rot to suggest it is embarras