StarfallEx icon indicating copy to clipboard operation
StarfallEx copied to clipboard

RenderTarget is affected by HDR when rendered to itself.

Open thegrb93 opened this issue 8 years ago • 18 comments

I never noticed since I leave HDR off, but maybe needs http://wiki.garrysmod.com/page/Enums/CREATERENDERTARGETFLAGS to fix. dunno

thegrb93 avatar Nov 30 '16 02:11 thegrb93

~~Also doesn't seem to affect gm_flatgrass~~

thegrb93 avatar Nov 30 '16 05:11 thegrb93

it does affect in gm_flatgrass Without HDR

With HDR

h3xcat avatar Dec 18 '16 07:12 h3xcat

I'll look at it in the morning. Just finished the semester so should have some time.

thegrb93 avatar Dec 18 '16 10:12 thegrb93

I still can't reproduce it. Can I get a copy of some code to reproduce it with? (I think @Damianu gave me one, but I don't have it anymore).

thegrb93 avatar Dec 22 '16 11:12 thegrb93

Without HDR

With HDR

hdr_test.lua

h3xcat avatar Dec 22 '16 12:12 h3xcat

I think it's because the background is pure black which makes HDR overcompensate. Look at the sky in the background, it turns white too.

thegrb93 avatar Dec 22 '16 19:12 thegrb93

I got to figure out why wire screens don't get affected this way though.

thegrb93 avatar Dec 22 '16 19:12 thegrb93

By the way, Matrix() returns an identity matrix.

thegrb93 avatar Dec 22 '16 19:12 thegrb93

I think the only difference between starfall and wiremod is they use cam.Start3D2D while starfall's uses 3D.

thegrb93 avatar Dec 22 '16 23:12 thegrb93

The render target stores the image after HDR processing. And because I reuse old render target image, it turns old pixels brighter and brighter in each frame. Wire screens don't reuse old render target images, so its not visible.

That's my guess.

h3xcat avatar Dec 23 '16 00:12 h3xcat

So I need to modify RT textures to not do any HDR. I'll try

thegrb93 avatar Dec 23 '16 00:12 thegrb93

Not sure how. Tried this but no cigar.

GetRenderTargetEx( rtname, 1024, 1024, 
	RT_SIZE_OFFSCREEN, 
	0,  
	2048, 
	0, 
	IMAGE_FORMAT_DEFAULT 
)

I'll see if anyone replies to https://facepunch.com/showthread.php?t=1508566&p=51570474&viewfull=1#post51570474 otherwise I'll make a request in the garrysmod requests.

thegrb93 avatar Dec 23 '16 00:12 thegrb93

Okay, I've found out that this only happens when you render the rendertarget to itself.

thegrb93 avatar Dec 23 '16 23:12 thegrb93

Actually it does not. For me it was enough to draw web image to renderarget and hold it in memory, then it goes darker but not full dark. When you render rendertarget to itself its more glitchy than HDR.

Damianu avatar Jan 05 '17 01:01 Damianu

If I remember correctly, wire screens are affected similarly.

thegrb93 avatar Jan 05 '17 03:01 thegrb93

Going to leave it open for future reference.

thegrb93 avatar Feb 28 '17 20:02 thegrb93

If anyone wants to know the solution. Use a double buffer (i.e. two rendertargets).

thegrb93 avatar Sep 08 '17 20:09 thegrb93

There might be a material flag that can be applied to the rendertarget material to prevent this. I'm not yet willing to spend the time experimenting to test this theory yet, but it might be fixable.

thegrb93 avatar May 14 '18 18:05 thegrb93