Updated HLSL samplers to DirectX 10 syntax #166
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Currently
SAMPLER_TYPE
is defined in HLSL as sampler2D, which is the obsolete DirectX 9 syntax from 2002.This works fine with the old Unity Built-In render pipeline (BRP), which is itself deprecated.
However, it is not compatible with the newer URP and HDRP pipelines which are meant to supersede BRP. URP and HDRP use the Direct X 10 syntax (released in 2006).
Direct X 10 replaces the old
sampler2D
with Texture objects (eg.Texture2D
) which also provide added benefits, like decoupling the texture object from the sampler state, querying size and max lod, etc...Unreal also uses the DirectX 10 syntax exclusively.
This means texture-related functions in Lygia are currently unusable with Unity URP, Unity HDRP and Unreal.
I have updated the samplers to the DirectX 10 syntax in order to remedy this issue (which is also what has been done in the Lygia Unreal Examples repo).
I have defined a default sample state
DEFAULT_SAMPLER_STATE defaultLinearClampSampler
, which meansSAMPLER_FNC(TEX, UV)
still takes two arguments and no other change is required in Lygia.The new syntax is perfectly compatible with Unity BRP, however the examples need to be slightly updated (
sampler2D
becomesTexture2D
), I'll follow up with a PR of the Unity examples as soon as this one is merged.