Cool VL Viewer forum
http://sldev.free.fr/forum/

PBR base color texture substitution
http://sldev.free.fr/forum/viewtopic.php?f=9&t=2436
Page 1 of 1

Author:  stuffstuffstuff [ 2023-12-12 21:27:57 ]
Post subject:  PBR base color texture substitution

As you know, if an object with a PBR material doesn't have a diffuse texture underneath the PBR material, it will look like a piece of wood if the forward renderer is used.

Given this, how feasible would it be to implement the following?:

1) Detect when the face of an object has a PBR material

2) Detect when that given face is using the default wood texture

3) If 1 and 2 are true, replace the wood texture with the base color texture from the PBR material.

Of course some creators will go out of their way to place textures telling people "update your viewer to PBR" or something like that, but my proposal would at least make the objects that were never textured to begin with look better.

Author:  Henri Beauchamp [ 2023-12-12 22:10:04 ]
Post subject:  Re: PBR base color texture substitution

I already thought about baking a diffuse texture for faces bearing a PBR material and lacking one such texture... This should be doable.

Sadly, I do not have the know-how (I know close to nothing or at least too little to OpenGL and shader language): I'm mainly a system programmer (operating systems, system software & utilities, system services), not a game engine or 3D graphics application programmer.

But if someone can provide me with OpenGL code and a shader that would combine PBR textures into baked diffuse, I could do the rest of the integration into the viewer code...

Author:  stuffstuffstuff [ 2023-12-12 22:37:35 ]
Post subject:  Re: PBR base color texture substitution

Henri Beauchamp wrote:
I already thought about baking a diffuse texture for faces bearing a PBR material and lacking one such texture... This should be doable.

Sadly, I do not have the know-how (I know close to nothing or at least too little to OpenGL and shader language): I'm mainly a system programmer (operating systems, system software & utilities, system services), not a game engine or 3D graphics application programmer.

But if someone can provide me with OpenGL code and a shader that would combine PBR textures into baked diffuse, I could do the rest of the integration into the viewer code...


No worries, I understand! Maybe I will figure out how to do it myself one of these days.

Author:  Henri Beauchamp [ 2023-12-23 10:30:28 ]
Post subject:  Re: PBR base color texture substitution

I finally made an attempt at a very naive hack, consisting in simply switching the renderer to the base color texture for faces with PBR material and without a proper fallback substitution diffuse texture (i.e. with a default plywood or default blank texture set as the diffuse map).
EDIT: I also added a mode in which the diffuse (even non-default) texture is force-replaced with the base color texture for faces with a GLTF material, and I perfected the hack so that the base color texture color and transforms are used when it replaces the diffuse texture.

The result is not that bad (even though still very far from what a proper diffuse texture baking would allow to achieve). Here is what it gives in Runitai's villa (Rumpus Room 2 sim) on Aditi where many/most PBR objects do lack a diffuse fallback texture (click the pictures for the full size screenshots):

PBR rendering mode:
Attachment:
small-PBR.jpg
small-PBR.jpg [ 82.94 KiB | Viewed 24990 times ]


ALM without the hack:
Attachment:
smallsize-ALM-no-diffuse.jpg
smallsize-ALM-no-diffuse.jpg [ 58.2 KiB | Viewed 24758 times ]


ALM with base color replacing default diffuse:
Attachment:
smallsize-ALM-base-color.jpg
smallsize-ALM-base-color.jpg [ 65.86 KiB | Viewed 24758 times ]


Forward with base color replacing default diffuse:
Attachment:
smallsize-forward-base-color.jpg
smallsize-forward-base-color.jpg [ 62.93 KiB | Viewed 24758 times ]


ALM with base color always replacing diffuse:
Attachment:
smallsize-ALM-base-color-forced.jpg
smallsize-ALM-base-color-forced.jpg [ 80.85 KiB | Viewed 24758 times ]


Forward with base color always replacing diffuse:
Attachment:
smallsize-forward-base-color-forced.jpg
smallsize-forward-base-color-forced.jpg [ 77.77 KiB | Viewed 24758 times ]



Note that the current quick and dirty hack lacks proper texture color, offsets and scale support (i.e. the color, offsets and scale from the default diffuse texture are applied instead of the one used by the base color map), but as long as a white color is used and the offsets and scale are the same, it kind of "works"... (EDIT: fixed in the new version)

Note how the GLTF materials of the room walls and ceiling do have a fallback diffuse texture, but use a different color for their PBR material (which, incidentally, and due to a bug of mine in the current viewer version, is wrongly used instead of the diffuse texture color in non-PBR rendering modes: I fixed this bug while implementing the hack).
Note also that forcing the use of the GLTF materials base color map (and its transforms and color) in non-PBR rending mode sometimes lead to bad result: the small round table vanishes (becomes invisible) in this forced mode (that's because it does not use any texture in its GLTF material)... (EDIT: "fixed" in the latest version of my hack, where I simply do not touch the diffuse texture when no base color map exists in the PBR material: not ideal, but better than a vanishing object).

Author:  Henri Beauchamp [ 2023-12-30 10:38:12 ]
Post subject:  Re: PBR base color texture substitution

Hack implemented in today's release (v1.32.0.4). See the new toggles in the "Advanced" -> "Rendering" -> "Deferred rendering" menu.

Author:  Henri Beauchamp [ 2024-01-06 09:52:14 ]
Post subject:  Re: PBR base color texture substitution

In today's release (v1.32.0.5) I further refined this hack as follow:

  • When forcing the use of base color instead of diffuse texture, the hack won't apply any more to faces bearing a legacy material (i.e. not just a diffuse texture), which were obviously properly setup by the creator and thus won't need the hack...
  • A fourth mode has been added to force the use of the GLTF base color parameters (i.e. basically the color and transparency) even when the base color texture does not exist (in this case, the diffuse texture is replaced with a blank texture); this may cause some GLTF-enabled objects to stop rendering (*).

Here is what the new toggles now look like ("Advanced" -> "Rendering" -> "Deferred rendering" menu):
Attachment:
AdvancedRenderingMenu.png
AdvancedRenderingMenu.png [ 22.61 KiB | Viewed 22003 times ]

With:
  • Always use diffuse texture: to see what other non-PBR viewers will see.
  • Use base color for missing diffuse: to replace "default" (plywood and blank) diffuse textures with the PBR base color texture and parameters when they exist.
  • Always use base color with texture: to always replace the diffuse texture of a face without a legacy material with the base color texture and parameters, on the condition there is one such base color texture in the PBR material.
  • Always use base color: to always replace the diffuse texture of a face without a legacy material with the base color texture (a blank texture when there is no texture map for the base color) and parameters (some PBR-enabled objects might (*) disappear then).


(*) I only saw this happening in Aditi, with early (test) PBR objects, so it could just be the consequence of changed GLTF data during LL's PBR viewer & GLTF server development. Feel free to share your observations in this mode, since I'm still trying to figure out why the Hell these objects vanish...

Page 1 of 1 All times are UTC
Powered by phpBB® Forum Software © phpBB Group
https://www.phpbb.com/