Jump to content

How do I achieve the same effect without default environment?


fateriddle
 Share

Recommended Posts

https://www.babylonjs-playground.com/#14KRGG#23

It is the waterSphpere example, except I comment out line 23:

// var helper = scene.createDefaultEnvironment();
 
Then the outer sphere become transparent...  I don't want to use createDefaultEnvironment in a real project, but how do I mimic what it provides to make this example works as intended?
Link to comment
Share on other sites

scene.createDefaultEnvironment()

is a convenience function for:

new EnvironmentHelper(undefined, this);

So, you just need to make sure you pass in only the options you want to keep.  You are creating it with the default options:
https://github.com/BabylonJS/Babylon.js/blob/master/src/Helpers/babylon.environmentHelper.ts#L194

So, you can either call with the options you would like to or work your way backwards from that file to get just the parts you need :) At least I think that is the best starting point.

Link to comment
Share on other sites

I'm not sure if I well understand your question, but if you just want to use a custom environment texture (which is in any case needed when in PBR workflow), you just have to not use the helper and manually create your envTex:

var hdrTexture = new BABYLON.CubeTexture("textures/environment.env", scene);
hdrTexture.gammaSpace = false;
scene.environmentTexture = hdrTexture;

https://www.babylonjs-playground.com/#14KRGG#26

But if you want also use a custom reflection texture, you still need the environmentTexture but it's possible to add a reflectionTexture on your material:

waterMaterial.reflectivityColor = new BABYLON.Color3(0.05, 0.05, 0.05);
waterMaterial.reflectionTexture = new BABYLON.CubeTexture("textures/skybox2", scene);
waterMaterial.reflectionTexture.coordinatesMode = BABYLON.Texture.SKYBOX_MODE;

https://www.babylonjs-playground.com/#14KRGG#27

 

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...