V!nc3r Posted January 29, 2018 Share Posted January 29, 2018 Hi all! Is it possible to define a bounding box size on a reflection probe ? Here a screen record in Unity3D, to show what I'm talking about: https://imgur.com/NoMzMil (another quick record with a simplier scene) By tweaking the probe cage as the same size of the room walls, I get kind of realtime effect just by using a probe (box projection need to be checked): I don't know technical logic behind this functionnality, maybe this bounding box option looks like an abstract cube mesh where is applied the cubemap as a texture, and materials using this probe reflect this cube inverted ? No idea Quote Link to comment Share on other sites More sharing options...
GameMonetize Posted January 29, 2018 Share Posted January 29, 2018 The reflection probe does not have a bounding box but you can still control what is rendered inside by adding / removing obejcts in the renderList Does it make sense? Quote Link to comment Share on other sites More sharing options...
V!nc3r Posted January 30, 2018 Author Share Posted January 30, 2018 Nope, my explanations was unclear I think. I will try to make a cornell box scene example in the playground to show the desired effect. And maybe in my example on Unity I havn't spotted the correct parameters. Rather than the bounding box, I think the two important parameters on Unity are the probe origin and the box projection checked (at 0:29 - it's in fact probably only this box projection which I interested in). Quote Link to comment Share on other sites More sharing options...
GameMonetize Posted January 30, 2018 Share Posted January 30, 2018 We are not supporting non infinite reflection probe unfortunately Quote Link to comment Share on other sites More sharing options...
V!nc3r Posted January 31, 2018 Author Share Posted January 31, 2018 Ok (so non-infinite reflection probe is the correct name, I'm gonna remember that ). Maybe this can be add to the BJS whishlist ? I suppose this functionnality bring the fact to rewrite another reflection probe system, like generate dynamic cubemap with a probe > map this cubemap onto an invisible cube (where x,y,z scale can be set) > use this cube to project reflection depending on the camera angle. Looks like complicated. So, I will try to cheat with realtime reflection using a mirrorPlane for now. Quote Link to comment Share on other sites More sharing options...
GameMonetize Posted January 31, 2018 Share Posted January 31, 2018 Yeah this is rather complex actually and this is why we decided to not support it Quote Link to comment Share on other sites More sharing options...
BitOfGold Posted January 31, 2018 Share Posted January 31, 2018 I got it implemented once, but only in the legacy PBR code. So this is parallax correction, to a box defined by vCubemapSize and vCubemapCenter. (faster than any size box but it worked) The code was like this (in reflectionFunction.fx): #ifdef PARALLAXCORRECTION vec3 parallaxCorrectNormal( vec3 pos, vec3 v, vec3 cubeSize, vec3 cubePos ) { vec3 nDir = normalize(v); vec3 rbmax = ( .5 * ( cubeSize - cubePos ) - pos ) / nDir; vec3 rbmin = ( - .5 * ( cubeSize - cubePos ) - pos ) / nDir; vec3 rbminmax; rbminmax.x = ( nDir.x > 0. )?rbmax.x:rbmin.x; rbminmax.y = ( nDir.y > 0. )?rbmax.y:rbmin.y; rbminmax.z = ( nDir.z > 0. )?rbmax.z:rbmin.z; float correction = min(min(rbminmax.x, rbminmax.y), rbminmax.z); vec3 boxIntersection = pos + nDir * correction; return boxIntersection - cubePos; } #endif and later: #ifdef REFLECTIONMAP_CUBIC vec3 viewDir = worldPos.xyz - vEyePosition.xyz; vec3 coords = reflect(viewDir, worldNormal); #ifdef PARALLAXCORRECTION coords = parallaxCorrectNormal(worldPos.xyz, coords, vCubemapSize, vCubemapCenter ); #endif Rodrix3, V!nc3r and Pryme8 1 2 Quote Link to comment Share on other sites More sharing options...
BitOfGold Posted January 31, 2018 Share Posted January 31, 2018 It still works here: (You can look into the mirror on the wall and on the floor) https://www.bitofgold.com/cubemap/ Quote Link to comment Share on other sites More sharing options...
Pryme8 Posted January 31, 2018 Share Posted January 31, 2018 12 hours ago, V!nc3r said: Ok (so non-infinite reflection probe is the correct name, I'm gonna remember that ). Maybe this can be add to the BJS whishlist ? I suppose this functionnality bring the fact to rewrite another reflection probe system, like generate dynamic cubemap with a probe > map this cubemap onto an invisible cube (where x,y,z scale can be set) > use this cube to project reflection depending on the camera angle. Looks like complicated. So, I will try to cheat with realtime reflection using a mirrorPlane for now. I might be able to pull this off. If nobody does it by next week remind me. Quote Link to comment Share on other sites More sharing options...
GameMonetize Posted January 31, 2018 Share Posted January 31, 2018 I'll add it for you guys I will introduce a new REFLECTIONMAP_LOCALCUBIC which will be automatically set if the cubemap (or the probe) has a min.max box definition I'll keep this thread updated BitOfGold and Rodrix3 2 Quote Link to comment Share on other sites More sharing options...
V!nc3r Posted February 1, 2018 Author Share Posted February 1, 2018 Wow, that's rocks! Quote Link to comment Share on other sites More sharing options...
Guest Posted February 1, 2018 Share Posted February 1, 2018 And here we are:) Doc: http://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode Demo: https://www.babylonjs-playground.com/#RNASML (clear your cache) BitOfGold and V!nc3r 2 Quote Link to comment Share on other sites More sharing options...
Pryme8 Posted February 1, 2018 Share Posted February 1, 2018 Looks like it is mirroring the sky on the box until you look up a hair. Quote Link to comment Share on other sites More sharing options...
Guest Posted February 1, 2018 Share Posted February 1, 2018 Nope the ground is just clipped Quote Link to comment Share on other sites More sharing options...
Guest Posted February 1, 2018 Share Posted February 1, 2018 Better: https://www.babylonjs-playground.com/#RNASML#2 Quote Link to comment Share on other sites More sharing options...
V!nc3r Posted February 13, 2018 Author Share Posted February 13, 2018 (edited) Here a test with the cornell box scene : https://www.babylonjs-playground.com/#59ZXVF#25 Why, if I try to attenutate the reflection, by setting metallic or reflectionTexture.level to 0.1, my material become darker? I see that I must set both scene.ambientColor and material.ambientColor to white to avoid this : https://www.babylonjs-playground.com/#59ZXVF#17 (lines 5 and 104). Is this "physically" correct? [edit] or maybe I have to replace the environmentBRDFTexture on the ground material, with the cubeTexture of my probe? But how can I do that, since the BRDF texture looks like a weird texture, how can I regenerate dynamically one, using a probe? Edited July 4, 2018 by V!nc3r quick fix of PG Quote Link to comment Share on other sites More sharing options...
Guest Posted February 13, 2018 Share Posted February 13, 2018 The BRDFTexture should not be change as it is a tool for use to compute some optics value. You can however try to set it to null to use a different algorithm Reducing the metalness will indeed reduce the amount of received light To attenuate the reflection, can you try to play with reflectivityColor perhaps? https://www.babylonjs-playground.com/#24BYDQ pinging @Sebavan for other ideas 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.