Gile[s] Lightmapper Ogre export plugin

Discussion area about developing or extending OGRE, adding plugins for it or building applications on it. No newbie questions please, use the Help forum for that.
User avatar
walaber
OGRE Expert User
OGRE Expert User
Posts: 829
Joined: Sat Oct 02, 2004 2:20 pm
Location: California, USA
Contact:

Gile[s] Lightmapper Ogre export plugin

Post by walaber »

This is my current WIP exporter for the Gile[s] Lightmapper. Gile[s] is a very powerful lightmapper, which I have been using for quite a while now, with fantastic results.

I recently started learning/developing in Ogre (namely using the Newton Game Dynamics physics SDK), and realized I need a way to use Gile[s] lightmapped meshes in Ogre. so I set out to write an Ogre export plugin for the program... and it's almost done.

here's a WIP screenshot:

Image

THINGS TO FIX:
1) error in generating IndexBuffers (easy fix)
2) flip handed-ness when exporting (Gile[s] is left-handed) (easy fix)
3) errors in generating the material scripts.

I have number 1 and 2 solved, I just have to implement them. as for #3, I will probably be asking sime questions from users here, as you can see from the screenshot, the transparency/alpha isn't working right (the shot is from the Ogre mesh viewer app) :D
Go Go Gadget OGRE!!
Image
User avatar
Banania
Gremlin
Posts: 150
Joined: Wed Oct 20, 2004 2:35 pm
Location: Paris, France
Contact:

Post by Banania »

Very cool !

Don't hesitate to ask questions.

Good luck !
Banania
User avatar
walaber
OGRE Expert User
OGRE Expert User
Posts: 829
Joined: Sat Oct 02, 2004 2:20 pm
Location: California, USA
Contact:

Post by walaber »

thanks. I made a few fixes... it now exports the mesh properly, and makes the mesh right-handed for Ogre (or is it the other way around...)!

updates screenshot:
Image

now if someone could explain how I can get the tree leaves to be properly transparent I'd really appreciate it!! here's the material script:

Code: Select all

// Material created by Gile[s] Ogre Exporter by Walaber
material Gile[s]_Trunk 
{ 
	technique 
	{ 
		pass 
		{ 
			emissive 1 1 1 1
			scene_blend alpha_blend 
			lighting off 
			texture_unit
			{
				texture Wood03.png
				filtering none 
				tex_coord_set 0 
				colour_op modulate 
			} 
		} 
	} 
} 


// Material created by Gile[s] Ogre Exporter by Walaber
material Gile[s]_Leaf 
{ 
	technique 
	{ 
		pass 
		{ 
			emissive 1 1 1 1
			scene_blend alpha_blend 
			lighting off 
			cull_hardware none 
			texture_unit
			{
				texture Cross04.png
				filtering none 
				tex_coord_set 0 
				colour_op modulate 
			} 
		} 
	} 
} 


// Material created by Gile[s] Ogre Exporter by Walaber
material Gile[s]_Floor 
{ 
	technique 
	{ 
		pass 
		{ 
			emissive 1 1 1 1
			scene_blend alpha_blend 
			lighting off 
			texture_unit
			{
				texture anFloor2.jpg
				filtering bilinear 
				tex_coord_set 0 
				colour_op modulate 
			} 
			texture_unit
			{
				texture tree_lm.png
				tex_address_mode clamp 
				filtering none 
				tex_coord_set 1 
				colour_op_ex modulate_x2 src_current src_texture 
			} 
		} 
	} 
} 
Go Go Gadget OGRE!!
Image
User avatar
DWORD
OGRE Retired Moderator
OGRE Retired Moderator
Posts: 1365
Joined: Tue Sep 07, 2004 12:43 pm
Location: Aalborg, Denmark
Contact:

Post by DWORD »

I think you need 'depth_write off' in material pass to make the transparent objects render correctly. Also using 'emissive 1 1 1 1' has no effect when turning off dynamic lighting, and consider turning off alpha blending for the floor (and trunk?). I know this is work in progress, so I don't mean to bite off your head.

Edit: Btw I don't know Gile[s], but this looks nice :)
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
Contact:

Post by sinbad »

Actually if the alpha is 'hard' ie not partial, then you need 'alpha_rejection greater 128' in your texture_unit, and depth_write should still be 'on'.
User avatar
walaber
OGRE Expert User
OGRE Expert User
Posts: 829
Joined: Sat Oct 02, 2004 2:20 pm
Location: California, USA
Contact:

Post by walaber »

they are .png images, so they should have a proper alpha channel...

I realize there is a lot of excess data in the material script, it's obviously generated automatically from the Gile[s] data, and coule use a few more "brains"

[edit]

with a little hand-editing of the material script, I got it working. with a little modification to my material script generator code, I should be in business!

Image
Go Go Gadget OGRE!!
Image
User avatar
Robomaniac
Hobgoblin
Posts: 508
Joined: Tue Feb 03, 2004 6:39 am

Post by Robomaniac »

Sweet
phear hingo

My Webpage
User avatar
DWORD
OGRE Retired Moderator
OGRE Retired Moderator
Posts: 1365
Joined: Tue Sep 07, 2004 12:43 pm
Location: Aalborg, Denmark
Contact:

Post by DWORD »

Now that's something! :D I like the middle picture.
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
Contact:

Post by sinbad »

Excellent! Would you be willing to contribute this exporter to the ogreaddons area?
User avatar
walaber
OGRE Expert User
OGRE Expert User
Posts: 829
Joined: Sat Oct 02, 2004 2:20 pm
Location: California, USA
Contact:

Post by walaber »

absolutely. give me some time to fix it up a little more, and I'd be glad to submit it.

what about the source? should I submit that as well? if so I should probably clean it up a little...
Go Go Gadget OGRE!!
Image
User avatar
SpannerMan
Gold Sponsor
Gold Sponsor
Posts: 446
Joined: Fri May 02, 2003 10:05 am
Location: UK
Contact:

Post by SpannerMan »

Looking extremely cool Walaber :)
User avatar
:wumpus:
OGRE Retired Team Member
OGRE Retired Team Member
Posts: 3067
Joined: Tue Feb 10, 2004 12:53 pm
Location: The Netherlands
x 1

Post by :wumpus: »

walaber wrote:what about the source? should I submit that as well? if so I should probably clean it up a little...
Well, you could also decide to sell an executable and get rich :-) But to be included in ogreaddons we need the source code with a GPL/LGPL compatible license (AFAIK)
User avatar
walaber
OGRE Expert User
OGRE Expert User
Posts: 829
Joined: Sat Oct 02, 2004 2:20 pm
Location: California, USA
Contact:

Post by walaber »

I assume this means I have to open that door to the secret and mysterious world of CVS? :wink:

I'll have to do a little research about licenses, etc... and make sure it's okay with the author of Gile[s] as well.
Go Go Gadget OGRE!!
Image
User avatar
walaber
OGRE Expert User
OGRE Expert User
Posts: 829
Joined: Sat Oct 02, 2004 2:20 pm
Location: California, USA
Contact:

Post by walaber »

yet another question... is there anyway to make completely solid, non-white objects in Ogre?

for example, I want to have an object that is rendered with no lighting, but is completely red aka rgb(1 0 0)... if I set "lighting off" in the material script, the object goes white... so do I accomplish this?

it's necessary to make the exporter compatible with all materials Gile[s] can create...

any help would be greatly appreciated.
Go Go Gadget OGRE!!
Image
User avatar
DWORD
OGRE Retired Moderator
OGRE Retired Moderator
Posts: 1365
Joined: Tue Sep 07, 2004 12:43 pm
Location: Aalborg, Denmark
Contact:

Post by DWORD »

walaber wrote:for example, I want to have an object that is rendered with no lighting, but is completely red aka rgb(1 0 0)... if I set "lighting off" in the material script, the object goes white... so do I accomplish this?
You can use:

Code: Select all

material Red
{
	technique
	{
		pass
		{
			ambient 0 0 0
			diffuse 0 0 0
			emissive 1 0 0
		}
	}
}
User avatar
walaber
OGRE Expert User
OGRE Expert User
Posts: 829
Joined: Sat Oct 02, 2004 2:20 pm
Location: California, USA
Contact:

Post by walaber »

thanks... I gave it a try... but in the MeshViewer, it still "shades" the object, it doesn't stay a solid color...

I'll keep working with it... once I get these material settings, the exporter will basically be complete!
Go Go Gadget OGRE!!
Image
User avatar
killah
Gnoblar
Posts: 7
Joined: Sat Oct 09, 2004 1:00 pm

Post by killah »

These shots are really impressive, congratulations! :D
Try it and if you can't solve it... try again!
User avatar
:wumpus:
OGRE Retired Team Member
OGRE Retired Team Member
Posts: 3067
Joined: Tue Feb 10, 2004 12:53 pm
Location: The Netherlands
x 1

Post by :wumpus: »

walaber wrote: for example, I want to have an object that is rendered with no lighting, but is completely red aka rgb(1 0 0)... if I set "lighting off" in the material script, the object goes white... so do I accomplish this?
I'm not sure if this is possible currently, when Lighting is set to off, the base color of the object is always set to white (with glColor3f in GL and ?? in D3D). It can only be changed by the vertex colours of the mesh. We could change things to use the Diffuse color for this as this is unused anyway with lighting and vertex colors set to off.
User avatar
DWORD
OGRE Retired Moderator
OGRE Retired Moderator
Posts: 1365
Joined: Tue Sep 07, 2004 12:43 pm
Location: Aalborg, Denmark
Contact:

Post by DWORD »

walaber wrote:thanks... I gave it a try... but in the MeshViewer, it still "shades" the object, it doesn't stay a solid color...
Hmm... it worked for me (in my app. at least), but it's a hack anyway :?
:wumpus: wrote:We could change things to use the Diffuse color for this as this is unused anyway with lighting and vertex colors set to off.
Sounds like a good idea imho. :)
User avatar
:wumpus:
OGRE Retired Team Member
OGRE Retired Team Member
Posts: 3067
Joined: Tue Feb 10, 2004 12:53 pm
Location: The Netherlands
x 1

Post by :wumpus: »

I need Sinbads advise on this; we could re-use the Diffuse, Ambient or even Emissive statement for the base color, or add a new one
User avatar
walaber
OGRE Expert User
OGRE Expert User
Posts: 829
Joined: Sat Oct 02, 2004 2:20 pm
Location: California, USA
Contact:

Post by walaber »

I think it would be a nice addition... personally I think either the diffuse or emmisive value would be the most "logical"...

without this feature, I cannot properly re-create some materials that can be created in Gile[s]...

othewise progress is going well on the exporter... I hope to knock more of the kinks out of the material script generator soon...
Go Go Gadget OGRE!!
Image
User avatar
:wumpus:
OGRE Retired Team Member
OGRE Retired Team Member
Posts: 3067
Joined: Tue Feb 10, 2004 12:53 pm
Location: The Netherlands
x 1

Post by :wumpus: »

Thinking about it, there are even two base colors for GL and D3D (and two vertex colour channels).. so using the diffuse and specular for those would make some sense. (most of the time you won't use the second color, but still)

But it could give problems with the default values (materials should be able to assume the base color is white if it isn't set). Diffuse and specular default to 0.0 .. I'm still not too sure about the syntax.
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
Contact:

Post by sinbad »

Code: Select all

material Red
{
   technique
   {
      pass
      {
         ambient 0 0 0
         diffuse 0 0 0
         emissive 1 0 0
         specular 0 0 0 0 
      }
   }
}
That should give you a solid red colour with no variations in colour. If there are variations, something is wrong. There is no need for any other feature to be created to support this since it should already work. I wouldn't rely on the MeshViewer, use a real Ogre application since cTh no longer maintains MeshViewer.
User avatar
:wumpus:
OGRE Retired Team Member
OGRE Retired Team Member
Posts: 3067
Joined: Tue Feb 10, 2004 12:53 pm
Location: The Netherlands
x 1

Post by :wumpus: »

That only works with lighting on, though. It's better for performance to disable lighting for materials that aren't affected by realtime lights.
User avatar
epopov
Halfling
Posts: 85
Joined: Tue Jun 10, 2003 2:57 pm
Contact:

Post by epopov »

I don't know if it's an option, but a simple vertex program would work I think (it would just return a constant color).
A vertex program may be overkill for this, though, if you target cards without this support (but I think vertex programs may be emulated if not supported by the card - at leat by directx).
Post Reply