MV3D - 3D rendering for RMMV with Babylon.js

mv3d.createFog = function () {

var fountain = BABYLON.Mesh.CreateBox("foutain", .01, mv3d.scene);
fountain.visibility = 0;
fountain.x = $gamePlayer.x;
fountain.y = $gamePlayer.y;
fountain.z = $gamePlayer.z;





particleSystem = new BABYLON.GPUParticleSystem("particles", { capacity: 50000 }, mv3d.scene);
particleSystem.manualEmitCount = particleSystem.activeParticleCount;
particleSystem.minEmitBox = new BABYLON.Vector3(-50, 0, -50); // Starting all from
particleSystem.maxEmitBox = new BABYLON.Vector3(50, 1, 50); // To..


particleSystem.particleTexture = new BABYLON.Texture("/img/MV3D/Fog.png", mv3d.scene);
particleSystem.emitter = fountain;

particleSystem.color1 = new BABYLON.Color4(0.8, 0.8, 0.8, 0.1);
particleSystem.color2 = new BABYLON.Color4(.95, .95, .95, 0.15);
particleSystem.colorDead = new BABYLON.Color4(0.9, 0.9, 0.9, 0.1);
particleSystem.minSize = 3.5;
particleSystem.maxSize = 5.0;
particleSystem.minLifeTime = Number.MAX_SAFE_INTEGER;
particleSystem.emitRate = 50000;
particleSystem.blendMode = BABYLON.ParticleSystem.BLENDMODE_STANDARD;
particleSystem.gravity = new BABYLON.Vector3(0, 0, 0);
particleSystem.direction1 = new BABYLON.Vector3(0, 0, 0);
particleSystem.direction2 = new BABYLON.Vector3(0, 0, 0);
particleSystem.minAngularSpeed = -2;
particleSystem.maxAngularSpeed = 2;
particleSystem.minEmitPower = .5;
particleSystem.maxEmitPower = 1;
particleSystem.updateSpeed = 0.005;

particleSystem.start();

mv3d.fog = fountain;
mv3d.fogParticle = particleSystem;
};
--------------------------------------

sitll no fog...
nofog.png
mv3d.createFog = function () {

var fountain = BABYLON.Mesh.CreateBox("foutain", .01, mv3d.scene);
fountain.visibility = 0;
fountain.x = $gamePlayer.x;
fountain.y = $gamePlayer.y;
fountain.z = $gamePlayer.z;





particleSystem = new BABYLON.GPUParticleSystem("particles", { capacity: 50000 }, mv3d.scene);
particleSystem.manualEmitCount = particleSystem.activeParticleCount;
particleSystem.minEmitBox = new BABYLON.Vector3(-50, 0, -50); // Starting all from
particleSystem.maxEmitBox = new BABYLON.Vector3(50, 1, 50); // To..


particleSystem.particleTexture = new BABYLON.Texture("/img/MV3D/Fog.png", mv3d.scene);
particleSystem.emitter = fountain;

particleSystem.color1 = new BABYLON.Color4(0.8, 0.8, 0.8, 0.1);
particleSystem.color2 = new BABYLON.Color4(.95, .95, .95, 0.15);
particleSystem.colorDead = new BABYLON.Color4(0.9, 0.9, 0.9, 0.1);
particleSystem.minSize = 3.5;
particleSystem.maxSize = 5.0;
particleSystem.minLifeTime = Number.MAX_SAFE_INTEGER;
particleSystem.emitRate = 50000;
particleSystem.blendMode = BABYLON.ParticleSystem.BLENDMODE_STANDARD;
particleSystem.gravity = new BABYLON.Vector3(0, 0, 0);
particleSystem.direction1 = new BABYLON.Vector3(0, 0, 0);
particleSystem.direction2 = new BABYLON.Vector3(0, 0, 0);
particleSystem.minAngularSpeed = -2;
particleSystem.maxAngularSpeed = 2;
particleSystem.minEmitPower = .5;
particleSystem.maxEmitPower = 1;
particleSystem.updateSpeed = 0.005;

particleSystem.start();

mv3d.fog = fountain;
mv3d.fogParticle = particleSystem;
};
--------------------------------------

