Converting HLSL shaders to GLSL shaders is quite straightforward.

Here are some of the syntax that needs to be changed for them to work as GLSL shaders.


  1. Replace Texture2D with sampler2D
  2. Replace fragment function with void main() {
  3. Replace matrices
    1. Replace float3x3 with mat3
    2. Replace float4x4 with mat4
    3. Replace float2x2 with mat2
    4. Change order of elements. HLSL is row mayor, whereas GLSL is column major
  4. replace float2 with vec2
  5. replace float3 with vec3
  6. replace float4 with vec4
  7. Change Load to texelFetch
  8. Replace Sample with texture
  9. Replace return with Output =