-
-
Notifications
You must be signed in to change notification settings - Fork 51
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
support more procedural shader uniform types, including arrays #1178
base: master
Are you sure you want to change the base?
Conversation
@@ -356,16 +356,53 @@ void Procedural::prepare(gpu::Batch& batch, | |||
} | |||
} | |||
// Then fill in every reflections the new custom bindings | |||
int customSlot = procedural::slot::uniform::Custom; | |||
size_t customSlot = procedural::slot::uniform::Custom; | |||
_slotMap.clear(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
per the spec, float/vec2/vec3/vec4/mat3/mat4 take up a single uniform slot, whereas array types take up as many as the length of the array.
we compute how many slots each uniform is going to need up here, and then in Procedural::setupUniforms
we can just look it up
std::string uniformName = key.toLocal8Bit().data(); | ||
std::string trueUniformName = uniformName; | ||
if (isArrayUniform) { | ||
trueUniformName += "[0]"; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
due to the internals of how our shader management classes work, reflection->uniforms expects the slot to be specified for just the first element of array types, with [0]
included at the end of the string
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is awesome :)
Could we add example script to our scripting API documentation?
great point, maybe the best place is to update the procedural shader guide? I added some more info and an example here: overte-org/overte-docs-sphinx#54 |
Thank you! I think it's the best way to do it. |
procedural shaders previously supported uniforms of types float, vec2, vec3, and vec4. this PR adds support for mat3, mat4, vec3[], vec4[], mat3[], and mat4[].
here is a script that demonstrates this feature. it creates a procedural particle entity and places a new particle every time you click on an entity (up to 50 particles in this example but it would support more). in the vertex shader, the click positions (and normals) are sent as a uniform vec3[].