Hi everyone,
I'm curious about something. I'm using structured buffers to send data in a vert/frag shader wrapped in a DX11 api check.
With the new experimental OpenGL stuff I was hoping that those might "just work" like compute shaders. This is sadly not the case.
Has anyone else tried this? From what I understand about OpenGL(which isn't a lot), there isn't an exact cross over for DX StructuredBuffers, but is there something else that Unity's compute buffers will work with?
Replies
It turns out using surface shaders are what's failing, not the structured buffer conversion:
This works just fine:
This does not: it fails at the line StructuredBuffer with "Syntax Error"
http://forum.unity3d.com/threads/structuredbuffer-with-surface-shader.173000/
I think it should work. Here's a snipped that will be in the documentation really soon:
"DirectX 11 HLSL syntax and Surface Shaders
Currently some parts of surface shader compilation pipeline do not understand DX11-specific HLSL syntax. If you're HLSL features like StructuredBuffers, RWTextures and other non-DX9 syntax, you have to wrap it into a DX11-only preprocessor macro:
#ifdef SHADER_API_D3D11
// DX11-specific code, e.g.
StructuredBuffer<float4> myColors;
RWTexture2D<float4> myRandomWriteTexture;
#endif
"
I normally have it wrapped in the API checks, but I can't do that if compiling to OpenGL or OpenGLES.