Skip to content

Commit

Permalink
Use linear tonemapping to prevent HDR artifacts (#1777)
Browse files Browse the repository at this point in the history
  • Loading branch information
thegrb93 authored Jun 16, 2024
1 parent d7f9646 commit caefbeb
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions lua/entities/starfall_screen/cl_init.lua
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,7 @@ function ENT:SetBackgroundColor(r, g, b, a)
self.ScreenQuad[5] = Color(r, g, b, math.max(a, 1))
end

local VECTOR_1_1_1 = Vector(1, 1, 1)
local writez = Material("engine/writez")
function ENT:DrawTranslucent()
self:DrawModel()
Expand Down Expand Up @@ -128,6 +129,9 @@ function ENT:DrawTranslucent()
render.SetStencilCompareFunction(STENCILCOMPARISONFUNCTION_EQUAL)
render.SetStencilTestMask(1)

local tone = render.GetToneMappingScaleLinear()
render.SetToneMappingScaleLinear(VECTOR_1_1_1)

--Clear it to the clear color and clear depth as well
local color = self.ScreenQuad[5]
if color.a == 255 then
Expand All @@ -143,6 +147,8 @@ function ENT:DrawTranslucent()
render.PopFilterMag()
render.PopFilterMin()

render.SetToneMappingScaleLinear(tone)

render.SetStencilEnable(false)

--Give the screen back its depth
Expand Down

0 comments on commit caefbeb

Please sign in to comment.