HeroEngine Forums
Welcome, Guest. Please login or Register for HeroCloud Account.

Author Topic: [Resolved] Strange shading of polygons  (Read 6774 times)

Taschenmogul

  • General Accounts
  • *
  • Posts: 34
    • View Profile
[Resolved] Strange shading of polygons
« on: May 24, 11, 04:17:05 PM »

Hi there!

Iīve noticed this problem a while ago and tried different things out to solve it - while working with testtiles for tilesets I got this really strange shading that, as I saw later, was connected to the individual triangles of the tiles.
Iīve posted a picture showing the problem below.

So I looked around and found no reference to this problem, neither here in the forum nor on the wiki, nor via google.
Seemed like nobody else had this problem.
Now I have a bit of experience with 3d modelling and rendering but have not had any concrete experience with making models for games.
Seems to me like itīs kind of a phong shading issue and Iīve mainly worked with SDS and Nurbs in the past so that I havenīt got that much experience with phong shading on triangulated meshes.
So perhaps itīs a common problem that everybody knows to solve (or to accept) and thatīs why I didnīt find any mention of it?

On the other hand I just canīt imagine that others could consider that shading acceptable, so I guess there has to be a solution to it.
Now after some experiments I have found something like a solution but Iīm unsure if that can really be it.

Now, below is a (modified) screenshot from the engine.



Lefthand you see two simple groups of 2x4 assets with visible edges (colorized to be better recognizable), on the right we see those models without edgelighting.
The group in the top row is made of the original model and especially on the right you can see how bad shading errors get.
Below you see a group of modified models, and as you can see the shading errors are gone.

What I have done is the following, and you can see it on the left where the arrows are hinting at the respective polygons - I simply have flipped the internal edges by 90 degrees. And shading errors are gone.
So Iīm uncertain.
Do we really have to manually define internal edges of wouldbe quads, not being able to simply click "triangulate"?
Can this really be the solution?
Or does someone have a better one and could perhaps hint me in the right direction with some enlightening link?

Please, help me out of my not-getting-it! ;-)
« Last Edit: Oct 26, 12, 04:24:11 PM by HE-Cooper »
Logged

HE-HERB

  • HeroEngine
  • *****
  • Posts: 530
    • View Profile
    • HeroEngine
Re: Strange shading of polygons
« Reply #1 on: May 24, 11, 09:54:55 PM »

Have you reviewed the console and errors GUIs for errors and warnings related to mesh issues or duplicate / conflicting material names or settings?

Cheers
Logged
herb marselas
graphics guy

Taschenmogul

  • General Accounts
  • *
  • Posts: 34
    • View Profile
Re: Strange shading of polygons
« Reply #2 on: May 25, 11, 01:51:44 AM »

Yes, there are no error messages regarding this, neither in the error log nor in the console, and Iīve made sure that there were no material conflicts or texture errors.
Those problems even stay if I turn on "1x1 textures" (which is what you see on the screenshot above) and I was able to replicate it with a number (practically every testtile) of assets, so Iīm pretty sure that itīs no material or texture problem. (Well, as long as thereīs no "Donīt destroy my shading!" button in the exporter that I should have overlooked. ;-)

This whole problem seems to be linked to the dynamic lighting system, cause this shading changes dependent on those settings, with distorted shades moving over the object when changing the lightīs angle.
I tried turning of the directional lighting alltogether but while changing the respective values in the environment tab does change the lighting, unchecking any of the boxes doesnīt do a thing.
Setting the brightness of lighting to zero results in a completely dark scene, unchecking the adjacent box doesnīt result in any change though, for example.
Iīve also had some other strange shadowing issues where a tile seemed to receive distored shadows of another tile, in a way that could not be explained, that is, on a polygon that faced away from the other object and could in no way receive shadows from it.

Regarding the source of the problem my first idea was that, because I used simple onesided assets, light would shine through be back of the faces, projecting on the opposed faces of the asset.
That wouldnīt explain the strange shading though, cause then lighting should be equal on all those opposed faces.
Plus even completely turning of shadows doesnīt change the shading (though I think to remember that it made the strange shadows from the other asset disappear) and obscuring the assets from light, such as putting them underground/ below a heightmap doesnīt do anything either.


Regards
Logged

Stadi_Thompson

  • General Accounts
  • *
  • Posts: 324
    • View Profile
Re: Strange shading of polygons
« Reply #3 on: May 25, 11, 02:02:41 PM »

something is wrong with the way you are creating your models in your 3d program. try averaging the normals or running some kind of normal operation on your models. we have used Maya and Max models and never had any issues. try making a default sphere and export it. not sure what edge lighting is, also you should not be flipping edges. create a 2 x 4 plane move the middle vertices inward and export. that is not an engine issue in the pictures. looks to me as if each poly is its own object which is why it is lighting each facet as it was a single object. Try merging vertices or edges.
Logged

Taschenmogul

  • General Accounts
  • *
  • Posts: 34
    • View Profile
Re: Strange shading of polygons
« Reply #4 on: May 26, 11, 11:39:24 AM »

@info360covers:

Iīm pretty sure, normals are not the problem.
Iīve really tried a lot, and not all models showed that shading problem.
Simple planes (like you mentioned) most of the time donīt exhibit this kind of shading, more complex models also donīt.
It seems to especially affect assets that are meant to be used as tiles, showing "open edges".
Iīve specifically looked for "bad" normals, but they seem to be pretty perfect; meaning that the normals of the edges on the edge of the model point in the same direction as the normals of inner edges.
Edges or vertices are ok too.
The model you see on the image really is just a part of a normal cube.
Thereīs not much geometry at all and so itīs pretty easy to make sure the model is ok (thatīs why I chose it) - and it is.

Apart from that, solely modelling in Max or Maya is no option for us as we donīt have enough licenses for every 3D artist and thus have to rely on Wings/Blender, etc..
Logged

Stonebeard

  • General Accounts
  • *
  • Posts: 1
    • View Profile
Re: Strange shading of polygons
« Reply #5 on: Jun 05, 11, 08:21:43 AM »

What program/s are you using?

It almost looks like your having problems with smoothing groups, but something is telling me it is a lighting issue due to triangulation, well depending on conditions .. generate and apply a lightmap with the UV editor.
Logged

Taschenmogul

  • General Accounts
  • *
  • Posts: 34
    • View Profile
Re: Strange shading of polygons
« Reply #6 on: Jun 05, 11, 04:06:03 PM »

@olard:

Thank you!!!
Smoothing groups it was!
Now Iīm feeling a little dumb, but Iīll at least explain what exactly happened, so that others may not make the same simple mistake:

Blender doesnīt support smoothing groups as such and I, as said having mostly worked with SDS and Nurbs, was not that well accustomed to them.
When importing via OBJ, importing smoothing groups could be selected, but as there were no such groups I didnīt select it.
This resulted in the object being treated as being uniformly smoothed though, even it was not apparent to me (whyever; I SHOULD have seen this).
Now, explicitly importing smoothing groups even though there are none fixes this; this way the object is treated as uniformly sharpened.

So when working with more complex models you have to come up with a different approach then what you would normally do in Blender to set edges sharp.
Donīt use "mark sharp" creases to set edges as sharp, but instead split the mesh into different independent parts, according to what you want to be smoothed and what should stay sharp. Of course you could also create smoothing groups in Max/Maya after importing the model, but that would probably mess up workflow.

So, Iīll do a little more testing, but as it seems this problem could now be solved.
Thanks to all for your support!
Logged