question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Object shadows (in ver 100)

See original GitHub issue

Hi, 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.) image

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:closed
  • Created 5 years ago
  • Comments:7 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
IceCreamYoucommented, Jul 6, 2021

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.

0reactions
maemaemae3commented, Feb 1, 2019

No problem. Thank you very much for giving me many advices! I keep trial and error.

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found