3D model formats

248 views
Skip to first unread message

Denis Taniguchi

unread,
Feb 21, 2022, 9:58:21 AM2/21/22
to vsg-...@googlegroups.com
Hi guys,

I was just wondering what is the best 3D format to support PBR with
textures at the moment (Base color, Metalic, Roughness, and AO). Does
anyone have any sample 3D model working with VSG PbrMaterial?

Cheers,


Denis

Robert Osfield

unread,
Feb 21, 2022, 10:20:21 AM2/21/22
to vsg-users : VulkanSceneGraph Developer Discussion Group
Hi Denis,

I have been using the Khronos glTF example set that has a range of models with PBR:


The Assimp project also has test models found in assimp/tests/models:


The latest VSG also has vsg::Light classes that are using by the asimp shaders used by vsg::Builder and vsgXchange::assimp, but for lighting support vsgXchange support you'll need to use the Lights_Experimental branch.  When using the new lighting support you'll need to place a light source into your scene otherwise the scene will come out all black.  I discuss this all in depth in the vsg-users "Extensible State/Pipeline Configuration with PBR, Lighting & Shadows" thread.

My plan for next 2-4 weeks is to tackle high level shader/state management to help with creation of scene graphs with state that leverages the new lighting etc. support and as this matures update vsgXchange (including the Assimp based loader) to use this new support.  Once that's all matured it'll be merged with VSG and vsgXchange master. As part of this work I'd like to add support for texture projection/projection lights and basic shadow mapping.   Once I dive back into this work I'll write up thoughts/progress here on vsg-users.

I mention off of this as it's all interwoven with PBR rendering.

Cheers,
Robert.

Denis Taniguchi

unread,
Feb 21, 2022, 1:07:00 PM2/21/22
to vsg-users : VulkanSceneGraph Developer Discussion Group

Hi Robert,

Thanks for the tips!

I tried to open the MetalRoughSpheres example in glTF-Sample-Models with vsgExample's vsgviewer but its spheres are without textures. Are there any ENV variable, or specific one I need to use? Should I use the regular, binary, or embedded? Should the texture be in specific folder?

Cheers,

Denis

Robert Osfield

unread,
Feb 21, 2022, 2:01:42 PM2/21/22
to vsg-...@googlegroups.com

On Mon, 21 Feb 2022 at 18:07, 'Denis
I tried to open the MetalRoughSpheres example in glTF-Sample-Models with vsgExample's vsgviewer but its spheres are without textures. Are there any ENV variable, or specific one I need to use? Should I use the regular, binary, or embedded? Should the texture be in specific folder?

I presume you are referring to:

  vsgviewer glTF-Sample-Models/2.0/MetalRoughSpheres/glTF/MetalRoughSpheres.gltf

I don't see any textures either - just a collection of white and yellow spheres. There are other models in glTF-Sample-Models that have textures that appear fine so my first assumption would be that it's either something related to the model or Assimp, as the same vsgXchange::Assimp code path should be able to handle textures.  For instance the following all load with textures:

   vsgviewer glTF-Sample-Models/2.0/FlightHelmet/glTF/FlightHelmet.gltf
   vsgviewer glTF-Sample-Models/2.0/Sponza/glTF/Sponza.gltf
   vsgviewer glTF-Sample-Models/2.0/SpecGlossVsMetalRough/glTF/SpecGlossVsMetalRough.gltf

The last model is a good example of PBR.  It looks best with the new lighting functionality but that will have to wait till you use the Light_Experiment branch of vsgXchange or for me to complete the upcoming work outlined earlier.

As to the cause of the problem with the model without expected textures, it may be worth finding another 3rd party gltf loader that you can use to load the files to see how it renders the problem models. It would also be worth see if other Assimp based renderers have the same problem with models. Once we have a clearer picture of where the problem might lie then we can start to look into what the solution might be - be it reporting the problem model, reporting a problem with Assimp or fix a bug in our vsgxchange::Assimp loader.

Cheers,
Robert.


Denis Taniguchi

unread,
Feb 22, 2022, 5:09:06 AM2/22/22
to vsg-users : VulkanSceneGraph Developer Discussion Group
Hi Robert,

This is what I get running vsgviewer glTF-Sample-Models/2.0/SpecGlossVsMetalRough/glTF/SpecGlossVsMetalRough.gltf:
FlightHelmet.png
Debugging assimp.cpp I can see that it can recognize the texture files. Moreover vertex, normals, etc are also being correctly read. I opened the model in blender, and it correctly displays the helmet, so it is not a corrupted file.
If I was using a game engine my next step would be to see the wireframe rendering (to check if the vertices are actually being drawn), and after that alter the frag shader to just output a colour to see if the fragments are being processes. How easily can I do this in VSG?
Cheers,

Denis

Robert Osfield

unread,
Feb 22, 2022, 6:03:20 AM2/22/22
to vsg-...@googlegroups.com
Hi Denis.

On Tue, 22 Feb 2022 at 10:09, 'Denis Taniguchi' via vsg-users
This is what I get running vsgviewer glTF-Sample-Models/2.0/SpecGlossVsMetalRough/glTF/SpecGlossVsMetalRough.gltf:

K, that screenshot is very wrong.  We'll need to step through what might be wrong.  This is what I see:

SpecGlossVsMetaRought.png
What hardware and Vulkan drivers are you using?

Could you run vsgivewer with the Vulkan debug enabled by running with an additional -d command line parameter i.e:

    vsgviewer -d glTF-Sample-Models/2.0/SpecGlossVsMetalRough/glTF/SpecGlossVsMetalRough.gltf

 
Debugging assimp.cpp I can see that it can recognize the texture files. Moreover vertex, normals, etc are also being correctly read. I opened the model in blender, and it correctly displays the helmet, so it is not a corrupted file.
If I was using a game engine my next step would be to see the wireframe rendering (to check if the vertices are actually being drawn), and after that alter the frag shader to just output a colour to see if the fragments are being processes. How easily can I do this in VSG?

This is where we start detouring off in the weeds a bit with having to learn other areas of the VSG/Vulkan to do this.  It's possible to enable
wireframe and substitute shaders but it's not yet as easy I'd like to be - making Vulkan easier to work with is one of my core goals with the VSG project,
but taming Vulkan beast doesn't always reveal itself on the first iteration through an implementation.  Making things easier to customize w.r.t state/shaders
is something I'll be tackling in next 4-6 weeks when I work on the state composer functionality.

Short term you can look at the vsgstateswitch example for an example of overriding the rasterization mode for wireframe (this particular example has two views, one filled one wireframe.):


An example of swapping the shaders can be found in the vsgclip example:


However, at this point in time I'd recommend having a look at the output of the Vulkan debug layer, so run vsgviewer with the -d command line option and see if any issues are reported to the console. On my system )Ubuntu 21.04 + NVidia 2060 + Nidia drivers) everything runs without any problems,

I would also recommend trying out vsgviewer with the problem model on other systems with different hardward/drivers.

Cheers,
Robert.
 

Denis Taniguchi

unread,
Feb 22, 2022, 6:24:53 AM2/22/22
to vsg-users : VulkanSceneGraph Developer Discussion Group
Hi Robert,

Thanks for always getting back so quickly.
Sorry, the image I sent you before was for the FlightHelmet.gltf file. You can see the googles somewhat present.
For the ScecGlossVsMetalRough.gltf I get this:
test.png
It didn't output anything in the terminal tough.
>What hardware and Vulkan drivers are you using?
I have a NVidia T500 (Thinkpad P14s) using nvidia-driver-470 on a Ubuntu 20.04.
I will have a look at these examples, thanks!
Cheers,

Denis

Denis Taniguchi

unread,
Feb 22, 2022, 6:47:20 AM2/22/22
to vsg-users : VulkanSceneGraph Developer Discussion Group
Just to be sure I have downloaded this project with Vulkan examples (https://github.com/SaschaWillems/Vulkan.git) and they run fine. I have also updated the driver to 510.

Robert Osfield

unread,
Feb 22, 2022, 6:53:13 AM2/22/22
to vsg-...@googlegroups.com
On Tue, 22 Feb 2022 at 11:47, 'Denis Taniguchi' via vsg-users : VulkanSceneGraph Developer Discussion Group <vsg-...@googlegroups.com> wrote:
Just to be sure I have downloaded this project with Vulkan examples (https://github.com/SaschaWillems/Vulkan.git) and they run fine. I have also updated the driver to 510.

Do any of the Sascha Williems examples test out gltf with PBR?

Which version of the VSG, vsgXchange and Assimp are you building against?

I'm using VSG/vsgXhange/vsgExamples master with assimp on branch assimp_5.0_release.

It may be worth me uploading a gltf converted to .vsgb so you can test it to make sure it's not a loader issue.

Denis Taniguchi

unread,
Feb 22, 2022, 7:04:40 AM2/22/22
to vsg-users : VulkanSceneGraph Developer Discussion Group
> Do any of the Sascha Williems examples test out gltf with PBR?
Yes, gltfloading:
Sascha.png
I guess the helmet is the new teapot? :)

> Which version of the VSG, vsgXchange and Assimp are you building against?
VSG: b83998efec73f4418b06deee123cd69172bcfb7b
vsgXchange: b96dc46a738b43f75934e0bdf48efd4ab6e3c7fe
Assimp: 80b0b897edfc8d97a3071033b95dcd6b799e403b (tag: v5.1.4)

> It may be worth me uploading a gltf converted to .vsgb so you can test it to make sure it's not a loader issue.
Yeah, that might help!

Cheers,

Denis

Robert Osfield

unread,
Feb 22, 2022, 7:19:29 AM2/22/22
to vsg-...@googlegroups.com
On Tue, 22 Feb 2022 at 12:04, 'Denis Taniguchi' via vsg-users : VulkanSceneGraph Developer Discussion Group <vsg-...@googlegroups.com> wrote:
I guess the helmet is the new teapot? :)

