Passing a float3 from script?
Posted: Fri Mar 01, 2019 12:32 am
he leading questions is... can I and if so how do I pass a float3 from c# to a shader? I think this will solve my problem.
Here's the whole story:
I have a character made up of several interchangable models. Each of the models has a pivot that don't necessarily align. I want to design a shader that has a treatment toward the bottom of the model set.
Here's a picture of a test case:
T
I got it working on a pair of test shapes (on the left), a sphere and a cylinder. I just pass vertex position in to the UV's, and they have an aligned projected texture through the whole set, sweet!
But... on the right... is the scenario I'm working with. It's multiple models with variant offsets. And the character can move around the level and rotate, etc... But because the models have different positions, compared to the parent "Empty", the uv's are not coherent, so what's at the bottom of one of the meshes doesn't line up with what's at the bottom of the next piece.
So... to solve this, I'm imagining I can use a script to just pass the position of the parent "Empty" node, and use that as an offset (added to world position node). But I don't know if/how a shader can take in external data like that from script. Is that possible?
Here's the whole story:
I have a character made up of several interchangable models. Each of the models has a pivot that don't necessarily align. I want to design a shader that has a treatment toward the bottom of the model set.
Here's a picture of a test case:
T
I got it working on a pair of test shapes (on the left), a sphere and a cylinder. I just pass vertex position in to the UV's, and they have an aligned projected texture through the whole set, sweet!
But... on the right... is the scenario I'm working with. It's multiple models with variant offsets. And the character can move around the level and rotate, etc... But because the models have different positions, compared to the parent "Empty", the uv's are not coherent, so what's at the bottom of one of the meshes doesn't line up with what's at the bottom of the next piece.
So... to solve this, I'm imagining I can use a script to just pass the position of the parent "Empty" node, and use that as an offset (added to world position node). But I don't know if/how a shader can take in external data like that from script. Is that possible?