itowns icon indicating copy to clipboard operation
itowns copied to clipboard

MeshPhysicalMaterial and shadow look weird in a small scene rendering

Open yuzhou2013 opened this issue 2 years ago • 10 comments

Hello everyone, I just start a itowns environment , and put a whole city gltf model on the map. For the large scale scene, the materials and shadows looks good. Then I place another independent building on the map corresponding with a spotlight on it. When the camera zoom in, the MeshPhysicalMaterials on the building is blured and the shadows is distored, everything look weird. When I enlarge the model to 500x times, the MeshPhysicalMaterials and shadows looks good again.

I think may be the large scene is the reason, but I don't know how to fix this. Can anyone offer some suggestions? Thanks a lot!

yuzhou2013 avatar Mar 03 '22 15:03 yuzhou2013

Hello, Could you share an code example ?

what do you mean by I enlarge the model to 500x times ?

gchoqueux avatar Mar 03 '22 15:03 gchoqueux

Thank you for reply. Here are the screenshot: this is a small model, and the shadow looks wierd wecom-temp-5c98b1c49fcf1e4e52a73397c18f9587

then I enlarge the model, things looks better. wecom-temp-a9e4cff4d953625b2d5168ca1c75f5a6

In the end, I enlarge the model 500x times, the model become sharpe, and materials looks good. wecom-temp-6053118c64b524e3853ac6e6c7dfe408

In order to express this question more clearly, I upload a whole building in the scene. From the screenshot, we can see the distored shadow and bured shining shadow wecom-temp-16f0f518c1e6c1747c30032dad3d23ca

image

I refer to the writing of react-fiber, and try to make the effects ` const bottleMaterial = new THREE.MeshPhysicalMaterial({ color: '#ffffff', transmission: 1, roughness: 0.1, thickness: 100, envMapIntensity: 20, clearcoat: , ior: 1 })

return new Promise((resovle,reject) => {
    itowns.glTFLoader.load(`/summodel2.glb`,(glb) => {
        const {nodes,materials} = convertNodeMaterial(glb)
        resovle(
            <group position={[-2839591.5155920475, 4664200.675698617,3284803.339808643]}>
                <spotLight useHelper={SpotLightHelper} position={[10, 10, 50]} castShadow intensity={1}/>
                <ambientLight intensity={0.2} />
                <pointLight position={[-10, 50, -10]} color="white" intensity={0} />
                <pointLight position={[0, 60, 5]} intensity={0} />
                <directionalLight position={[0, 40, 0]} color="grey" intensity={0} />
                <group rotation={[Math.PI/2,0,0]}>
                <mesh receiveShadow castShadow material={material} geometry={nodes.Cube.geometry} position={[10, 10, -50]} scale={[500, 500, 500]} rotation={[0, 0, 0]}/>
                <mesh receiveShadow castShadow material={material} geometry={nodes.Cube1.geometry} position={[10, 10, -50]} scale={[500, 500, 500]} rotation={[0, 0, 0]}/>
                <mesh receiveShadow castShadow material={material} geometry={nodes.Cube2.geometry} position={[10, 10, -50]} scale={[500, 500, 500]} rotation={[0, 0, 0]}/>
                <mesh receiveShadow castShadow material={material} geometry={nodes.Plane.geometry} position={[10, 10, -50]} scale={[500, 500, 500]} rotation={[0, 0, 0]}/>
            </group>
            </group>
        )
    })
})`

In react-fiber, the rendering effect is as follows: image

I think it is very meaningful to combine the big city scene and the small architectural scene to show. Thanks a lot

yuzhou2013 avatar Mar 03 '22 16:03 yuzhou2013

Hello, I made another test as follows: This is the original effect in gltf-viewer: image

Then I load it in itowns: Enlarge the dragon 20x times, we can see a lot of noise in the refraction image image

Enlarge the dragon 2000x times, the refraction is much better now image

Enlarge the dragon 50000x times, image

Anyone knows how to fix this?

yuzhou2013 avatar Mar 04 '22 04:03 yuzhou2013

How do tiles receive shadows

GGBond-GIS avatar Mar 28 '22 11:03 GGBond-GIS

@yuzhou2013 I have you try in THREE.js scene without itowns?

https://discourse.threejs.org/t/should-i-use-a-light-for-every-object-to-cast-high-quality-shadow/2154/2

https://stackoverflow.com/questions/49332256/how-to-improve-shadow-quality-in-three-js

gchoqueux avatar Mar 28 '22 13:03 gchoqueux

How do tiles receive shadows

For the moment it isn't possible

gchoqueux avatar Mar 28 '22 13:03 gchoqueux

瓷砖如何接收阴影

暂时不可能

image I can only try to modify the ground mesh object to achieve the effect, but it's a little contrary

GGBond-GIS avatar Mar 29 '22 02:03 GGBond-GIS

瓷砖如何接收抱

暂时可能

Can I add a layer of ground mesh objects to the whole earth image

GGBond-GIS avatar Mar 29 '22 02:03 GGBond-GIS

How do tiles receive shadows

For the moment it isn't possible

Can I use tilemesh and change the material to three Shadowmaterial to receive shadows, but I found that tilemesh is not a constructor image

GGBond-GIS avatar Mar 29 '22 07:03 GGBond-GIS

but I found that tilemesh is not a constructor

TileMesh isn't exported in itowns

gchoqueux avatar Mar 29 '22 16:03 gchoqueux