Skip to content

Commit

Permalink
Merge pull request #26 from BredaUniversityGames/revert-20-ja-texture…
Browse files Browse the repository at this point in the history
…-alpha-improvement

Revert "Improved texture sampling to allow for soft/dithered texture edges."
  • Loading branch information
SamBoots authored Jun 8, 2024
2 parents afae0c4 + ea96606 commit c481f08
Showing 1 changed file with 15 additions and 8 deletions.
23 changes: 15 additions & 8 deletions RT/Renderer/Backend/DX12/assets/shaders/include/common.hlsl
Original file line number Diff line number Diff line change
Expand Up @@ -768,10 +768,6 @@ bool IsHitTransparent(uint instance_idx, uint primitive_idx, float2 barycentrics
};
float2 uv = GetHitAttribute(uvs, barycentrics);
float2 uv_rotated = GetRotatedUVs(orient, uv);
float4 color = UnpackRGBA(instance_data.material_color);
float4 tri_color = UnpackRGBA(hit_triangle.color);
float base_alpha = color.a * tri_color.a;
float dither = RandomSample(pixel_pos, instance_idx);

// TODO(daniel): Clean this messy silly code up!
if (material_index2 != 0xFFFFFFFF)
Expand All @@ -787,18 +783,29 @@ bool IsHitTransparent(uint instance_idx, uint primitive_idx, float2 barycentrics
return true;
}

if (albedo2.a >= dither)
if (albedo2.a > 0.0)
{
material = g_materials[material_index2];
return dither >= base_alpha;
material_index = material_index2;
uv = uv_rotated;
}
}

material = g_materials[material_index];
Texture2D tex_albedo = GetTextureFromIndex(material.albedo_index);
float4 albedo = tex_albedo.SampleLevel(g_sampler_point_wrap, uv, 0);

return dither >= albedo.a * base_alpha;
if (albedo.a == 0.0)
{
return true;
}
else
{
float4 color = UnpackRGBA(instance_data.material_color);
float4 tri_color = UnpackRGBA(hit_triangle.color);
float dither = RandomSample(pixel_pos, instance_idx);

return dither > color.a * tri_color.a;
}
}

// -----------------------------------------------------------
Expand Down

0 comments on commit c481f08

Please sign in to comment.