Page 1 of 2

Can't get gouraud shading on my model?

Posted: Fri Dec 29, 2006 2:09 pm
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).

Posted: Fri Dec 29, 2006 2:34 pm
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.

Posted: Fri Dec 29, 2006 2:49 pm
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

Posted: Fri Dec 29, 2006 3:11 pm
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:

Posted: Fri Dec 29, 2006 5:43 pm
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 ??

Posted: Fri Dec 29, 2006 8:45 pm
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.

Posted: Fri Dec 29, 2006 8:55 pm
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

Posted: Fri Dec 29, 2006 10:55 pm
by xskinyx
is your model properly smoothed? perhaps smoothing groups are not loaded on 3ds models so try a different model format?

Posted: Sat Dec 30, 2006 12:29 am
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.

Posted: Sat Dec 30, 2006 2:46 am
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

Posted: Sat Dec 30, 2006 8:24 am
by BlindSide
Damn I was hoping to get similar effect on planets...

Posted: Sat Dec 30, 2006 9:39 pm
by Trefall
Well, bumpmapping with no tangents will have to do I guess.

Posted: Mon Jan 01, 2007 9:07 am
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?

Posted: Mon Jan 01, 2007 12:50 pm
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?

Posted: Mon Jan 01, 2007 4:01 pm
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.