Improve road surface material creation to support custom material properties
This commit is contained in:
@@ -4309,24 +4309,41 @@ export class RuntimeHost {
|
|||||||
}
|
}
|
||||||
|
|
||||||
const textureSet = this.getOrCreateTextureSet(material);
|
const textureSet = this.getOrCreateTextureSet(material);
|
||||||
|
const isCustomMaterial = material.kind === "custom";
|
||||||
return this.configureRoadSurfaceMaterial(
|
const materialTransparent =
|
||||||
new MeshPhysicalMaterial({
|
isCustomMaterial &&
|
||||||
color: 0xffffff,
|
(material.opacity < 0.999 || textureSet.albedoHasAlpha);
|
||||||
|
const roadMaterial = new MeshPhysicalMaterial({
|
||||||
|
color: isCustomMaterial ? material.albedoColorHex : 0xffffff,
|
||||||
map: textureSet.baseColor,
|
map: textureSet.baseColor,
|
||||||
normalMap: textureSet.normal,
|
normalMap: textureSet.normal,
|
||||||
roughnessMap: textureSet.roughness,
|
roughnessMap: textureSet.roughness,
|
||||||
roughness: 1,
|
roughness: isCustomMaterial ? material.roughness : 1,
|
||||||
metalnessMap: textureSet.metallic,
|
metalnessMap: textureSet.metallic,
|
||||||
metalness: textureSet.metallic === null ? 0.03 : 1,
|
metalness: isCustomMaterial
|
||||||
|
? material.metallic
|
||||||
|
: textureSet.metallic === null
|
||||||
|
? 0.03
|
||||||
|
: 1,
|
||||||
specularColorMap: textureSet.specular,
|
specularColorMap: textureSet.specular,
|
||||||
specularColor: new Color(0xffffff),
|
specularColor: new Color(0xffffff),
|
||||||
specularIntensity: textureSet.specular === null ? 0.2 : 1,
|
specularIntensity: textureSet.specular === null ? 0.2 : 1,
|
||||||
|
transparent: materialTransparent,
|
||||||
|
opacity: isCustomMaterial ? material.opacity : 1,
|
||||||
|
depthWrite: !materialTransparent,
|
||||||
side: DoubleSide
|
side: DoubleSide
|
||||||
})
|
});
|
||||||
|
|
||||||
|
if (isCustomMaterial && textureSet.normal !== null) {
|
||||||
|
roadMaterial.normalScale.set(
|
||||||
|
material.normalStrength,
|
||||||
|
material.normalStrength
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return this.configureRoadSurfaceMaterial(roadMaterial);
|
||||||
|
}
|
||||||
|
|
||||||
private createRuntimeRoadSurfaceMaterial(path: RuntimePath): Material {
|
private createRuntimeRoadSurfaceMaterial(path: RuntimePath): Material {
|
||||||
return this.createRuntimeRoadGeneratedMaterial(path.road.material, 0x5f5747);
|
return this.createRuntimeRoadGeneratedMaterial(path.road.material, 0x5f5747);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user