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

Reading and Writing to the same texture

$
0
0
Hi, I am trying to create a paint-like shader where the shader draws color into a texture while preserving the paint from the previous frame. #pragma kernel Paint Texture2D Input; RWTexture2D Out; SamplerState samplerInput; float2 position; float radius; [numthreads(32, 32, 1)] void Paint(uint3 id : SV_DispatchThreadID) { float4 colorIn = Out[id.xy]; float xdist = position.x - id.x; float ydist = position.y - id.y; float dist = sqrt(xdist * xdist + ydist * ydist); int on = sign(radius - dist); Out[id.xy] = float4(max(colorIn.r, on), 0.0, 0.0, 1.0); } This code was working, but stopped working when I updated to Unity 2017.3.1f1. Is there a better way to do this that won't break when Unity updates?

Viewing all articles
Browse latest Browse all 287

Trending Articles



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