• Drawing a material to the screen (with a specific alpha)
    12 replies, posted
Ok, i've tried two different ways, to no avail: Render: [code] render.SetBlend(mat_alpha) render.SetMaterial(Pain) render.DrawScreenQuad() render.SetBlend(1) [/code] Draw: [code] local QuadTable = {} QuadTable.texture = surface.GetTextureID( "effects/screenpain" ) QuadTable.color = Color( 255, 255, 255, mat_alpha*255 ) QuadTable.x = 0 QuadTable.y = 0 QuadTable.w = ScrW() QuadTable.h = ScrH() draw.TexturedQuad( QuadTable ) [/code] Both draw the texture on the screen, only it's at full alpha, which isn't what I want. I've checked mat_alpha, and that seems to be fine. VMT of the texture looks like this, in case i've bodged it... [code] "UnlitGeneric" { "$basetexture" "effects/screenpain" "$additive" 1 "$nolod" 1 "$translucent" 1 "$vertexalpha" 1 } [/code] Any ideas?
Try [url=http://wiki.garrysmod.com/?title=Surface.DrawTexturedRect]this[/url].
I think this will work for what your doing. [lua] RunConsoleCommand("pp_mat_overlay", "effects/screenpain"); [/lua] Hopefully that helped.
[QUOTE=NullPoint;19058766]Try [url=http://wiki.garrysmod.com/?title=Surface.DrawTexturedRect]this[/url].[/QUOTE] As he said, try this: [lua]surface.SetDrawColor(255, 255, 255, mat_alpha) surface.SetMaterial(Pain) surface.DrawTexturedRect(0, 0, ScrW(), ScrH())[/lua]
[QUOTE=Battlepope98;19059359]I think this will work for what your doing. [lua] RunConsoleCommand("pp_mat_overlay", "effects/screenpain"); [/lua] Hopefully that helped.[/QUOTE] No.
[QUOTE=_Kilburn;19060189]As he said, try this: [lua]surface.SetDrawColor(255, 255, 255, mat_alpha) surface.SetMaterial(Pain) surface.DrawTexturedRect(0, 0, ScrW(), ScrH())[/lua][/QUOTE] More complete example: [lua] local Pain = surface.GetTextureID( "effects/screenpain" ); hook.Add("HUDPaint","PainDraw",function() if (PAIN_SHOULD_DRAW) then surface.SetDrawColor(255, 255, 255, mat_alpha*255); surface.SetMaterial(Pain); surface.DrawTexturedRect(0, 0, ScrW(), ScrH()); end end);[/lua]
Tried it. Didn't seem to work. I'm going to go ahead and see if it works in HUDPaint instead of RenderScreenSpaceEffects, but that can't be the problem since it still renders, just at full alpha all the time
are you sure mat_alpha isn't 1? And surface is supposed to be used in 2d rendering, ie HUDPaint.
Set render.SetBlend to less than 1?
mat_alpha is usually between 0.3 and 0.8, constantly changing. I've definitely debugged that one. Putting it in HUDPaint failed as well.
[QUOTE=Toneo;19071743]mat_alpha is usually between 0.3 and 0.8, constantly changing. I've definitely debugged that one. Putting it in HUDPaint failed as well.[/QUOTE] Yes but... [QUOTE=Toneo;19058704] [lua] render.SetBlend(mat_alpha) render.SetMaterial(Pain) render.DrawScreenQuad() render.SetBlend(1) -- Here [/lua] [/QUOTE] You're setting it to mat_alpha but then a few lines down are setting it to 1.
[QUOTE=DEADBEEF;19076261]Yes but... You're setting it to mat_alpha but then a few lines down are setting it to 1.[/QUOTE] He sets it back to 1 after he draws the screenquad.
Of course, I'm blind.
Sorry, you need to Log In to post a reply to this thread.