diff --git a/web/src/beta/lib/core/engines/Cesium/CustomShaders/NonPBRLightingShader.ts b/web/src/beta/lib/core/engines/Cesium/CustomShaders/NonPBRLightingShader.ts new file mode 100644 index 0000000000..d060a1738c --- /dev/null +++ b/web/src/beta/lib/core/engines/Cesium/CustomShaders/NonPBRLightingShader.ts @@ -0,0 +1,20 @@ +import { + CustomShader, + CustomShaderMode, + CustomShaderTranslucencyMode, + LightingModel, +} from "cesium"; + +export const NonPBRLightingShader = new CustomShader({ + mode: CustomShaderMode.MODIFY_MATERIAL, // Need lighting + lightingModel: LightingModel.PBR, + translucencyMode: CustomShaderTranslucencyMode.OPAQUE, + fragmentShaderText: /* glsl */ ` + void fragmentMain(FragmentInput fsInput, inout czm_modelMaterial material) { + material.diffuse = vec3(1.0); + material.specular = vec3(0.0); + material.emissive = vec3(0.0); + material.alpha = 1.0; + } + `, +}); diff --git a/web/src/beta/lib/core/engines/Cesium/Feature/Model/index.tsx b/web/src/beta/lib/core/engines/Cesium/Feature/Model/index.tsx index df10f95b3a..75d1e285ec 100644 --- a/web/src/beta/lib/core/engines/Cesium/Feature/Model/index.tsx +++ b/web/src/beta/lib/core/engines/Cesium/Feature/Model/index.tsx @@ -6,6 +6,7 @@ import { toColor } from "@reearth/beta/utils/value"; import type { ModelAppearance } from "../../.."; import { colorBlendMode, heightReference, shadowMode } from "../../common"; +import { NonPBRLightingShader } from "../../CustomShaders/NonPBRLightingShader"; import { EntityExt, extractSimpleLayerData, @@ -62,6 +63,7 @@ export default function Model({ id, isVisible, property, geometry, layer, featur silhouetteColor, bearing, silhouetteSize = 1, + pbr, } = property ?? {}; const actualUrl = useMemo(() => model || url || data?.url, [model, url, data?.url]); @@ -107,6 +109,7 @@ export default function Model({ id, isVisible, property, geometry, layer, featur uri={actualUrl} scale={scale} shadows={shadowMode(shadows)} + customShader={pbr === false ? NonPBRLightingShader : undefined} colorBlendMode={colorBlendMode(colorBlend)} colorBlendAmount={colorBlendAmount} color={modelColor} diff --git a/web/src/beta/lib/core/engines/Cesium/Feature/Tileset/index.tsx b/web/src/beta/lib/core/engines/Cesium/Feature/Tileset/index.tsx index b7a1315f7e..bab9a60519 100644 --- a/web/src/beta/lib/core/engines/Cesium/Feature/Tileset/index.tsx +++ b/web/src/beta/lib/core/engines/Cesium/Feature/Tileset/index.tsx @@ -3,6 +3,7 @@ import { Cesium3DTileset } from "resium"; import type { Cesium3DTilesAppearance, ComputedLayer } from "../../.."; import { colorBlendModeFor3DTile, shadowMode } from "../../common"; +import { NonPBRLightingShader } from "../../CustomShaders/NonPBRLightingShader"; import Box from "../Box"; import { type FeatureComponentConfig, type FeatureProps } from "../utils"; @@ -23,7 +24,7 @@ function Tileset({ evalFeature, ...props }: Props): JSX.Element | null { - const { shadows, colorBlendMode } = property ?? {}; + const { shadows, colorBlendMode, pbr } = property ?? {}; const boxId = `${layer?.id}_box`; const { tilesetUrl, ref, style, clippingPlanes, builtinBoxProps } = useHooks({ id, @@ -49,6 +50,7 @@ function Tileset({