Gildor's Forums

Author Topic: Normals generation questions  (Read 3552 times)
proteal
Sponsor
Newbie
*
Posts: 3


View Profile
Normals generation questions
« on: July 06, 2012, 22:15 »

Since PSK doesn't have normals data, what algorithm does UE Viewer use to generate normals?  And tangent/bitangent?

Are there ever noticeable discrepancies from not having the original normal data?

When UE Viewer builds OpenGL vertex data from wedges, does it ever split wedges for differing normals?
Logged
Gildor
Administrator
Hero Member
*****
Posts: 7972



View Profile WWW
Re: Normals generation questions
« Reply #1 on: July 06, 2012, 22:30 »

First of all, Unreal does not operates with PSK data, it uses different and more complex internal mesh format. PSK is just a format used by Epic Games to export data from modeling software to the game engine.

UE3 mesh has normal, tangent and binormal data stored in the mesh, because normal generation is relatively slow process, and engine programmers decided to store normals in packages instead of rebuilding them every time. Current version of the umodel uses this data for rendering, but older versions used this information, so I have functions to compute mesh tangent space. This code is used for UE1/UE2 meshes now. To share normal between wedges I'm analyzing "Points" data - each wedge has an index for vertex position in "Points" array. When 2 or more wedges shared the same "point" I'm smoothing normals between them (they will share normal which is computed from the normals of adjacent triangles), but when wedges uses different "point", even when position is exactly the same, normals will not be shared.

Tangent and binormal are computed with use of the vertex normal and information about UV coordinates of other vertices in neighbor triangles. Algorithm is my own, but I don't think it is something "unique", it is quite simple task.

There is a small difference when I'm using precomputed normals/tangents from Unreal data or when I'm computing them. It is not significant enough to change my algorithm.

I hope I did answered to your question. If no - feel free to ask other questions.
Logged
proteal
Sponsor
Newbie
*
Posts: 3


View Profile
Re: Normals generation questions
« Reply #2 on: July 06, 2012, 22:48 »

Thanks so much for the fast response.  That all makes sense to me.

I don't suppose there's any way to export that internal mesh data?  My intent is to import the models into my own engine, and would prefer the original normals.  If not, I'll just implement the generation as you described.
Logged
Gildor
Administrator
Hero Member
*****
Posts: 7972



View Profile WWW
Re: Normals generation questions
« Reply #3 on: July 06, 2012, 22:53 »

Sorry, umodel can export into psk or md5mesh formats only, both formats has no place for normals.
By the way, "original normals" are also generated by Unreal engine, because most meshes were imported using the same psk format. Only recent UE3 versions has FBX support which could hold normal data as well.
« Last Edit: July 06, 2012, 22:55 by gildor » Logged
proteal
Sponsor
Newbie
*
Posts: 3


View Profile
Re: Normals generation questions
« Reply #4 on: July 06, 2012, 23:03 »

All right.  Thanks again for this incredible tool.  I'm writing a game engine for fun and this is the only way I've found to get some high-quality assets for testing.
Logged
Gildor
Administrator
Hero Member
*****
Posts: 7972



View Profile WWW
Re: Normals generation questions
« Reply #5 on: July 06, 2012, 23:11 »

That's a nice hobby. I had the similar one before started to work on umodel.
Logged
Jump to:  

Powered by SMF | SMF © 2006-2009, Simple Machines LLC
Leviathan design by Bloc | XHTML | CSS