Can't get gouraud shading on my model?

If you are a new Irrlicht Engine user, and have a newbie-question, this is the forum for you. You may also post general programming questions here.
Trefall
Posts: 45
Joined: Tue Dec 05, 2006 8:49 pm

Can't get gouraud shading on my model?

Post by Trefall »

Image
Image

I've been working on this for some time now, trying to figure out why I get flat shading on my models, but no luck. Also, if I don't add the material flag normal_map_solid or parallax, I only get a white sphere where shaded parts are totaly black.

I'm pretty new to irrlicht, so I'm sure there is something I'm missing here, but so far I haven't been able to figure out what causes this, since clearly I have gouraud shading enabled, right?

I'm using the irrWizard and used a snippet from the perpixel lighting example in irrlicht to load the model with normal map (though that is disabled now). I might add that when I have a normal/parallax map actually loaded, the flat shading will consume the whole model, making the wireframe much more distinguishable.

Any ideas on what is causing this? Here is the source code, it that would help. I load the scene in AppRunState.cpp in the loadSpaceScene(...) function (it's a little bit messy right now due to wip).
Saturn
Posts: 418
Joined: Mon Sep 25, 2006 5:58 pm

Post by Saturn »

I am not sure, but maybe the problem is the building of tangents. Irrlicht modifies (it did earlier, don't know if it has been changed) the original normal in the process. Maybe it realigns the normal to the face normal and doing this will give all adjacent vertices of a face the same normal and the result will look as if flat shaded.

You can test this by not creating tangents.
Trefall
Posts: 45
Joined: Tue Dec 05, 2006 8:49 pm

Post by Trefall »

Thanks for the tip. Sadly it didn't work though. And without tangents I wouldn't be able to do bumpmapping either, so I would really like to have tangents calculated for the mesh.

I changed the createMeshWithTangents(...) to createMeshUniquePrimitives(...), and I ended up with a flat shaded, white sphere, equal to what I would have before if I didn't enable the normal_map_solid material flag.

Image
Trefall
Posts: 45
Joined: Tue Dec 05, 2006 8:49 pm

Post by Trefall »

I just checked the perpixel lighting example that comes with irrlicht again, and it seems the planet rotating in this scene suffers the same problem I am facing :cry:
trooper
Posts: 85
Joined: Fri Nov 03, 2006 7:34 pm
Location: Maryland, USA
Contact:

Post by trooper »

Hey,

OK just so you know, I have compiled and run your source, the problem with everything being white is your light sources.


You are creating 2 lights and adding billboards, that are not shown in the code above, but the brightness of the lights is way too much, try changing it from 20000 to around 5000, and you will see better results.

I am not near my own machine right now, but I will look again later. :wink:

I noticed that you also used a 3DS model, not the earth .X model that come with irrlicht.
Has this been modifed and exported to 3DS, or is it a completley new model ??
You scratch my back, I'll scratch yours.
Trefall
Posts: 45
Joined: Tue Dec 05, 2006 8:49 pm

Post by Trefall »

Thanks a lot for taking your time trooper, the intensity of those lights were definately way too strong and was causing the planet to go totally white. So that solves that one problem.

The shading is still flat though. Here's an example with normal mapping turned off and no tangents calculated for the mesh:
Image

And I'm using a totally new 3d mesh exported from 3d studio max. It's just a simple geosphere with a diffuse map. I have tried with the earth.x as well though, and as I commented in my previous post, testing it in the perpixel lighting example, the wireframe is visible in that example as well, same problem as I'm having as far as I can tell, though the parallax map covers it up very well.
Trefall
Posts: 45
Joined: Tue Dec 05, 2006 8:49 pm

Post by Trefall »

Using the Apfelbaum Software renderer, I actually managed to get smooth/gouraud shading, while both directx and opengl drivers results in flat shading. The problem of the visible wireframe underneath is still there though.

Image
xskinyx
Posts: 25
Joined: Fri Dec 29, 2006 3:28 am

Post by xskinyx »

is your model properly smoothed? perhaps smoothing groups are not loaded on 3ds models so try a different model format?
hybrid
Admin
Posts: 14143
Joined: Wed Apr 19, 2006 9:20 pm
Location: Oldenburg(Oldb), Germany
Contact:

Post by hybrid »

They are not supported, and using the tangent mesh conversion will destroy them anyway. So don't expect these to work. Only support for smoothing groups is in .x format yet.
Trefall
Posts: 45
Joined: Tue Dec 05, 2006 8:49 pm

Post by Trefall »

Thanks guys. I did a retry at implementing the earth.x model and did a test with and without tangents, and the tangents definately screws up the smoothing. So I guess I'm flailing in the void trying to get normal mapping working nicely at this point, so I'll just continue without for the time being. Again, great to see the support of the community surrounding this engine.

Image
Image
BlindSide
Admin
Posts: 2821
Joined: Thu Dec 08, 2005 9:09 am
Location: NZ!

Post by BlindSide »

Damn I was hoping to get similar effect on planets...
Trefall
Posts: 45
Joined: Tue Dec 05, 2006 8:49 pm

Post by Trefall »

Well, bumpmapping with no tangents will have to do I guess.
luckymutt
Posts: 453
Joined: Sun Mar 06, 2005 11:56 pm
Location: C-Ville

Post by luckymutt »

hybrid wrote:They are not supported, and using the tangent mesh conversion will destroy them anyway. So don't expect these to work. Only support for smoothing groups is in .x format yet.
Man, I'd hate to contradict hybrid, however...
isn't gouraud shading supported witht the *.obj?
I recall having nicely shaded round surfaces with *.obj

or am I missing something?
Join us in the Irrlicht chatroom:
[url]irc://irc.freenode.net/irrlicht[/url]

I love deadlines. I like the whooshing sound they make as they fly by. -D.Adams
BlindSide
Admin
Posts: 2821
Joined: Thu Dec 08, 2005 9:09 am
Location: NZ!

Post by BlindSide »

I dont think he means gouraud shading, smoothing groups is probably something else because alot of models, ms3d, 3ds, etc, have fine gouraud shading. I think smoothing groups is something you change in the modeller to make the model smoother?
Trefall
Posts: 45
Joined: Tue Dec 05, 2006 8:49 pm

Post by Trefall »

If you look at the screenies from the .3ds model I used, it does look like both the shading and the smoothing-groups are out. If you look at the screenie I took using the .3ds running on the software driver, you can see how the smooth shading is working, while the smoothing-groups are not.

When I started using the .x model, the shading was smooth, but tangents screwed up the smoothing-groups.

This might just be a trick of the eye caused by the lack of smoothing-groups for the .3ds format though, refering to the first screenie in the topic, but I don't know.
Post Reply