TIGSource Forums

Developer => Technical => Topic started by: kamac on November 27, 2011, 10:35:53 AM



Title: Irrlicht - lighting
Post by: kamac on November 27, 2011, 10:35:53 AM
Hi.

I need to make effective & nice looking light for one big object which cannot be a terrain.

This is what i could achieve with

Code:
video::SLight light_data;
light_data.AmbientColor = video::SColorf(1.0,1.0,1.0);
light_data.DiffuseColor = video::SColorf(1.0, 1.0, 1.0);
light_data.SpecularColor = video::SColorf(0.5,0.5,0.5);
light_data.CastShadows = true;
light_data.Radius = 745.0;
light_data.Type = video::ELT_DIRECTIONAL;
    
scene::ILightSceneNode* light = menage->addLightSceneNode(0, core::vector3df(60,40,50));
light->setLightData(light_data);

(http://img856.imageshack.us/img856/6961/whatd.png)

I need help ASAP  :concerned:!

If you have any idea on how to make good-looking lights with possible shadow dropping, write now!  :screamy:


Title: Re: Irrlicht - lighting
Post by: rivon on November 27, 2011, 12:48:25 PM
I need to make effective & nice looking light for one big object which cannot be a terrain.
What did you try to say, again? I didn't understand the sentence.


Title: Re: Irrlicht - lighting
Post by: kamac on November 27, 2011, 01:03:57 PM
Well, i've made it look better using .3ds file instead of .obj. Here's how it looks now:

(http://img853.imageshack.us/img853/5296/whatw.png)

But, is there a way to make this lighting smoother? As you can see it isn't as smooth as it was on (not working) .obj.


Title: Re: Irrlicht - lighting
Post by: moi on November 27, 2011, 01:39:22 PM
I think OBJ looked better.
Maybe the light was too far or badly oriented.
also: a bit of ambient light should help.


Title: Re: Irrlicht - lighting
Post by: kamac on November 27, 2011, 01:46:04 PM
Here's a comparison:

1) .3ds

(http://img59.imageshack.us/img59/2512/onefo.png)

2) .obj

(http://img403.imageshack.us/img403/802/twor.png)


No matter how big ambient color will be, it stays the same at .obj.


Title: Re: Irrlicht - lighting
Post by: moi on November 27, 2011, 01:48:57 PM
could be a problem with UV wrapping


Title: Re: Irrlicht - lighting
Post by: kamac on November 27, 2011, 01:54:14 PM
I wonder how can i fix that.

Models are being made in Blender, and we're ( me and my brother ) are using materials, not an uv map (one .png or .bmp). We use colors, but wanted to use textures.


Title: Re: Irrlicht - lighting
Post by: InfiniteStateMachine on November 27, 2011, 05:09:21 PM
The second screenshot has all the edges set to be smooth. You lost the smoothing group information in the export.

Not sure if those black patches are on account of the smoothing groups. It's possible. Could also be non-perpendicular normals.


Title: Re: Irrlicht - lighting
Post by: increpare on November 27, 2011, 06:59:04 PM
It sure looks like there's something weird going on with the normals and/or the lighting.


Title: Re: Irrlicht - lighting
Post by: bart_the_13th on November 27, 2011, 09:04:29 PM
Or maybe, the light direction is wrong? Looks like it facing upward instead downward


Title: Re: Irrlicht - lighting
Post by: kamac on November 28, 2011, 09:36:12 AM
I've still got completely no idea how to fix it  :concerned:


Title: Re: Irrlicht - lighting
Post by: increpare on November 28, 2011, 09:48:19 AM
I've still got completely no idea how to fix it  :concerned:
ignoring comments may not be working.  maybe you could try replying to some of our suggestions to let us know whether or not they were any use.  if they weren't, we might suggest new things.


Title: Re: Irrlicht - lighting
Post by: kamac on November 28, 2011, 10:02:45 AM
Quote
It sure looks like there's something weird going on with the normals and/or the lighting.

I've tried changing normals's settings, no use. The same lighting works fine for .3ds.

Quote
Or maybe, the light direction is wrong? Looks like it facing upward instead downward

It's facing towards point 0,0,0 from point 15,60,5. Map from downwards looks just the same as from upwards.

The second screenshot has all the edges set to be smooth. You lost the smoothing group information in the export.

Quote
Not sure if those black patches are on account of the smoothing groups. It's possible. Could also be non-perpendicular normals.

I'm unsure how do i fix that?

Quote
could be a problem with UV wrapping

UV wrapping seems fine to me.


Title: Re: Irrlicht - lighting
Post by: moi on November 28, 2011, 10:30:51 AM
I don't know how that will help, but the OBJ version seems to be just vertex lit (light intensity varies linearly between triangle points).
I remember vaguely a similar (but not obligatorily the same) problem that was resolved when I did an UV unwrap of the mesh or sthg like that of the sort. Sort of like.

But I think your problem would be resolved much faster in a modelling forum.


Title: Re: Irrlicht - lighting
Post by: MattG on November 28, 2011, 10:32:00 AM
Fix the light vector first so you have a good angle.

next set ambient light values for both the world (c++) and the objects(blender) to receive ambient light. using your fog color as the ambient light color is a good starting point.

check that your diffuse settings on the material in blender are set as bright as possible so that your lighting works on the materials.

IMO its best to use a white or light grey diffuse material, wtih texture making the color not diffuse material settings making the color. if your materials are too dark, lights wont do much. The vertex smoothing on the .obj is a seperate issue from getting your lighting to work nice







Title: Re: Irrlicht - lighting
Post by: increpare on November 28, 2011, 11:21:54 AM
Doing a visualization of the normal vectors might help clarify things

(http://www.pda-fx.net/content/techniques/scene3dview02.jpg)


Title: Re: Irrlicht - lighting
Post by: kamac on November 28, 2011, 12:45:04 PM
Meantime, i have problem with .x file. Any idea why verticles may be so mixed?

(http://img535.imageshack.us/img535/389/beztytuujeni.png)


Just look at guy's feet. Verts went mad.

@EDIT

Fixed it.


Title: Re: Irrlicht - lighting
Post by: MattG on November 28, 2011, 02:47:31 PM
Meantime, i have problem with .x file. Any idea why verticles may be so mixed?

(http://img535.imageshack.us/img535/389/beztytuujeni.png)


Just look at guy's feet. Verts went mad.

@EDIT

Fixed it.

I have had to filter alot of .x output through deep exploration to get the files clean. Try doing a double export to clean up the .x file IE export then reimport into blender then rexport the result. This will soemtimes clean up a messed file if you dont have deep exploration


Title: Re: Irrlicht - lighting
Post by: moi on November 28, 2011, 03:19:13 PM
(http://rafael.blogadera.com/files/2011/03/pointy-boots.jpeg)


Title: Re: Irrlicht - lighting
Post by: bart_the_13th on November 28, 2011, 06:11:50 PM
You might have done this, but just to make sure, have you enable the lightning on the terrain model? like:
Code:
terrain->setMaterialFlag(EMF_LIGHTING, true);


Title: Re: Irrlicht - lighting
Post by: InfiniteStateMachine on November 28, 2011, 07:33:52 PM
regarding the export. It might be the obj export plugin you use for blender. If it has options, look to make sure there is something to preserve hard edges.


Title: Re: Irrlicht - lighting
Post by: kamac on November 29, 2011, 05:03:37 AM
You might have done this, but just to make sure, have you enable the lightning on the terrain model? like:
Code:
terrain->setMaterialFlag(EMF_LIGHTING, true);


It's obvious one (to me).

@moi,  :durr:

Quote
regarding the export. It might be the obj export plugin you use for blender. If it has options, look to make sure there is something to preserve hard edges.

I will, thanks.


Title: Re: Irrlicht - lighting
Post by: rivon on November 29, 2011, 05:51:14 AM
Or try it with other formats like VRML, Collada etc. which Blender and Irrlicht supports.


Title: Re: Irrlicht - lighting
Post by: kamac on December 01, 2011, 07:16:56 AM
This is a serious problem. Much of my .x exports from blender are looking this way:

(http://img341.imageshack.us/img341/307/verts.png)

And i don't know if it's Blender's fault or is it Irrlicht...

I'll add that much animated objects has these verticles. It's happening when i select "export armatures" in Blender to make bones impact on the model (animate it).


Title: Re: Irrlicht - lighting
Post by: InfiniteStateMachine on December 02, 2011, 10:24:32 AM
It could be a lot of things but I've had that problem before when I've accidentally given 0% weight influence on a couple verts (assuming that you did skeletal animation).

Could also be something with the format if that happens to every animated model.


Title: Re: Irrlicht - lighting
Post by: MattG on December 02, 2011, 11:06:47 AM
ya getting the export setting right will help. Also try converting to polygons in blender before export might help.

try using a sky color for fog, it makes better ambient color when sky/fog/ambient lighting settings are all a similar tone

looks like the dragon wing might b going through the camera plane making the geometry matrix distort


Title: Re: Irrlicht - lighting
Post by: kamac on December 03, 2011, 08:54:43 AM
I've got the problem solved. And it wasn't exporter.

The problem was with models - not every verticle had assigned bone or so.