Skip to content
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

Extend specification of "geomPropValue" to be able to specify varying vs uniform inputs #1051

Open
bernardkwok opened this issue Dec 7, 2020 · 2 comments
Labels
Core Core change required Enhancement New feature or request ShaderGen Shader Generation change required
Milestone

Comments

@bernardkwok
Copy link

#1042, fixes so that varying inputs are created for all but boolean and string properties. The focus for hardware shading APIs (e.g. GLSL) and tbd effect on software shading APIs (e.g OSL)

This is a placeholder update the specification to be able to explicit allow denoting whether something is varying vs uniform.

If we take into account support for USD "primvars" then note that varying also has a frequency (per face vs per vertex) which
could be considered as a "hint" for the binding.

Some ideas:

Idea 1: from @niklasharrysson (keep same interface with references which indicate frequencey)

  • Longer term we should start using the geompropdef element. This is already in the spec and should be used to define new geometric stream/properties like this.

So before you can call the geompropvalue node to get the value from a geomprop this geomprop has to be defined first using a geompropdef element. If/when we start using this we could introduce a "uniform" attribute on these definitions to tag the geomprops as being uniform or varying. Boolean and string would naturally always be "uniform"

Idea 2: from @JGamache-autodesk (vary the interface to indicate frequency)

  • recommend splitting the nodedef into varyinggeompropvalue and uniformgeompropvalue
@bernardkwok bernardkwok added Enhancement New feature or request ShaderGen Shader Generation change required Core Core change required labels Dec 7, 2020
@bernardkwok bernardkwok added this to the 1.38 milestone Dec 7, 2020
@JGamache-autodesk
Copy link
Collaborator

For USD, we can not resolve a constant PrimVar as a uniform parameter. This would force compiling 2 shaders per geompropvalue just in case we have a single value in the PrimVar versus an array of values at bind time. For multiple geompropvalue the number of shader combinations would explode.

The solution could be to always declare these values as varying on the OpenGL codegen side, and use constant vertex attributes at bind time if the PrimVar is a constant. This can be done using the correctly typed variant in the https://www.khronos.org/registry/OpenGL-Refpages/gl4/html/glVertexAttrib.xhtml family of functions.

@bernardkwok
Copy link
Author

bernardkwok commented Dec 8, 2020

Leaving a "current state" note:

  • Current unit tests look like this:
    geomprop_tests.pdf
  • For OSL getattribute() is called but routes nothing as these attributes don't exist via the stock sphere geometry given with testrender.
  • For MDL (not shown) geompropvalue is not currently implemented MDL: Add support for geompropvalue and scene color data #1052 (Part of MDL 1.7 support list).
  • The GLSL unit test render can route varying data. Uniform into varying routing would need to be added but is not hard to do using the technique from above. Note that the GLSL test render does not have uniform buffer object support testing so that is additional work.

@bernardkwok bernardkwok modified the milestones: 1.38, 1.39 Jan 15, 2021
@kwokcb kwokcb modified the milestones: 1.39, 1.38.4 Dec 16, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Core Core change required Enhancement New feature or request ShaderGen Shader Generation change required
Projects
None yet
Development

No branches or pull requests

3 participants