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
x 22

OgreDecal: A mesh-based decal generator

Post by fd9_ »

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.
bstone
OGRE Expert User
OGRE Expert User
Posts: 1920
Joined: Sun Feb 19, 2012 9:24 pm
Location: Russia
x 201

Re: Mesh Decal Generator

Post by bstone »

Looks good, but you should definitely notch the depth bias a bit on the decal materials to fix that z-fight flicker.
fd9_
Halfling
Posts: 64
Joined: Wed Aug 20, 2008 9:20 pm
x 22

Re: Mesh Decal Generator

Post by fd9_ »

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.
User avatar
amigoface
Greenskin
Posts: 132
Joined: Mon Oct 13, 2008 3:01 pm

Re: Mesh Decal Generator

Post by amigoface »

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
Rambus
Greenskin
Posts: 100
Joined: Tue Aug 01, 2006 6:50 am
Location: Canada
x 6

Re: Mesh Decal Generator

Post by Rambus »

Very nice :)

I would also like to peak at the source.
Alexiss
Halfling
Posts: 74
Joined: Wed Aug 10, 2011 2:11 pm
x 11

Re: Mesh Decal Generator

Post by Alexiss »

Wow, that would be awesome. Kudos for your work
Pulas
Halfling
Posts: 61
Joined: Sat Oct 29, 2011 9:39 am

Re: Mesh Decal Generator

Post by Pulas »

Very interesting! I am waiting for the source release...
User avatar
duststorm
Minaton
Posts: 921
Joined: Sat Jul 31, 2010 6:29 pm
Location: Belgium
x 80

Re: Mesh Decal Generator

Post by duststorm »

Great work! This is a very nifty feature to have on hand when you need it.
You should definitely release it! :mrgreen:
Developer @ MakeHuman.org
User avatar
Zonder
Ogre Magi
Posts: 1173
Joined: Mon Aug 04, 2008 7:51 pm
Location: Manchester - England
x 76

Re: Mesh Decal Generator

Post by Zonder »

Yeah great work. This is something on my list to look into so I would be interested in the source as well :)
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 »

It looks amazing, kudos for you!
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
x 65

Re: Mesh Decal Generator

Post by TheSHEEEP »

Hmm... do we have a decals sample yet?...
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
x 87

Re: Mesh Decal Generator

Post by Xavyiy »

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
fd9_
Halfling
Posts: 64
Joined: Wed Aug 20, 2008 9:20 pm
x 22

Re: Mesh Decal Generator

Post by fd9_ »

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. :)
Treon
Kobold
Posts: 37
Joined: Mon Mar 07, 2011 2:30 pm

Re: Mesh Decal Generator

Post by Treon »

looks really nice, it indeed would be interesting to officially intergate it into Ogre.
User avatar
syedhs
Silver Sponsor
Silver Sponsor
Posts: 2703
Joined: Mon Aug 29, 2005 3:24 pm
Location: Kuala Lumpur, Malaysia
x 51

Re: Mesh Decal Generator

Post by syedhs »

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:
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
x 179

Re: Mesh Decal Generator

Post by jacmoe »

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. :)
/* 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 16

Re: Mesh Decal Generator

Post by AshMcConnell »

Cool stuff, great work!

Could this be used for "blob" shadows?
User avatar
nevarim
Gnoll
Posts: 675
Joined: Mon Jul 05, 2010 6:16 pm
Location: Pavia Italy
x 4

Re: Mesh Decal Generator

Post by nevarim »

seems great this project :D
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
x 80

Re: Mesh Decal Generator

Post by duststorm »

AshMcConnell wrote:Could this be used for "blob" shadows?
I believe so.
fd9_, do you have an idea of the performance of the decals?
Developer @ MakeHuman.org
fd9_
Halfling
Posts: 64
Joined: Wed Aug 20, 2008 9:20 pm
x 22

Re: Mesh Decal Generator

Post by fd9_ »

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.
bstone
OGRE Expert User
OGRE Expert User
Posts: 1920
Joined: Sun Feb 19, 2012 9:24 pm
Location: Russia
x 201

Re: Mesh Decal Generator

Post by bstone »

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.
fd9_
Halfling
Posts: 64
Joined: Wed Aug 20, 2008 9:20 pm
x 22

Re: Mesh Decal Generator

Post by fd9_ »

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
			}
       
     }
   }
 }
 
fd9_
Halfling
Posts: 64
Joined: Wed Aug 20, 2008 9:20 pm
x 22

Re: OgreDecal

Post by fd9_ »

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!
User avatar
nevarim
Gnoll
Posts: 675
Joined: Mon Jul 05, 2010 6:16 pm
Location: Pavia Italy
x 4

Re: OgreDecal

Post by nevarim »

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
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
x 22

Re: OgreDecal

Post by fd9_ »

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?