OgreDecal: A mesh-based decal generator

A place to show off your latest screenshots and for people to comment on them. Only start a new thread here if you have some nice images to show off!
fd9_
Halfling
Posts: 64
Joined: Wed Aug 20, 2008 9:20 pm

OgreDecal: A mesh-based decal generator

Post by fd9_ » Tue Sep 18, 2012 7:15 pm

Image
Image
[youtube]IPpY8v5-8kE[/youtube]

Frustrated by the lack of any built-in mesh decal generator for Ogre3D, I decided to go through the painstaking process of making one myself, which actually didn't turn out to be too bad. It's more or less based on the approach described here: http://blog.wolfire.com/2009/06/how-to-project-decals/

It's not perfect, but works well enough in most of the simple test cases I've tried. If there is enough interest, I'll clean it up a little bit and release the source.

Update 9/28:
The source is now available on github. I've posted all of the links and information on the wiki
Last edited by fd9_ on Sun Oct 07, 2012 6:15 pm, edited 6 times in total.
0 x

bstone
OGRE Expert User
OGRE Expert User
Posts: 1920
Joined: Sun Feb 19, 2012 9:24 pm
Location: Russia

Re: Mesh Decal Generator

Post by bstone » Tue Sep 18, 2012 7:28 pm

Looks good, but you should definitely notch the depth bias a bit on the decal materials to fix that z-fight flicker.
0 x

fd9_
Halfling
Posts: 64
Joined: Wed Aug 20, 2008 9:20 pm

Re: Mesh Decal Generator

Post by fd9_ » Tue Sep 18, 2012 8:07 pm

bstone wrote:Looks good, but you should definitely notch the depth bias a bit on the decal materials to fix that z-fight flicker.
Thanks, I added depth_bias and it looks much better now.
0 x

User avatar
amigoface
Greenskin
Posts: 132
Joined: Mon Oct 13, 2008 3:01 pm

Re: Mesh Decal Generator

Post by amigoface » Tue Sep 18, 2012 8:58 pm

fd9_ wrote:Image
It's not perfect, but works well enough in most of the simple test cases I've tried. If there is enough interest, I'll clean it up a little bit and release the source.
definitively yes !!!, please
0 x

Rambus
Greenskin
Posts: 100
Joined: Tue Aug 01, 2006 6:50 am
Location: Canada
Contact:

Re: Mesh Decal Generator

Post by Rambus » Tue Sep 18, 2012 9:22 pm

Very nice :)

I would also like to peak at the source.
0 x

Alexiss
Halfling
Posts: 74
Joined: Wed Aug 10, 2011 2:11 pm

Re: Mesh Decal Generator

Post by Alexiss » Tue Sep 18, 2012 9:52 pm

Wow, that would be awesome. Kudos for your work
0 x

Pulas
Halfling
Posts: 61
Joined: Sat Oct 29, 2011 9:39 am

Re: Mesh Decal Generator

Post by Pulas » Wed Sep 19, 2012 2:52 am

Very interesting! I am waiting for the source release...
0 x

User avatar
duststorm
Minaton
Posts: 921
Joined: Sat Jul 31, 2010 6:29 pm
Location: Belgium
Contact:

Re: Mesh Decal Generator

Post by duststorm » Wed Sep 19, 2012 8:34 am

Great work! This is a very nifty feature to have on hand when you need it.
You should definitely release it! :mrgreen:
0 x
Developer @ MakeHuman.org

User avatar
Zonder
Ogre Magi
Posts: 1127
Joined: Mon Aug 04, 2008 7:51 pm
Location: Manchester - England
x 19

Re: Mesh Decal Generator

Post by Zonder » Wed Sep 19, 2012 9:58 am

Yeah great work. This is something on my list to look into so I would be interested in the source as well :)
0 x
There are 10 types of people in the world: Those who understand binary, and those who don't...

User avatar
Slappy
Bronze Sponsor
Bronze Sponsor
Posts: 139
Joined: Fri Sep 28, 2007 8:30 pm
Location: Slovakia

Re: Mesh Decal Generator

Post by Slappy » Wed Sep 19, 2012 10:09 am

It looks amazing, kudos for you!
0 x
Cool looking Graphical Installers in NSIS and Inno Setup: http://www.graphical-installer.com - FREE for Ogre projects
I offer NSIS/Inno Setup scripting, C/C++/C#/Delphi programming: http://www.unsigned.sk
Develop NSIS/Inno Setup projects directly in Visual Studio 2005-2015: http://www.visual-installer.com/
or RAD Studio 2009-XE8: http://www.rad-installer.com/

