I need to have some variable/object in the graphics memory that can be accessed within my fragment shader and within my normal C# code. Preferably a 16Byte vec4
What I want to do:
- [In C#] Read variable from graphic memory to cpu memory
- [In C#] Set variable to zero
- [In C#] Execute normal drawing of my scene
- [In Shader] One of the fragment passes writes something to the variable (UPDATE)
- Restart the loop
(UPDATE) I pass the current mouse coordinates to the fragment shader with uniform variables. The fragment shader then checks if it is the corresponding pixel. If yes it writes a certain color for colorpicking into the variable. The reason I dont write to a FS output is that I simply didn't find any solution on the internet on how to get this output into my normal memory. Additionaly i would have an output for each pixel instead of one
What I want is basically a uniform variable that a shader can write to.
Is there any kind of variable/object that fits my needs and if so how performant will it be?