hcmetal Posted September 15, 2018 Share Posted September 15, 2018 Hello everyone, I have been trying to create my own hdr environment map and use it in Babylon. A panorama is rendered in 3s Max 2019 using the V-Ray Next (4.02.04) sun system and saved as a .hdr file. The .hdr file is then loaded into Lys and converted to a specular .dds file, following the instructions from https://doc.babylonjs.com/how_to/physically_based_rendering Looks fine in Lys: However, in Babylon some strange things are happening PG: https://playground.babylonjs.com/#FDQ594 Two things to notice: 1. Reflection on the sphere with chrome pbr material. The sun looks funky: 2. Reflection on the ground with a none metallic pbr material. The sun looks funky too: Both materials have very sensitive roughness behaviour. More detail can be found in the PG. The .hdr output from Vray is here: vrayhdrtest.hdr I suspect something has gone wrong during the conversion in Lys, or the original render out of V-Ray has some problem. Hope someone can point me to the right direction. Thanks a lot! PatrickRyan 1 Quote Link to comment Share on other sites More sharing options...
Sebavan Posted September 17, 2018 Share Posted September 17, 2018 Indeed, the file seems corrupted as if I look into the mips manually it is broken from mip 3: @PatrickRyan Could you try to generate the DDS in LYS to see what happens ? PatrickRyan and hcmetal 1 1 Quote Link to comment Share on other sites More sharing options...
PatrickRyan Posted September 17, 2018 Share Posted September 17, 2018 Hi @hcmetal! I took a look at your playground and HDR and noticed a couple of things. When you are generating a DDS in Lys, make sure to step through the MIPs in the MIP preview slider. The brute force method is failing on your image as you can see in the screen shot below. The easiest way to fix this is to uncheck "Render ground truth specular using brute force method" as there is something in the pixels of your HDR that is making the computation fail. I normally use OpenEXR for my renders and images coming into Lys, so I would love to see if you could try exporting your environment as an EXR and see if you have the same problem. It may give us some more clarity about best practices. When calling your environment, you need to make sure you call it saying it's precomputed data like this: var hdrTexture = BABYLON.CubeTexture.CreateFromPrefilteredData("https://raw.githubusercontent.com/PatrickRyanMS/BabylonJStextures/master/DDS/Studio_Softbox_2Umbrellas_cube_specular.dds", scene); hdrTexture.name = "envTex"; hdrTexture.gammaSpace = false; scene.environmentTexture = hdrTexture; You also want to set the gamma space to false because the DDS file is in linear color space as you exported it as a 32-bit float texture. Rendering it as gamma will cause it to render too dark. I updated your playground and added our test spheres glb so that you can see all of the MIP levels present in the DDS. This is a handy test mesh to use when testing environments as it has all of the roughness values on a chrome sphere which will render all of the MIP levels for you and you can see what breaks. Another good practice if you are just creating a Babylon.js sphere is to use full white for material base color as that will reflect exactly what the environment texture is. Any other color will bias what you see and can throw you off when trying to understand what the environment is doing. Please let me know if you have other questions or if any of this doesn't make sense. Take care. Edited playground: https://playground.babylonjs.com/#FDQ594#2 Raw source for HDR environment sphere test asset: https://raw.githubusercontent.com/PatrickRyanMS/SampleModels/master/ENV_Spheres/ENV_Spheres.glb Github repo of the test sphere asset: https://github.com/PatrickRyanMS/SampleModels/tree/master/ENV_Spheres hcmetal 1 Quote Link to comment Share on other sites More sharing options...
hcmetal Posted September 18, 2018 Author Share Posted September 18, 2018 @Sebavan @PatrickRyan, thanks for your help! Unchecking "Render ground truth specular using brute force method" in Lys solves the problem. With both .hdr and .exr format, using brute force method produce broken MIP at level 2. @PatrickRyan, I have adopted the best practices you recommended and the lighting is much more natural. Thank you for sharing your wisdom and experience. Cheers! Sebavan, PatrickRyan and GameMonetize 3 Quote Link to comment Share on other sites More sharing options...
Recommended Posts
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.