Author Topic: Material Picker Channel Lock  (Read 251 times)

I was going to post under discussion, but after a few minutes of searching, then thumbing through the the API, I figured asking a few questions to try and implement this myself would be better than creating another post for a feature that has been requested since 2015.

I'm hand painting height information that will have all be converted to normal maps for the final export. Therefore, I'd like to be able to sample layers I've already drawn to get my prior height settings as I work.

Not being able to lock or restrict the layers I sample from or at least filter the results to my chosen brush settings when sampling using the eye drop makes the process tedious. I have enough distinct layers that making a dozen fill layers at different heights isn't productive either.

What I can't seem to understand is why this feature, which has been long requested, is difficult to implement.

Full disclosure, I only started looking through the API about 30 minutes ago as I was writing this post so I'm hoping I'm just glossing over something easy.

A quick survey of the classes didn't reveal a quick solution. Only the "shader picker" is returned under search when looking for Material Picker.

So before I dive deeper, I was wondering if this is feasible with what is currently exposed in either the JavaScript or Python API.

I see I could add a custom ToolBarWidget from a qml file if I wanted to implement my own tool.
I see that there are functions to query the available channel identifiers as well as different queries for identifying information in the shader.

However, what I don't see is an ability to call the color picker functionality, which I assume is complex enough. I don't know how substance painter works under the hood, so things like intersection tests, reversing the transforms to UV space to sample textures in memory, or maybe some big G-Buffer variants holding all the info and just literally sampling from that come to mind.

Most of the JavaScript documentation appears to revolve around extending the UI or calling existing functionality that has been exposed for things like the baker, resources, and saving the project.

I tried looking at the Python documentation to see if there is a more extensive set of methods, but didn't find much at this time.

So I'm left more with just wondering about what is under the hood. I assume the algorithm you use to sample the screen space pixel using the material picker already has some sort of filtering present as you'd need to match up the returned results with channels that are enabled by the user. Although, by my count, with only 28 channels currently in Substance Painter, I do wonder why a 32 bit mask couldn't be passed as an optional parameter in whatever function call completes the process. Of course, that imposes a temporary limit and who knows how many channels you'll support later.
Better would just be an intermediary function above the base code for performing material value lookup could be added that would look at the existing set of channels enabled by the user in the current tool and only populate those portions that are activated.

George Lecakes
Director
Rowan VR Center

The Material picker will always pick all the channels for now.
Being able to restrict which channel should be picked is a feature request currently in our backlog.

So I'm left more with just wondering about what is under the hood. I assume the algorithm you use to sample the screen space pixel using the material picker already has some sort of filtering present as you'd need to match up the returned results with channels that are enabled by the user. Although, by my count, with only 28 channels currently in Substance Painter, I do wonder why a 32 bit mask couldn't be passed as an optional parameter in whatever function call completes the process.
I would have to check, but I'm pretty sure the system doesn't work like that. That would limit us in some ways. When you pick on the mesh we retrieve the UV coordinate, which gives us a position and which pixel to read for each channel. Then we look at the pixel alpha value to know if we should discard the information (aka enable or not the channel in Tool material list).
Don't forget your log file. It can be exported from the Help menu of the software.
-----------
Fabrice Piquet aka Froyok. Product Manager, Technical Artist and Documentation at Adobe.