Binsk
Member
EDIT: Solved, see this post
Howdy!
I'm well along in designing a 3D engine for GameMaker and in doing so have tread on a lot of new ground, for me, anyway. One part of this has been Gamma correction / HDR. GameMaker poses some interesting problems and I am reaching out hoping that someone who has better experience with these concepts can help me out.
Where I'm at is I've designed the beginnings of a deferred shading system. I render textures for ambient, albedo, metallic, roughness, normal, and depth when generating the GBUFFER. I then calculate lighting in chunks before resolving the final values.
The problem comes when I need to apply gamma correction. This is something that needs to be done on the final combined lighting value as I understand it. My problem arises when it comes to storing the color data between passes.
As GameMaker is limited to RGBA8 buffers the precision is way too low and once I pass the data outside the shader I lose a lot of detail, especially since values will be higher than the [0..1] range. This causes extreme banding once I apply the gamma correction at the end.
I have tried to split the colors into two separate buffers and then merge them together when calculating gamma effectively giving me 16bits for each color. This provides a significant improvement but still has very obvious banding. There's also just the imprecision of the packing/unpacking in the first place and the fact that each individual 8-bit channel can now go above the threshold when combined over multiple passes.
I am thinking the fundamental issue is trying to store values larger than 1 since that will always go out of range and get 'clamped' by the datatype as even storing everything in RGBA8 looks fine so long as I calculate all the lights and perform the gamma correction in a single pass. I can't seem to find a proper solution to this multipass problem wherever I look.
Is anyone there that understands how this is generally accomplished? Any ideas, concepts I should research or anything would help me with this one. Is there some other way I can format my MRTs that would help with doing this?
Howdy!
I'm well along in designing a 3D engine for GameMaker and in doing so have tread on a lot of new ground, for me, anyway. One part of this has been Gamma correction / HDR. GameMaker poses some interesting problems and I am reaching out hoping that someone who has better experience with these concepts can help me out.
Where I'm at is I've designed the beginnings of a deferred shading system. I render textures for ambient, albedo, metallic, roughness, normal, and depth when generating the GBUFFER. I then calculate lighting in chunks before resolving the final values.
The problem comes when I need to apply gamma correction. This is something that needs to be done on the final combined lighting value as I understand it. My problem arises when it comes to storing the color data between passes.
As GameMaker is limited to RGBA8 buffers the precision is way too low and once I pass the data outside the shader I lose a lot of detail, especially since values will be higher than the [0..1] range. This causes extreme banding once I apply the gamma correction at the end.
I have tried to split the colors into two separate buffers and then merge them together when calculating gamma effectively giving me 16bits for each color. This provides a significant improvement but still has very obvious banding. There's also just the imprecision of the packing/unpacking in the first place and the fact that each individual 8-bit channel can now go above the threshold when combined over multiple passes.
I am thinking the fundamental issue is trying to store values larger than 1 since that will always go out of range and get 'clamped' by the datatype as even storing everything in RGBA8 looks fine so long as I calculate all the lights and perform the gamma correction in a single pass. I can't seem to find a proper solution to this multipass problem wherever I look.
Is anyone there that understands how this is generally accomplished? Any ideas, concepts I should research or anything would help me with this one. Is there some other way I can format my MRTs that would help with doing this?
Last edited: