Quantcast
Channel: Questions in topic: "compute shader"
Viewing all articles
Browse latest Browse all 287

Compute shader "Fill With Red" example not working

$
0
0
I want to get started with compute shaders but I seem to be stuck on the very first step. Here is my example code: private void Update() { if (Input.GetKeyDown(KeyCode.G)) { m_outputRenderTexture = new RenderTexture(m_width, m_height, 0); m_outputRenderTexture.enableRandomWrite = true; int kernelIndex = m_computeShader.FindKernel("CSMain"); m_computeShader.SetTexture(kernelIndex, "OutputTexture", m_outputRenderTexture); m_computeShader.Dispatch(kernelIndex, 1, 1, 1); } } and the referenced compute shader: #pragma kernel CSMain RWTexture2D OutputTexture; [numthreads(1,1,1)] void CSMain (uint3 id : SV_DispatchThreadID) { OutputTexture[id.xy] = float4(1, 0, 0, 1); } So when I press "G" I should see "m_outputRenderTexture" become red, I think? Nothing seems to be happening, though. I've tried getting compute shaders to fill simple buffers successfully so I at least know they're working.

Viewing all articles
Browse latest Browse all 287

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>