Object shadows (in ver 100)
See original GitHub issueHi, this lib is very easy to use. Thanks a lot! However, it’s not able to recieve shadows in any materials.
Here is the screenshot.(the under layer which casting shadow correctly is MeshLambertMaterial I implemented.)
I implemented like this:
// Generate a terrain
const map_gras = texLoader.load('./img/snow.jpg');
const map_sand = texLoader.load('./img/sand.jpg');
const map_ston = texLoader.load('./img/ston.jpg');
const map_snow = texLoader.load('./img/snow.jpg');
tex_load_manager.onLoad = function () {
const blend = THREE.Terrain.generateBlendedMaterial([
{ texture: map_sand },
{ texture: map_gras, levels: [-80, -35, 20, 50] },
{ texture: map_ston, levels: [20, 50, 60, 85] },
{ texture: map_snow, glsl: '1.0 - smoothstep(65.0 + smoothstep(-256.0, 256.0, vPosition.x) * 10.0, 80.0, vPosition.z)' },
{ texture: map_ston, glsl: 'slope > 0.7853981633974483 ? 0.2 : 1.0 - smoothstep(0.47123889803846897, 0.7853981633974483, slope) + 0.2' }, // between 27 and 45 degrees
]);
let xS = 128, yS = 128;
let terrainScene = THREE.Terrain({
easing: THREE.Terrain.Linear,
frequency: 2.5,
heightmap: THREE.Terrain.DiamondSquare,
material: blend,
maxHeight: 100,
minHeight: -100,
steps: 1,
useBufferGeometry: false,
xSegments: xS,
xSize: 1024,
ySegments: yS,
ySize: 1024,
});
terrainScene.receiveShadow = true;
// Assuming you already have your global scene, add the terrain to it
scene.add(terrainScene);
}.bind(this);
I’m using threejs version 100, but it seems not working since ver 91. It seems related to #6 but I’m new at GLSL so it’s bit confusing to investigate this.
would you henp me?
Issue Analytics
- State:
- Created 5 years ago
- Comments:7 (4 by maintainers)
Top Results From Across the Web
Using Cel Shader to Cast Shadows on 100% Luminant Objects
In this tutorial I'm going to show you how you can use Cinema 4D's Cel Shader to allow for shadows to be cast...
Read more >How to Make Shadows for your Virtual 3D Objects! - YouTube
... of a shot faster than a lack of shadows. How easy is it to add realistic shadows to the virtual 3D objects...
Read more >Using Cel Shader to Cast Shadows on 100% Luminant Objects
In this tutorial I'm going to show you how you can use Cinema 4D's Cel Shader to allow for shadows to be cast...
Read more >Low-alpha transparent objects don't cast shadows ... - GitHub
Issue description: Shadows of objects with a transparent material and Opaque Pre-pass enabled disappear when alpha drops below 0.1. In the ...
Read more >Lights and shadows - form•Z
All Objects: When this option is selected (default), the shadow map is generated for all the objects in the project that cast shadows,...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
I haven’t specifically tried it, but I think this should be fixed in v1.6.1+ thanks to the improved way the textures are generated. Please feel free to reopen if that’s not the case.
No problem. Thank you very much for giving me many advices! I keep trial and error.