project-navigation
Personal tools

Author Topic: A (Finally!) proper low-poly head without the headache  (Read 39243 times)

Offline Destructavator

  • Combination Multiple Specialty Developer
  • Administrator
  • PHALANX Commander
  • *****
  • Posts: 1908
  • Creater of Scorchcrafter, knows the zarakites...
    • View Profile
Re: A (Finally!) proper low-poly head without the headache
« Reply #45 on: September 04, 2009, 07:27:19 pm »
Now I'll tell you my version of it. Maybe I miss something or don't understand - feel free to correct me. MD2 is just mech, it have no bones, no lightmap, just polygons. As I told you, I test it on 2.2.1 - and found no problems, but the texture is just to bright. In 2.3 I have the same problem as you, but I'm sure that it no more bright than the texture! And that's it! But don't you think that the brightness itself is too high - look at the old body - it's glowing!

Check this out. I play a bit with gamma\brightness\contrast in game - model is fine and the texture is ok (all but alliace - wrong again in FlatTop.md2, last post of 2nd page. How did you make them?). Default brigtness is bad.

I did some research on this issue - If I got all my information right, the problem lies in how the python export script for Blender tells Blender the brightness of the texture, normal graphics used for the texture, such as Jpeg, TGA, whatever - they have a color value range for all colors (red, blue, green) of 0 to 255, total of 256 possible values.

The Quake MD2 format uses a range of 0 to 162, a total of 163 possible values for each color, according to some research on the net.

Somehow the color values aren't being converted or read properly, and as Migel said, the default brightness is bad, getting mucked up by the buggy python export script for Blender.  I looked again at the python script, but, not knowing how to program in python, I can't make heads or tails of the code.  I did find a line with the number "162" in the code, in a spot where I think the code is faulty, but I don't know how to correct it.

I have a feeling the faulty Blender export script isn't converting the color values between the two ranges (0 to 256 and 0 to 162) properly, which shoves the default brightness way too high.  In other words, I think the python script is telling the MD2 to incorrectly read the texture, with too much brightness.

I'm attaching the Jpeg skin texture, as you can see the brightness of the texture in this graphic file doesn't look way too bright, this is how Blender creates the texture file in Jpeg format.  I also loaded this Jpeg texture in GIMP and checked the stats of it, I couldn't find anything wrong or out of the ordinary with it.

Of course I could be wrong on many of these points, anyone is free to correct me, but this is my best guess.

Edit:  Did some more research on the MD2 format, it contains a "LightNormalIndex" property, which I think is messed up because of the faulty python export script.
« Last Edit: September 04, 2009, 08:22:48 pm by Destructavator »

Offline bayo

  • Professional loser
  • Project Coder
  • Captain
  • ***
  • Posts: 733
    • View Profile
Re: A (Finally!) proper low-poly head without the headache
« Reply #46 on: September 04, 2009, 11:09:32 pm »
I read a little about MD2, but the 162 limitation have nothing to do with texture. Anyway it make no sens to only use 0..162 for each color components.

But i also read this model contain normal per vertices. You can have a problem with normal description (Blender, but i dont think) or normal generation (Python script). Maybe it exists some tool to check MD2 normals.

----
Hoo and if you can rotate the texture, to have a more natural orientation of the face, maybe it can be usefull for next artists.
« Last Edit: September 04, 2009, 11:12:01 pm by bayo »

Offline Destructavator

  • Combination Multiple Specialty Developer
  • Administrator
  • PHALANX Commander
  • *****
  • Posts: 1908
  • Creater of Scorchcrafter, knows the zarakites...
    • View Profile
Re: A (Finally!) proper low-poly head without the headache
« Reply #47 on: September 04, 2009, 11:30:56 pm »
I read a little about MD2, but the 162 limitation have nothing to do with texture. Anyway it make no sens to only use 0..162 for each color components.

OK, I misunderstood some of what I researched then.  Thanks for checking that out for me.

Quote
But i also read this model contain normal per vertices. You can have a problem with normal description (Blender, but i dont think) or normal generation (Python script). Maybe it exists some tool to check MD2 normals.

