Switching fog on the fly - textures disappear

Hi! I am making a racing game and have different camera views. I would like to have Fog from one view but FogExp2 from another. Indeed I can do the switch but some of the textures disappear when I do that! In particular those are textures that were applied as decals.
Should this in principle be possible to do?
thanks a lot and best regards

Predrag

Can you please explain your motivation behind using two types of fog in an application? TBH, I’ve never seen this done.

:slight_smile: as I mentioned I have several different views while driving and one fog looks better from the cockpit view and the other from “behind” view. Also in the meantime I have managed to preserve the textures but they become transparent!! after I switch fog. Not all of them but some - really strange behavior. The thing is my whole scene is covered by some 320 decals of sand and some of 200 of asphalt in order to avoid texture repetition pattern (those decal textures are affected). You can actually see it here - the game is almost finished (it is played using the cell phone as the steering wheel - using webRTC) can handle more master computers and/or split screen racing. I think it will be a fairly good demonstration what one can do using three.js, matter.js phaser3 and some other tools… (in the first video you can see fog appearing - it is actually a sand dust)


(used recorder does not go over 15-20 FPS - but in reality game is super smooth)

I managed to introduce colored sunglasses effect and some other neat stuff. Three.js is an awesome product (I used VTK a lot)

cheers!

P.

1 Like

Please demonstrate the issue with a live example. In the following fiddle, I’ve changed the fog from THREE.Fog to THREE.FogExp2 after one second. The texture plane is rendered correctly though:

https://jsfiddle.net/qtjp7vny/

BTW: Switching the fog type is expensive since all materials have to be recompiled. Not necessarily something you want to do during a racing game (since you will perceive a frame drop). Also keep in mind that if you configure the fog too dense, it will entirely cover the material and thus no texture will be visible.

Thanks a lot! I really appreciate your help. I will try to reproduce the issue with the minima example. best regards! Predrag