Jump to content

Cubemap SKYBOX_MODE projection origin


V!nc3r
 Share

Recommended Posts

Hi all!

I need to reproduce an effect 360-wall-mapping like. To do that, a cubemap projection using SKYBOX_MODE is perfect.

ovfXjVq.gif

Here my example playground: http://www.babylonjs-playground.com/#JCZIXE#7:

  • click on Cubemap02 button (this assign a cubemap using SKYBOX_MODE)
  • you can see that the skybox projection use the object origin as projection origin (screenshot from Blender, showing where is the object origin)
  • click on switch cam button: this teleport you on a FreeCam at the object origin (the orange sphere), and you can see that the cubemap isn't deformed at all despite of its projection on the 3D mesh: that's the result wanted.

BUT: click on the Cubemap01 button: this applied another cubemap on the mesh, using the same object origin... Except I want to project this lightmap from the green sphere point of view.

Only for reference, if you unzoom you will see the same object duplicate twice but with different origins, showing cubemap projected from other coordinates.

(you can download test scene sources here).

So my question is: is it possible to dynamically change the center of a skyxbox cubemap projection?

Potential bonus: couldn't this projection technique leads us to point light cubemap shadowing?

Link to comment
Share on other sites

1 hour ago, Sebavan said:

We do not support changing the center as by default cubemap are considered at infinite distance so would look the same.

Can't we fake the center ? We tried to change pivot point &  matrix / reflectionTextureMatrix, = without success 😅

Link to comment
Share on other sites

The pull request is out : https://github.com/BabylonJS/Babylon.js/pull/4982

The result once deployed will be testable on: http://www.babylonjs-playground.com/#JCZIXE#9

Basically you can add this on the texture to offset it:

// Offset the skybox center.
var point1ToPoint2 = cameraPoint02.position.subtract(cameraPoint01.position);
var reflectionMatrix = BABYLON.Matrix.Translation(point1ToPoint2.x, point1ToPoint2.y, point1ToPoint2.z);
otherOriginRefMat.reflectionTexture.setReflectionTextureMatrix(reflectionMatrix);
 
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...