TheSHEEEP
OGRE Retired Team Member
OGRE Retired Team Member
Posts: 972
Joined: Mon Jun 02, 2008 6:52 pm
Location: Berlin

Re: Mesh Decal Generator

Post by TheSHEEEP » Wed Sep 19, 2012 11:52 am

Hmm... do we have a decals sample yet?...
0 x
My site! - Have a look :)
Also on Twitter - extra fluffy

User avatar
Xavyiy
OGRE Expert User
OGRE Expert User
Posts: 847
Joined: Tue Apr 12, 2005 2:35 pm
Location: Albacete - Spain

Re: Mesh Decal Generator

Post by Xavyiy » Wed Sep 19, 2012 12:39 pm

Congrats, looks really nice!

+1 for the source release! Also, it would be interesting to officially intergate it into the Ogre core.

With some precautions in the implementation: make it compatible with static geometry, maybe even with "animated models"(updating the decal geometry when needed), etc it could be really useful for almost all people using Ogre.

Xavier
0 x

fd9_
Halfling
Posts: 64
Joined: Wed Aug 20, 2008 9:20 pm

Re: Mesh Decal Generator

Post by fd9_ » Wed Sep 19, 2012 6:08 pm

Wow, thanks everyone for the encouraging feedback! I'll work on getting a release out soon (there are still a couple things left I need to do). I have no plans for supporting animated geometry - I'll let someone else tackle that. :)
0 x

Treon
Kobold
Posts: 37
Joined: Mon Mar 07, 2011 2:30 pm

Re: Mesh Decal Generator

Post by Treon » Wed Sep 19, 2012 6:23 pm

looks really nice, it indeed would be interesting to officially intergate it into Ogre.
0 x

User avatar
syedhs
Silver Sponsor
Silver Sponsor
Posts: 2702
Joined: Mon Aug 29, 2005 3:24 pm
Location: Kuala Lumpur, Malaysia
x 2

Re: Mesh Decal Generator

Post by syedhs » Wed Sep 19, 2012 10:12 pm

fd9_ wrote:Wow, thanks everyone for the encouraging feedback! I'll work on getting a release out soon (there are still a couple things left I need to do). I have no plans for supporting animated geometry - I'll let someone else tackle that. :)
Release early, release often :wink:
0 x
A willow deeply scarred, somebody's broken heart
And a washed-out dream
They follow the pattern of the wind, ya' see
Cause they got no place to be
That's why I'm starting with me

User avatar
jacmoe
OGRE Retired Moderator
OGRE Retired Moderator
Posts: 20570
Joined: Thu Jan 22, 2004 10:13 am
Location: Denmark
Contact:

Re: Mesh Decal Generator

Post by jacmoe » Wed Sep 19, 2012 10:39 pm

I really want to have my grubby paws on some source code! :D
fd9_ wrote:I have no plans for supporting animated geometry - I'll let someone else tackle that. :)
Just whack it into a Bitbucket repository, and let people tackle it. :)
0 x
/* Less noise. More signal. */
Ogitor Scenebuilder - powered by Ogre, presented by Qt, fueled by Passion.
OgreAddons - the Ogre code suppository.

User avatar
AshMcConnell
Silver Sponsor
Silver Sponsor
Posts: 605
Joined: Fri Dec 14, 2007 11:44 am
Location: Northern Ireland
x 2
Contact:

Re: Mesh Decal Generator

Post by AshMcConnell » Thu Sep 20, 2012 8:44 pm

Cool stuff, great work!

Could this be used for "blob" shadows?
0 x

User avatar
nevarim
Gnoll
Posts: 655
Joined: Mon Jul 05, 2010 6:16 pm
Location: Pavia Italy
Contact:

Re: Mesh Decal Generator

Post by nevarim » Fri Sep 21, 2012 7:51 am

seems great this project :D
0 x
i'm a noob until proven otherwise :D
used in my project ;) and thanks to everyone :D
Ogre 3d
Mygui
Skyx
Hydrax
MOC
CCS

User avatar
duststorm
Minaton
Posts: 921
Joined: Sat Jul 31, 2010 6:29 pm
Location: Belgium
Contact:

Re: Mesh Decal Generator

Post by duststorm » Fri Sep 21, 2012 1:12 pm

AshMcConnell wrote:Could this be used for "blob" shadows?
I believe so.
fd9_, do you have an idea of the performance of the decals?
0 x
Developer @ MakeHuman.org

fd9_
Halfling
Posts: 64
Joined: Wed Aug 20, 2008 9:20 pm

Re: Mesh Decal Generator

Post by fd9_ » Fri Sep 21, 2012 6:17 pm

duststorm wrote:
AshMcConnell wrote:Could this be used for "blob" shadows?
I believe so.
fd9_, do you have an idea of the performance of the decals?
Well, there are two different categories: the performance of the calculation itself and then the rendering cost.

The calculation is going to be dependent on the size of the decal and the amount of triangles in the scene. You start out with an AABB and calculate all the triangles in the scene that intersect it. For simplicity, my world is a single mesh which I test against, and I ignore any other objects. Right now I'm using Bullet to perform the AABB-triangle and clipping tests, but I plan to separate that code out so the algorithm is independent of any physics engine. Since the world can potentially be very large, I'll most likely provide some sort of optional callback function (i.e, GetTrianglesInAABB), so that the end-user can make use of any optimizations provided by whichever physics engine they may end up using. By default, the algorithm will just use a brute-force test.

I'm currently using an indexed triangle list for the rendering operation with a single begin()/end(), and I seem to be getting an average of 6 batches per decal. Now I don't really know how Ogre optimizes this stuff internally, but my understanding was that if you have a single object with a single material, you should be able to render it in one batch. I've tried using one scene node per decal, and I've tried using a single global scene node for every decal, but it doesn't seem to make any difference. I know Ogre has a static geometry feature, but I haven't tried using that yet. My initial thought was that perhaps I needed a triangle strip to get it down to 1 batch, but from my reading so far, it seems that an indexed triangle list should be just as fast. Perhaps someone can clarify this, since this is not my area of expertise. Isn't it possible to somehow have all decals of the same material rendered in the same batch as well?

About the shadow blob: I don't see why it wouldn't work, if optimized correctly.
0 x

bstone
OGRE Expert User
OGRE Expert User
Posts: 1920
Joined: Sun Feb 19, 2012 9:24 pm
Location: Russia

Re: Mesh Decal Generator

Post by bstone » Fri Sep 21, 2012 6:51 pm

As long as there's one begin()/end() section of the ManualObject per decal you should be getting one batch per decal as well. If you have materials with multiple passes (e.g. per light) then you will see the related increase in the batch counts.
0 x

fd9_
Halfling
Posts: 64
Joined: Wed Aug 20, 2008 9:20 pm

Re: Mesh Decal Generator

Post by fd9_ » Fri Sep 21, 2012 7:35 pm

bstone wrote:As long as there's one begin()/end() section of the ManualObject per decal you should be getting one batch per decal as well. If you have materials with multiple passes (e.g. per light) then you will see the related increase in the batch counts.
There is only one begin()/end() sequence and my material is set up like this:

Code: Select all

 material SmileyFace
 {
   technique
   {
     pass
     {
         alpha_rejection greater_equal 128
         lighting on
         depth_write on
         depth_bias 4

         
         texture_unit
			{
				texture SmileyFace.png
			}
       
     }
   }
 }
 
0 x

fd9_
Halfling
Posts: 64
Joined: Wed Aug 20, 2008 9:20 pm

Re: OgreDecal

Post by fd9_ » Fri Sep 28, 2012 8:51 pm

I've spent the last week or so cleaning up the source code (as best I could) and provided a wealth of information on the wiki. Please read the wiki before using it, especially the last part. Let me know how it goes.

Go to the wiki!
0 x

User avatar
nevarim
Gnoll
Posts: 655
Joined: Mon Jul 05, 2010 6:16 pm
Location: Pavia Italy
Contact:

Re: OgreDecal

Post by nevarim » Fri Sep 28, 2012 9:20 pm

great work fd9 :D

would be nice if there was a part that explains how to use a decal on the ground as a pointer (there are no so many info on this part on forum and are all old ;) )

thankss ;)

Nevarim
0 x
i'm a noob until proven otherwise :D
used in my project ;) and thanks to everyone :D
Ogre 3d
Mygui
Skyx
Hydrax
MOC
CCS

fd9_
Halfling
Posts: 64
Joined: Wed Aug 20, 2008 9:20 pm

Re: OgreDecal

Post by fd9_ » Fri Sep 28, 2012 10:32 pm

nevarim wrote:great work fd9 :D

would be nice if there was a part that explains how to use a decal on the ground as a pointer (there are no so many info on this part on forum and are all old ;) )

thankss ;)

Nevarim
You mean like this?

[youtube]5PwggRRPHIM[/youtube]

All you need to do is cast a ray into the scene and create a new decal each frame. You can use this class to cast the ray: http://www.ogre3d.org/docs/api/html/cla ... Query.html

Does that help?
0 x

Post Reply