stride icon indicating copy to clipboard operation
stride copied to clipboard

Fix implicit truncation of vector type shader warning

Open Basewq opened this issue 9 months ago • 0 comments

PR Details

Explicitly declare the data components used in the modulo operator & the data conversion to take place (ie. float modulo and convert to int2 data type).

Description

See above.

Related Issue

Using material Transparency -> Dithered Shadows (enabled by default) on a model would trigger "implicit truncation of vector type" warning at run-time. Feature was introduced in #1256

Motivation and Context

streams.ShadingPosition is float4 data type. The original code would do a float modulo operation returning a float4 and implicit convert to int2. This would trigger a warning due to zw components being dropped. While the explicit int2(...) is probably not needed, it's better to spell it out that we're not the same data type.

Types of changes

  • [ ] Docs change / refactoring / dependency upgrade
  • [X] Bug fix (non-breaking change which fixes an issue)
  • [ ] New feature (non-breaking change which adds functionality)
  • [ ] Breaking change (fix or feature that would cause existing functionality to change)

Checklist

  • [ ] My change requires a change to the documentation.
  • [ ] I have added tests to cover my changes.
  • [ ] All new and existing tests passed.
  • [ ] I have built and run the editor to try this change out.

Full disclosure: I did not build/run the editor. I tested the original line & modified line on a local project with a custom shader. The original line triggered the warning on the project, and the modified line did not trigger the warning - the app did not crash.

Basewq avatar May 12 '24 12:05 Basewq