-
Notifications
You must be signed in to change notification settings - Fork 358
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add imagearray node #2132
base: main
Are you sure you want to change the base?
Add imagearray node #2132
Conversation
For OSL, would it make sense to have the filename *within* the textureresource struct be the array, and keep colorspace as a regular non-array string? How often would you have an array of images feeding into an <imagearray> that weren’t all in the same colorspace?
|
Really? That sounds like maybe a bug or just something unimplemented because the case didn't come up. |
@lgritz - I posted this issue to the OSL project, as a response to your comment above. If there's a good reason things are the way they are feel free to close. @crydalch - This is not an array of filenames, but instead a MaterialX realization of the hardware shading concept of texture arrays, where a number of images are bound to a single texture unit and then selected by index. So you read the texel from an by providing a UV value and an integer index, and then get back the color(?) value. I guess we could provide a nodegraph fallback implementation that works the way you describe - but for the hardware languages I think we would likely want to directly use the hardware support. This nodegraph idea might work around the current complexities in the OSL implementation. I don't think this proposal necessarily infers array versions of other nodes, at least not yet, and certainly not necessarily. Though I can see a world where one might want to add an image-array version of something like hextile for instance, and then randomly selecting an index to use to increase variation in the generated texture. |
…SL and MSL. OSL not yet supported since arrays of structs are not permitted as parameters in OSL - so textureresource needs to be refactored in OSL.
… imagearray - to hopefully make this an easier adoption.
2451cc4
to
093fcb4
Compare
As previously discussed, this PR adds a new
<imagearray>
node. It behaves very similarly to the<image>
node but accepts an array of filenames, instead of a single file. Theindex
integer input is used to select which filename from the array of filenames is used.This PR adds shader gen and render support for both MSL and GLSL. Both MSL and GLSL use texture arrays to implement the
<imagearray>
node.I attempted an OSL implementation, but the texture filename in OSL uses a struct (
textureresource
).In order to support
<imagearray>
in OSL we would need an array of thistexture resource
struct. Unfortunately arrays of structs are not supported as OSL parameters.I believe we should be able to refactor how filenames and colorspaces are managed in OSL, and thus allow
<imagearray>
to be supported in OSL, but I'm opting to leave this to a follow up PR, as its likely to be a more invasive change.