- Home /
CustomRenderTexture how do you get the current pixel?
Ok so obviously I'm missing something. All I want to do - really simple i believe - is: on each Update call to the CustomRenderTexture material i want to take each pixel from the CustomRenderTexture and lerp it towards red so that over a period of time it turns completely red. so... I'm trying ...
half4 frag(v2f_customrendertexture i) : COLOR
{
float2 uv = i.globalTexcoord;
half4 redColor = {1,0,0,1};
half4 myPixelColor = tex2D(_MainTex, uv);
half4 c = lerp(redColor , myPixelColor , 0.99);
return c;//
where _MainTex is set to the CustomRenderTexture that has the material with this shader on set as its update material. and i call update every frame on the crt. but what i don't see is any iterative change I guess i shouldn't be using _MainTex like that but i can't see where to get the current pixel color from the custom render texture from. I tried _SelfTexture2D but i couldn't get that to work and that's for double buffered ones anyway and i don't believe i need it double buffered for this - right? I'm running this on windows in the Editor.
The way I'm trying to put pixels into the rendertexture is just by turning a camera on and off that draws to it. As soon as I turn off the camera the cube it was drawing into the rendertexture disappears immediately instead of fading to red.
any guidance appreciated! Thanks.
Answer by rossstyantsemteq · Jun 13, 2019 at 09:27 AM
Ah ok... so this does need to be double buffered. because i'm sampling individiual pixels from the preceding result. When i set it to double-buffered and use _SelfTexture2D it works... it fades up from black to red... but when i turn on and off the camera that draws a cube (without clearing) to the render texture - the cube just disappears from the render texture instead of as i would expect staying there and fading out....Hmmmm...
Answer by Sonia120 · Jun 13, 2019 at 11:26 AM
I don't know how to setup a custom render texture shader with Amplify so any advice on this??kroger survey?
Answer by christopher1238 · Jun 18, 2019 at 06:28 AM
Ok alright... so this needs to be twofold cushioned. since i'm inspecting individiual pixels from the former outcome. When I set it to twofold supported and use _SelfTexture2D it works... it blurs up from dark to red... however, when I turn on and off the camera that draws an auto dialer solid shape (without clearing) to the render surface - the 3D shape just vanishes from the render surface rather than as I would expect remaining there and blurring out
,Im not getting it all please help me that how can i fix this issue im unable to setup a customized render texture shader feeling very helpful krogerfeedback