In my project I wrote a custom material which is based on PBRCustomMaterial. I pass some data via uniforms into it.
For two days I was trying to catch a following bug in my code:
If a mesh which uses this material is scaled, suddenly uniforms stop working.
But if the mesh was scaled previously and then material applied, it looks normal until it is scaled to default (1,1,1).
I was thinking that it was mistake somewhere in my code or I’m using these functions in an unintended way.
I prepared a small example which reproduces https://www.babylonjs-playground.com/#I8SFV3#2
Bug appears in playground when mesh is scaled in the debugging window.
Also in a small sinusoidal loop mesh is painted in black when scale is 1.
i don’t get the bug ?
The idea or reproduction? In playground every 360 frames sphere blinks to black. Maybe it would be better to change denominator to 36. Then every 10 frames.
I’m sorry. But in version #3 the scale never hits the value of 1. Do I understand correctly that for my project I should somehow write a workaround to ensure that scale never lands on a value of 1?
that is not depend to scale 1 as i know
Hello again. But on what does this bug depend on then? Because in all examples value of 1 is avoided in slightly different ways.
ok let me look deeper
just for ask is it necessary you scale object to -1?
I think no. Let me check in my project.
Well, I think I can work without negative scaling.
haha catch it
Thank you. But the problem is not in the Math class. I just use it to demonstrate the bug. In my project scaling is performed by inputs in textboxes.
if initial scale=1 i can’t scale
if initial scale!=1 i can scale to all values except 1.
The source of problem should be PBRCustomMaterial or the ways I handle uniforms.
Can this depend on Matrix manipulations in WorldMatrix?
if you can share in here or private some part that can help otherwise you most try make it in PG
So here I added keyboard handles. If line 47 is commented, we have case 1. If uncommented case 2. Btw using cache_txt alters the colors, but problem is still in place.
mybe that depend to “NONUNIFORMSCALING”
i dont know what is this ?
Looks like it is an answer. If ignorenonuniformscaling=true, then on first observation it works. I will try to use this in project. Will mark it as solution if I succeed. Thanks!