local TEX_SIZE
= 512
local tex
= GetRenderTargetEx(
"ExampleMaskRT", TEX_SIZE, TEX_SIZE, RT_SIZE_OFFSCREEN,
MATERIAL_RT_DEPTH_SHARED , 0, 0, IMAGE_FORMAT_RGBA8888 )
local myMat
= CreateMaterial(
"ExampleMaskRTMat",
"UnlitGeneric", {
[
"$basetexture"]
= tex:
GetName(),
[
"$translucent"]
= "1"
} )
local txBackground
= Material(
"models/weapons/v_toolgun/screen_bg" )
local mask
= Material(
"gui/gradient_down" )
function RenderMaskedRT()
surface.
SetDrawColor( color_white )
surface.
SetMaterial( txBackground )
surface.
DrawTexturedRect( 0, 0, TEX_SIZE, TEX_SIZE )
surface.
DrawTexturedRectRotated( TEX_SIZE / 2, TEX_SIZE / 2, TEX_SIZE, TEX_SIZE,
CurTime() * 20 )
render.
SetWriteDepthToDestAlpha(
false )
render.
OverrideBlend(
true, BLEND_SRC_COLOR, BLEND_SRC_ALPHA, BLENDFUNC_MIN )
surface.
SetMaterial( mask )
surface.
DrawTexturedRect( 0, 0, TEX_SIZE, TEX_SIZE )
render.
OverrideBlend(
false )
render.
SetWriteDepthToDestAlpha(
true )
end
hook.
Add(
"HUDPaint",
"DrawExampleMaskMat",
function()
render.
PushRenderTarget( tex )
cam.
Start2D()
render.
Clear( 0, 0, 0, 0 )
RenderMaskedRT()
cam.
End2D()
render.
PopRenderTarget()
surface.
SetDrawColor( color_white )
surface.
SetMaterial( myMat )
surface.
DrawTexturedRect( 520, 0, TEX_SIZE, TEX_SIZE )
end )