I think its the python export script - It displays fine in Blender, and I heard other people have had similar problems with the normal generation with various versions of that script, from what I researched, in some cases resulting in the same problem with the amount of lighting and brightness.

Lots of MD2 tools are out there, I'll see if I can find one that can fix or at least analyze this.

Quote
Hoo and if you can rotate the texture, to have a more natural orientation of the face, maybe it can be usefull for next artists.

Won't be necessary - Once we get past these issues and a test MD2 imports into the game OK, I'll upload full source files for all the textures, texture groups, and components used to build the face and all its parts.  Then anyone who uses Blender can easily re-construct their own version of the face texture, much easier than taking that rendered texture and trying to draw on it.  It would all go into the data source, although we're not quite there yet because these issues with the lighting/normals still need to be worked out.

@Migel:  If you happen to be reading this, could you please upload (attach in a post) a fixed, working version of the model and texture that displays properly in the game?  I'd like to compare it side by side with my version that comes out of Blender, to try and get a few more clues on how to solve these issues.

Offline bayo

  • Professional loser
  • Project Coder
  • Captain
  • ***
  • Posts: 733
    • View Profile
Re: A (Finally!) proper low-poly head without the headache
« Reply #48 on: September 04, 2009, 11:48:31 pm »
Can you check https://svn.blender.org/svnroot/bf-blender/trunk/blender/release/scripts/md2_export.py ?
If it dont work, i need to have your last Blender file, and a little help to know how to export the head myself.
« Last Edit: September 04, 2009, 11:52:43 pm by bayo »

Offline Destructavator

  • Combination Multiple Specialty Developer
  • Administrator
  • PHALANX Commander
  • *****
  • Posts: 1908
  • Creater of Scorchcrafter, knows the zarakites...
    • View Profile
Re: A (Finally!) proper low-poly head without the headache
« Reply #49 on: September 05, 2009, 12:37:31 am »
Nope, I tried this latest script and it still shows way too much brightness.

Before digging deeper into what the python script is doing, perhaps I'm not testing it in the game properly - I only modified one .ufo file, the "team_humans.ufo" file, so it reads like this:

Code: [Select]
models {
female {
soldiers/female body head01a 0
soldiers/female body head01b 0
soldiers/female body head01c 0
soldiers/female body head03a 0
soldiers/female body head03b 0
}

male {
soldiers/male body head01a 0
soldiers/male body head01b 0
soldiers/male body head02a 0
soldiers/male body head02b 0
soldiers/male body head03a 0
soldiers/male body head03b 0
soldiers/male body FlatTop 0
}
}

Am I doing this right?  (The md2 is called "FlatTop.md2".)

Offline Mattn

  • Administrator
  • PHALANX Commander
  • *****
  • Posts: 4831
  • https://github.com/mgerhardy/vengi
    • View Profile
    • Vengi Voxel Tools
Re: A (Finally!) proper low-poly head without the headache
« Reply #50 on: September 05, 2009, 07:23:11 am »
yes - that is right:

"body head skinnum"

but for the final version please make sure that they match the naming scheme ;)

Offline bayo

  • Professional loser
  • Project Coder
  • Captain
  • ***
  • Posts: 733
    • View Profile
Re: A (Finally!) proper low-poly head without the headache
« Reply #51 on: September 05, 2009, 02:29:41 pm »
I test md2 normals with a hacked tool.

