How do you create a cbuffer or global variable that is gpu modifiable?

Posted by bobobobo on Game Development See other posts from Game Development or by bobobobo
Published on 2012-06-27T18:58:50Z Indexed on 2012/06/27 21:26 UTC
Read the original article Hit count: 977

Filed under:
|
|

I'm implementing tonemapping in a pixel shader, for hdr lighting.

The vertex shader outputs vertices with colors. I need to find the max color and save it in a global.

However when I try and write the global in my hlsl code,

//clamp the max color below by this color
clamp( maxColor, output.color, float4( 1e6,1e6,1e6,1e6 ) ) ;

I see:

error X3025: global variables are implicitly constant, enable compatibility mode to allow modification

What is the correct way to declare a shader global in d3d11 that the vertex shader can write to, and the pixel shader can read?

I realize this is a bit tough since the vertex shaders are supposed to run in parallel, and introducing a shader global that they all write to means a lock..

© Game Development or respective owner

Related posts about shaders

Related posts about directx11