I'm using HLSL Shader Model 5.0. I'm using a Texture2D with the vertex positions for a mesh. In the Shader I'm trying to displace patchepositions along the normal of the patches I'd like to actualize the new position to the texture out of the shader, so the next patch is using the modified value. There is the Load function for loading values out of the texture, but is there a function to store values back into the texture? I didn't find anything. How do you guys managing similar problems? thx
In Direct3D 11.1 you can use unordered access views (UAVs) for read-writable textures in all shader stages. So you can add an If you're limited to Direct3D 11.0, you could implement your displacement operation using a pixel shader and doing a standard full-screen pass on the texture containing the positions. Another possibility (though likely slower) is using a compute shader. In either case, you would do this as a pre-pass before actually drawing the displaced mesh. |
|||||||||||||||||
|
You cannot moddify textures in the pixelshader that way, the only way to do that is to render to a texture. Direct compute offers you the possibility to read and write data to a texture on demand. you could achive your diserd effect by having a Direct compute pass. Here is a good link to msdn about compute shaders |
|||
|
Since it's vertex data you want to store somewhere you also have the option of using stream out from either the vertex or geometry shader. |
|||
|