Your export (i use your md2 from http://ufoai.ninex.info/forum/index.php?topic=3996.msg30262#msg30262)
(image with black hair) look better than the default blender md2 export (i use http://ufoai.ninex.info/forum/index.php?topic=4040.msg30475#msg30475 with the default Blender export).

Anyway i dont think this normal "error" create the brightness.
Mattn, can it be a problem with shaders? And can we export the same model into md3 to test ingame?
« Last Edit: September 05, 2009, 02:31:58 pm by bayo »

Offline Destructavator

  • Combination Multiple Specialty Developer
  • Administrator
  • PHALANX Commander
  • *****
  • Posts: 1908
  • Creater of Scorchcrafter, knows the zarakites...
    • View Profile
Re: A (Finally!) proper low-poly head without the headache
« Reply #52 on: September 05, 2009, 02:54:12 pm »
Quote
Mattn, can it be a problem with shaders? And can we export the same model into md3 to test ingame?

I've wondered myself if UFO:AI isn't displaying the models right, because I've loaded my exported MD2s into other graphic engines and they display properly.

I've also tried loading the existing models into various editors, they also display OK, and I can't seem to find differences between them and my own MD2s.


Offline Migel

  • Rookie
  • ***
  • Posts: 95
    • View Profile
Re: A (Finally!) proper low-poly head without the headache
« Reply #53 on: September 05, 2009, 03:10:06 pm »
Destructavator, listen, you realy get me wrong. I can swear there is no problem with the model, ONLY PROBLEM IS THE SKIN!!!
And the brightness in game of course. To show you that I draw quick skin - check it (it not pretending on anything but to test). Test it with your model. Even with that awful brightness it shows normally. MD2 have no lightmap.
« Last Edit: September 05, 2009, 03:11:52 pm by Migel »

Offline Migel

  • Rookie
  • ***
  • Posts: 95
    • View Profile
Re: A (Finally!) proper low-poly head without the headache
« Reply #54 on: September 05, 2009, 03:50:06 pm »
By the way, about brightness - try to drop brightness to 0 and look at the models - some affected more, than the other, and some are not affected at all. Same for contrast. Are they useing different shaders?

Offline bayo

  • Professional loser
  • Project Coder
  • Captain
  • ***
  • Posts: 733
    • View Profile
Re: A (Finally!) proper low-poly head without the headache
« Reply #55 on: September 05, 2009, 04:29:31 pm »
yeaa, looking another head skin, the brightness look like the Migel skin.

Offline Destructavator

  • Combination Multiple Specialty Developer
  • Administrator
  • PHALANX Commander
  • *****
  • Posts: 1908
  • Creater of Scorchcrafter, knows the zarakites...
    • View Profile
Re: A (Finally!) proper low-poly head without the headache
« Reply #56 on: September 05, 2009, 05:00:38 pm »
Migel, I've got to hand it to you - I think you're closer to the right answer than the rest of us.

I cranked down the brightness in Blender before export, this latest shot is how it came out.

The only issue I have now is that inside Blender the model looks very dark of course.

I guess we could add it to the wiki, that if anyone creates a model in Blender and wants to export it for UFO:AI, that they should turn the brightness way down before export.

Edit:  This was done by turning the light reflection level for the textures, inside Blender, from 1.0 down to 0.6 in the materials.

Offline Kildor

  • Project Artist
  • Captain
  • ***
  • Posts: 757
  • Project mapper and some other stuff`er
    • View Profile
    • http://ufoai.nx0.ru
Re: A (Finally!) proper low-poly head without the headache
« Reply #57 on: September 05, 2009, 05:02:45 pm »
But now model (head and body) is very bright too. Or do I missed something?

Offline Destructavator

  • Combination Multiple Specialty Developer
  • Administrator
  • PHALANX Commander
  • *****
  • Posts: 1908
  • Creater of Scorchcrafter, knows the zarakites...
    • View Profile
Re: A (Finally!) proper low-poly head without the headache
« Reply #58 on: September 05, 2009, 05:12:12 pm »
But now model (head and body) is very bright too. Or do I missed something?

These are with the default game video settings.

There's actually another thread about the default (global) brightness being too intense.

Offline Migel

  • Rookie
  • ***
  • Posts: 95
    • View Profile
Re: A (Finally!) proper low-poly head without the headache
« Reply #59 on: September 05, 2009, 05:24:03 pm »
Quote
I guess we could add it to the wiki, that if anyone creates a model in Blender and wants to export it for UFO:AI, that they should turn the brightness way down before export.
I think there is no need for that. When the global brightness will be set to normal problem will be solved by itself. As for now I suggest you test your model on both 2.3 and 2.2.1 versions. 2.2.1 is old, but it's stable, and show skins right.