V!nc3r Posted August 22, 2018 Share Posted August 22, 2018 Hi all! I need to reproduce an effect 360-wall-mapping like. To do that, a cubemap projection using SKYBOX_MODE is perfect. 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? sharp and devAxeon 2 Quote Link to comment Share on other sites More sharing options...
Sebavan Posted August 22, 2018 Share Posted August 22, 2018 We do not support changing the center as by default cubemap are considered at infinite distance so would look the same. You could try to use local cubemap for this section Using local cubemap mode of http://doc.babylonjs.com/how_to/reflect#cubetexture Quote Link to comment Share on other sites More sharing options...
V!nc3r Posted August 22, 2018 Author Share Posted August 22, 2018 Yes but it seems local cubemap mode doesn't work with SKYBOX_MODE http://www.babylonjs-playground.com/#JCZIXE#8 (line 74), and unfortunatly the SKYBOX_MODE is the only way to get the texture projection I want. Quote Link to comment Share on other sites More sharing options...
Sebavan Posted August 22, 2018 Share Posted August 22, 2018 Yup this would be interesting to add indeed, I ll check what I can do. V!nc3r 1 Quote Link to comment Share on other sites More sharing options...
sharp Posted August 22, 2018 Share Posted August 22, 2018 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 ? Quote Link to comment Share on other sites More sharing options...
Sebavan Posted August 22, 2018 Share Posted August 22, 2018 Ok I got something allowing adding a reflection texture matrix for skybox mode. Basically the matrix will fit with your translations from origin to new origin. I will make a PR and new release ASAP. Quote Link to comment Share on other sites More sharing options...
Sebavan Posted August 22, 2018 Share Posted August 22, 2018 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); V!nc3r, dbawel, sharp and 2 others 5 Quote Link to comment Share on other sites More sharing options...
V!nc3r Posted August 23, 2018 Author Share Posted August 23, 2018 You roxx! 'can't wait to test that ? Quote Link to comment Share on other sites More sharing options...
V!nc3r Posted August 23, 2018 Author Share Posted August 23, 2018 It works \o/ Thanks :) Quote Link to comment Share on other sites More sharing options...
Guest Posted August 23, 2018 Share Posted August 23, 2018 Excellent! Flagging as solved! Quote Link to comment Share on other sites More sharing options...
V!nc3r Posted August 24, 2018 Author Share Posted August 24, 2018 And is this new functionnality can help to get point light cubemap shadows? Quote Link to comment Share on other sites More sharing options...
V!nc3r Posted August 24, 2018 Author Share Posted August 24, 2018 Yay! Updating skybox position on each render : http://www.babylonjs-playground.com/#JCZIXE#12 Nice job @Sebavan Quote Link to comment Share on other sites More sharing options...
Guest Posted August 24, 2018 Share Posted August 24, 2018 Excellent! 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.