All Downloads are FREE. Search and download functionalities are using the official Maven repository.

Common.ShaderLib.GLSLCompat.glsllib Maven / Gradle / Ivy

The newest version!
#ifdef GL_ES
  #ifdef FRAGMENT_SHADER
    precision highp float;
    precision highp int;
    precision highp sampler2DArray;
    precision highp sampler2DShadow;
    precision highp samplerCube;
    precision highp sampler3D;
    precision highp sampler2D;
    #if __VERSION__ >= 310
      precision highp sampler2DMS;
    #endif
  #endif
#endif

#if defined GL_ES
#  define hfloat highp float
#  define hvec2  highp vec2
#  define hvec3  highp vec3
#  define hvec4  highp vec4
#  define lfloat lowp float
#  define lvec2 lowp vec2
#  define lvec3 lowp vec3
#  define lvec4 lowp vec4
#else
#  define hfloat float
#  define hvec2  vec2
#  define hvec3  vec3
#  define hvec4  vec4
#  define lfloat float
#  define lvec2  vec2
#  define lvec3  vec3
#  define lvec4  vec4
#endif

#if __VERSION__ >= 130

#ifdef FRAGMENT_SHADER
  #ifdef GL_ES
    #ifdef BOUND_DRAW_BUFFER
      #for i=0..15 ( #if $i<=BOUND_DRAW_BUFFER  $0 #endif ) 
        #if BOUND_DRAW_BUFFER == $i
          layout( location = $i ) out highp vec4 outFragColor;
        #else
          layout( location = $i ) out highp vec4 outNOP$i;
        #endif
      #endfor
    #else
      out highp vec4 outFragColor;
    #endif
  #else
    out vec4 outFragColor;
  #endif
#endif

#  define texture1D texture
#  define texture2D texture
#  define texture3D texture
#  define textureCube texture
#  define texture2DLod textureLod
#  define textureCubeLod textureLod
#  define texture2DArray texture
#  if defined VERTEX_SHADER
#    define varying out
#    define attribute in
#  elif defined FRAGMENT_SHADER
#    define varying in
#    define gl_FragColor outFragColor
#  endif
#else
#  define isnan(val) !(val<0.0||val>0.0||val==0.0)
#endif

#if __VERSION__ == 110
mat3 mat3_sub(mat4 m) {
  return mat3(m[0].xyz, m[1].xyz, m[2].xyz);
}
#else
 #define mat3_sub mat3
#endif

#if __VERSION__ <= 140
float determinant(mat2 m) {
  return m[0][0] * m[1][1] - m[1][0] * m[0][1];
}

float determinant(mat3 m) {
  return  + m[0][0] * (m[1][1] * m[2][2] - m[1][2] * m[2][1])
          - m[0][1] * (m[1][0] * m[2][2] - m[1][2] * m[2][0])
          + m[0][2] * (m[1][0] * m[2][1] - m[1][1] * m[2][0]);
}
#endif

#if __VERSION__ <= 130
mat2 inverse(mat2 m) {
  return mat2(m[1][1], -m[0][1], -m[1][0], m[0][0]) / determinant(m);
}

mat3 inverse(mat3 m) {
  return mat3(
    + (m[1][1] * m[2][2] - m[2][1] * m[1][2]),
    - (m[1][0] * m[2][2] - m[2][0] * m[1][2]),
    + (m[1][0] * m[2][1] - m[2][0] * m[1][1]),
    - (m[0][1] * m[2][2] - m[2][1] * m[0][2]),
    + (m[0][0] * m[2][2] - m[2][0] * m[0][2]),
    - (m[0][0] * m[2][1] - m[2][0] * m[0][1]),
    + (m[0][1] * m[1][2] - m[1][1] * m[0][2]),
    - (m[0][0] * m[1][2] - m[1][0] * m[0][2]),
    + (m[0][0] * m[1][1] - m[1][0] * m[0][1])) / determinant(m);
}
#endif





© 2015 - 2024 Weber Informatics LLC | Privacy Policy