Skip to content
Snippets Groups Projects
Commit 81cc4a40 authored by Alexander Rose's avatar Alexander Rose
Browse files

added glsl qualifiers

parent 71590f3a
Branches
Tags
No related merge requests found
......@@ -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);
......
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));
}
......
// (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],
......
......@@ -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);
......
// (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);
......
......@@ -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;
......
// (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],
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment