B4J Tutorial WebGL library, working with fog.

Hi all,

today I will show how the WebGL library can use the fog in your scene and can be fine tuned by code or by GUI.
This will simulate a real realistic fog. Allowed fog and exponential fog.
This can even used to simulate unrealisting colored fog and even to simulate dark.

Here a Youtube video that show it. Make sure to set the player to 1080p.



Here you can get some other demos that use fog on the threejs official site.
https://threejs.org/examples/?q=fog#webgl_geometry_terrain
https://threejs.org/examples/?q=fog#webgpu_custom_fog
https://threejs.org/examples/?q=fog#webgpu_custom_fog_background

Stay tuned.
 
Last edited:

max123

Well-Known Member
Licensed User
Longtime User
Thanks @aeric and other peoples that liked it. ;)

This is the same project published here, anyone can do the test itself as I do in the video, and most important can edit the main code to suit needs:
https://www.b4x.com/android/forum/threads/develop-full-3d-games-with-webgl-library.167783/#content

Just I omitted this on the video of last post, but I retained that fog is an important part I have to show because it permits to create ambient scenes, not only add fog, it even permits to do a dark scene, eg. in the night.

Today I will release the first playable game, the first really playable 3D game I developed in my life, a Billiard 8 Balls. ;) 🎱🎱🎱🎱

The game is not all my own work, I started from an existing project and extended it by adding all the ToDos of the original project, including positional audio and environment. I have some issues to set up, when more audio play together, the oudio output is distorced (clipping), but I will work on it, generally it works and is playable. As all WebGL library demo scenes in the tutorials, it even works online (but not multiplayer). I started at my home and my friend @roncoa played it on Android Pixel 8a and even on PC remotely over the web. It can be extended to play multiclient online using SocketIO. It is something I will add un future.

I never imagined to develop a 3D library that I even can use for most use cases and even to develop games. I ensure this is absolutely amazing, expecially after I've managed to have the same library full code compatible with B4A and almost all tutorials, even this one on this video, will work on Android in a native app inside a WebView just to copy/paste the code from B4J to B4A IDE. Sometime depending of things one have to do may need to adapt mouse vs touch, but on Android Javascript permits even to read any sensor, like accelerometer, gyroscope etc... And there is even the possibility to use up 4 gamepads, over USB or BT, same than desktop side.

I remember the time I've spent in past on my Commodore C=64, Atari-130XE, Sinclair Spectum ZX and Amiga 512 at 10-15 year old to develop in basic and assembler some sort of unrecognized 2D games pacman styles. This evolved now.... this is a big step I think 🤣🤣🤣

I don't know if iOS WebView support WebGL, but I think yes. I do not developed the library for B4i because I don't use it and I don't have any iOS real device.
JavaFX do not support WebGL at all, and this is a serious shortcoming, but they will have to add to keep up with the others, all the browsers now support WebGL and WebGPU natively.

Stay tuned!
 
Last edited:
Top