+3
W trakcie analizy
Support for arrays both local and global (Unity 5.4)
Unity 5.4 allows us to pass arrays of floats, vectors, and matricies to the shader. It also allows us to set global arrays of float/vectors/matricies.
I am not sure how you would interact with arrays with the current node graph, but, for a start, it would be nice to be able to define float/vector/matrix array inputs in our node graph (with the ability to toggle between local/global, as with other shader inputs) and allow us to connect these as inputs to code nodes so we can do whatever we like with them.
Customer support service by UserEcho
Bump
Possibly at some point, but I'm currently swamped in work on another project I'm afraid :(
hey buddy,
Maybe it would be a good idea to give us the power to inject snippets of code in to the shader. I keep running in to issues I could solve using code blocks but I end up needing to declare some variables, and that is impossible to do within shader forge. You need to edit the shader manually. Which sucks.
If in the side bar we could type in some code and have shader forge inject that into the part of the shader where variables are defined, we could work around issues like this where you are unable to keep up with new features. :)
For example, to get array support,i could just tell shader forge to inject "uniform float arrayName[2];" in to the area where variables are defined, and then I can make use of this in a code block. Boom, preliminary array support. I was also just reading a feature request on here regarding projection shaders. The user got it mostly working except that he needer to use a place holder node which he had to later swap out with the correct projection UVs. (I assume by declaring the projecttion UV variable and replacing his place holder variable with that instead). If we had this feature, that issue would be solved too. I am no shader expert but feel that this could be easy to implement and offer good "bang for buck" for you when it comes to deciding which feature will be most useful versus how much effort you have to put in to achieve it.
Bump.. I keep budding heads with this restriction, please atleast provide some way for us to make use of global arrays in code blocks, maybe something like what I mentioned in the comment above. I totally understand that adding node graph support for arrays is going to be a beast of a feature for you to implement. I'm happy to wait for a official solution but in the meantime let us make do with code blocks. Maybe an experimental array input node (which can be toggled to "global" like other input nodes), and make it so that it can only connect as an input to a code block or something.
I don't know the cleanest or nicest solution here, but something would be better than nothing...
This is quite tricky to do right. Ideally, this would work similar to textures, as in, you have an ArraySource (Similar to TextureAsset) and an ArraySampler (Similar to Texture2D when Tex input is connected), but at this point, adding additional type of inputs/outputs is more and more convoluted and tricky. I can look into it, but I can't make any promises. Which type is most important for you? float arrays? float4 arrays?
Float4 arrays keep coming up again and again for me. Id like to be able to pass, say, an array of World positions to my shader.
An example: foliage being deformed/moved around by characters walking around the world. I was able to put this together by encoding positions as pixels in a global texture. This shader was made in SF for an aquarium game I never actually finished https://gfycat.com/InfantilePersonalArchaeocete
It works, but it's clunky. I pass the texture source in to a code block and just iterate and sample all pixels and compute an offset for each vertex using 2 for loops. Its clunky and requires lots of texture lookups. Not to mention having to maintain some texture by changing the pixels and reuploading it to the gpu when something moves.
Again, I'm happy to wait for a polished solution, but some form of preliminary experimental support for them would be nice.
I'm not sure arrays would help much in this regard. I think the proper solution would be to have a low-res render texture containing motion data, projected onto your whole patch of grass, and then sample that texture in world space to get the grass offset data you need. Even if SF had array support, it wouldn't have for-loop support in any case
Fair enough, I have not had much experience with arrays, I've learned most of what I have through shader forge so I'm not sure on the limitations and such. What about, say, a heatmap? I have a strategy game with resources underground, represented as an array of vector3 positions for where each patch of ore is under ground. It woukd be nice to pass this to a shader and render out a heat map.