• draw.DrawText visible through wall
    10 replies, posted
Hi. I have a problem in my PostDrawOpaqueRenderables. The user info on top of the players head are visible through walls. Me need visible only player model. [CODE] render.ClearStencil() render.SetStencilEnable(true) render.SetStencilWriteMask(255) render.SetStencilTestMask(255) render.SetStencilReferenceValue(15) render.SetStencilFailOperation(STENCILOPERATION_REPLACE) render.SetStencilZFailOperation(STENCILOPERATION_REPLACE) render.SetStencilPassOperation(STENCILOPERATION_KEEP) render.SetStencilCompareFunction(STENCILCOMPARISONFUNCTION_ALWAYS) render.SetBlend(0) ent:DrawModel() render.SetBlend(1) render.SetStencilCompareFunction(STENCILCOMPARISONFUNCTION_EQUAL) cam.Start3D2D(pos,ang,1) surface.SetDrawColor(255,255,255,255) surface.DrawRect(-ScrW(),-ScrH(),ScrW()*2,ScrH()*2) cam.End3D2D() ent:DrawModel() render.SetStencilEnable(false) render.ClearStencil()[/CODE] Is there a way to fix this? [T]http://i.imgur.com/WfIs4Xb.jpg[/T]
[img]http://wiki.garrysmod.com/favicon.ico[/img] [url=http://wiki.garrysmod.com/page/cam/IgnoreZ]cam.IgnoreZ[/url] iirc
Draw it in the post draw players hook or post draw translucent renderables
You're only drawing it where it failed the z test. Replace on pass and keep on zfail
[QUOTE=AJ10017;52108518]Draw it in the post draw players hook or post draw translucent renderables[/QUOTE] post draw players - crashes client. [editline]16th April 2017[/editline] [QUOTE=Bull29;52108468][img]http://wiki.garrysmod.com/favicon.ico[/img] [url=http://wiki.garrysmod.com/page/cam/IgnoreZ]cam.IgnoreZ[/url] iirc[/QUOTE] did not help [editline]16th April 2017[/editline] [QUOTE=bigdogmat;52108573]You're only drawing it where it failed the z test. Replace on pass and keep on zfail[/QUOTE] I'll try
[QUOTE=bigdogmat;52108573]You're only drawing it where it failed the z test. Replace on pass and keep on zfail[/QUOTE] not working. :(
When you call player:DrawModel(), you are not only drawing the player model, but you are also invoking the PrePlayerDraw and PostPlayerDraw hooks. One of these hooks is being used to draw the text. You need to find a way to temporarily stop that text from drawing while you are writing to the stencil buffer.
[QUOTE=Jcw87;52112769]You need to find a way to temporarily stop that text from drawing while you are writing to the stencil buffer.[/QUOTE] I do not know other functions. :(
[QUOTE=Jcw87;52112769]When you call player:DrawModel(), you are not only drawing the player model, but you are also invoking the PrePlayerDraw and PostPlayerDraw hooks. One of these hooks is being used to draw the text. You need to find a way to temporarily stop that text from drawing while you are writing to the stencil buffer.[/QUOTE] Its probably PostPlayerDraw. I'm not sure how hooks work exactly, but perhaps if you add a PostPlayerDraw hook with "return false" just before drawing the model, it should stop drawing the info text. Remember to remove that hook after the stencil stuff. Also, keep in mind you left the FailOperation and ZFailOperation on "replace" for the entire stencil block, so after you draw the rect, the entire screen is marked on the stencil buffer. Anything you try to draw after that will pass. You should set them to "Keep" where you change the compare operation.
[QUOTE=Pypsikan;52113367]I do not know other functions. :([/QUOTE] Set a variable inside the function when calling DrawModel, after its drawn set the variable to false. At the start of the function check if the variable is true and if so just return early.
nothing works. so bad.
Sorry, you need to Log In to post a reply to this thread.