Shader Conversion
Table of contents
HLSL to GLSL
Converting HLSL shaders to Flair GLSL shaders is quite straightforward. Here is the main syntax that needs to be changed.
- Replace
Texture2D
withsampler2D
- Replace fragment function with
void main() {
- Replace matrices
- Replace
float2x2
withmat2
- Replace
float3x3
withmat3
- Replace
float4x4
withmat4
- Change order of elements. HLSL is row mayor, whereas GLSL is column major
- Replace
- replace
float2
withvec2
- replace
float3
withvec3
- replace
float4
withvec4
- Change Load to texelFetch
- replace
Load
withtexelFetch
- replace
int3 loc = int3(i.pos.xy
withivec2 loc = ivec2(gl_FragCoord.xy
- replace
- Replace Sample with texture
- replace
Sample
withtexture
- replace
i.uv
withf_texcoord
- replace
- Replace
return
withOutput =