passing array attributes to a shader

   2527   6   1
User Avatar
Member
1799 posts
Joined: Oct. 2010
Offline
Hey guys, I am having a bit of an issue with a shader and wanted to see if anyone has found a way around this issue…

I have several array attribute, which I want to pass to a shader to do some operations. So far I have tried:

- just a straight up bind VOP to bring in the array attribute. Does not seem to work ):

- bring the array as a joined string, then split in the shader into a string array. Hacky, but could work. Works great on string arrays, but I cannot seem to find a way to convert strings to floats or ints for numerical arrays ):

So I am wondering if:

- anyone knows how to import array attributes into a shader?
- anyone knows of a way to convert strings to numericals?
- anyone knows of a way that I am not thinking of?

super thanks in advance if you can help me!
-G
User Avatar
Member
8555 posts
Joined: July 2007
Offline
string to float = atof()
float to string = ftoa()
Tomas Slancik
FX Supervisor
Method Studios, NY
User Avatar
Member
1799 posts
Joined: Oct. 2010
Offline
lol thank you! too busy looking at VOPs to look at vex docs strange we do not have a vop for this..!
-G
User Avatar
Member
1799 posts
Joined: Oct. 2010
Offline
ouch.. this would not work with passing an array of UVs eh… cant quite interpolate strings in between vertices…?
-G
User Avatar
Member
1799 posts
Joined: Oct. 2010
Offline
ok time to rephrase my question:

I want to pass N amounts of UVsets to the shader, and I want, on a per sample basis, pick which UVSet I am using. what I have noticed:

- Shading Layer Param does not allow you to use a variable or bound attribute to control the shading layer

- I cannot import array attributes

- I cannot use strings as they cannot be brought in by vertex since they cannot interpolate

has anyone ever brought in an arbitrary number of UVsets into a shader and switched which UVset a sample uses?

Alternatively:

- has anyone implemented a UV project from camera VOP node, similar to the UV Texture SOP? Unfortunately the UV Project VOP only does cylindrical, polar, and orto ):

my eternal thanks…
-G
User Avatar
Member
1799 posts
Joined: Oct. 2010
Offline
ok found a way around the issue where I bring my cameras info in the shader as string arrays, then split them to calculate my projection UVs. Cool.. BUT…

now atof() does not seem to want to return my floats ): it either seems to return 0 or -1 when trying to pass my single split string off the array. Would love to be able to see why this is happening, but print does not seem to be printing anything to console either during a render…
-G
User Avatar
Member
1799 posts
Joined: Oct. 2010
Offline
mhhh.. ok digging deeper… looks like I unearthed a bug which causes a foreach sop to run twice, the second time invalidating the data. I will see if I can isolate the repro case and send to sidefx..
-G
  • Quick Links