TheGreyGhost / MinecraftByExample

Working sample code for the basic concepts in Minecraft and Forge.
Other
1.24k stars 187 forks source link

[mbe15_item_dynamic_item_model] Generated BakeQuads don`t have correct normal int in vertexInt[] #33

Closed rikka0w0 closed 6 years ago

rikka0w0 commented 6 years ago

If you look carefully, you will find that the diamond block on the chess board is actually darker than what it is supposed to be. I use some of the code in that example, for block rendering is completely fine, but when it comes to item rendering, the model looks too dark. After read though the source code of Minecraft and Forge, I realize that the seventh int returned by vertexToInts() should not always be zero. That int represents an normal vector, but in packed form: ?? ZZ YY XX, it is used by OpenGL to calculate lighting. See calculatePackedNormal() in my code for some idea about how to calc that int value:

You just need to pass coordinate of all four vertexes to the function, be careful, don`t change the order of vertexes, otherwise the result is unpredictable!

TheGreyGhost commented 6 years ago

Hi Keen, thanks for that, I will look into it. I'm currently updating to 1.12 which is taking a long time, I will be sure to add your changes. Cheers, TGG

TheGreyGhost commented 6 years ago

Fixed it in 1.12.2, you were right! Thanks for letting me know! TGG