Browse Source

added glsl qualifiers

Alexander Rose 6 years ago
parent
commit
81cc4a4090

+ 1 - 1
src/mol-gl/shader/utils/attenuation.glsl

@@ -4,7 +4,7 @@
 //
 // Improved
 // https://imdoingitwrong.wordpress.com/2011/02/10/improved-light-attenuation/
-float attenuation(float r, float f, float d) {
+float attenuation(const in float r, const in float f, const in float d) {
     float denom = d / r + 1.0;
     float attenuation = 1.0 / (denom*denom);
     float t = (attenuation - f) / (1.0 - f);

+ 1 - 1
src/mol-gl/shader/utils/decode-float-rgba.glsl

@@ -1,4 +1,4 @@
-float decodeFloatRGBA(vec4 rgba) {
+float decodeFloatRGBA(const in vec4 rgba) {
     return dot(rgba, vec4(1.0, 1/255.0, 1/65025.0, 1/16581375.0));
 }
 

+ 4 - 4
src/mol-gl/shader/utils/inverse.glsl

@@ -1,16 +1,16 @@
 // (c) 2014 Mikola Lysenko. MIT License
 // https://github.com/glslify/glsl-inverse
 
-float inverse(float m) {
+float inverse(const in float m) {
   return 1.0 / m;
 }
 
-mat2 inverse(mat2 m) {
+mat2 inverse(const in mat2 m) {
   return mat2(m[1][1],-m[0][1],
              -m[1][0], m[0][0]) / (m[0][0]*m[1][1] - m[0][1]*m[1][0]);
 }
 
-mat3 inverse(mat3 m) {
+mat3 inverse(const in mat3 m) {
   float a00 = m[0][0], a01 = m[0][1], a02 = m[0][2];
   float a10 = m[1][0], a11 = m[1][1], a12 = m[1][2];
   float a20 = m[2][0], a21 = m[2][1], a22 = m[2][2];
@@ -26,7 +26,7 @@ mat3 inverse(mat3 m) {
               b21, (-a21 * a00 + a01 * a20), (a11 * a00 - a01 * a10)) / det;
 }
 
-mat4 inverse(mat4 m) {
+mat4 inverse(const in mat4 m) {
   float
       a00 = m[0][0], a01 = m[0][1], a02 = m[0][2], a03 = m[0][3],
       a10 = m[1][0], a11 = m[1][1], a12 = m[1][2], a13 = m[1][3],

+ 1 - 1
src/mol-gl/shader/utils/oren-nayar-diffuse.glsl

@@ -3,7 +3,7 @@
 
 #define PI 3.14159265
 
-float orenNayarDiffuse(vec3 lightDirection, vec3 viewDirection, vec3 surfaceNormal, float roughness, float albedo) {
+float orenNayarDiffuse(const in vec3 lightDirection, const in vec3 viewDirection, const in vec3 surfaceNormal, const in float roughness, const in float albedo) {
     float LdotV = dot(lightDirection, viewDirection);
     float NdotL = dot(lightDirection, surfaceNormal);
     float NdotV = dot(surfaceNormal, viewDirection);

+ 1 - 1
src/mol-gl/shader/utils/phong-specular.glsl

@@ -1,7 +1,7 @@
 // (c) 2014 Mikola Lysenko. MIT License
 // https://github.com/glslify/glsl-specular-phong
 
-float phongSpecular(vec3 lightDirection, vec3 viewDirection, vec3 surfaceNormal, float shininess) {
+float phongSpecular(const in vec3 lightDirection, const in vec3 viewDirection, const in vec3 surfaceNormal, const in float shininess) {
     //Calculate Phong power
     vec3 R = -reflect(lightDirection, surfaceNormal);
     return pow(max(0.0, dot(viewDirection, R)), shininess);

+ 1 - 1
src/mol-gl/shader/utils/read-from-texture.glsl

@@ -4,7 +4,7 @@
  * @author Alexander Rose <alexander.rose@weirdbyte.de>
  */
 
-vec3 read_vec3 (sampler2D tex, float i, vec2 size) {
+vec3 read_vec3 (const in sampler2D tex, const in float i, const in vec2 size) {
     float x = mod(i, size.x);
     float y = floor(i / size.x);
     vec2 uv = (vec2(x, y) + 0.5) / size;

+ 4 - 4
src/mol-gl/shader/utils/transpose.glsl

@@ -1,22 +1,22 @@
 // (c) 2014 Mikola Lysenko. MIT License
 // https://github.com/glslify/glsl-transpose
 
-float transpose(float m) {
+float transpose(const in float m) {
   return m;
 }
 
-mat2 transpose(mat2 m) {
+mat2 transpose(const in mat2 m) {
   return mat2(m[0][0], m[1][0],
               m[0][1], m[1][1]);
 }
 
-mat3 transpose(mat3 m) {
+mat3 transpose(const in mat3 m) {
   return mat3(m[0][0], m[1][0], m[2][0],
               m[0][1], m[1][1], m[2][1],
               m[0][2], m[1][2], m[2][2]);
 }
 
-mat4 transpose(mat4 m) {
+mat4 transpose(const in mat4 m) {
   return mat4(m[0][0], m[1][0], m[2][0], m[3][0],
               m[0][1], m[1][1], m[2][1], m[3][1],
               m[0][2], m[1][2], m[2][2], m[3][2],