Skip to content

Instantly share code, notes, and snippets.

@makidoll
Last active August 9, 2022 17:27
Show Gist options
  • Save makidoll/7b048e3a3a052a94334d106d1dd2e54b to your computer and use it in GitHub Desktop.
Save makidoll/7b048e3a3a052a94334d106d1dd2e54b to your computer and use it in GitHub Desktop.
Convert GLSL to HLSL with 100% precision!

Convert GLSL to HLSL with 100% precision!

Have you tried translating GLSL code to HLSL and for some reason it never works, even through you've gone through it line by line? For example with noise functions.

Then do this!

  • Save your shader to a file and add to the top:
    #version 460
    precision mediump float;
    and make sure to add a main() function, calling your function such as:
    void main() {
      // code here so it doesn't get optimized away
    }
    
  • Download glslcc and run
    glslcc.exe --frag=shader.glsl --output=shader --lang=hlsl
  • Now you have cursed hlsl but working code! float param_1 = youreWelcome.z.xxxx
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment