Jump to content

Reflection probe bounding box


V!nc3r
 Share

Recommended Posts

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):

wOSpUwI.png

 

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 :)

 

 

 

 

Link to comment
Share on other sites

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).

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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



 

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

  • 2 weeks later...

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 by V!nc3r
quick fix of PG
Link to comment
Share on other sites

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

 

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...