-
Notifications
You must be signed in to change notification settings - Fork 304
Add tutorial + example SDF for shadow texture size #2597
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 4 commits
573f20e
f4b807e
391726a
9a28bd1
0bdc2a0
0d21682
b48725b
ba5ca5d
293560f
8a75772
41431c0
20891d5
a07babe
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,73 @@ | ||
<?xml version="1.0" ?> | ||
<sdf version="1.9"> | ||
<world name="default"> | ||
<scene> | ||
<background>0.1 0.1 0.1</background> | ||
<ambient>0.0 0.0 0.0</ambient> | ||
</scene> | ||
|
||
<!--GUI plugins--> | ||
<gui> | ||
<plugin filename="MinimalScene" name="3D View"> | ||
<engine>ogre2</engine> | ||
<camera_pose>-10 0 7 0 0.5 0</camera_pose> | ||
<shadows> | ||
<texture_size light_type="directional">16384</texture_size> | ||
</shadows> | ||
</plugin> | ||
|
||
<plugin filename="GzSceneManager" name="Scene Manager"/> | ||
<plugin filename="InteractiveViewControl" name="Interactive view control"/> | ||
</gui> | ||
|
||
<!--lighting--> | ||
<light type="directional" name="sun"> | ||
<pose>0 0 8 0 0 0</pose> | ||
<diffuse>1 1 1 1</diffuse> | ||
<specular>0 0 0 0</specular> | ||
<attenuation> | ||
<range>50</range> | ||
<constant>0</constant> | ||
<linear>0</linear> | ||
<quadratic>0</quadratic> | ||
</attenuation> | ||
<cast_shadows>true</cast_shadows> | ||
<direction>-2 2 -1.5</direction> | ||
<intensity>1.0</intensity> | ||
</light> | ||
|
||
<!--scene objects--> | ||
<include> | ||
<pose>0 0 0 0 0 -1.57</pose> | ||
<uri> | ||
https://fuel.gazebosim.org/1.0/OpenRobotics/models/Garden Mascot | ||
</uri> | ||
</include> | ||
|
||
<model name="floor"> | ||
<pose>-5 0 -0.5 0 0 0</pose> | ||
<static>true</static> | ||
<link name="link"> | ||
<collision name="collision"> | ||
<geometry> | ||
<box> | ||
<size>15 15 1</size> | ||
</box> | ||
</geometry> | ||
</collision> | ||
<visual name="visual"> | ||
<geometry> | ||
<box> | ||
<size>15 15 1</size> | ||
</box> | ||
</geometry> | ||
<material> | ||
<ambient>0.8 0.8 0.8 1</ambient> | ||
<diffuse>0.8 0.8 0.8 1</diffuse> | ||
<specular>0.8 0.8 0.8 1</specular> | ||
</material> | ||
</visual> | ||
</link> | ||
</model> | ||
</world> | ||
</sdf> |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,116 @@ | ||
\page shadow_texture_size Shadow Texture Size | ||
|
||
This tutorial showcases how to change the texture size of shadows casted by lights. | ||
|
||
<div style="text-align:center;"> | ||
\image html files/shadow_texture_size/shadow_texsize_2k_to_16k.gif width=60% | ||
</div> | ||
|
||
## Texture size options | ||
|
||
Supported texture sizes include: 512 px, 1024 px, 2048 px, 4096 px, 8192 px, 16384 px. | ||
athenaz2 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
The default shadow texture size for all lights is 2K. The default max texture size is 16K, but for less powerful computers, it may be a lower value, like 8K. | ||
|
||
## Changing shadow texture size | ||
|
||
The shadow texture size can be changed for the GUI with the usage of the Minimal Scene GUI plugin in the SDF. | ||
|
||
### Example usage for the GUI | ||
|
||
Let's change the shadow texture size for directional light with the SDF file below. (The finished SDF file can be viewed [here](https://github.com/gazebosim/gz-sim/blob/main/examples/worlds/shadow_texture_size.sdf).) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. can you mention that we currently only support changing shadow texture size for directional lights? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yup = done here b48725b There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. oh can you also change the link to point to gz-sim9 branch? i.e. https://github.com/gazebosim/gz-sim/tree/gz-sim9/examples/worlds/shadow_texture_size.sdf |
||
|
||
1) Save the below in an SDF file named `shadow_texsize_demo.sdf`: | ||
athenaz2 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
```xml | ||
<?xml version="1.0" ?> | ||
<sdf version="1.9"> | ||
<world name="default"> | ||
<scene> | ||
<background>0.1 0.1 0.1</background> | ||
<ambient>0.0 0.0 0.0</ambient> | ||
</scene> | ||
|
||
<!--GUI plugins--> | ||
<gui> | ||
<plugin filename="MinimalScene" name="3D View"> | ||
<engine>ogre2</engine> | ||
<camera_pose>-10 0 7 0 0.5 0</camera_pose> | ||
</plugin> | ||
|
||
<plugin filename="GzSceneManager" name="Scene Manager"/> | ||
<plugin filename="InteractiveViewControl" name="Interactive view control"/> | ||
</gui> | ||
|
||
<!--lighting--> | ||
<light type="directional" name="sun"> | ||
<pose>0 0 8 0 0 0</pose> | ||
<diffuse>1 1 1 1</diffuse> | ||
<specular>0 0 0 0</specular> | ||
<attenuation> | ||
<range>50</range> | ||
<constant>0</constant> | ||
<linear>0</linear> | ||
<quadratic>0</quadratic> | ||
</attenuation> | ||
<cast_shadows>true</cast_shadows> | ||
<direction>-2 2 -1.5</direction> | ||
<intensity>1.0</intensity> | ||
</light> | ||
|
||
<!--scene objects--> | ||
<include> | ||
<pose>0 0 0 0 0 -1.57</pose> | ||
<uri> | ||
https://fuel.gazebosim.org/1.0/OpenRobotics/models/Garden Mascot | ||
</uri> | ||
</include> | ||
|
||
<model name="floor"> | ||
<pose>-5 0 -0.5 0 0 0</pose> | ||
<static>true</static> | ||
<link name="link"> | ||
<collision name="collision"> | ||
<geometry> | ||
<box> | ||
<size>15 15 1</size> | ||
</box> | ||
</geometry> | ||
</collision> | ||
<visual name="visual"> | ||
<geometry> | ||
<box> | ||
<size>15 15 1</size> | ||
</box> | ||
</geometry> | ||
<material> | ||
<ambient>0.8 0.8 0.8 1</ambient> | ||
<diffuse>0.8 0.8 0.8 1</diffuse> | ||
<specular>0.8 0.8 0.8 1</specular> | ||
</material> | ||
</visual> | ||
</link> | ||
</model> | ||
</world> | ||
</sdf> | ||
``` | ||
|
||
2) Add the following lines to the Minimal Scene GUI plugin. | ||
|
||
```xml | ||
</shadows> | ||
<texture_size light_type="directional">8192</texture_size> | ||
</shadows> | ||
``` | ||
|
||
The `<texture_size>` value can be changed as per the Texture size options section. | ||
|
||
3) Open the `shadow_texsize_demo.sdf` world with | ||
|
||
```bash | ||
gz sim shadow_texsize_demo.sdf | ||
athenaz2 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
``` | ||
|
||
## Impact on VRAM usage | ||
|
||
Keep in mind that the larger the shadow texture size, the more VRAM is used. Thus, in a scene populated with many lights, changing the directional light's shadow texture size should be fine because there is typically only one directional light in a scene. But if the scene has many point lights and the point light's shadow texture size is increased, the VRAM consumption goes up significantly. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
set this to
8192
as I see that's what the tutorial tells the user to do?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
0d21682