Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

AppGameKit Studio Chat / No colors when importing blender exported FBX file

Author
Message
spenland
4
Years of Service
User Offline
Joined: 14th Nov 2019
Location:
Posted: 20th Nov 2019 18:27
I have a tree with materials - green and brown; no textures. When I export it to FBX it shows the colors in Windows 10's 3d viewer but when I use LoadObject("filename.fbx") and place the object in my game, the entire object is just gray.

Am I exporting incorrectly or not doing something in AppGameKit?
fubarpk
Retired Moderator
19
Years of Service
User Offline
Joined: 11th Jan 2005
Playing: AGK is my friend
Posted: 20th Nov 2019 20:36 Edited at: 20th Nov 2019 20:39
The windows 10's 3D viewer is most probably including the material colouring which can be included in fbx file
but doesn't work on all viewers to get it to work in AppGameKit the material associated with the fbx wont work like that
and needs to use a texture mapped version with a separate image

If you have it as an obj file with the associated mtl file Blink0k created a kenney converter which if you look on the
forums you will find that can convert coloured objects into a texture https://forum.thegamecreators.com/thread/223393
fubarpk
fubarpk on Itch...………...https://fubarpk.itch.io/
fubarpk on googleplay..https://play.google.com/store/apps/developer?id=fubarpk
Raven
19
Years of Service
User Offline
Joined: 23rd Mar 2005
Location: Hertfordshire, England
Posted: 21st Nov 2019 13:32
The Default Shader doesn't support Vertex Colours., you'll need to use a Custom Shader.
It makes sense this has been deprecated as it's uncommon to use any Vertex Data beyond Position, as the Fragment (Pixel) Pipeline is typically faster than the Vertex Pipeline.
Bengismo
6
Years of Service
User Offline
Joined: 20th Nov 2017
Location: Yorkshire, England
Posted: 21st Nov 2019 15:32 Edited at: 21st Nov 2019 15:43
Quote: "The Default Shader doesn't support Vertex Colours., you'll need to use a Custom Shader.
It makes sense this has been deprecated as it's uncommon to use any Vertex Data beyond Position, as the Fragment (Pixel) Pipeline is typically faster than the Vertex Pipeline."


lol....

The default vertex shader DOES support vertex colours. Spenland has already shown us pictures of his landscapes that are using per vertex colours and plenty of people (including me) have used per vertex colours too without needing any custom shader.

The issue is that the model materials are not loaded when AppGameKit loads an object. The fbxMaterial properties in the FBX file just are not used at all by AGK. The object colours all start at grey/white and are never set different no matter what function is used to load the object. So you have to manually set the colours (Ie SetObjectColor()).

Even worse than that, AppGameKit can and will combine multiple meshes into one single mesh on loading if it thinks the same texture is being used on both meshes, meaning that your leaves AND your tree might just be one single mesh in a single object meaning you cant set the colours individually. In the modeller you then need to enforce separate meshes/objects by assigning a different texture for each even if you dont plan to use a texture at all on the final object and use LoadObjectWithChildren so you get an object for each separately coloured item.

We covered multiple textures in blender with FBX which was pretty much the same issue.
https://forum.thegamecreators.com/thread/221784

There are other ways to get round this behavior too. (like .obj files from Magicapixel using a single pixel for each different colour used in the object meshes)
Raven
19
Years of Service
User Offline
Joined: 23rd Mar 2005
Location: Hertfordshire, England
Posted: 21st Nov 2019 18:10
Well here's a test Object and App., while it won't "Automatically" Load Assigned Imaged (although this might just be me not setting up the references properly) … it seems to work relatively "Fine"
But there is some weird behaviour when you start to use UV Scaling via AppGameKit rather than Shaders.

Attachments

Login to view attachments
Bengismo
6
Years of Service
User Offline
Joined: 20th Nov 2017
Location: Yorkshire, England
Posted: 21st Nov 2019 18:46 Edited at: 21st Nov 2019 18:50
This afternoon you said
Raven wrote: "The Default Shader doesn't support Vertex Colours., you'll need to use a Custom Shader."


