Skip to content

Commit

Permalink
Improve skypaint matproxy performance (#2107)
Browse files Browse the repository at this point in the history
  • Loading branch information
friztailo authored Jan 17, 2025
1 parent cd72f68 commit 1a9022c
Showing 1 changed file with 23 additions and 26 deletions.
49 changes: 23 additions & 26 deletions garrysmod/lua/matproxy/sky_paint.lua
Original file line number Diff line number Diff line change
Expand Up @@ -8,35 +8,32 @@ matproxy.Add( {
bind = function( self, mat, ent )

local skyPaint = g_SkyPaint
if ( !IsValid( skyPaint ) ) then return end

local values = skyPaint:GetNetworkVars()

mat:SetVector( "$TOPCOLOR", values.TopColor )
mat:SetVector( "$BOTTOMCOLOR", values.BottomColor )
mat:SetVector( "$DUSKCOLOR", values.DuskColor )
mat:SetFloat( "$DUSKSCALE", values.DuskScale )
mat:SetFloat( "$DUSKINTENSITY", values.DuskIntensity )
mat:SetFloat( "$FADEBIAS", values.FadeBias )
mat:SetFloat( "$HDRSCALE", values.HDRScale )

mat:SetVector( "$SUNNORMAL", values.SunNormal )
mat:SetVector( "$SUNCOLOR", values.SunColor )
mat:SetFloat( "$SUNSIZE", values.SunSize )

if ( values.DrawStars ) then

mat:SetInt( "$STARLAYERS", values.StarLayers )
mat:SetFloat( "$STARSCALE", values.StarScale )
mat:SetFloat( "$STARFADE", values.StarFade )
mat:SetFloat( "$STARPOS", values.StarSpeed * RealTime() )
mat:SetTexture( "$STARTEXTURE", values.StarTexture )
if ( not IsValid( skyPaint ) ) then return end

mat:SetVector( "$TOPCOLOR", skyPaint:GetDTVector( 0 ) )
mat:SetVector( "$BOTTOMCOLOR", skyPaint:GetDTVector( 1 ) )
mat:SetVector( "$DUSKCOLOR", skyPaint:GetDTVector( 4 ) )
mat:SetFloat( "$DUSKSCALE", skyPaint:GetDTFloat( 2 ) )
mat:SetFloat( "$DUSKINTENSITY", skyPaint:GetDTFloat( 3 ) )
mat:SetFloat( "$FADEBIAS", skyPaint:GetDTFloat( 0 ) )
mat:SetFloat( "$HDRSCALE", skyPaint:GetDTFloat( 1 ) )

mat:SetVector( "$SUNNORMAL", skyPaint:GetDTVector( 2 ) )
mat:SetVector( "$SUNCOLOR", skyPaint:GetDTVector( 3 ) )
mat:SetFloat( "$SUNSIZE", skyPaint:GetDTFloat( 4 ) )

if ( not skyPaint:GetDTBool( 0 ) ) then
return mat:SetInt( "$STARLAYERS", 0 )
end

else
mat:SetInt( "$STARLAYERS", skyPaint:GetDTInt( 0 ) )

mat:SetInt( "$STARLAYERS", 0 )
local star = skyPaint:GetDTAngle( 0 )
mat:SetFloat( "$STARSCALE", star.p )
mat:SetFloat( "$STARFADE", star.y )
mat:SetFloat( "$STARPOS", star.r * RealTime() )

end
mat:SetTexture( "$STARTEXTURE", skyPaint:GetDTString( 0 ) )

end
} )

0 comments on commit 1a9022c

Please sign in to comment.