hi,
can you please help me make rendering time for createhdrtexture render fast it take 30 seconds to render can i convert or what solution should i use
const createSky = (scene: Scene, textureSrc: string) => {
const skydome = MeshBuilder.CreateBox(
"sky",
{ size: 200, sideOrientation: Mesh.BACKSIDE },
scene
);
skydome.position.y = 100;
skydome.isPickable = false;
skydome.receiveShadows = true;
const sky = new BackgroundMaterial("skyMaterial", scene);
const hdrTexture = new HDRCubeTexture(textureSrc, scene, 2048);
hdrTexture.onLoadObservable.add(() => {
console.log("HDR texture ready!");
const sky = new BackgroundMaterial("skyMaterial", scene);
sky.reflectionTexture = hdrTexture;
sky.reflectionTexture.coordinatesMode = Texture.INVCUBIC_MODE;
sky.enableGroundProjection = true;
sky.projectedGroundRadius = 20;
sky.projectedGroundHeight = 3;
skydome.material = sky;
skydome.isPickable = false;
});
// sky.reflectionTexture = new HDRCubeTexture(textureSrc, scene, 2048);
// sky.reflectionTexture.coordinatesMode = Texture.EXPLICIT_MODE;
// sky.enableGroundProjection = true;
// sky.projectedGroundRadius = 30;
// sky.backFaceCulling = false;
// sky.projectedGroundHeight = 3;
// skydome.material = sky;
// skydome.isPickable = false;
// scene.imageProcessingConfiguration.toneMappingEnabled = true;
// scene.imageProcessingConfiguration.toneMappingType = ImageProcessingConfiguration.TONEMAPPING_ACES;
// scene.imageProcessingConfiguration.exposure = 1.5;
// scene.imageProcessingConfiguration.contrast = 1.2;
// skydome.ignoreCameraMaxZ = true
// skydome.infiniteDistance = true // this may clip scene meshes when Camera zooms out
return skydome;
};
also i create hdrlighting the whole scene take 2 minutes to render
const createHDRLighting = (
scene: Scene,
hdrTextureUrl: string,
environmentIntensity: string
) => {
if (props.page !== "single") {
const hdrTexture = new HDRCubeTexture(hdrTextureUrl, scene, 256);
// const hdrTexture = new HDRCubeTexture("/hdrmaps_com_free_10K.hdr", scene, 2048);
hdrTexture.level = 0.3; // Adjust this value (0.0 - 1.0) to reduce brightness
const hdrRotation = 10; // in degrees
hdrTexture.setReflectionTextureMatrix(Matrix.RotationY(Tools.ToRadians(hdrRotation)));
scene.environmentTexture = hdrTexture;
scene.environmentIntensity = environmentIntensity
? Number(environmentIntensity)
: 1.6;
const meshesToExclude = scene.meshes.filter(
(mesh) => mesh.name === "Shadow"
);
meshesToExclude.forEach((mesh) => {
// if (mesh.material && mesh.material instanceof PBRMaterial) {
// mesh.material.reflectionTexture = null; // Remove environment reflections
// mesh.material.reflectionColor = new Color3(0, 0, 0); // Set reflection color to black
// mesh.material.environmentIntensity = 0.0; // Reduce environment intensity
// // Optional: Set emissive color to provide ambient light if needed
// mesh.material.emissiveColor = new Color3(0, 0, 0); // Tweak this to your needs
// }
});
} else {
// const hdrTexture = new HDRCubeTexture("/hanger_exterior_cloudy_4k.hdr", scene, 2048);
const hdrTexture = new HDRCubeTexture("/test hdrs/11.hdr", scene, 256);
hdrTexture.level = 0.3; // Adjust this value (0.0 - 1.0) to reduce brightness
scene.environmentTexture = hdrTexture;
// scene.environmentIntensity = 3;
scene.environmentIntensity = 2.5;
scene.clearColor = new Color4(0.93, 0.93, 0.93, 1);
// const environment = scene.createDefaultEnvironment({
// skyboxColor: new Color4(0.9, 0.9, 0.9, 1),
// createGround: false,
// });
}
};