Skip to content

"mod()" conversion from Shadertoy to Unity is inaccurate. #41

@deeptronos

Description

@deeptronos

I was trying to get this shader running in Unity, and while the original ShaderMan conversion had many errors that I could fix just by intuitively going between the Unity .shader file, the original ShaderToy upload file, and this primitive guide, there was still a weird difference between the .shader's results and the original. After lots of trial and error, I found out from the last response in this forum thread that the HLSL fmod() function that ShaderMan used to replace usages of GLSL's mod() is inaccurate to the math that mod() does in GLSL. The easiest way to get the same functionality in HLSL is to#define a new mod() as such:

#define mod(x, y) (x - y * floor(x / y))

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions