Can you provide an up-to-date example on how to create skybox totally programmatically?
After looking at the PlayCanvas engine source code, I tried this:
var backImage = new Image();
backImage.src = backImageUrl;
var leftImage = new Image();
leftImage.src = leftImageUrl;
var frontImage = new Image();
frontImage.src = frontImageUrl;
var rightImage = new Image();
rightImage.src = rightImageUrl;
var topImage = new Image();
topImage.src = topImageUrl;
var bottomImage = new Image();
bottomImage.src = bottomImageUrl;
var skyboxCubemapTexture = new pc.Texture({
cubemap: true
});
skyboxCubemapTexture.source = [
backImage,
leftImage,
frontImage,
rightImage,
topImage,
bottomImage
];
app.scene.skybox = skyboxCubemapTexture;
// also tried app.scene.setSkybox(skyboxCubemapTexture);
@dave thanks a lot for your help - your example was very useful. After making my code exactly as yours the skybox didn’t appear initially, but then after some additional looking in the PlayCanvas framework source code I reached important realization - the skybox texture images I used had different sizes, thus making the _levels object empty and the skybox invalid. After making sure I used 6 textures all with the same size everything worked.
Dave, I used your project script, but it merged it with the existing skybox. How do I replace the skybox? Never mind, I had HDR set. Thanks. Got it. Except I’d really like to set the skybox from an existing cubemap instead of getting all the textures again.
@Leonidas Exactly, top is mine, bottom image is the viewer.
And yes I set skyboxMip to 0: app.scene.skyboxMip = 0;
I assume it has something todo with texture resolution of the generated DDS, but I really
don’t know. I want to use max FullHD screen width and it is responsive by now. On tablets and mobiles it looks a bit better due to the small size, but it’s still not as clean as in the viewer example which is using the editor. Does engine (only) something different, maybe?