DrawMaterialOverlay alpha

How do I make a material overlay have alpha? Like half alpha so it isn’t as intense?

It doesn’t have that functionality, you would do better by adding it in yourself. Here is my version:

[lua]
local lastTexture = nil
local mat_Overlay = nil

function DrawMaterialOverlayEx( texture, refractamount, nAlpha )

if ( texture ~= lastTexture or mat_Overlay == nil ) then
	mat_Overlay = Material( texture )
	lastTexture = texture
end

if ( mat_Overlay == nil || mat_Overlay:IsError() ) then return end
if ( nAlpha == nil ) then nAlpha = 1 end

render.UpdateScreenEffectTexture()

// FIXME: Changing refract amount affects textures used in the map/models.
mat_Overlay:SetFloat( "$alpha", nAlpha )
mat_Overlay:SetFloat( "$envmap", 0 )
mat_Overlay:SetFloat( "$envmaptint", 0 )
mat_Overlay:SetFloat( "$refractamount", refractamount )
mat_Overlay:SetInt( "$ignorez", 1 )

render.SetMaterial( mat_Overlay )
render.DrawScreenQuad()

end
[/lua]

Untested, but only added 3 lines so yeah.

Does not work sadly.

What code are you using? nAlpha should be between 0 and 1

I changed the function name to DrawMaterialOverlayAlpha.
[lua]DrawMaterialOverlayAlpha(“effects/combine_binocoverlay”, 0.5, 0.5);[/lua]
It draws it, but it still draws it at 1.0 alpha even when I set the alpha to 0.

Weird, Fixed:

[lua]
local lastTexture = nil
local mat_Overlay = nil

function DrawMaterialOverlay( texture, refractamount, nAlpha )

if ( texture ~= lastTexture or mat_Overlay == nil ) then
	mat_Overlay = Material( texture )
	lastTexture = texture
end

if ( mat_Overlay == nil || mat_Overlay:IsError() ) then return end
if ( nAlpha == nil ) then nAlpha = 1 end

render.UpdateScreenEffectTexture()

// FIXME: Changing refract amount affects textures used in the map/models.
mat_Overlay:SetFloat( "$alpha", nAlpha )
mat_Overlay:SetFloat( "$envmap", 0 )
mat_Overlay:SetFloat( "$envmaptint", 0 )
mat_Overlay:SetFloat( "$refractamount", refractamount )
mat_Overlay:SetInt( "$ignorez", 1 )

render.SetMaterial( mat_Overlay )
render.DrawScreenQuad()

end
[/lua]

Tested it this time too.

[editline]30th April 2015[/editline]

I’ve created a pull request so that this might get included in the game.