Theres no custom shader in your example and vertex colours work fine and are displayed. Just like i said. Thanks for confirming that.

What still doesnt work is that no material colours are applied.

See the attached FBX. If loaded into AppGameKit it will just appear as 2 white boxes ...but if loaded into a decent 3d modeller app then one box is red and the other is blue. Try it in the windows 10 3d viewer app or anything else that can load FBX. One is red and one is blue.

As the op stated above, he isnt using textures at all and he is most likely just setting the material colour of his meshes to a value. This does not apply per vertex colours...it merely stores a fbxMaterial in the file and applys it to mesh but AppGameKit takes no notice of that material. If his model had per vertex colours there wouldnt be a problem.

He (spenland) could fix his problem with per vertex colours if he wanted to....or apply a single colour texture so each mesh or various other methods...

As I stated above...the problem is setting a material colour has no effect...you have to use per vertex colours or set the values manually.


Ohh...And AppGameKit never automatically loads textures for you...you have to use GetObjectNumtextures()( and GetObjectTextureName() then load them yourself if you want to semi automate the textures applied to models.

Attachments

Login to view attachments
Raven
19
Years of Service
User Offline
Joined: 23rd Mar 2005
Location: Hertfordshire, England
Posted: 21st Nov 2019 20:12
He really shouldn't be using the Material Colour property... a reason why AppGameKit is likely not reading such, is because without an assigned texture the assumption is that it's a "Blank" Material.
Materials Colours are generally speaking "Place Holders" or "Colour Coding" for Development Purposes; it's a left over feature (and in FBX for Compatibility Purposes) prior to the advent of Group, Layer and Association Colours.
Like you'd use it to indicate Static Vs. Dynamic, IK Vs. HK, Mesh LOD, Interactive Vs. Non-Interactive... like you're not supposed to be using Material Colours.

As noted it's only there for Legacy Purposes.
The reason it works in FBX Viewer (Autodesk) and 3D Viewer (Microsoft)… is because they're designed to display the entire scene.

AGK also don't import Cameras, Lights, Helpers, Locators, etc. would you expect it to?
His choice is either using Vertex Colours … or a Texture / Shader Material.
That FBX doesn't automatically import Textures., that to me seems like lazy implementation.
Bengismo
6
Years of Service
User Offline
Joined: 20th Nov 2017
Location: Yorkshire, England
Posted: 21st Nov 2019 20:38
Even without a texture...every single object has a colour. Its easy to set it in AGK. Every other game engine ive used import the material colour and assign it to an object on loading (that includes the big 3 game dev platforms). Thats regardless of a texture assigned or not. In agk it will never be set from the values in the file.

Modellers too, Autodesk, cinema 4d, 3d studio max...even milkshape and blender all support material colours...its just agk that leaves the stock white colour even if its set in the model file. Typically, diffuse, emmisive and specular are stored dependant on format.

The fact that all object modellers and other engines support it is a clue to it being very standard and its still used.

The texture loading is not file fomat dependant. Agk will literally never load textures for you regardless of the format storing texture names or not. We have to manually do it which is a bit of a lazy implementation, like you said, but as is the lack of material colour assignment on loading. At least an option to assign it would be nice.

spenland
4
Years of Service
User Offline
Joined: 14th Nov 2019
Location:
Posted: 22nd Nov 2019 19:23
Thanks everyone. Some of that was over my head. I ended up just baking the materials into a uv texture which I set to the object's image. Works great.

Good to know that there is a LoadObjectWithChildren command, though.
Rick Nasher
6
Years of Service
User Offline
Joined: 25th Jul 2017
Location: Amsterdam
Posted: 4th Dec 2019 23:00
Still, I think most people agree it's a bit silly that we have to be doing this texture loading and assigning by hand, while should/could be an integrated, fully automated function, which would save people lot's of time and hassle..
If desired an override switch could be added to prevent auto-texturizing for those times needed.

I feel this would make lot's of people happy( including myself ghegheghe ).

Login to post a reply

Server time is: 2024-04-14 06:30:10
Your offset time is: 2024-04-14 06:30:10