Team Spartan Cookies & Milk Forums
  • Issue Tracker
  • Donations
  • Search
  • Member List
  • Help

Register

Team Spartan Cookies & Milk Forums Feedback Suggestions and improvements v
« Previous 1 … 11 12 13 14 15 … 36 Next »
Emitter's drawing priority
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Threaded Mode
Emitter's drawing priority
04-04-2020, 08:15 PM,
#1
The17thDoctor Offline
TSCM Average Enjoyer
****
Posts: 1,100
Threads: 249
Joined: Oct 2015
Emitter's drawing priority
I noticed using starfall emitters that if 2 2D3D cameras were created, the one that is last in the rendering hook is drawing over the original one, is there a possibility to add something in order to avoid this issue ?

The17thDoctor: Server take me to the most handsome person
srcds_linux: I cant send people to themselves...
Website Find
Reply
05-04-2020, 02:09 PM,
#2
Person8880 Offline
gpj.ecafllorT
*******
Posts: 2,407
Threads: 45
Joined: Sep 2013
RE: Emitter's drawing priority
This happens because 3D2D rendering disables writing to the depth buffer (though still tests against it).

I've added a new function, render.overrideDepthEnable() which will allow you to force depth writing to be enabled. Use this before starting a 3D2D camera with opaque drawing operations to have it properly respect depth.

For example (taken from the docs):
-- Force depth writing to be enabled (must be done outside the 3D2D block). 
render.overrideDepthEnable( true, true )

-- First render a red rectangle.
render.start3D2D( Pos, Ang, 0.1 )
render.setColor( 255, 0, 0 )
render.drawRect( 0, 0, 256, 256 )
render.end3D2D()

-- Then render a yellow rectange behind it, note how this rectangle is occluded.
-- If you comment out the overrideDepthEnable above, this will draw over the top of the red rectangle.
render.start3D2D( Pos - Dir * 5, Ang, 0.1 )
render.setColor( 255, 255, 0 )
render.drawRect( 0, 0, 256, 256 )
render.end3D2D()

-- Stop overriding depth writing.
render.overrideDepthEnable( false )

Note that for translucent elements, this won't help. Translucent elements have to be drawn in the right order as it doesn't make sense for them to write to the depth buffer (and if you try it you'll get very strange results).
Find
Reply
05-04-2020, 03:13 PM, (This post was last modified: 05-04-2020, 03:36 PM by The17thDoctor. Edited 3 times in total.)
#3
The17thDoctor Offline
TSCM Average Enjoyer
****
Posts: 1,100
Threads: 249
Joined: Oct 2015
RE: Emitter's drawing priority
Thank you, that will really help for what I wanted to do Smile

After trying the function, my starfall returned me :
SF:.txt:11: attempt to call field 'overrideDepthEnable' (a nil value)

If you have any idea on why it does that, here is my code by the way :

--@name Test
--@author
--@shared

if SERVER then

else
eself = ents.self()

hook("render","render",function()
render.overrideDepthEnable(true,true)

render.start3D2D(eself:toWorld(Vector(0,0,-35)),eself:toWorld(Angle(0,0,0)),0.1)
render.setColor(255,255,255)
render.drawRect(-50,-35,100,70)
render.end3D2D()

render.overrideDepthEnable(false)
end)
end

The17thDoctor: Server take me to the most handsome person
srcds_linux: I cant send people to themselves...
Website Find
Reply
05-04-2020, 03:56 PM, (This post was last modified: 05-04-2020, 03:59 PM by mariofludd. Edited 1 time in total.)
#4
mariofludd Offline
Novaaaaaaaaaaaaa
****
Posts: 528
Threads: 44
Joined: Dec 2013
RE: Emitter's drawing priority
(05-04-2020, 03:13 PM)The17thDoctor Wrote: Thank you, that will really help for what I wanted to do Smile

After trying the function, my starfall returned me :
SF:.txt:11: attempt to call field 'overrideDepthEnable' (a nil value)

If you have any idea on why it does that, here is my code by the way :

Line 11:  render.overrideDepthEnable(true,true)

maybe its the 2 true values?
(yes the docs have 2, try 1, see if it works)

[Image: efN9HsZ.png]
Find
Reply
05-04-2020, 03:58 PM,
#5
Person8880 Offline
gpj.ecafllorT
*******
Posts: 2,407
Threads: 45
Joined: Sep 2013
RE: Emitter's drawing priority
The server needs to restart for the function to be available. I've restarted server 2 which was empty so it should be available there.
Find
Reply
05-04-2020, 04:01 PM,
#6
The17thDoctor Offline
TSCM Average Enjoyer
****
Posts: 1,100
Threads: 249
Joined: Oct 2015
RE: Emitter's drawing priority
Thank you

The17thDoctor: Server take me to the most handsome person
srcds_linux: I cant send people to themselves...
Website Find
Reply
« Next Oldest | Next Newest »


  • View a Printable Version
Forum Jump:


Users browsing this thread: 1 Guest(s)
Contact UsTeam Spartan Cookies & MilkReturn to TopLite (Archive) ModeMark all forums readRSS Syndication

Powered By MyBB, © 2002-2026 MyBB Group.