Load normals from file

Started by Thomas., June 13, 2012, 06:55:25 PM

Previous topic - Next topic

Thomas.

Egon, please, could you add support for load normals from OBJ file? For compatibility you can add "Config.loadNormalsFromOBJ = false;" ... Thanks, in return I offer model for your game :) ... and it would be nice if you also add possibility for object without normals, maybe method "Object3D.build(boolean containsNormals);"

EgonOlsen

#1
Deal! Albeit i personally think that this normals-topic is highly overrated... ;) However, it will take some days to find the time to finish this. Can you provide me with a simple model that contains proper normals? A sphere might be useful for this.

Thomas.


Thomas.

I'm not sure, that help me loaded normals. It seems to be saved normals per face, not per vertex. What I want is well lighting box. But object without normals is still important for me...

In screenshots below is problem, which I have. I'm using per-pixel lighting. Any idea, how fix bad lighting polygons?








EgonOlsen

This doesn't really look like per-pixel to me... ???

Thomas.

It's should be per-pixel... Have you any per-pixel shader, which you can share? All objects have same shader...



Thomas.

I removed specular color, but problem is still same...


EgonOlsen

I see...the polygons are pretty large and because the normals on sharp edges are much different from those on flatter surfaces, it'll look this way despite of per pixel lighting. Increasing the geometries tessellation level should help, but it'll slow down the whole thing and uses more memory, so maybe that's not an option. I doubt that loading the normals from the file will help much, but we'll see. However, i still think that this is totally acceptable once you apply textures to the surfaces...but then again, i somehow like this vertex lit look of things like others like pixel art... :)

Thomas.

Whole problem is in normals in vertices. I need same normal in vertex and same in face... I also tried divide one polygon to many small, but every small polygon is visible and result is not much better...

EgonOlsen

If your vertex normals are equal to your face normals, you'll get flat shading. Or did i misunderstood that part?

Thomas.

#11
Yes, flat shading, but just in some part of object... I think, that this is called smooth groups and OBJ has support for this...



I don't know how engine working, but GenericVertexControler is working with for ex. 8 vertices in box, so I can't affect all 32 vertices, that are sent to GPU, so I expect that normal is saved per one together vertex and is impossible to implement something else...

EgonOlsen

I don't get that picture...if the highlighted part is supposed to illustrate a smoothing group, it's simple the opposite of vertex-normals=face-normals and if you feed such a model in your game, you should get smooth lighting. If you don't, you don't have per pixel lighting enabled for whatever reason....anyway, we'll see what we'll get when reading the normals from the file.

The engine shares normals just like it shares vertices. You can disable this behaviour at load time if you tell the Loader so and the model is build that way, but depending on the mesh, this will largely increase vertex count.


Thomas.

#13
Can I somehow get the lighting similar to medial bucket? I think, that this will need smoothing group and two way to calculate normals, because now engine every calculate normals like smooth...

edit: but it's not so hard, next boolean array to triangles (enable by parameter in constructor), if is smooth or flat. And calculate normal by old method, or just copy flat normal to vertex :)

Thomas.

#14
Sorry, I had confusion in smoothing groups, they are probably unnecessary. I did a little test with normals. Whatever are saved normals to OBJ file or not, results are same when I open the model in Deep Exploration, so it seem, that this program is using some more complicated calculation of normals...



this file contains normals and for testing will be probably better than sphere
http://dl.dropbox.com/u/26148874/obejct.zip