Page 1 of 1

[V ENB] Render Target issue

Posted: 09 May 2020, 11:43
by icelaglace
Hey Boris,

Is there a way to fix this issue or at least if you can point me to the correct direction to fix it :
In a shader, discard the pixels like
clip(coord.x > 0.5 || coord.y > 0.5 ? -1 : 1);


Using RenderTargetRGB32F, it generates garbage as it's not clearing it up.
Using RenderTargetRGBA64F, it keeps the image in the buffer and does not clean it.

My expected behaviour was black, it shows me garbage from the RenderTargetR16F buffer.
Image

I know it's an odd thing to try but I was testing something.

Thank you :)

EDIT : Solved, check Kitsune's method.

Re: [V ENB] Render Target issue

Posted: 09 May 2020, 13:29
by Kitsune
I usually fixed these issues by adding a second pass to the technique to clear out the render target beforehand. Something like that:

Code: Select all

//Pseudocode:
technique ExampleTech
{
    pass 0 { /* PixelShader that returns 0.0 */ }
    pass 1 { /* PixelShader with clipping op */ }
}
Alternatively you could also return 0.0 directly instead of discarding pixels by using if(any(coords > 0.5)) return 0.0;. Depending on what you want to do with your shader.

Re: [V ENB] Render Target issue

Posted: 09 May 2020, 13:42
by icelaglace
Thank you Kitsune!

I actually did try the same method earlier, it worked fine when I tried to clean up before writing new stuff on the render target. :)

I reported this because it's usually much better to clear the context on the CPU side rather than the GPU side.
Writing 0 as a pass is a hack, while working, isn't ideal. :mrgreen:

Re: [V ENB] Render Target issue

Posted: 09 May 2020, 13:59
by ENBSeries
I dont know which render targets will be used, so prefer to not waste performance cleanup them all. So yeah, extra prepass is good thing and the only one (and much better than using "if") condition.

Re: [V ENB] Render Target issue

Posted: 09 May 2020, 14:01
by icelaglace
Fair enough!
Thank you Boris!