This repository has been archived by the owner on Feb 3, 2025. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 498
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Custom shadow caster materials (#3048)
This allows the shadow caster material name to be specified in a `<ignition:shadow_caster_material_name/>` SDFormat element under `<scene/>`. To avoid breaking ABI, this data is not added to the `scene.proto` message, but instead is exposed through an ign-transport service named `/shadow_caster_material_name` by `physics::World`. An example material is provided that avoids heightmap self-shadowing and is used in a test. Signed-off-by: William Lew <WilliamMilesLew@gmail.com> * Improve console messages * Remove input parameter from service Signed-off-by: Steven Peters <scpeters@openrobotics.org> Co-authored-by: Steven Peters <scpeters@openrobotics.org>
- Loading branch information
1 parent
88afb77
commit 42f7e48
Showing
15 changed files
with
469 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
25 changes: 25 additions & 0 deletions
25
media/materials/programs/shadow_caster_ignore_heightmap_fp.glsl
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
uniform vec4 camera_position; | ||
uniform mat4 world_matrix; | ||
|
||
// uniform vec4 depth_range; | ||
varying vec4 vertex_depth; | ||
|
||
void main() | ||
{ | ||
float depth = (vertex_depth.z) / vertex_depth.w; | ||
|
||
// Linear | ||
// float depth = (vertex_depth.z - depth_range.x) / depth_range.w; | ||
|
||
vec4 magicVector1 = vec4(1.0, 0.0, 0.0, 0.0); | ||
vec4 magicVector2 = vec4(0.0, 1.0, 0.0, 0.0); | ||
vec4 magicVector3 = vec4(0.0, 0.0, 1.0, 0.0); | ||
|
||
bool matchingVectors = (magicVector1 == world_matrix[0] && magicVector2 == world_matrix[1] && magicVector3 == world_matrix[2]); | ||
|
||
if (length(camera_position.xyz) == 0 && matchingVectors) { | ||
depth = 1.0; | ||
} | ||
|
||
gl_FragColor = vec4(depth, depth, depth, 1.0); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
41 changes: 41 additions & 0 deletions
41
media/materials/scripts/shadow_caster_ignore_heightmap.program
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
vertex_program shadow_caster_vp_glsl glsl | ||
{ | ||
source shadow_caster_vp.glsl | ||
|
||
default_params | ||
{ | ||
param_named_auto world_view_proj_mat worldviewproj_matrix | ||
param_named_auto texel_offsets texel_offsets | ||
} | ||
} | ||
|
||
fragment_program shadow_caster_ignore_heightmap_fp_glsl glsl | ||
{ | ||
source shadow_caster_ignore_heightmap_fp.glsl | ||
|
||
default_params | ||
{ | ||
param_named_auto camera_position camera_position | ||
param_named_auto world_matrix world_matrix | ||
// param_named_auto depth_range shadow_scene_depth_range | ||
} | ||
} | ||
|
||
|
||
material Gazebo/shadow_caster_ignore_heightmap | ||
{ | ||
technique | ||
{ | ||
// all this will do is write depth and depth*depth to red and green | ||
pass | ||
{ | ||
vertex_program_ref shadow_caster_vp_glsl | ||
{ | ||
} | ||
|
||
fragment_program_ref shadow_caster_ignore_heightmap_fp_glsl | ||
{ | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.