sitll no fog...
View attachment 137223

You put it into a plugin file, enabled it in plugin manager then did a script call of mv3d.createFog();
Code:
mv3d.createFog = function () {

    var fountain = BABYLON.Mesh.CreateBox("foutain", .01, mv3d.scene);
    fountain.visibility = 0;
    fountain.x = $gamePlayer.x;
    fountain.y = $gamePlayer.y;
    fountain.z = $gamePlayer.z;




    if (BABYLON.GPUParticleSystem.IsSupported) {
    particleSystem = new BABYLON.GPUParticleSystem("particles", { capacity: 50000 }, mv3d.scene);
     } else {
     particleSystem = new BABYLON.ParticleSystem("particles", 2500 , mv3d.scene);
     }

    particleSystem.manualEmitCount = particleSystem.activeParticleCount;
    particleSystem.minEmitBox = new BABYLON.Vector3(-50, 0, -50); // Starting all from
    particleSystem.maxEmitBox = new BABYLON.Vector3(50, 1, 50); // To..


    particleSystem.particleTexture = new BABYLON.Texture("/img/MV3D/Fog.png", mv3d.scene);
    particleSystem.emitter = fountain;

    particleSystem.color1 = new BABYLON.Color4(0.8, 0.8, 0.8, 0.1);
    particleSystem.color2 = new BABYLON.Color4(.95, .95, .95, 0.15);
    particleSystem.colorDead = new BABYLON.Color4(0.9, 0.9, 0.9, 0.1);
    particleSystem.minSize = 3.5;
    particleSystem.maxSize = 5.0;
    particleSystem.minLifeTime = Number.MAX_SAFE_INTEGER;
    particleSystem.emitRate = 50000;
    particleSystem.blendMode = BABYLON.ParticleSystem.BLENDMODE_STANDARD;
    particleSystem.gravity = new BABYLON.Vector3(0, 0, 0);
    particleSystem.direction1 = new BABYLON.Vector3(0, 0, 0);
    particleSystem.direction2 = new BABYLON.Vector3(0, 0, 0);
    particleSystem.minAngularSpeed = -2;
    particleSystem.maxAngularSpeed = 2;
    particleSystem.minEmitPower = .5;
    particleSystem.maxEmitPower = 1;
    particleSystem.updateSpeed = 0.005;

    particleSystem.start();

    mv3d.fog = fountain;
    mv3d.fogParticle = particleSystem;
};
I mean maybe you don't have good enough GPU, try this version, CPU can't handle as much and I have no idea what it does when not supported.
Great ! I got it !

great.png


but fog too much at 30 sec after....

toomcuh.png


How to stop creat more fog at 30 sec ?
How to Different side?
From the example, I use this code
B,5,25:side(B,5,25),top(B,5,24),height(2)
but will make the sides different.
Can this option be set?
QZaZgS.jpg
How to Different side?
From the example, I use this code
B,5,25:side(B,5,25),top(B,5,24),height(2)
but will make the sides different.
Can this option be set?
QZaZgS.jpg

RIght now, you have to do sides as events, since sides from tiles config will use all 4 sides. This is the only workaround at the moment.
Great ! I got it !

View attachment 137246

but fog too much at 30 sec after....

View attachment 137249

How to stop creat more fog at 30 sec ?

Learn what you can do with the particles here.
In this case you can reduce the amount by reducing the first call.
particleSystem = new BABYLON.GPUParticleSystem("particles", { capacity: 50000 }, mv3d.scene);
capacity is 50000, lower it to the amount you want, you can also play with other settings like the size of it or the color or the radius to spread it out over greater distances. You change that in the plugin file itself.
@glaphen sems like you are having fun with babylon. Good work, but took me a bit to get what the ffxa videos were trying to show
Also oh, babylon has its own particles uh...

@ZAKERY you need to set them to "pop" on the tileset. Fences have an already-made setting using the terrain tag 2.

@seaotter were you able to make chrono engine work again? I made a fix for it, just make a js file and put it under allchrono engine and mv3d plugins, and in it paste
JavaScript:
const _mv3d_mogce_createcharacterfor = mv3d.createCharacterFor;
mv3d.createCharacterFor = function(char,order){
    if (!char._preLoad) {
        _mv3d_mogce_createcharacterfor.apply(this,arguments);
    }
}
@glaphen sems like you are having fun with babylon. Good work, but took me a bit to get what the ffxa videos were trying to show
Also oh, babylon has its own particles uh...

@ZAKERY you need to set them to "pop" on the tileset. Fences have an already-made setting using the terrain tag 2.

@seaotter were you able to make chrono engine work again? I made a fix for it, just make a js file and put it under allchrono engine and mv3d plugins, and in it paste
JavaScript:
const _mv3d_mogce_createcharacterfor = mv3d.createCharacterFor;
mv3d.createCharacterFor = function(char,order){
    if (!char._preLoad) {
        _mv3d_mogce_createcharacterfor.apply(this,arguments);
    }
}
Great, fix now!
Learn what you can do with the particles here.
In this case you can reduce the amount by reducing the first call.
particleSystem = new BABYLON.GPUParticleSystem("particles", { capacity: 50000 }, mv3d.scene);
capacity is 50000, lower it to the amount you want, you can also play with other settings like the size of it or the color or the radius to spread it out over greater distances. You change that in the plugin file itself.
mv3d.createFog at last version can't run

>_<
01. I got mv3d.createFog is not a function
02.mv3d.createFog at last version can't run

>_<

How are you changing it, it's just changing the number in the file.
Code:
mv3d.createFog = function () {

    var fountain = BABYLON.Mesh.CreateBox("foutain", .01, mv3d.scene);
    fountain.visibility = 0;
    fountain.x = $gamePlayer.x;
    fountain.y = $gamePlayer.y;
    fountain.z = $gamePlayer.z;




    if (BABYLON.GPUParticleSystem.IsSupported) {
    particleSystem = new BABYLON.GPUParticleSystem("particles", { capacity: 25000 }, mv3d.scene);
     } else {
     particleSystem = new BABYLON.ParticleSystem("particles", 2500 , mv3d.scene);
     }

    particleSystem.manualEmitCount = particleSystem.activeParticleCount;
    particleSystem.minEmitBox = new BABYLON.Vector3(-50, 0, -50); // Starting all from
    particleSystem.maxEmitBox = new BABYLON.Vector3(50, 1, 50); // To..


    particleSystem.particleTexture = new BABYLON.Texture("/img/MV3D/Fog.png", mv3d.scene);
    particleSystem.emitter = fountain;

    particleSystem.color1 = new BABYLON.Color4(0.8, 0.8, 0.8, 0.1);
    particleSystem.color2 = new BABYLON.Color4(.95, .95, .95, 0.15);
    particleSystem.colorDead = new BABYLON.Color4(0.9, 0.9, 0.9, 0.1);
    particleSystem.minSize = 3.5;
    particleSystem.maxSize = 5.0;
    particleSystem.minLifeTime = Number.MAX_SAFE_INTEGER;
    particleSystem.emitRate = 50000;
    particleSystem.blendMode = BABYLON.ParticleSystem.BLENDMODE_STANDARD;
    particleSystem.gravity = new BABYLON.Vector3(0, 0, 0);
    particleSystem.direction1 = new BABYLON.Vector3(0, 0, 0);
    particleSystem.direction2 = new BABYLON.Vector3(0, 0, 0);
    particleSystem.minAngularSpeed = -2;
    particleSystem.maxAngularSpeed = 2;
    particleSystem.minEmitPower = .5;
    particleSystem.maxEmitPower = 1;
    particleSystem.updateSpeed = 0.005;

    particleSystem.start();

    mv3d.fog = fountain;
    mv3d.fogParticle = particleSystem;
};
2 keyboard button presses now it's 25000 instead of 50000.
How are you changing it, it's just changing the number in the file.
Code:
mv3d.createFog = function () {

    var fountain = BABYLON.Mesh.CreateBox("foutain", .01, mv3d.scene);
    fountain.visibility = 0;
    fountain.x = $gamePlayer.x;
    fountain.y = $gamePlayer.y;
    fountain.z = $gamePlayer.z;




    if (BABYLON.GPUParticleSystem.IsSupported) {
    particleSystem = new BABYLON.GPUParticleSystem("particles", { capacity: 25000 }, mv3d.scene);
     } else {
     particleSystem = new BABYLON.ParticleSystem("particles", 2500 , mv3d.scene);
     }

    particleSystem.manualEmitCount = particleSystem.activeParticleCount;
    particleSystem.minEmitBox = new BABYLON.Vector3(-50, 0, -50); // Starting all from
    particleSystem.maxEmitBox = new BABYLON.Vector3(50, 1, 50); // To..


    particleSystem.particleTexture = new BABYLON.Texture("/img/MV3D/Fog.png", mv3d.scene);
    particleSystem.emitter = fountain;

    particleSystem.color1 = new BABYLON.Color4(0.8, 0.8, 0.8, 0.1);
    particleSystem.color2 = new BABYLON.Color4(.95, .95, .95, 0.15);
    particleSystem.colorDead = new BABYLON.Color4(0.9, 0.9, 0.9, 0.1);
    particleSystem.minSize = 3.5;
    particleSystem.maxSize = 5.0;
    particleSystem.minLifeTime = Number.MAX_SAFE_INTEGER;
    particleSystem.emitRate = 50000;
    particleSystem.blendMode = BABYLON.ParticleSystem.BLENDMODE_STANDARD;
    particleSystem.gravity = new BABYLON.Vector3(0, 0, 0);
    particleSystem.direction1 = new BABYLON.Vector3(0, 0, 0);
    particleSystem.direction2 = new BABYLON.Vector3(0, 0, 0);
    particleSystem.minAngularSpeed = -2;
    particleSystem.maxAngularSpeed = 2;
    particleSystem.minEmitPower = .5;
    particleSystem.maxEmitPower = 1;
    particleSystem.updateSpeed = 0.005;

    particleSystem.start();

    mv3d.fog = fountain;
    mv3d.fogParticle = particleSystem;
};
2 keyboard button presses now it's 25000 instead of 50000.
great ^_^ , but...
this code at 0.5.1.5 is ok, at 0.5.2 is not work.
I don't know why ?
>_<
great ^_^ , but...
this code at 0.5.1.5 is ok, at 0.5.2 is not work.
I don't know why ?
>_<
You're right didn't even realize I was using 5.1.5 to test, I played with the options in compare and it seems to be this.
Code:
        enumRenderGroups: {
            BACK: 0,
            MAIN: 1,
            FRONT: 2
        },
If you search enumRenderGroups and change the numbers all to 0 it works but I have no idea if it breaks anything else. Seems to make some invisible barrier that makes it only show far from character in new version.
I've done my game with this latest plug-in. I accidentally deleted my map and I didn't know how to get it back. It's nice that I didn't have to do it all over again.
You're right didn't even realize I was using 5.1.5 to test, I played with the options in compare and it seems to be this.
Code:
        enumRenderGroups: {
            BACK: 0,
            MAIN: 1,
            FRONT: 2
        },
If you search enumRenderGroups and change the numbers all to 0 it works but I have no idea if it breaks anything else. Seems to make some invisible barrier that makes it only show far from character in new version.
so, if at 0.5.2 version
Can you get me a new code for 0.5.2 ?
so, if at 0.5.2 version
Can you get me a new code for 0.5.2 ?

Just open mv3d up in whatever even notepad, use replace command Ctrl+H if notepad.
Code:
enumRenderGroups:{BACK:0,MAIN:1,FRONT:2}
put that into top to be replaced.
Code:
enumRenderGroups:{BACK:0,MAIN:0,FRONT:0}
that into bottom to replace with.
Just open mv3d up in whatever even notepad, use replace command Ctrl+H if notepad.
Code:
enumRenderGroups:{BACK:0,MAIN:1,FRONT:2}
put that into top to be replaced.
Code:
enumRenderGroups:{BACK:0,MAIN:0,FRONT:0}
that into bottom to replace with.

01. mv3d.js like is a pkzip done javascript files, he can't to modify

02.if I push
Code:
enumRenderGroups:{BACK:0,MAIN:0,FRONT:0}
at others create fog.js , he still error.
1584609415045.png
@seaotter don't modify mv3d.js
create a new text file, save it with the extension .js instead of .txt, of rename it from .txt to .js
put that code in the text file, move the text file to your plugin folder, then add it to your project as a plugin bellow mv3d.
you just created an extension plugin to mv3d. that adds things to mv3d without modifying mv3d.js itself.
and NOW that you have the extension plugin with the mv3d.createFog function you can call it.
@seaotter don't modify mv3d.js
create a new text file, save it with the extension .js instead of .txt, of rename it from .txt to .js
put that code in the text file, move the text file to your plugin folder, then add it to your project as a plugin bellow mv3d.
you just created an extension plugin to mv3d. that adds things to mv3d without modifying mv3d.js itself.
and NOW that you have the extension plugin with the mv3d.createFog function you can call it.
thank for your note !
I try that mv3d.createFog function can't run at 0.5.2 , but can run at 0.5.1.5
thank for your note !
I try that mv3d.createFog function can't run at 0.5.2 , but can run at 0.5.1.5

Ok I tried to see if I could change it in new plugin and this seems to work.
Code:
mv3d.enumRenderGroups = {
                BACK: 0,
            MAIN: 0,
            FRONT: 0
        };
Just put it inside the fog plugin, below it, like.
Code:
mv3d.createFog = function () {

    var fountain = BABYLON.Mesh.CreateBox("foutain", .01, mv3d.scene);
    fountain.visibility = 0;
    fountain.x = $gamePlayer.x;
    fountain.y = $gamePlayer.y;
    fountain.z = $gamePlayer.z;





    var particleSystem = new BABYLON.GPUParticleSystem("particles", { capacity: 50000 }, mv3d.scene);
    particleSystem.manualEmitCount = particleSystem.activeParticleCount;
    particleSystem.minEmitBox = new BABYLON.Vector3(-50, 0, -50); // Starting all from
    particleSystem.maxEmitBox = new BABYLON.Vector3(50, 1, 50); // To..
   

    particleSystem.particleTexture = new BABYLON.Texture("/img/MV3D/Fog.png", mv3d.scene);
    particleSystem.emitter = fountain;
   
    particleSystem.color1 = new BABYLON.Color4(0.8, 0.8, 0.8, 0.1);
    particleSystem.color2 = new BABYLON.Color4(.95, .95, .95, 0.15);
    particleSystem.colorDead = new BABYLON.Color4(0.9, 0.9, 0.9, 0.1);
    particleSystem.minSize = 3.5;
    particleSystem.maxSize = 5.0;
    particleSystem.minLifeTime = Number.MAX_SAFE_INTEGER;
    particleSystem.emitRate = 50000;
    particleSystem.blendMode = BABYLON.ParticleSystem.BLENDMODE_STANDARD;
    particleSystem.gravity = new BABYLON.Vector3(0, 0, 0);
    particleSystem.direction1 = new BABYLON.Vector3(0, 0, 0);
    particleSystem.direction2 = new BABYLON.Vector3(0, 0, 0);
    particleSystem.minAngularSpeed = -2;
    particleSystem.maxAngularSpeed = 2;
    particleSystem.minEmitPower = .5;
    particleSystem.maxEmitPower = 1;
    particleSystem.updateSpeed = 0.005;
   
    particleSystem.start();
   
    mv3d.fog = fountain;
    mv3d.fogParticle = particleSystem;
};

mv3d.enumRenderGroups = {
                BACK: 0,
            MAIN: 0,
            FRONT: 0
        };
@palatkorn
I'm planning on allowing different textures for north, south, east, and west in version 0.6.

For those with the bush tiles showing on top of the fog effect, it's because those tiles have alpha(1). Remove that from the tileset configuration and it should look correct. Meshes with alpha blending are sorted in a special way, which can be buggy in some cases.

@ZAKERY
For the fences, use terrain tag 2. For trees, terrain tag 1. You can configure the terrain tags in the plugin parameters.

Original thread: https://forums.rpgmakerweb.com/threads/mv3d-3d-rendering-for-rmmv-with-babylon-js.114971/