Billboard Clouds

Threads related to Google Summer of Code
swx
Google Summer of Code Student
Google Summer of Code Student
Posts: 31
Joined: Sun May 21, 2006 4:03 am
Location: Sweden

Billboard Clouds

Post by swx »

What I have done so far:
  • Wavefront Object importer and exporter.
    Simpler plane selector.
    Texture packing using bsp trees.
    Various image resizing tools.
    Various helper functions for the more complex plane selector that will be implemented later.
    Function for calculating a tight fit rectangle for a set of points.
    Various math functions missing in Ogre (like fromToRotationMatrix in my code).
I'm currently working on getting Ogre to actually do any rendering so that I can generate textures for the billboards. Once I've managed to do that, the library is functional in the sense that it can import a wavefront object, create billboards, texture and normalmap and export it as a wavefront object and some image files that can be used.

I will then clean up the interface and code a little and start on the more complex plane selector, which I reckon will take most of the time that's left since there are a lot of things needed for it to work and not take too long time to finish.

Pics of a simplified tree mesh from various angles. The number of planes is dependent on the specified error value specified so simplified models dont have to have this many billboards. The more complex algorithm will probably give better billboards.
Image
Image
Image

Packing (will probably implement a better algorithm later):
Image
User avatar
jacmoe
OGRE Retired Moderator
OGRE Retired Moderator
Posts: 20570
Joined: Thu Jan 22, 2004 10:13 am
Location: Denmark
x 179

Post by jacmoe »

I noticed some very interesting commits to the ogreaddons repository lately, and wondered when you'll post some progress about it, and now you do! 8)

Will this allow you to dynamically change LOD, like switching to the full mesh when up very close, and removing billboards from the cloud as the tree fades into the horizon?
Or is that left as an exercise for later?

Looks very promising! And really looking forward to see some textured Ogre rendered billboard cloud trees! :)
/* Less noise. More signal. */
Ogitor Scenebuilder - powered by Ogre, presented by Qt, fueled by Passion.
OgreAddons - the Ogre code suppository.
User avatar
farakon
Google Summer of Code Student
Google Summer of Code Student
Posts: 66
Joined: Sat May 13, 2006 6:47 am

Post by farakon »

seems really interresting :) especially the packing algorithm which seems to give a somewhow optimized result. Can u tell me how the packing algorithm work if it's not much? (basic principle) --Sorry, but I m tempted by sexy algorithms :D
User avatar
sinbad
OGRE Retired Team Member
OGRE Retired Team Member
Posts: 19269
Joined: Sun Oct 06, 2002 11:19 pm
Location: Guernsey, Channel Islands
x 66

Post by sinbad »

Nice work.
farakon wrote:Can u tell me how the packing algorithm work if it's not much? (basic principle) --Sorry, but I m tempted by sexy algorithms :D
Looks like a tree based box packer to me :) In fact he mentions "Texture packing using bsp trees. " Probably something like this: http://www.blackpawn.com/texts/lightmaps/ . Not that complex but if you can guarantee your textures are rectangular it works really well.
User avatar
Wretched_Wyx
Orc
Posts: 498
Joined: Thu Mar 16, 2006 5:27 pm

Post by Wretched_Wyx »

Heh, interesting timing. I have been chatting with the author (Frank Kane... Cool name eh?) of SilverLining about a free for non-commercial use license option.
User avatar
jacmoe
OGRE Retired Moderator
OGRE Retired Moderator
Posts: 20570
Joined: Thu Jan 22, 2004 10:13 am
Location: Denmark
x 179

Post by jacmoe »

That sounds interesting!
However, billboard clouds is something different.
It means clouds of billboards, not billboards of clouds. :wink:
/* Less noise. More signal. */
Ogitor Scenebuilder - powered by Ogre, presented by Qt, fueled by Passion.
OgreAddons - the Ogre code suppository.
Lioric
Google Summer of Code Mentor
Google Summer of Code Mentor
Posts: 295
Joined: Fri Aug 06, 2004 10:25 pm

Post by Lioric »

Very nice
Will this allow you to dynamically change LOD, like switching to the full mesh when up very close, and removing billboards from the cloud as the tree fades into the horizon?
Or is that left as an exercise for later?
Adding LOD levels should be very easy, as this is produced by varying the error threshold parameter (as suggested by swx), using the current lod as the input for the next

Additionally, texture resolution can be part of the lods system

But the first iteration should focus on correctly generating the billboards

swx: i did a fast review of the code commits of today, seems you are locking the pixelbuffer returned by the renderTexture, you should use "blitToMemory" when using renderTextures, as they are not lockable (on some machines locking works, but not on others)
User avatar
tuan kuranes
OGRE Retired Moderator
OGRE Retired Moderator
Posts: 2653
Joined: Wed Sep 24, 2003 8:07 am
Location: Haute Garonne, France
x 4

Post by tuan kuranes »

Nice.
Why wavefront ".obj" and not Ogre ".mesh" ? is it a limitation of Ogre Format ?

"Texture packing using bsp trees." : interesting !
I used a very fast quadtree packer (limited to square) in my dynamic impostor code. I wonder how fast bsp insertion/removing would be ?

@sinbad: If fast enough perhaps that could go into Ogre Core ?
It could allow using a single Render Texture but for multiples viewport transparently for user ?
At term it could also be used to do some automatic cheap "Atlas" packing (static geometry, instancing) maximizing their speed ?
btw, here's new paper on lod level and bbclouds for foliage which is worth reading.
User avatar
jacmoe
OGRE Retired Moderator
OGRE Retired Moderator
Posts: 20570
Joined: Thu Jan 22, 2004 10:13 am
Location: Denmark
x 179

Post by jacmoe »

He's probably using the .obj format because Blender has excellent Wavefront support.
I can see that he's testing it in Blender.
The Ogre mesh importer is not stable enough.
/* Less noise. More signal. */
Ogitor Scenebuilder - powered by Ogre, presented by Qt, fueled by Passion.
OgreAddons - the Ogre code suppository.
swx
Google Summer of Code Student
Google Summer of Code Student
Posts: 31
Joined: Sun May 21, 2006 4:03 am
Location: Sweden

Post by swx »

tuan kuranes: that's the algorithm I use for the plane selector.
sinbad: yeah, thats the lightmap packing algorithm I use.
tuan kuranes: I use wavefront object files since it has importers and exporters to every 3d editor known to man ;)

Multiple LOD levels could probably be created by using the previous billboard cloud, but I doubt that the result will be very good... Its probably better to build from scratch using a larger error value.
User avatar
CaseyB
OGRE Contributor
OGRE Contributor
Posts: 1335
Joined: Sun Nov 20, 2005 2:42 pm
Location: Columbus, Ohio
x 3

Post by CaseyB »

swx wrote:Multiple LOD levels could probably be created by using the previous billboard cloud, but I doubt that the result will be very good... Its probably better to build from scratch using a larger error value.
Isn't the LOD calculated at the creation of the Ogre Mesh file as well? So would the swap into bbclouds happen automatically like the change in LOD's?
Image
Image
swx
Google Summer of Code Student
Google Summer of Code Student
Posts: 31
Joined: Sun May 21, 2006 4:03 am
Location: Sweden

Post by swx »

Just a quick update. I've got basic texturing working, but still have some things I want to fix before I post any new screens. Hopefully I'll have something new to show tomorrow :)
swx
Google Summer of Code Student
Google Summer of Code Student
Posts: 31
Joined: Sun May 21, 2006 4:03 am
Location: Sweden

Post by swx »

Texturing works, but I really need to improve the texture usage...
Image
swx
Google Summer of Code Student
Google Summer of Code Student
Posts: 31
Joined: Sun May 21, 2006 4:03 am
Location: Sweden

Post by swx »

Modified my texture size function slightly:
Image
User avatar
IFASS
Gnome
Posts: 387
Joined: Tue Jan 04, 2005 12:07 pm
Location: Netherlands

Post by IFASS »

That is some nice improvement! ;)

Keep it up!
Image
Lioric
Google Summer of Code Mentor
Google Summer of Code Mentor
Posts: 295
Joined: Fri Aug 06, 2004 10:25 pm

Post by Lioric »

Mats, can you please add log messages when commiting code to the cvs
User avatar
sinbad
OGRE Retired Team Member
OGRE Retired Team Member
Posts: 19269
Joined: Sun Oct 06, 2002 11:19 pm
Location: Guernsey, Channel Islands
x 66

Post by sinbad »

Lioric wrote:Mats, can you please add log messages when commiting code to the cvs
I've already prodded him on email about this ;)

Nice work, looks like it's really coming together.
swx
Google Summer of Code Student
Google Summer of Code Student
Posts: 31
Joined: Sun May 21, 2006 4:03 am
Location: Sweden

Post by swx »

Quick update:

I'm working on integrating normalmap generation, I'll hopefully have some screens tomorrow. Had to do a lot of bug fixing the last couple of days, that's why I havent posted any new screens ;)

I'm also trying to clean up the code and interfaces since I really hate ugly code ;)
swx
Google Summer of Code Student
Google Summer of Code Student
Posts: 31
Joined: Sun May 21, 2006 4:03 am
Location: Sweden

Post by swx »

Normalmap for a single billboard:
Image
swx
Google Summer of Code Student
Google Summer of Code Student
Posts: 31
Joined: Sun May 21, 2006 4:03 am
Location: Sweden

Post by swx »

A finished normalmap for a really low-poly billboard cloud:
Image
User avatar
Falagard
OGRE Retired Moderator
OGRE Retired Moderator
Posts: 2060
Joined: Thu Feb 26, 2004 12:11 am
Location: Toronto, Canada
x 3

Post by Falagard »

This is pretty sweet.

So if I understand correctly this technique is good for things like generating a representation of a mesh that will be used as one of its LOD levels when far away from the mesh. So close up you'd use the actual mesh and further back you'd switch to the billboard cloud?

