1
$\begingroup$

I am new to graphics programming and i'm learning opengl. I managed to make a really simple renderer where i can import models display theirs textures with all lighting. My goal is to make a simple painting software like Substance painter or Mari but much much simpler and i don't have any idea on how they work ? I googled but couldn't find a good answer.

Thanks.

$\endgroup$
3
$\begingroup$

We had some related questions lately, so you might find them useful:

I can't tell you how the named applications do it, since I don't have access to the code, but painting onto a 3d model could be achieved as follows:

When you click the "paint" button, you cast a ray from the camera position into your 3d scene. For perspective projections, the direction depends on the mouse's screen position. You can look into my answer to this question to get an idea of how this is done.

Now perform a collision check of the ray and your model to find the affected triangle/triangles and vertices. Calculate the Barycentric coordinates where the ray hits the affected triangle. Use them to interpolate the texture coordinates of the intersection point. From the model data, you should know, which texture is used at the target location.

Now you know where you want to paint in your models' texture. How to proceed depends on what you want to paint. In case you just want to paint a pixel, you have to overwrite the texture's pixel at this location. You can do this either on the CPU or on the GPU using the rendering pipeline.

If you don't understand some things I mentioned yet, read the links I provided and continue learning OpenGL. Things will get clearer as soon as you know the rendering pipeline and get used to working with textures. If something is still not clear after that, feel free to ask.

| improve this answer | |
$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.