Constant Billboard Size

Discussion of proposed new features.

Constant Billboard Size

PostPosted by Enhex » 23 May 2016, 07:41

Having a billboard with a constant size in screen space, size that doesn't change with distance from the camera, is useful for things like indicators of 3D positions.

While it should be possible to use WorldToScreenPoint() to get screen position, and then either position a 2D sprite or use ScreenToWorldPoint() to get a 3D position for a billboard, it requires manual updating and culling, and should be less efficient than having the billboard render directly with constant size, and the depth and parent ndoe information is lost (unless manually saved and accessed).

If I recall correctly, in OGRE3D it was possible to achieve that with:
Ogre::BillboardSet::setPointRenderingEnabled()
http://www.ogre3d.org/docs/api/1.9/clas ... 1bbd8cf3b6
Last edited by Enhex on 23 May 2016, 17:20, edited 1 time in total.
User avatar
Enhex
Most active user
Most active user
 
Posts: 325
Joined: 31 Dec 2014, 12:23

Re: Constant Billboard Size

PostPosted by cadaver » 23 May 2016, 07:59

Should be doable. Note that for proper culling this would be best done on CPU side, which means it will have to keep adjusting the size and updating the vertex buffer as the camera moves.
User avatar
cadaver
Urho3D author
Urho3D author
 
Posts: 1802
Joined: 16 Jan 2014, 14:52
Location: Finland

Re: Constant Billboard Size

PostPosted by yushli » 23 May 2016, 08:32

That sounds like a nice feature to have. Waiting for it to appear in the master branch...
User avatar
yushli
Some active
Some active
 
Posts: 94
Joined: 18 Oct 2014, 05:42

Re: Constant Billboard Size

PostPosted by Victor » 23 May 2016, 15:39

This does sound a pretty cool feature! At some point I know I will definitely need to use such a feature.
User avatar
Victor
Have some posts
Have some posts
 
Posts: 48
Joined: 11 May 2016, 14:22

Re: Constant Billboard Size

PostPosted by Enhex » 23 May 2016, 18:58

Another problem that constant billboard size can solve is handling multiple cameras.
User avatar
Enhex
Most active user
Most active user
 
Posts: 325
Joined: 31 Dec 2014, 12:23

Re: Constant Billboard Size

PostPosted by cadaver » 25 May 2016, 12:44

Screen size billboards have been added to master branch. See BillboardSet::SetFixedScreenSize(). In this mode the billboard size corresponds to pixels (for easy use of specifically-sized textures as markers), but node scale can affect it too.

It occurred to me that Text3D would benefit from the same option, and after programming it once it's easier to do again.
User avatar
cadaver
Urho3D author
Urho3D author
 
Posts: 1802
Joined: 16 Jan 2014, 14:52
Location: Finland

Re: Constant Billboard Size

PostPosted by Victor » 25 May 2016, 13:07

Wow thanks man! This is awesome!
User avatar
Victor
Have some posts
Have some posts
 
Posts: 48
Joined: 11 May 2016, 14:22

Re: Constant Billboard Size

PostPosted by Enhex » 28 May 2016, 08:30

Gave it a try. Works with single viewport, but with multiple viewports only one of the viewports scale is used, so the billboards render with incorrect scale in all the other viewports.

The problem can be replicated in the multiple viewports sample:
- set both cameras to look at the same direction (remove rear's rotation)
- use authographic on one of the cameras to make the effect more noticable
- - setting main cam to ortho causes the rear cam to have regular size billboards
- - setting rear cam to ortho causes the rear cam to have shrinking billboards as u get closer

Perhaps moving the size updating into a BeginViewUpdate event handler would solve it.
User avatar
Enhex
Most active user
Most active user
 
Posts: 325
Joined: 31 Dec 2014, 12:23

Re: Constant Billboard Size

PostPosted by cadaver » 28 May 2016, 10:36

The problem is that all BeginViewUpdate's for all viewports are called before rendering happens, so drawables would need to store per-view information, or recalculate the information right before actual rendering. In general this is not a trivially solvable problem, because for efficiency we'd rather not interleave view update and rendering, and in some cases (e.g. mirror views which use a RTT) we would need to recurse into view preparation+rendering right in the middle of view preparation, which also could cause unexpected code interactions. I believe this case is solvable by some hack code but a general good solution is hard to achieve.
User avatar
cadaver
Urho3D author
Urho3D author
 
Posts: 1802
Joined: 16 Jan 2014, 14:52
Location: Finland

Re: Constant Billboard Size

PostPosted by cadaver » 28 May 2016, 13:03

Should be fixed in master branch. Text3D had also a similar issue in relation to both screen scaling & face camera mode, which also was fixed.
User avatar
cadaver
Urho3D author
Urho3D author
 
Posts: 1802
Joined: 16 Jan 2014, 14:52
Location: Finland


Return to Feature Request

Who is online

Users browsing this forum: No registered users and 0 guests

cron