Indeed :-)

Is Sacha's gltf example using Assimp of another glTF loader?
 
> Which version of the VSG, vsgXchange and Assimp are you building against?
VSG: b83998efec73f4418b06deee123cd69172bcfb7b
vsgXchange: b96dc46a738b43f75934e0bdf48efd4ab6e3c7fe
Assimp: 80b0b897edfc8d97a3071033b95dcd6b799e403b (tag: v5.1.4)

The VSG and vsgXchange versions are pretty up to date, and similar to mine, you are using a more modern version of assimp than I, so perhaps the cause of the difference.  Could you try the  assimp_5.0_release branch.
 
> It may be worth me uploading a gltf converted to .vsgb so you can test it to make sure it's not a loader issue.
Yeah, that might help!

I'm in the middle of refactoring the VSG's memory management so not in good position to create a file, once I've got the code back in a stable place I'll build a .vsgb version of the files and see how you get on, this will be later this afternoon.

Denis Taniguchi

unread,
Feb 22, 2022, 8:31:22 AM2/22/22
to vsg-users : VulkanSceneGraph Developer Discussion Group
> Is Sacha's gltf example using Assimp of another glTF loader?
tinygltf apparently.

> Could you try the  assimp_5.0_release branch.
Tried assimp_5.0_release branch, but same result unfortunately.

> this will be later this afternoon
No problem, thanks!

Cheers,

Denis

Denis Taniguchi

unread,
Feb 22, 2022, 11:39:04 AM2/22/22
to vsg-users : VulkanSceneGraph Developer Discussion Group
Ok, I found out what the issue is:
helmet.png
I decided to just edit vsgXchange/src/assimp/shaders/assimp_pbr_frag.cpp file. I know I need to compile everything to test, but I thought that it was quicker than trying to learn how to switch states.
So when I comment out the alpha mask bit the helmet is displayed correctly:
    if (pbr.alphaMask == 1.0f)
    {
        if (baseColor.a < pbr.alphaMaskCutoff)
            discard;
    }
Now, I need to figure out why that bit has a different behaviour in my machine. If you have any ideas please nudge me. :)
Cheers,

Denis

Robert Osfield

unread,
Feb 22, 2022, 11:55:08 AM2/22/22
to vsg-...@googlegroups.com
Good to hear you've got things rendering properly.  I'm just heading out the door, but can reflect on the finding properly tomorrow.

Denis Taniguchi

unread,
Feb 22, 2022, 12:01:30 PM2/22/22
to vsg-users : VulkanSceneGraph Developer Discussion Group
Outputting just the alpha channel in the fragment shader gives me:
helmet_alpha.png
The Base Colour texture is sRGB (without alpha channel). So I am wondering it is assuming default 0 instead of 1 for alpha.

Denis Taniguchi

unread,
Feb 22, 2022, 12:46:43 PM2/22/22
to vsg-users : VulkanSceneGraph Developer Discussion Group
If I add an alpha channel to every base colour texture I don't see the issue. Not sure why when you do a texture(diffuseMap, texCoord0) on a RGB texture the alpha is returning 0.

Robert Osfield

unread,
Feb 22, 2022, 1:15:49 PM2/22/22
to vsg-...@googlegroups.com
Hi Denis,

On Tue, 22 Feb 2022 at 17:46, 'Denis Taniguchi' via vsg-users : VulkanSceneGraph Developer Discussion Group <vsg-...@googlegroups.com> wrote:
If I add an alpha channel to every base colour texture I don't see the issue. Not sure why when you do a texture(diffuseMap, texCoord0) on a RGB texture the alpha is returning 0.

Kudos on figuring out a key aspect to this bug.  Vulkan requires RGBA textures so if the source image is RGB you have to convert it to RGBA prior to copying to GPU memory.  The VSG does this for you and "should" be mapping RGB to RGB1.0.

As I've been loading the same models and not seeing the same error, I have to wonder if there might be an uninitialized variable somewhere in the mix so that the results diverge at runtime.

As a check to see whether my models work fine on your system could you try the converted bottle.vsgb model (original file was SpecGlossVsMetalRough.gltf):

 
Tomorrow I think it would be worth investigating the RGB -> RGBA code paths for the data that the vsgXchange::Assimp loader is loading.

Denis Taniguchi

unread,
Feb 23, 2022, 5:28:02 AM2/23/22
to vsg-users : VulkanSceneGraph Developer Discussion Group
Hi Robert,
The model you sent me works fine.
Cheers,

Denis
Reply all
Reply to author
Forward
0 new messages