Inverted glow layer for GLTF imported mesh after baking transformations to vertices

I’m trying to bake right-handled to left-handed conversion from GLTF loader.

https://www.babylonjs-playground.com/#LRFB2D#90

Before baking

After baking

Disabling backfaceCulling helps, but seems like wrong way.
Changing sideOrientation to CW has no effect. (Should I do this?)

It is possible that I do not understand how to convert right-hand to left-hand correctly and forgot something?

I think that converting out of box via one method or flag could be more convenient than now(I found this thread).

Use right hand mode for all scene is not my case, and I really want to drop __root__ node and any transformations, because I have many instances of imported mesh.

Also, I suppose, that .babylon format can help me, but sounds like future is in gltf. (Maybe I’m not right?..)

Sorry for the bad English.

1 Like

The baking does work if you set scene.useRightHandedSystem = true:

https://www.babylonjs-playground.com/#LRFB2D#91

1 Like

Can I convert without changing scene to right handed?
Why glow effect add this weird effect? It’s not a bug?

Frankly I don’t know, I searched a bit and found that setting useRightHandedSystem = true did the trick…

unfortunately this solution is not suitable for me =(

pinging @sebavan

Currently having a look too.

I found it, the side orientation is not taking into account the determinant in the effect layer, I ll push the fix shortly.

1 Like

Ah, beaten for 3mn!

Note it’s not only the determinant (in the use case it is > 0 so has no effect, it’s mesh.overrideMaterialSideOrientation that matters). I have done something like:

let mainDeterminant = renderingMesh._getWorldMatrixDeterminant();
let sideOrientation = renderingMesh.overrideMaterialSideOrientation;
if (sideOrientation == null) {
    sideOrientation = material.sideOrientation;
}
if (mainDeterminant < 0) {
    sideOrientation = (sideOrientation === Material.ClockWiseSideOrientation ? Material.CounterClockWiseSideOrientation : Material.ClockWiseSideOrientation);
}

engine.setState(material.backFaceCulling, material.zOffset, false, sideOrientation === Material.ClockWiseSideOrientation);

in EffectLayer._renderSubMesh.

3 Likes

Yup it is what I have :slight_smile: and testing at the moment

PR is in this will be in the next nightly

3 Likes

@sebavan @Evgeni_Popov Thanks a lot!

Please, tell me, .setParent(null) and .bakeTransformationsToVertices() is right way to drop __root__ parenting and clear transformations, or I need to do something else(sideOreintation, mb?..) ?

May you add to mesh loader functionality, that automatically covert right hand to left during importing from gltf and don’t create additional nodes?

I think what you did is ok, no need for anything else.

I think that would require more work, as animations, for eg, may have to be corrected too.

1 Like

I have a question that is off-topic to the OP, but somewhat relevant to the answers:

How do you learn to program in 3D like this? I work as a full-stack engineer building interfaces and APIs/general backend infrastructure, and my education is in computer science (weak on linear algebra and calculus, unfortunately).

I’m specifically asking for texts and other resources. It’s not an abstract question: I want to be where @Evgeni_Popov and @gleb-cher and @sebavan and @Deltakosh are at. I am fascinated that you took the screenshots / playground provided by OP and quickly converted that into a bugfix.

Easy answer: we spent a lot of time using it and playing with the code:)

3 Likes

3D programming was what I was interested in far long ago when I was doing demos. Then I had to earn money, so I worked as a regular software programmer (no more 3D), but since august of last year, after I quit my job some months before, I found Babylonjs, fell in love with it and now working with the team :slight_smile:

4 Likes

Base:

BJS:

1 Like