Hi
I have a little trouble with transparency.
What i have:
I have 2 inverted spheres (negative scale) for 360 images. Primary has -1000 scale, Secondary has -500 scale.
Then i have 13 materials for them (has “view” in their name and low quality emissive texture)
And then i have those camera settings (look at ClearColor)
What i need to do:
I need to animate from old material to new.
What i did:
I use 2 spheres to animate from old material to new.
On start i disable Secondary sphere (s2), and enable Primary(s1).
When i need to animate i have 2 materials: old and new. I enable s2 and change it’s material to oldMaterial. Then i assign newMaterial to s1. (We can’t see s1, 'cose s2 is opaque, so nothing is changed for viewer yet). Then we set animation flag.
Every tick we execute this code:
if(ViewSwitcher.animating){
ViewSwitcher.animationTime+=Math.min(dt,0.06);
if (ViewSwitcher.animationTime > this.animDuration) {
ViewSwitcher.animating=false;
ViewSwitcher.animationTime=0;
ViewSwitcher.animSphereEntity.model.meshInstances[0].material.opacity=1;
ViewSwitcher.animSphereEntity.model.meshInstances[0].material.update();
ViewSwitcher.animSphereEntity.enabled=false;
return;
}
var percent = ViewSwitcher.animationTime / this.animDuration;
var opacityValue = this.opacityCurve.value(percent);
ViewSwitcher.animSphereEntity.model.meshInstances[0].material.opacity=opacityValue;
ViewSwitcher.animSphereEntity.model.meshInstances[0].material.update();
}
We animating s2’s opacity and after it’s reached 0 we disable s2, as we can’t see it. In the end we see just s1 with newMaterial.
What i got:
Do you remember this bad boy?
When i execute that code i have consistent result:
when moving from material1 to material2 - everything is fine, smooth transition. BUT when i move from material2 to material1 i see that PINK color instead of material1! (it can be any materials, but tendency is clear, there is some consistent transparency order)
You can try it yourself (https://playcanv.as/p/4pIoNgIe/)
When loaded press or look at this:
everything is smooth, yeah?
Then turn around and press or look at this:
PINK all the way!
I changed every possible material property.
Code is exactly same. So, what should i do?
EDIT: i forgot to link material settings: