Welcome, Guest. Please login or register.

Login with username, password and session length

 
Advanced search

11991 Posts in 1587 Topics- by 3508 Members - Latest Member: NevilleKemp

26. May 2012, 07:12:06 pm
Xith3D CommunityGeneral CategoryFeature Requests & Brilliant Ideas (Moderators: Marvin Fröhlich, 'n ddrylliog)Conditional Switch
Pages: [1] 2
Print
Author Topic: Conditional Switch  (Read 4741 times)
Patheros
Getting respectable
***
Offline Offline

Posts: 267


Dead Dolphin


View Profile WWW Email
« on: 20. February 2007, 08:03:34 pm »

In my project I have objects that are some times very far from the camera, and other times are very near. When they are close I want to render them as a Model, but when they are far away I want to render them as a billboard. Is there a way to achieve this effect with a single Universe and multiple views? It would be cool if I could achieve this with a Switch node that changes based on the view currently being rendered.
« Last Edit: 20. February 2007, 08:06:48 pm by Patheros » Logged

"I like my method, what was my method again?" - Jon
Marvin Fröhlich
Xith Lord
Administrator
Guru
*****
Offline Offline

Posts: 4381


May the 4th, be with you...


View Profile
« Reply #1 on: 20. February 2007, 08:20:01 pm »

In my project I have objects that are some times very far from the camera, and other times are very near. When they are close I want to render them as a Model, but when they are far away I want to render them as a billboard. Is there a way to achieve this effect with a single Universe and multiple views? It would be cool if I could achieve this with a Switch node that changes based on the view currently being rendered.

This is a technique called LOD (level of detail). A model is rendered in different complexities when it is nearer or farer to the camera. And it is also imaginable, that the farest LOD contains just a billboard.

I don't know, if we already have this in Xith. I didn't find it anywhere but in some model loader implementations. I anyway wanted to implement such a technique in the core. It should not be very difficult. So if not anybody tells me, that it already exists, I would advise you to wait some days and it will be awailable.

Marvin
Logged
Mathias 'cylab' Henze
Fierce Warrior
****
Offline Offline

Posts: 540

1064620
View Profile WWW
« Reply #2 on: 21. February 2007, 12:20:24 am »

The Switch is already there: http://xith.org/javadoc/core/org/xith3d/scenegraph/Switch.html all you need is a scheduled operation, that checks the distance between the switch and the viewer and select the appropriate subgraph.

This is called discrete LOD contrary to continuous LOD, because the former just switches between different models while the latter continuously transform the models mesh to get the best triangle count.
Logged

Marvin Fröhlich
Xith Lord
Administrator
Guru
*****
Offline Offline

Posts: 4381


May the 4th, be with you...


View Profile
« Reply #3 on: 21. February 2007, 12:29:10 am »

The Switch is already there: http://xith.org/javadoc/core/org/xith3d/scenegraph/Switch.html all you need is a scheduled operation, that checks the distance between the switch and the viewer and select the appropriate subgraph.

Of course the Switch is already there, and I would use it for built-in LOD support. But it would just be convenient, if I could do the following:

Code:
LODSwitch ls = new LODSwitch();

ls.addLODItem( new LODItem( node1, minDist1, maxDist1 ) );
ls.addLODItem( new LODItem( node2, minDist2, maxDist2 ) );
ls.addLODItem( new LODItem( node3, minDist2, maxDist3 ) );

So I will implement that.

Marvin
« Last Edit: 01. March 2007, 02:45:47 am by Marvin Fröhlich » Logged
hawkwind
Getting respectable
***
Offline Offline

Posts: 363



View Profile Email
« Reply #4 on: 21. February 2007, 12:51:44 am »

Whenever I see a billboard at the end its often pretty obviously different than a shape,  I would use a low poly count shape instead.
Logged
Patheros
Getting respectable
***
Offline Offline

Posts: 267


Dead Dolphin


View Profile WWW Email
« Reply #5 on: 21. February 2007, 02:08:23 am »

Another idea I had is as follows.

I'm making a space environment centered around a planet. Most of the time you will be close enough to the planet that I just render it right there. However if you get far enough away it gets cut off by the far clipping distance. So rather than just decrease its level of detail, I'm thinking I could move it into the sky box and render it there appropriately.
Logged

"I like my method, what was my method again?" - Jon
Marvin Fröhlich
Xith Lord
Administrator
Guru
*****
Offline Offline

Posts: 4381


May the 4th, be with you...


View Profile
« Reply #6 on: 21. February 2007, 02:18:07 am »

Another idea I had is as follows.

I'm making a space environment centered around a planet. Most of the time you will be close enough to the planet that I just render it right there. However if you get far enough away it gets cut off by the far clipping distance. So rather than just decrease its level of detail, I'm thinking I could move it into the sky box and render it there appropriately.

This is exactly, what the SkyBox is there for Wink.

Marvin
Logged
Patheros
Getting respectable
***
Offline Offline

Posts: 267


Dead Dolphin


View Profile WWW Email
« Reply #7 on: 25. February 2007, 06:13:45 pm »

But it would just be convenient, if I could do the following:

Code:
LODSwitch ls = new LODSwitch();

ls.addLODItem( new LODItem( node1, minDist1, maxDist1 ) );
ls.addLODItem( new LODItem( node2, minDist2, maxDist2 ) );
ls.addLODItem( new LODItem( node3, minDist2, maxDist3 ) );

So I will implement that.

Marvin

Is this simplemented yet? And if so where is it?
Logged

"I like my method, what was my method again?" - Jon
Patheros
Getting respectable
***
Offline Offline

Posts: 267


Dead Dolphin


View Profile WWW Email
« Reply #8 on: 25. February 2007, 06:20:46 pm »

Another idea I had is as follows.

I'm making a space environment centered around a planet. Most of the time you will be close enough to the planet that I just render it right there. However if you get far enough away it gets cut off by the far clipping distance. So rather than just decrease its level of detail, I'm thinking I could move it into the sky box and render it there appropriately.

This is exactly, what the SkyBox is there for Wink.

Marvin

The problem is it needs to move in the sky box. I allow the camera to view the planet from any side, so if above it, the planet needs to be in the bottom of the sky box, but as you move to the bottom of it the planet needs to move above you.
Logged

"I like my method, what was my method again?" - Jon
Marvin Fröhlich
Xith Lord
Administrator
Guru
*****
Offline Offline

Posts: 4381


May the 4th, be with you...


View Profile
« Reply #9 on: 25. February 2007, 06:35:30 pm »

Is this simplemented yet? And if so where is it?

Oh, sorry, I forgot. Had several other things to do. Please give me two or three days. OK?

The problem is it needs to move in the sky box. I allow the camera to view the planet from any side, so if above it, the planet needs to be in the bottom of the sky box, but as you move to the bottom of it the planet needs to move above you.

Hmm... The SkyBox is always fixed around the Camera. But it is not fixed in relative rotation. Did you test that, or is it just a theoretical thought? Please have a look at the SkyBoxTest in xith-tk (update SVN before!). It should demonstrate, what you want.

Marvin
Logged
Patheros
Getting respectable
***
Offline Offline

Posts: 267


Dead Dolphin


View Profile WWW Email
« Reply #10 on: 25. February 2007, 06:43:37 pm »


Oh, sorry, I forgot. Had several other things to do. Please give me two or three days. OK?


No problem at all.


Hmm... The SkyBox is always fixed around the Camera. But it is not fixed in relative rotation. Did you test that, or is it just a theoretical thought? Please have a look at the SkyBoxTest in xith-tk (update SVN before!). It should demonstrate, what you want.


I have looked at the SkyBoxTest and I'm actually using Background to put stars in the sky already.

I've been using the term SkyBox incorectly. I mean simply a Background node.

I want to render a sphere (the planet) on a Background node in such a way that it looks like you are able to fly around it and look at it from the other side.
Logged

"I like my method, what was my method again?" - Jon
Marvin Fröhlich
Xith Lord
Administrator
Guru
*****
Offline Offline

Posts: 4381


May the 4th, be with you...


View Profile
« Reply #11 on: 25. February 2007, 06:50:37 pm »

I have looked at the SkyBoxTest and I'm actually using Background to put stars in the sky already.

Well, I've just modified it in a way, that a sphere is rendered in the center. But I see, your problem is a different one.

I've been using the term SkyBox incorectly. I mean simply a Background node.

I want to render a sphere (the planet) on a Background node in such a way that it looks like you are able to fly around it and look at it from the other side.

Huh Sorry, I don't understand you again. A Background Node cannot be flight around. That's why it is a Background Node, isn't it? If you want to fly around it, that you'll have to use a regular (far away) Node.

Maybe someone else has an idea?

Marvin
Logged
Patheros
Getting respectable
***
Offline Offline

Posts: 267


Dead Dolphin


View Profile WWW Email
« Reply #12 on: 25. February 2007, 07:00:22 pm »

A Background Node cannot be flight around. That's why it is a Background Node, isn't it? If you want to fly around it, that you'll have to use a regular (far away) Node.

Maybe someone else has an idea?

Marvin

My idea was to create the illusion of being close. Its a force perspective trick. If you close one eye and hold your hand up so your fingers appear to be holding a far away object, then move your head slowly from side to side, keeping your fingers virtually around the far away object you will see what I mean. It should look (a little) like your hand is far bigger than it is, and its at the distance of the far away object.

The whole reason I thought to do this was so I didn't have to have an enormously high far clipping distance. 95% of my objects won't be rendered at far distances, however a small percentage (like the planet) will be. Presumably the shorter the far clipping distance is the better performance is. No?
Logged

"I like my method, what was my method again?" - Jon
Marvin Fröhlich
Xith Lord
Administrator
Guru
*****
Offline Offline

Posts: 4381


May the 4th, be with you...


View Profile
« Reply #13 on: 25. February 2007, 07:32:30 pm »

Presumably the shorter the far clipping distance is the better performance is. No?

I don't think so. The nearer the far clipping plane, the better is depth buffer precision. But I will test the performance impact of that.

Marvin
Logged
horati
Global Moderator
Getting respectable
*****
Offline Offline

Posts: 393


View Profile
« Reply #14 on: 25. February 2007, 08:22:38 pm »

I definitely see your point that 1000s of objects between you and the drawn planet would benefit from a short clipping distance; however, you still want super large but super far away objects to appear.

Can't you achieve your goal by using an additional render pass?  You could draw the planet in its own (probably display list?) scenegraph rendered behind the primary scene graph with the short clipping distance you desire.
Logged

Kevin
"It may not seem like a big deal, but ignorance of character encoding issues leads to insidious code rot akin to y2k."
http://stackoverflow.com/users/3474/sylvarking
Pages: [1] 2
Print
Jump to:  

Theme orange-lt created by panic