Skip to content

Conversation

JaimeTorrealba
Copy link
Member

closes #476

Copy link

netlify bot commented Jan 11, 2024

Deploy Preview for tresjs-docs ready!

Name Link
🔨 Latest commit 85b4392
🔍 Latest deploy log https://app.netlify.com/sites/tresjs-docs/deploys/65b4f043260e610008c4d057
😎 Deploy Preview https://deploy-preview-506--tresjs-docs.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site configuration.

@JaimeTorrealba JaimeTorrealba self-assigned this Jan 11, 2024
@JaimeTorrealba JaimeTorrealba changed the title Feat(app): light-shadows and shaders docs examples feat(app): light-shadows and shaders docs examples Jan 11, 2024
@JaimeTorrealba JaimeTorrealba changed the title feat(app): light-shadows and shaders docs examples docs(app): light-shadows and shaders docs examples Jan 11, 2024
Copy link
Member

@alvarosabu alvarosabu left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey @JaimeTorrealba the guide needs some work, please take a look to the comments, any question let me now


We could divide this into three steps.

**Number 1**: Set the shadows on the renderer
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
**Number 1**: Set the shadows on the renderer
### Set the shadows on the renderer

//...
</template>
```
**Number 2**: Set the light to cast shadow
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
**Number 2**: Set the light to cast shadow
### Set the light to cast shadow

//...
</template>
```
**Number 3**: Set the objects to cast or receive shadows
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
**Number 3**: Set the objects to cast or receive shadows
### Set the objects to cast or receive shadows

We will build a simple scene with three meshes and a plane but only two will have shadows.
<SandboxDemo url="https://play.tresjs.org/#eNqVVt1y2jwQfRUN30WSKdimhLbjL3Qo9GfaadpM4K7uhbAXUGpLGkn8pJm8e1eSDXZCMmRCGGv37NHZ1XrFXWuqQH+QMlivoBW3LnSqmDREg1lJklO+G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eeslX2Cyg1lju/VHiZADj3Z8mP2CLzztnIbJVXh7OE85r0CJfWY0eNlrxDGXXcE7tV/eC4Q+Pqf60dW9umVRDqMFfO876q5pJu17zht+ucA7vjmP8TJX2mfWC3q7g9/8AWlN6bg==" />

## Let's first setup our scene (optional)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Try being more concise with titles ex:

Setting up the scene (optional)

The "let's first setup..." is a narrative for tutorials or articles. If you still want to include it do it on the paragraph but not in the title

</template>
```

_Note that I intentionally did not apply `cast-shadow` to the ``Cone` so it doesn't cast any shadow_
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
_Note that I intentionally did not apply `cast-shadow` to the ``Cone` so it doesn't cast any shadow_
_Note that I intentionally did not apply `cast-shadow` to the `Cone` so it doesn't cast any shadow_

_Note that I intentionally did not apply `cast-shadow` to the ``Cone` so it doesn't cast any shadow_

::: warning
The overuse of shadows in this way could drop your performance. However, there are ways to increase your performance, for more information please check out [this video](https://youtu.be/WGNvVGrS0kY?si=q7XyL5eABKUh3gbS&t=1256)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The warning feels misplaced at the end of the guide, specially because the immediate text above doesn't add context about performance.

@JaimeTorrealba please add it below Lights and shadows explanation


There are also many types of shadows, for example the "soft shadow" is generated automatially when an object receives more light from one side, but in summary a "ThreeJS default shadow" that is directed towards another surface needs to be cast by a mesh and another mesh needs to receive it. As we see in our example, the `Plane` is receiving a shadow but not casting it. Please note that not all materials can cast or receive shadows.

Internally, ThreeJS automatically generates a new mesh with a (ShadowMaterial)[https://threejs.org/docs/index.html?q=shado#api/en/materials/ShadowMaterial] which gets updated in each frame, that is why if you apply animations, the shadow also is animated, but also why you have to use shadows carefully, because they could slow your performance down.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The links format for markdown are incorrect.

@JaimeTorrealba
Copy link
Member Author

@alvarosabu thanks for pay attention to these details, I believe we're ready, let me know

Copy link
Member

@alvarosabu alvarosabu left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@JaimeTorrealba way better now, I just added some quick suggestions for the wording of the Shadows setup, we were using the same terms everywhere, was redundant to read.


## Setting our lights and shadow

We could divide this into three steps.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
We could divide this into three steps.
We could divide this into three steps:


We could divide this into three steps.

### Set the shadows on the renderer
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
### Set the shadows on the renderer
### Activate shadows on the renderer

The overuse of shadows in this way could drop your performance. However, there are ways to increase your performance, for more information please check out [this video](https://youtu.be/WGNvVGrS0kY?si=q7XyL5eABKUh3gbS&t=1256)
:::

## Setting our lights and shadow
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
## Setting our lights and shadow
## Enabling shadows

//...
</template>
```
### Set the light to cast shadow
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
### Set the light to cast shadow
### Set the light to cast shadows

@alvarosabu alvarosabu merged commit 7af155c into main Jan 27, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: No status
Development

Successfully merging this pull request may close these issues.

[Docs] - How to enable shadows and lights.
2 participants