How do I store data from within the GPU? Like a dictionary for example?
I wanted to keep track of information with individual particles and have different shaders read to and write from it while being compatible with ios and android.
There are some information regarding it (ie. StructuedBuffer, RWStructureBuffer) in this forum. I couldn’t find how to utilize it in monogame as there seemed to be no nuget packages for it. Am also wary it may not be compatible with mobile platform.
i used chatgpt adn thought of this because of how film encodes sound in the margin on the film. that you see fi the projector guy is moving the camera to set the viewport …
I i tell the chapbot normal 3.5 or 4 , via teh talk interface, not a codex… to code you a monogame shader that will encode the cpu ray ID as some bits in the colors say the alpha channell or soemthing you dont need… then do yur hit test or hwatever , collisoin , cust via sampling , and have that map be in the out the , usdate a writeable raster surface or mask or textrue that you pass in ass a parameter or put it inthe .out of viewport area … then afster the blit, splat, draw or whatever, tell bot to decode the dictionary from the image pixels to the IDs to get bavck the array index of rays or whatever… or particles. that way you know which ray hit whay… this can work it you are doing some ray casts… say 250 of them… yo can fix the index in one ARGB channel adn sample it from the CPU side and if thre is a Hit or a collission… cheap and fast ray cut in 2d. im not sure about StrucuredBuffer that might be for. inf the Compute branch wiht has no IOS support last i checked… its a bit hack like but ist practical and the robot coded it like its been done betore or it invented it as i told ti to… if there is a proper way the bot didnt know it do i made that up from my film audio signal encoding.
in fluid shaders the colors are used as velocity fields and normal maps and signed distance fucntions. its normal to do that …i think…
I have never actually tried this, but my initial thought would be to write the shaders that share memory into the same MG Effect as different Techniques.
They don’t have to be in the same file: you can use #include MyFile.fx to split up fx files and reuse shader code (a fact that took me a frankly embarassing amount of time to discover).
I suspect a ‘global’ array is something you can’t implement on the GPU for much the same reason you can’t access one C# applications variables from other applications. ‘Shaders’ are programs that run on the GPU: exposing them to each other is just asking for trouble.