An example would be a maple tree. When close you have full geometry for trunk and leaves, when further back you switch to billboard cloud.

Can this work with something tricky like this situation:

Imagine I have a vertex program that renders tree leaves so they always face the camera, similar to SpeedTree. Can you generate a billboard cloud from this mesh - even though the geometry is actually positioned in a vertex program? I know this is a bit of a tricky situation and I'm just curious. You must be doing something like determining the cross sections based on the vertices of the original mesh, and then doing render to texture for the textures applied to the billboard cloud.

Clay
Lioric
Google Summer of Code Mentor
Google Summer of Code Mentor
Posts: 295
Joined: Fri Aug 06, 2004 10:25 pm

Post by Lioric »

Very nice work :)

Im sure users will be very impressed with the results
So if I understand correctly this technique is good for things like generating a representation of a mesh that will be used as one of its LOD levels when far away from the mesh. So close up you'd use the actual mesh and further back you'd switch to the billboard cloud?
That is probably no necessary, a billboard cloud can be used as the full resolution level of detail, and lower res version of the same billboard cloud or lower resolution billboard cloud versions of the original model should be used at the lods

Take a look at this video to have an idea of their use, all the 150.000 trees are billboard clouds, and just frustum culling is used as the culling process

http://www.vrvis.at/vr/billboardclouds/ ... 1.5_hi.mpg

Billboard clouds are pre-generated off-line, so it is not relevant if you use use a vertex shader in your original tree meshes
User avatar
Falagard
OGRE Retired Moderator
OGRE Retired Moderator
Posts: 2060
Joined: Thu Feb 26, 2004 12:11 am
Location: Toronto, Canada
x 3

Post by Falagard »

Bull, unless I see a demo of that in action instead of a blurry video, I can't imagine anyone walking up to a tree trunk within a few feet and being fooled by a billboard cloud. You can even freeze frame that video as he's at the closest to the trees and see the billboard separation of the trunk. Now, I can see the billboard cloud being used for the leaves at all times, so maybe if this thing works as well as it looks, I'd toss out my whole leaf rendering code and use billboard clouds instead for the leaves at all times, while displaying a full mesh trunk while close up, Then use billboard cloud for a lower LOD.

It did look very impressive for large forest rendering, and would fit in extremely nicely with a high resolution tree generated with Arbaro / MeshTree where there are far too many leaves to be rendered in realtime. I just don't think the trunk will fool anyone close up.

My question about vertex programs is still definitely relevant and here's why:

Let's pretend that the billboard cloud doesn't fool a user close up, or that I want to continue using SpeedTree type solution when close because I like how it looks, the leaves can flutter nicely, or whatever, then you're going to have to create a real mesh representation of the tree and leaves for in game, and only use the billboard cloud for a lower level of detail. During the content creation process you're going to be creating trees that work with SpeedTree style rendering where it's a collection of camera oriented quads. If you're going to be switching LODs from the SpeedTree style leaf rendering to billboard cloud rendering you're going to want them to match up fairly closely. Of course the billboard cloud calculation is going to be done offline, but is it done using Ogre and render to texture, or done with some other technique that doesn't even require a render system at all? If it's done using Ogre and render to texture then it might be possible to actually render the tree into the billboard cloud using the same technique (vertex shader) as when it's displayed in game, so when you switch LODs it looks very similar.

Clay
Last edited by Falagard on Wed Jul 05, 2006 4:11 am, edited 1 time in total.
User avatar
jacmoe
OGRE Retired Moderator
OGRE Retired Moderator
Posts: 20570
Joined: Thu Jan 22, 2004 10:13 am
Location: Denmark
x 179

Post by jacmoe »

Falagard wrote:Bull, unless I see a demo of that in action instead of a blurry video, I can't imagine anyone walking up to a tree within a few feet and being fooled by a billboard cloud.
Billboard clouds are not supposed to be viewed up close.
That's not the way SpeedTree is handling it either. That's handled by LOD.
Try and run Oblivion through OldBlivion and you can see what goes on behind the scenes. :wink:
/* Less noise. More signal. */
Ogitor Scenebuilder - powered by Ogre, presented by Qt, fueled by Passion.
OgreAddons - the Ogre code suppository.
User avatar
Falagard
OGRE Retired Moderator
OGRE Retired Moderator
Posts: 2060
Joined: Thu Feb 26, 2004 12:11 am
Location: Toronto, Canada
x 3

Post by Falagard »

That's what I'm saying dude, but not what Lioric said.
a billboard cloud can be used as the full resolution level of detail
Also, I don't know what you mean by this:
That's not the way SpeedTree is handling it either. That's handled by LOD.
I know how SpeedTree works, I've spent months with it, and implemented my own unique version similar to it, remember? :-)

SpeedTree uses camera oriented quads for the leaves when close up, a mesh representation of the trunk close up, then a lesser number of camera oriented quads for further away, but they are scaled larger, and a lower resolution mesh for the trunk, etc. for several levels of detail, finally a single camera oriented billboard for the lowest level of detail. They also use "fronds" which are quads that don't face the camera and are used for fake branches.