Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
deeptronos opened this issue Dec 3, 2021 · 0 comments
Open

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

deeptronos opened this issue Dec 3, 2021 · 0 comments

Comments

@deeptronos
Copy link

deeptronos commented Dec 3, 2021

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))

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant