StandardRenderingPipeline comes up with a set of postprocess effects which relate to the real world. There are different post process effects such as light effect and illumination effect.
In the example given below, you will see various effects like lens effect, post process effect of lights, etc.
It uses an HDR cube texture and the texture has to be .hdr. This texture gives a panaromic effect which can be seen while you rotate the camera.
var hdrTexture = new BABYLON.HDRCubeTexture("images/GravelPlaza_REF.hdr", scene, 512);
Standard rendering pipeline class is called to get the effect with the following line of code −
// Create rendering pipeline var pipeline = new BABYLON.StandardRenderingPipeline("standard", scene, 1.0 / devicePixelRatio, null, [camera]); pipeline.lensTexture = new BABYLON.Texture("images/lensdirt.jpg", scene)
In the demo shown below, we will create the cubetexture environment. We will use ground mesh for the same and apply standard rendering pipeline to the whole scene.
The texture is given to it using lensTexture which is an image and you can see the same texture as you move the scene.
<!doctype html> <html> <head> <meta charset = "utf-8"> <title>BabylonJs - Basic Element-Creating Scene</title> <script src = "babylon.js"></script> <style> canvas {width: 100%; height: 100%;} </style> </head> <body> <canvas id = "renderCanvas"></canvas> <script type = "text/javascript"> var canvas = document.getElementById("renderCanvas"); var engine = new BABYLON.Engine(canvas, true); var createScene = function() { var scene = new BABYLON.Scene(engine); var camera = new BABYLON.ArcRotateCamera("Camera", -Math.PI / 4, Math.PI / 2.5, 200, BABYLON.Vector3.Zero(), scene); camera.attachControl(canvas, true); camera.minZ = 0.1; // Light new BABYLON.PointLight("point", new BABYLON.Vector3(0, 40, 0), scene); // Environment Texture var hdrTexture = new BABYLON.HDRCubeTexture("images/GravelPlaza_REF.hdr", scene, 512); // Skybox var hdrSkybox = BABYLON.Mesh.CreateBox("hdrSkyBox", 1000.0, scene); var hdrSkyboxMaterial = new BABYLON.PBRMaterial("skyBox", scene); hdrSkyboxMaterial.backFaceCulling = false; hdrSkyboxMaterial.reflectionTexture = hdrTexture.clone(); hdrSkyboxMaterial.reflectionTexture.coordinatesMode = BABYLON.Texture.SKYBOX_MODE; hdrSkyboxMaterial.microSurface = 1.0; hdrSkyboxMaterial.cameraExposure = 0.6; hdrSkyboxMaterial.cameraContrast = 1.6; hdrSkyboxMaterial.disableLighting = true; hdrSkybox.material = hdrSkyboxMaterial; hdrSkybox.infiniteDistance = true; // Create mesh var woodbox = BABYLON.MeshBuilder.CreateBox("plane", { width: 40, height: 50, depth: 65 }, scene); var wood = new BABYLON.PBRMaterial("wood", scene); wood.reflectionTexture = hdrTexture; wood.directIntensity = 1.5; wood.environmentIntensity = 0.5; wood.specularIntensity = 0.3; wood.cameraExposure = 0.9; wood.cameraContrast = 1.6; wood.reflectivityTexture = new BABYLON.Texture("images/reflectivity.png", scene); wood.useMicroSurfaceFromReflectivityMapAlpha = true; wood.albedoColor = BABYLON.Color3.White(); wood.albedoTexture = new BABYLON.Texture("images/albedo.png", scene); woodbox.material = wood; // Create rendering pipeline var pipeline = new BABYLON.StandardRenderingPipeline("standard", scene, 1.0 / devicePixelRatio, null, [camera]); pipeline.lensTexture = new BABYLON.Texture("images/lensdirt.jpg", scene); // Return scene return scene; }; var scene = createScene(); engine.runRenderLoop(function() { scene.render(); }); </script> </body> </html>
Create images folder and store the .hdr file in it. We have used images/GravelPlaza_REF.hdr from www.hdrlabs.com.
You can downwload .hdr type files of your choice and use in the demo link.
The above line of code will generate the following output −
In this demo, we have used images images/GravelPlaza_REF.hdr, images/reflectivity.png, images/albedo.png, images/lensdirt.jpg. The images are stored in images/ folder locally and are also pasted below for reference. You can download any images of your choice and use in the demo link. Please note it is difficult to paste the .hdr files here as the size of it is very large.