Skip to content

Commit

Permalink
[rendering] fixed an issue where the shadow maps would not emulate wi…
Browse files Browse the repository at this point in the history
…nd animation for point lights, causing animated vertices to come in and out of light in a wrong way
  • Loading branch information
PanosK92 committed Jan 7, 2025
1 parent b1a6748 commit e496b1b
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 23 deletions.
49 changes: 26 additions & 23 deletions data/shaders/common_vertex_processing.hlsl
Original file line number Diff line number Diff line change
Expand Up @@ -265,34 +265,37 @@ gbuffer_vertex transform_to_world_space(Vertex_PosUvNorTan input, uint instance_
vertex.transform = transform;
vertex.transform_previous = transform_previous;

// vertex processing
{
// get material and surface
MaterialParameters material = GetMaterial();
Surface surface; surface.flags = material.flags;

// apply ambient animation - done here so that it can benefit from potentially tessellated surfaces
vertex.position = vertex_processing::ambient_animation(
surface,
vertex.position,
extract_position(vertex.transform),
vertex.instance_id,
buffer_frame.wind,
(float)buffer_frame.time
);

vertex.position_previous = vertex_processing::ambient_animation(
surface,
vertex.position_previous,
extract_position(vertex.transform_previous),
vertex.instance_id,
buffer_frame.wind,
(float)buffer_frame.time - buffer_frame.delta_time
);
}

return vertex;
}

gbuffer_vertex transform_to_clip_space(gbuffer_vertex vertex)
{
// get material and surface
MaterialParameters material = GetMaterial();
Surface surface; surface.flags = material.flags;

// apply ambient animation - done here so that it can benefit from potentially tessellated surfaces
vertex.position = vertex_processing::ambient_animation(
surface,
vertex.position,
extract_position(vertex.transform),
vertex.instance_id,
buffer_frame.wind,
(float)buffer_frame.time
);

vertex.position_previous = vertex_processing::ambient_animation(
surface,
vertex.position_previous,
extract_position(vertex.transform_previous),
vertex.instance_id,
buffer_frame.wind,
(float)buffer_frame.time - buffer_frame.delta_time
);

vertex.position_clip = mul(float4(vertex.position, 1.0f), pass_is_transparent() ? buffer_frame.view_projection_unjittered : buffer_frame.view_projection);
vertex.position_clip_current = vertex.position_clip;
vertex.position_clip_previous = mul(float4(vertex.position_previous, 1.0f), pass_is_transparent() ? buffer_frame.view_projection_previous_unjittered : buffer_frame.view_projection_previous);
Expand Down
9 changes: 9 additions & 0 deletions runtime/Game/Game.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -754,18 +754,27 @@ namespace Spartan

// disable back face culling and enable wind
{
// these are the ropes and the metal rings that hold them
if (Material* material = entity->GetDescendantByName("curtain_03_1")->GetComponent<Renderable>()->GetMaterial())
{
material->SetProperty(MaterialProperty::WindAnimation, 1.0f);
}

// this is fabric
if (Material* material = entity->GetDescendantByName("curtain_03_2")->GetComponent<Renderable>()->GetMaterial())
{
material->SetProperty(MaterialProperty::CullMode, static_cast<float>(RHI_CullMode::None));
material->SetProperty(MaterialProperty::WindAnimation, 1.0f);
}

// this is fabric
if (Material* material = entity->GetDescendantByName("curtain_03_3")->GetComponent<Renderable>()->GetMaterial())
{
material->SetProperty(MaterialProperty::CullMode, static_cast<float>(RHI_CullMode::None));
material->SetProperty(MaterialProperty::WindAnimation, 1.0f);
}

// this is fabric
if (Material* material = entity->GetDescendantByName("curtain_hanging_06_3")->GetComponent<Renderable>()->GetMaterial())
{
material->SetProperty(MaterialProperty::CullMode, static_cast<float>(RHI_CullMode::None));
Expand Down

0 comments on commit e496b1b

Please sign in to comment.