/**
 * @file diffuseSkinnedV.glsl
 *
 * Copyright (c) 2007-$CurrentYear$, Linden Research, Inc.
 * $License$
 */

#version 120

mat4 getObjectSkinnedTransform();

void main()
{
	//transform vertex
	gl_TexCoord[0] = gl_TextureMatrix[0] * gl_MultiTexCoord0;

	mat4 mat = getObjectSkinnedTransform();

	mat = gl_ModelViewMatrix * mat;
	vec3 pos = (mat*gl_Vertex).xyz;

	gl_FrontColor = gl_Color;

	gl_Position = gl_ProjectionMatrix*vec4(pos, 1.0);
}

Fix for broken shadows on rigged attachments when attachment penetrates shadow frustum near clip plane.

/**
 * @file attachmentShadowV.glsl
 *
 * Copyright (c) 2007-$CurrentYear$, Linden Research, Inc.
 * $License$
 */

#version 120

mat4 getObjectSkinnedTransform();

void main()
{
	//transform vertex
	gl_TexCoord[0] = gl_TextureMatrix[0] * gl_MultiTexCoord0;

	mat4 mat = getObjectSkinnedTransform();

	mat = gl_ModelViewMatrix * mat;
	vec3 pos = (mat*gl_Vertex).xyz;

	gl_FrontColor = gl_Color;

	vec4 p = gl_ProjectionMatrix * vec4(pos, 1.0);
	p.z = max(p.z, -p.w+0.01);
	gl_Position = p;
}


COMMONDEFS=$(srcdir)/gtk-types.defs $(srcdir)/gdk-types.defs \
		   $(srcdir)/atk-types.defs $(srcdir)/pango-types.defs

GTK_OVERRIDES = \
	$(srcdir)/gtk.overrides \
	$(srcdir)/gtkcontainer.overrides \
	$(srcdir)/gtkstyle.overrides \
	$(srcdir)/gtktextview.overrides \
	$(srcdir)/gtktreeview.overrides

$(builddir)/gen_gtk.c: $(srcdir)/gtk.defs $(COMMONDEFS) $(srcdir)/gtk-extrafuncs.defs $(GTK_OVERRIDES)
$(builddir)/gen_gdk.c: $(srcdir)/gdk.defs $(COMMONDEFS) $(srcdir)/gdk.overrides
$(builddir)/gen_atk.c: $(COMMONDEFS) $(srcdir)/atk.overrides
$(builddir)/gen_pango.c: $(COMMONDEFS) $(srcdir)/pango.overrides

gen_%.c : %.defs
	( \
     $(PHP) $(top_srcdir)/generator/generator.php \
	 	-l $(@D)/gen_$(*F).log \
        -r $(*D)/atk-types.defs \
        -r $(*D)/pango-types.defs \
        -r $(*D)/gdk-types.defs \
        -r $(*D)/gtk-types.defs \
        -o $*.overrides \
        -p $(*F) \
        -f $@ $*.defs \
     && grep -h "^PHP_GTK_EXPORT_CE" $@ | sed -e "s!^!extern !" > $(@D)/gen_$(*F).h \
	)

Adjust paths to common defs.

COMMONDEFS=$(srcdir)/gtk-types.defs $(srcdir)/gdk-types.defs \
		   $(srcdir)/atk-types.defs $(srcdir)/pango-types.defs

GTK_OVERRIDES = \
	$(srcdir)/gtk.overrides \
	$(srcdir)/gtkcontainer.overrides \
	$(srcdir)/gtkstyle.overrides \
	$(srcdir)/gtktextview.overrides \
	$(srcdir)/gtktreeview.overrides

$(builddir)/gen_gtk.c: $(srcdir)/gtk.defs $(COMMONDEFS) $(srcdir)/gtk-extrafuncs.defs $(GTK_OVERRIDES)
$(builddir)/gen_gdk.c: $(srcdir)/gdk.defs $(COMMONDEFS) $(srcdir)/gdk.overrides
$(builddir)/gen_atk.c: $(COMMONDEFS) $(srcdir)/atk.overrides
$(builddir)/gen_pango.c: $(COMMONDEFS) $(srcdir)/pango.overrides

gen_%.c : %.defs
	( \
     $(PHP) $(top_srcdir)/generator/generator.php \
	 	-l $(@D)/gen_$(*F).log \
        -r ext/gtk+/atk-types.defs   \
        -r ext/gtk+/pango-types.defs \
        -r ext/gtk+/gdk-types.defs   \
        -r ext/gtk+/gtk-types.defs   \
        -o $*.overrides \
        -p $(*F) \
        -f $@ $*.defs \
     && grep -h "^PHP_GTK_EXPORT_CE" $@ | sed -e "s!^!extern !" > $(@D)/gen_$(*F).h \
	)


a = 50;
lt = a; // this needs to be bigger than the stuff below, so let's just use "a"
Point(1) = {-a,-a,-a, lt};
Point(2) = {-a,a,-a, lt};
Point(3) = {a, a,-a, lt};
Point(4) = {a,-a,-a, lt};
Line(1) = {1,4};
Line(2) = {4,3};
Line(3) = {3,2};
Line(4) = {2,1};
Line Loop(5) = {2,3,4,1};
Plane Surface(6) = {5};
Physical Surface(1) = {6};

Field[1] = MathEval;
// This is generated using the formula a/5-(a/5-a/50)*(Cos(3.14*x/a)+..)/2
Field[1].F = "10-(10-1)*(Cos(3.14*x/50)+Cos(3.14*y/50))/2";

Background Field = 1;

Make the mesh even more dense to be more accurate.

a = 50;
lt = a; // this needs to be bigger than the stuff below, so let's just use "a"
Point(1) = {-a,-a,-a, lt};
Point(2) = {-a,a,-a, lt};
Point(3) = {a, a,-a, lt};
Point(4) = {a,-a,-a, lt};
Line(1) = {1,4};
Line(2) = {4,3};
Line(3) = {3,2};
Line(4) = {2,1};
Line Loop(5) = {2,3,4,1};
Plane Surface(6) = {5};
Physical Surface(1) = {6};

Field[1] = MathEval;
// This is generated using the formula a/5-(a/5-a/50)*(Cos(3.14*x/a)+..)/2
Field[1].F = "10-(10-0.05)*(Cos(3.14*x/50)+Cos(3.14*y/50))/2";

Background Field = 1;


uniform vec3 color;
uniform sampler2D texture;

void main() {
  vec4 input = texture2D(texture, gl_TexCoord[0].xy);

  // Add to base color by default. Negative values can be used for subtractive dyeing otherwise.
  vec4 dye = vec4(1.0 + color[0], 1.0 + color[1], 1.0 + color[2], 1.0);

  // Apply to a grayscale version of the image.
  float average = (input.r + input.g + input.b) / 3.0;
  vec4 gray = vec4(average, average, average, input.a);

  gl_FragColor = vec4(gray * dye);
}

Stop using reserved word in colorize shader

uniform vec3 color;
uniform sampler2D texture;

void main() {
  vec4 origColor = texture2D(texture, gl_TexCoord[0].xy);

  // Add to base color by default. Negative values can be used for subtractive dyeing otherwise.
  vec4 dye = vec4(1.0 + color[0], 1.0 + color[1], 1.0 + color[2], 1.0);

  // Apply to a grayscale version of the image.
  float average = (origColor.r + origColor.g + origColor.b) / 3.0;
  vec4 gray = vec4(average, average, average, origColor.a);

  gl_FragColor = vec4(gray * dye);
}


uniform sampler2D colorTexture;

#ifdef DEBUG_SHOW_DEPTH
uniform sampler2D u_packedTranslucentDepth;
#endif

varying vec2 v_textureCoordinates;

void main()
{
#ifdef DEBUG_SHOW_DEPTH
    if (v_textureCoordinates.x < 0.5)
    {
        gl_FragColor.rgb = vec3(czm_unpackDepth(texture2D(u_packedTranslucentDepth, v_textureCoordinates)));
        gl_FragColor.a = 1.0;
    }
#else
    vec4 color = texture2D(colorTexture, v_textureCoordinates);

#ifdef PICK
    if (color == vec4(0.0))
    {
        discard;
    }
#endif
    gl_FragColor = color;
#endif
}

Fix classification color by doing premultiplied alpha

uniform sampler2D colorTexture;

#ifdef DEBUG_SHOW_DEPTH
uniform sampler2D u_packedTranslucentDepth;
#endif

varying vec2 v_textureCoordinates;

void main()
{
#ifdef DEBUG_SHOW_DEPTH
    if (v_textureCoordinates.x < 0.5)
    {
        gl_FragColor.rgb = vec3(czm_unpackDepth(texture2D(u_packedTranslucentDepth, v_textureCoordinates)));
        gl_FragColor.a = 1.0;
    }
#else
    vec4 color = texture2D(colorTexture, v_textureCoordinates);

#ifdef PICK
    if (color == vec4(0.0))
    {
        discard;
    }
#else
    // Reverse premultiplication process to get the correct composited result of the classification primitives
    color.rgb /= color.a;
#endif
    gl_FragColor = color;
#endif
}


#version 440

in float amplitude;
in float radius;
in vec2 centerPosition;
in vec2 direction;
layout(location = 0) out vec3 heightMap;

uniform ivec2 heightMapSize;

float BlendFunction(float distanceFromCenter)
{
	float value = distanceFromCenter / (2 * radius);
	if(value < 0.5)
		return 1.0;
	if(value == 0.5)
		return value;
	else
		return 0.0;
}

float ComputeHeight(float distanceFromCenter)
{
	return (amplitude / 2.0) * (cos(3.14159 * distanceFromCenter /  radius) + 1.0) * BlendFunction(distanceFromCenter);
}

vec2 ComputeHorizontalDisplacement(float distanceFromCenter)
{
	float u = length(direction * distanceFromCenter);
	return -sin(3.14159 * u / radius) * BlendFunction(u) * direction;
}

void main()
{
	float distanceFromCenter = 2 * radius * distance(gl_PointCoord , vec2(0.5,0.5));
	float height = ComputeHeight(distanceFromCenter);
	vec2 horizontalDisplacement = ComputeHorizontalDisplacement(distanceFromCenter) * height;
	heightMap = vec3(height,horizontalDisplacement);
}

Fix deplacement horizontal wave particle

#version 440

in float amplitude;
in float radius;
in vec2 centerPosition;
in vec2 direction;
layout(location = 0) out vec3 heightMap;

uniform ivec2 heightMapSize;

float BlendFunction(float distanceFromCenter)
{
	float value = distanceFromCenter / (2 * radius);
	if(value < 0.5)
		return 1.0;
	if(value == 0.5)
		return value;
	else
		return 0.0;
}

float ComputeHeight(float distanceFromCenter)
{
	return (amplitude / 2.0) * (cos(3.14159 * distanceFromCenter /  radius) + 1.0) * BlendFunction(distanceFromCenter);
}

vec2 ComputeHorizontalDisplacement(float distanceFromCenter)
{
	float u = length(direction * distanceFromCenter);
	return -sin(2 * 3.14159 * u / radius) * BlendFunction(u) * direction;
}

void main()
{
	float distanceFromCenter = 2 * radius * distance(gl_PointCoord , vec2(0.5,0.5));
	float height = ComputeHeight(distanceFromCenter);
	vec2 horizontalDisplacement = ComputeHorizontalDisplacement(distanceFromCenter) * height;
	heightMap = vec3(height,horizontalDisplacement);
}


PhysicalMaterial material;

#ifdef STANDARD_SG
	material.diffuseColor = diffuseColor.rgb * ( 1.0 - max( max( specular2Factor.r, specular2Factor.g ), specular2Factor.b ) );
	material.specularRoughness = clamp( 1.0 - glossinessFactor, 0.04, 1.0 );
	material.specularColor = specular2Factor.rgb;
#else
	material.diffuseColor = diffuseColor.rgb * ( 1.0 - metalnessFactor );
	material.specularRoughness = clamp( roughnessFactor, 0.04, 1.0 );
	#ifdef STANDARD
		material.specularColor = mix( vec3( DEFAULT_SPECULAR_COEFFICIENT ), diffuseColor.rgb, metalnessFactor );
	#else
		material.specularColor = mix( vec3( MAXIMUM_SPECULAR_COEFFICIENT * pow2( reflectivity ) ), diffuseColor.rgb, metalnessFactor );
		material.clearCoat = saturate( clearCoat ); // Burley clearcoat model
		material.clearCoatRoughness = clamp( clearCoatRoughness, 0.04, 1.0 );
	#endif
#endif

Fix diffuse shader code of Specular-Glossiness

PhysicalMaterial material;

#ifdef STANDARD_SG
	material.diffuseColor = diffuseColor.rgb;
	material.specularRoughness = clamp( 1.0 - glossinessFactor, 0.04, 1.0 );
	material.specularColor = specular2Factor.rgb;
#else
	material.diffuseColor = diffuseColor.rgb * ( 1.0 - metalnessFactor );
	material.specularRoughness = clamp( roughnessFactor, 0.04, 1.0 );
	#ifdef STANDARD
		material.specularColor = mix( vec3( DEFAULT_SPECULAR_COEFFICIENT ), diffuseColor.rgb, metalnessFactor );
	#else
		material.specularColor = mix( vec3( MAXIMUM_SPECULAR_COEFFICIENT * pow2( reflectivity ) ), diffuseColor.rgb, metalnessFactor );
		material.clearCoat = saturate( clearCoat ); // Burley clearcoat model
		material.clearCoatRoughness = clamp( clearCoatRoughness, 0.04, 1.0 );
	#endif
#endif


precision mediump float;
varying vec2 vTextureCoords;
varying vec4 vColour;
varying float distance;
uniform sampler2D sTexture;
uniform vec4 uMod;
uniform vec4 uFade;
uniform vec4 uFog;

void main() {

    gl_FragColor = texture2D( sTexture, vTextureCoords );

    if ( gl_FragColor.a < 0.5 ) {
        discard;
    }

  gl_FragColor = gl_FragColor * uFade.a;

}

Bring back the lightning modulation

precision mediump float;
varying vec2 vTextureCoords;
varying vec4 vColour;
varying float distance;
uniform sampler2D sTexture;
uniform vec4 uMod;
uniform vec4 uFade;
uniform vec4 uFog;

void main() {

    gl_FragColor = texture2D( sTexture, vTextureCoords );

    if ( gl_FragColor.a < 0.5 ) {
        discard;
    }

  gl_FragColor = gl_FragColor * uFade.a * uMod;

}


#version 130

uniform mat4 modelViewMatrix;
uniform mat4 projectionMatrix;
uniform mat4 modelViewProjectionMatrix;

#if defined(VERTEX_SHADER)
uniform vec3 color = vec3(1.0);

in vec3 position;
in vec3 normal;
out vec3 position_eye;

void main()
{
    gl_Position = modelViewProjectionMatrix * vec4(position,1.0);
    position_eye = (modelViewMatrix * vec4(position,1.0)).xyz;
    //gl_FrontColor = vec4(color*abs(dot(normal, lightDir)), 1.0);
}

//------------------------------------------------------------------------------
#elif defined(FRAGMENT_SHADER)
uniform vec3 lightDir_eye = vec3(0.0,0.0,-1.0);
in vec3 position_eye;

out vec4 fragColor;

// Faceted shading, without requiring special support in the C++ code.
void main()
{
    vec3 normal = normalize(cross(dFdx(position_eye), dFdy(position_eye)));
    fragColor = vec4(vec3(abs(dot(normal, lightDir_eye))), 1);
}
#endif

Support per-vertex colors in mesh face shader

#version 130

uniform mat4 modelViewMatrix;
uniform mat4 projectionMatrix;
uniform mat4 modelViewProjectionMatrix;

#if defined(VERTEX_SHADER)
in vec3 position;
in vec3 normal;
in vec3 color;
out vec3 position_eye;
out vec3 fcolor;

void main()
{
    gl_Position = modelViewProjectionMatrix * vec4(position,1.0);
    position_eye = (modelViewMatrix * vec4(position,1.0)).xyz;
    fcolor = color;
    //gl_FrontColor = vec4(color*abs(dot(normal, lightDir)), 1.0);
}

//------------------------------------------------------------------------------
#elif defined(FRAGMENT_SHADER)
uniform vec3 lightDir_eye = vec3(0.0,0.0,-1.0);
in vec3 position_eye;
in vec3 fcolor;

out vec4 fragColor;

// Faceted shading, without requiring special support in the C++ code.
void main()
{
    vec3 normal = normalize(cross(dFdx(position_eye), dFdy(position_eye)));
    fragColor = vec4(fcolor*abs(dot(normal, lightDir_eye)), 1);
}
#endif


#ifdef GL_ES
precision highp float;
#endif

// TODO: This should probably be configurable somewhere
#define MAX_JOINT_COUNT 4

attribute vec3 vertexPosition;
attribute vec3 vertexNormal;

attribute float vertexJointA;
attribute float vertexWeightA;
attribute float vertexJointB;
attribute float vertexWeightB;

uniform float scaleFactor;

uniform mat4 modelToWorld;
uniform mat4 worldToView;
uniform mat4 projection;

uniform mat4 jointMatrices[MAX_JOINT_COUNT];

uniform vec4 sunLight;
uniform vec4 fillColor;

varying vec4 vertexColor;

void main(void) {
	vec4 scaledPosition = vec4(scaleFactor * vertexPosition, 1.0);
	vec4 positionA = jointMatrices[int(vertexJointA)] * scaledPosition;
	vec4 positionB = jointMatrices[int(vertexJointB)] * scaledPosition;
	vec4 weightedPosition = positionA * vertexWeightA + positionB * vertexWeightB;

	gl_Position = projection * (worldToView * (modelToWorld * weightedPosition));

	vec3 normalInView = normalize((worldToView * (modelToWorld * vec4(vertexNormal, 0.0))).xyz);
	float sunLightIncidence = max(0.0, dot(normalInView, sunLight.xyz));
	vertexColor = vec4(fillColor.rgb * mix(1.0, sunLightIncidence, sunLight.w), 1.0);
}

Transform the normals based on joint information

#ifdef GL_ES
precision highp float;
#endif

// TODO: This should probably be configurable somewhere
#define MAX_JOINT_COUNT 4

attribute vec3 vertexPosition;
attribute vec3 vertexNormal;

attribute float vertexJointA;
attribute float vertexWeightA;
attribute float vertexJointB;
attribute float vertexWeightB;

uniform float scaleFactor;

uniform mat4 modelToWorld;
uniform mat4 worldToView;
uniform mat4 projection;

uniform mat4 jointMatrices[MAX_JOINT_COUNT];

uniform vec4 sunLight;
uniform vec4 fillColor;

varying vec4 vertexColor;

void main(void) {
	vec4 scaledPosition = vec4(scaleFactor * vertexPosition, 1.0);
	vec4 positionA = jointMatrices[int(vertexJointA)] * scaledPosition;
	vec4 positionB = jointMatrices[int(vertexJointB)] * scaledPosition;
	vec4 weightedPosition = positionA * vertexWeightA + positionB * vertexWeightB;

	gl_Position = projection * (worldToView * (modelToWorld * weightedPosition));

	vec4 normalJoint = jointMatrices[int(vertexJointA)] * vec4(vertexNormal, 0.0);
	vec3 normalInView = normalize((worldToView * (modelToWorld * normalJoint)).xyz);
	float sunLightIncidence = max(0.0, dot(normalInView, sunLight.xyz));
	vertexColor = vec4(fillColor.rgb * mix(1.0, sunLightIncidence, sunLight.w), 1.0);
}


#version 410

uniform sampler2D diffuse_texture;
uniform sampler2D opacity_texture;
uniform int has_diffuse_texture;
uniform int has_opacity_texture;

in VS_OUT {
	vec2 texcoord;
} fs_in;

out vec4 frag_color;

void main()
{
	float alpha = 1.0f;
	if (has_opacity_texture != 0) {
		alpha = texture(opacity_texture,
		                vec2(1.0f - fs_in.texcoord.x, fs_in.texcoord.y)).r;
		if (alpha == 0.0f)
			discard;
	}

	if (has_diffuse_texture != 0)
		frag_color = texture(diffuse_texture, fs_in.texcoord);
	else
		frag_color = vec4(1.0);

	frag_color *= alpha;
}

Remove the opacity texture and use the alpha from the diffuse

#version 410

uniform sampler2D diffuse_texture;
uniform int has_diffuse_texture;

in VS_OUT {
	vec2 texcoord;
} fs_in;

out vec4 frag_color;

void main()
{
	if (has_diffuse_texture != 0) {
		frag_color = texture(diffuse_texture, fs_in.texcoord);
		if (frag_color.a < 0.2f)
			discard;
	} else {
		frag_color = vec4(1.0);
	}
}


#version 330
in vec3 position;
out vec3 vUV;

#pragma include "global_uniforms_incl.glsl"

void main(void) {
    vec4 eyespacePos = (g_view * vec4(position, 0.0));
    eyespacePos.w = 1;
    gl_Position = g_model * eyespacePos; // model matrix here contains the infinite projection
    vUV = position;
}

Fix Skybox in WebGL/OpenGL ES 2.x

#version 330
in vec3 position;
out vec3 vUV;

#pragma include "global_uniforms_incl.glsl"

void main(void) {
    vec4 eyespacePos = (g_view * vec4(position, 0.0));
    eyespacePos.w = 1.0;
    gl_Position = g_model * eyespacePos; // model matrix here contains the infinite projection
    vUV = position;
}


layout(std140) uniform b_Locals {
    mat4 u_World;
    mat4 u_JointMatrix[4];
    vec4 u_Color;
    vec4 u_MatParams;
    vec4 u_UvRange;
};

Add joint matrices to shaders

layout(std140) uniform b_Locals {
    vec4 u_Color;
    vec4 u_MatParams;
    vec4 u_UvRange;
    mat4 u_World;
    mat4 u_JointMatrix[4];
};


#version 330

uniform bool isPVCOn;
uniform bool isPVAOn;
uniform vec4 barColor;

in vec4 pervcol;
out vec4 outColor;

void main(void)
{
   float a  = isPVAOn ? pervcol.w : 1.0;
   outColor = vec4(isPVCOn ? pervcol.xyz : barColor.xyz, isPVAOn ? pervcol.w : 1.0);
}

Remove obsolete code from histogram fragment shader

#version 330

uniform bool isPVCOn;
uniform bool isPVAOn;
uniform vec4 barColor;

in vec4 pervcol;
out vec4 outColor;

void main(void)
{
   outColor = vec4(isPVCOn ? pervcol.xyz : barColor.xyz, isPVAOn ? pervcol.w : 1.0);
}


attribute vec3 aVertexPosition;
attribute vec3 aVertexNormal;
attribute vec2 aWeight;

attribute float aJointIndex;
attribute float aJointWeight;

uniform vec3 uAmbientColor;

uniform vec3 uLightingDirection;
uniform vec3 uDirectionalColor;

uniform mat3 uNMatrix;

uniform mat4 uMVMatrix;
uniform mat4 uPMatrix;

uniform mat4 boneMatrices[2];

varying vec3 vLightWeighting;

void main (void) {
  // Select joint matrix for this vertex
  mat4 jointMatrix;
  if (aJointIndex < 1.0) {
    jointMatrix = boneMatrices[0];
  } else if (aJointIndex < 2.0) {
    jointMatrix = boneMatrices[1];
  }

  // Lighting
  vec3 transformedNormal = uNMatrix * aVertexNormal;
  float directionalLightWeighting = max(dot(transformedNormal, uLightingDirection), 0.0);
  vLightWeighting = uAmbientColor + uDirectionalColor * directionalLightWeighting;

  // We only have one index right now... so the weight is always 1.
  gl_Position = uPMatrix * uMVMatrix * jointMatrix * aJointWeight * vec4(aVertexPosition, 1.0);
}

Use left handed coordinate system

attribute vec3 aVertexPosition;
attribute vec3 aVertexNormal;
attribute vec2 aWeight;

attribute float aJointIndex;
attribute float aJointWeight;

uniform vec3 uAmbientColor;

uniform vec3 uLightingDirection;
uniform vec3 uDirectionalColor;

uniform mat3 uNMatrix;

uniform mat4 uMVMatrix;
uniform mat4 uPMatrix;

uniform mat4 boneMatrices[2];

varying vec3 vLightWeighting;

void main (void) {
  // Select joint matrix for this vertex
  mat4 jointMatrix;
  if (aJointIndex < 1.0) {
    jointMatrix = boneMatrices[0];
  } else if (aJointIndex < 2.0) {
    jointMatrix = boneMatrices[1];
  }

  // Lighting
  vec3 transformedNormal = uNMatrix * aVertexNormal;
  float directionalLightWeighting = max(dot(transformedNormal, uLightingDirection), 0.0);
  vLightWeighting = uAmbientColor + uDirectionalColor * directionalLightWeighting;

  // Blender uses a right handed coordinate system. We convert to left handed here
  vec4 leftWorldSpace = jointMatrix * aJointWeight * vec4(aVertexPosition, 1.0);
  float y = leftWorldSpace.z;
  float z = -leftWorldSpace.y;
  leftWorldSpace.y = y;
  leftWorldSpace.z = z;

  // TODO: Is that even world space?. Just guessing and don't have wifi...
  vec4 leftHandedPosition = uPMatrix * uMVMatrix * leftWorldSpace;

  // We only have one index right now... so the weight is always 1.
  gl_Position = leftHandedPosition;
}


[general]
precision: single

[space]
crs:      4326
origin_x: -83.747389
origin_y: 32.917647
rotation: 42.957964853112
units:    ft

[time]
units:    days
base:     1899-12-31

[output]
head:     1-23-07_NOASP.hed
cbud:     1-23-07_NOASP.ccf

Fix Carolina crs and rotation

[general]
precision: single

[space]
crs:      4269
origin_x: -83.747389
origin_y: 32.917647
rotation: -42.957964853112
units:    ft

[time]
units:    days
base:     1899-12-31

[output]
head:     1-23-07_NOASP.hed
cbud:     1-23-07_NOASP.ccf


/**
 * @private
 */
vec4 czm_translucentPhong(vec3 toEye, czm_material material)
{
    // Diffuse from directional light sources at eye (for top-down and horizon views)
    float diffuse = czm_getLambertDiffuse(vec3(0.0, 0.0, 1.0), material.normal);
    diffuse += czm_getLambertDiffuse(vec3(0.0, 1.0, 0.0), material.normal);
    diffuse = clamp(diffuse, 0.0, 1.0);

    // Specular from sun and pseudo-moon
    float specular = czm_getSpecular(czm_sunDirectionEC, toEye, material.normal, material.shininess);
    specular += czm_getSpecular(czm_moonDirectionEC, toEye, material.normal, material.shininess);

    // Temporary workaround for adding ambient.
    vec3 materialDiffuse = material.diffuse * 0.5;

    vec3 ambient = materialDiffuse;
    vec3 color = ambient + material.emission;
    color += materialDiffuse * diffuse;
    color += material.specular * specular;

    return vec4(color, material.alpha);
}

Fix lighting issue for translucent geometry in 2D.

/**
 * @private
 */
vec4 czm_translucentPhong(vec3 toEye, czm_material material)
{
    // Diffuse from directional light sources at eye (for top-down and horizon views)
    float diffuse = czm_getLambertDiffuse(vec3(0.0, 0.0, 1.0), material.normal);

    if (czm_sceneMode == czm_sceneMode3D) {
        // (and horizon views in 3D)
        diffuse += czm_getLambertDiffuse(vec3(0.0, 1.0, 0.0), material.normal);
    }

    diffuse = clamp(diffuse, 0.0, 1.0);

    // Specular from sun and pseudo-moon
    float specular = czm_getSpecular(czm_sunDirectionEC, toEye, material.normal, material.shininess);
    specular += czm_getSpecular(czm_moonDirectionEC, toEye, material.normal, material.shininess);

    // Temporary workaround for adding ambient.
    vec3 materialDiffuse = material.diffuse * 0.5;

    vec3 ambient = materialDiffuse;
    vec3 color = ambient + material.emission;
    color += materialDiffuse * diffuse;
    color += material.specular * specular;

    return vec4(color, material.alpha);
}


#include <metal_stdlib>
#include <simd/simd.h>

using namespace metal;

struct main0_in
{
    float vIn3 [[user(locn3)]];
    float vIn2 [[user(locn2)]];
    float4 vIn1 [[user(locn1)]];
    float4 vIn0 [[user(locn0)]];
};

struct main0_out
{
    float4 FragColor [[color(0)]];
};

fragment main0_out main0(main0_in in [[stage_in]])
{
    main0_out out = {};
    bool4 l = bool4(false, true, false, false);
    out.FragColor = float4(l.x ? in.vIn1.x : in.vIn0.x, l.y ? in.vIn1.y : in.vIn0.y, l.z ? in.vIn1.z : in.vIn0.z, l.w ? in.vIn1.w : in.vIn0.w);
    bool f = true;
    out.FragColor = float4(f ? in.vIn3 : in.vIn2);
    float4 _35;
    if (f)
    {
        _35 = in.vIn0;
    }
    else
    {
        _35 = in.vIn1;
    }
    out.FragColor = _35;
    float _44;
    if (f)
    {
        _44 = in.vIn2;
    }
    else
    {
        _44 = in.vIn3;
    }
    out.FragColor = float4(_44);
    return out;
}

Update MSL reference shaders affected by upstream pull.

#include <metal_stdlib>
#include <simd/simd.h>

using namespace metal;

struct main0_in
{
    float vIn3 [[user(locn3)]];
    float vIn2 [[user(locn2)]];
    float4 vIn1 [[user(locn1)]];
    float4 vIn0 [[user(locn0)]];
};

struct main0_out
{
    float4 FragColor [[color(0)]];
};

fragment main0_out main0(main0_in in [[stage_in]])
{
    main0_out out = {};
    bool4 l = bool4(false, true, false, false);
    out.FragColor = float4(l.x ? in.vIn1.x : in.vIn0.x, l.y ? in.vIn1.y : in.vIn0.y, l.z ? in.vIn1.z : in.vIn0.z, l.w ? in.vIn1.w : in.vIn0.w);
    bool f = true;
    out.FragColor = float4(f ? in.vIn3 : in.vIn2);
    out.FragColor = f ? in.vIn0 : in.vIn1;
    out.FragColor = float4(f ? in.vIn2 : in.vIn3);
    return out;
}


ENESIM_OPENGL_SHADER(
uniform sampler2D merge_texture_0;
uniform sampler2D merge_texture_1;

void main()
{
	vec4 texel0 = texture2D(merge_texture_0, gl_TexCoord[0]);
	vec4 texel1 = texture2D(merge_texture_1, gl_TexCoord[0]);
	gl_FragColor = mix(texel1, texel0, texel0.a);
	gl_FragColor = texel1.aaaa;
	//gl_TexCoord[0]; //vec4(1.0, 0.0, 1.0, 1.0);
}
)

Make it show the final path

ENESIM_OPENGL_SHADER(
uniform sampler2D merge_texture_0;
uniform sampler2D merge_texture_1;

void main()
{
	vec4 texel0 = texture2D(merge_texture_0, gl_TexCoord[0]);
	vec4 texel1 = texture2D(merge_texture_1, gl_TexCoord[0]);
	gl_FragColor = mix(texel1, texel0, texel0.a);
	//gl_FragColor = texel1.aaaa;
	//gl_TexCoord[0]; //vec4(1.0, 0.0, 1.0, 1.0);
}
)


#ifdef USE_FOG

	float fogDepth = length( vFogPosition );

	#ifdef FOG_EXP2

		float fogFactor = whiteCompliment( exp2( - fogDensity * fogDensity * fogDepth * fogDepth * LOG2 ) );

	#else

		float fogFactor = smoothstep( fogNear, fogFar, fogDepth );

	#endif

	gl_FragColor.rgb = mix( gl_FragColor.rgb, fogColor, fogFactor );

#endif

Make distance fog calculation overflow less in mediump

#ifdef USE_FOG

	// divide then multiply by max component to try to avoid saturating mediump precision
	vec3 fogPositionAbs = abs( vFogPosition );
	float fogMaxComponent = max( fogPositionAbs.x, max( fogPositionAbs.y, fogPositionAbs.z ) );
	float fogDepth = length( vFogPosition / fogMaxComponent ) * fogMaxComponent;

	#ifdef FOG_EXP2

		float fogFactor = whiteCompliment( exp2( - fogDensity * fogDensity * fogDepth * fogDepth * LOG2 ) );

	#else

		float fogFactor = smoothstep( fogNear, fogFar, fogDepth );

	#endif

	gl_FragColor.rgb = mix( gl_FragColor.rgb, fogColor, fogFactor );

#endif


precision mediump float;

uniform sampler2D s_tex;
varying vec2 v_texCoord;
varying vec3 v_normal;

void main()
{
    vec3 n = normalize(v_normal);
    float fFrontFacing = float(gl_FrontFacing);
    vec4 color = texture2D(s_tex, v_texCoord);
    gl_FragColor = vec4(color.rgb * (n.z * (fFrontFacing-0.5)*2.0) + vec3(0.1,0.1,0.1)*(1.0-fFrontFacing), color.a);
}

Discard fragments with low alpha

precision mediump float;

uniform sampler2D s_tex;
varying vec2 v_texCoord;
varying vec3 v_normal;

void main()
{
    vec4 color = texture2D(s_tex, v_texCoord);

    if (color.a < 0.01) {
        discard;
    }

    vec3 n = normalize(v_normal);
    float fFrontFacing = float(gl_FrontFacing);
    gl_FragColor = vec4(color.rgb * (n.z * (fFrontFacing-0.5)*2.0) + vec3(0.1,0.1,0.1)*(1.0-fFrontFacing), color.a);
}


#version 330

uniform sampler2D color;
uniform vec4 screenSize;

in vec2 texcoord;

#define FXAA_PC 1
#define FXAA_GLSL_130 1
#define FXAA_QUALITY__PRESET 39
#define FXAA_GREEN_AS_LUMA 1

#include "fxaa3_11.h"

void main(void)
{
    vec4 zero = vec4(0.0, 0.0, 0.0, 0.0);
    gl_FragColor = FxaaPixelShader(texcoord, zero, color, color, color, screenSize.zw, zero, zero, zero, 0.75, 0.166, 0.0833, 8.0, 0.125, 0.05, zero);
}

Enable GL_ARB_gpu_shader5 since apparently the shader tries to use it

#version 330
#extension GL_ARB_gpu_shader5 : enable

uniform sampler2D color;
uniform vec4 screenSize;

in vec2 texcoord;

#define FXAA_PC 1
#define FXAA_GLSL_130 1
#define FXAA_QUALITY__PRESET 39
#define FXAA_GREEN_AS_LUMA 1

#include "fxaa3_11.h"

void main(void)
{
    vec4 zero = vec4(0.0, 0.0, 0.0, 0.0);
    gl_FragColor = FxaaPixelShader(texcoord, zero, color, color, color, screenSize.zw, zero, zero, zero, 0.75, 0.166, 0.0833, 8.0, 0.125, 0.05, zero);
}


#version 400

// the matrices
uniform mat4 matProjection;
uniform mat4 matView;
uniform mat4 matModel;
uniform mat3 matNormal;

// the vertex attributes
in vec3 vertPosition;
in vec3 vertNormal;
in vec3 vertTangent;
in vec3 vertBitangent;
in vec2 vertTexCoord;

// constants
const vec3 lightPos = vec3( 0.0, 20.0, 20.0 );

// outputs
out vec3 vLightPos;
sample out vec3 vPosition;
sample out vec3 vNormal;
sample out vec3 vTangent;
sample out vec3 vBitangent;
sample out vec2 vTexCoord;

void main()
{
    vec4 position = matView * matModel * vec4( vertPosition, 1.0 );
    vec4 light = matView * vec4( lightPos, 1.0 );

    vNormal = normalize( matNormal * vertNormal );
    vTangent = normalize( matNormal * vertTangent );
    vBitangent = normalize( matNormal * vertBitangent );
    vPosition = vec3( position / position.w );
    vTexCoord = vertTexCoord;
    vLightPos = vec3( light / light.w );

    gl_Position = matProjection * matView * matModel *
            vec4( vertPosition, 1.0 );
}

Add hack to fix issue with mirrored normal map.

#version 400

// the matrices
uniform mat4 matProjection;
uniform mat4 matView;
uniform mat4 matModel;
uniform mat3 matNormal;

// the vertex attributes
in vec3 vertPosition;
in vec3 vertNormal;
in vec3 vertTangent;
in vec3 vertBitangent;
in vec2 vertTexCoord;

// constants
const vec3 lightPos = vec3( 0.0, 20.0, 20.0 );

// outputs
out vec3 vLightPos;
sample out vec3 vPosition;
sample out vec3 vNormal;
sample out vec3 vTangent;
sample out vec3 vBitangent;
sample out vec2 vTexCoord;

void main()
{
    vec4 position = matView * matModel * vec4( vertPosition, 1.0 );
    vec4 light = matView * vec4( lightPos, 1.0 );

    // HACK: Force left-handed tangents to make compatible with mirrored normal
    //       map.
    // TODO: find more elegant solution
    vec3 N = normalize( matNormal * vertNormal );;
    vec3 T = normalize( matNormal * vertTangent );
    vec3 B = normalize( matNormal * vertBitangent );
    if ( dot( cross( N, T ), B ) > 0.0 )
    {
        T = T * -1.0;
    }

    vNormal = N;
    vTangent = T;
    vBitangent = B;
    vPosition = vec3( position / position.w );
    vTexCoord = vertTexCoord;
    vLightPos = vec3( light / light.w );

    gl_Position = matProjection * matView * matModel *
            vec4( vertPosition, 1.0 );
}


precision highp float;

const vec2 cellDimensions = vec2( 480, 320 );
const vec2 gridSize = vec2( 8, 8 );
// Size of a single texel in an input camera image.
const vec2 texelSize = vec2( 1.0 ) / (cellDimensions * vec2(2));

vec2 getTextureOffset( float index )
{
	float column = mod(index, gridSize.x);
	float row = floor(index / gridSize.x);

	return vec2(column, row) / gridSize;
}

vec2 offsetTextureCoordinate( vec2 coord, float index )
{
	return (coord / gridSize) + getTextureOffset( index );
}

float wrappedIndex( float baseIndex, float offset )
{
	return floor(mod(baseIndex - (offset * 64.0), 64.0));
}

Cut blur in half again.

precision highp float;

const vec2 cellDimensions = vec2( 480, 320 );
const vec2 gridSize = vec2( 8, 8 );
// Size of a single texel in an input camera image.
const vec2 texelSize = vec2( 1.0 ) / (cellDimensions * vec2(4));

vec2 getTextureOffset( float index )
{
	float column = mod(index, gridSize.x);
	float row = floor(index / gridSize.x);

	return vec2(column, row) / gridSize;
}

vec2 offsetTextureCoordinate( vec2 coord, float index )
{
	return (coord / gridSize) + getTextureOffset( index );
}

float wrappedIndex( float baseIndex, float offset )
{
	return floor(mod(baseIndex - (offset * 64.0), 64.0));
}


#version 100
// Copyright 2022 The Android Open Source Project
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
//      http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

// ES 2 fragment shader that samples from a (non-external) texture with
// uTexSampler, copying from this texture to the current output
// while adjusting contrast based on uContrastFactor.

precision mediump float;
uniform sampler2D uTexSampler;
uniform float uContrastFactor;
varying vec2 vTexSamplingCoord;

void main() {
    vec4 inputColor = texture2D(uTexSampler, vTexSamplingCoord);

    gl_FragColor = vec4(
        clamp(uContrastFactor * (inputColor.r - 0.5) + 0.5, 0.0, 1.0),
        clamp(uContrastFactor * (inputColor.g - 0.5) + 0.5, 0.0, 1.0),
        clamp(uContrastFactor * (inputColor.b - 0.5) + 0.5, 0.0, 1.0),
        inputColor.a);
}

Remove clamp function in contrast fragment shader.

#version 100
// Copyright 2022 The Android Open Source Project
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
//      http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

// ES 2 fragment shader that samples from a (non-external) texture with
// uTexSampler, copying from this texture to the current output
// while adjusting contrast based on uContrastFactor.

precision mediump float;
uniform sampler2D uTexSampler;
uniform float uContrastFactor;
varying vec2 vTexSamplingCoord;

void main() {
    vec4 inputColor = texture2D(uTexSampler, vTexSamplingCoord);

    gl_FragColor = vec4(
        uContrastFactor * (inputColor.r - 0.5) + 0.5,
        uContrastFactor * (inputColor.g - 0.5) + 0.5,
        uContrastFactor * (inputColor.b - 0.5) + 0.5,
        inputColor.a);
}


/**
 * @file impostorF.glsl
 *
 * Copyright (c) 2007-$CurrentYear$, Linden Research, Inc.
 * $License$
 */

uniform sampler2D diffuseMap;
uniform sampler2D normalMap;
uniform sampler2D specularMap;

void main()
{
	gl_FragData[0] = texture2D(diffuseMap, gl_TexCoord[0].xy);
	gl_FragData[1] = texture2D(specularMap, gl_TexCoord[0].xy);
	gl_FragData[2] = vec4(texture2D(normalMap, gl_TexCoord[0].xy).xyz, 0.0);
}

Fix for impostors being fullbright when deferred rendering enabled.

/**
 * @file impostorF.glsl
 *
 * Copyright (c) 2007-$CurrentYear$, Linden Research, Inc.
 * $License$
 */

uniform sampler2D diffuseMap;
uniform sampler2D normalMap;
uniform sampler2D specularMap;

void main()
{
	vec4 col = texture2D(diffuseMap, gl_TexCoord[0].xy);
	gl_FragData[0] = vec4(col.rgb, col.a <= 0.5 ? 0.0 : 0.005);
	gl_FragData[1] = texture2D(specularMap, gl_TexCoord[0].xy);
	gl_FragData[2] = vec4(texture2D(normalMap, gl_TexCoord[0].xy).xyz, 0.0);
}


COMMONDEFS=$(srcdir)/gtk-types.defs $(srcdir)/gdk-types.defs \
		   $(srcdir)/atk-types.defs $(srcdir)/pango-types.defs

GTK_OVERRIDES = \
	$(srcdir)/gtk.overrides \
	$(srcdir)/gtkstyle.overrides

$(srcdir)/gen_gtk.c: $(srcdir)/gtk.defs $(COMMONDEFS) $(srcdir)/gtk-extrafuncs.defs $(GTK_OVERRIDES)
$(srcdir)/gen_gdk.c: $(srcdir)/gdk.defs $(COMMONDEFS) $(srcdir)/gdk.overrides
$(srcdir)/gen_atk.c: $(COMMONDEFS) $(srcdir)/atk.overrides
$(srcdir)/gen_pango.c: $(COMMONDEFS) $(srcdir)/pango.overrides

gen_%.c : %.defs
	( \
     $(PHP) $(top_srcdir)/generator/generator.php \
	 	-l $(@D)/gen_$(*F).log \
        -r $(*D)/atk-types.defs \
        -r $(*D)/pango-types.defs \
        -r $(*D)/gdk-types.defs \
        -r $(*D)/gtk-types.defs \
        -o $*.overrides \
        -p $(*F) \
        -f $@ $*.defs \
     && grep -h "^PHP_GTK_EXPORT_CE" $@ | sed -e "s!^!extern !" > $(@D)/gen_$(@F).h \
	)

Fix generation error that resulted in a wrong header file being created.

COMMONDEFS=$(srcdir)/gtk-types.defs $(srcdir)/gdk-types.defs \
		   $(srcdir)/atk-types.defs $(srcdir)/pango-types.defs

GTK_OVERRIDES = \
	$(srcdir)/gtk.overrides \
	$(srcdir)/gtkstyle.overrides

$(srcdir)/gen_gtk.c: $(srcdir)/gtk.defs $(COMMONDEFS) $(srcdir)/gtk-extrafuncs.defs $(GTK_OVERRIDES)
$(srcdir)/gen_gdk.c: $(srcdir)/gdk.defs $(COMMONDEFS) $(srcdir)/gdk.overrides
$(srcdir)/gen_atk.c: $(COMMONDEFS) $(srcdir)/atk.overrides
$(srcdir)/gen_pango.c: $(COMMONDEFS) $(srcdir)/pango.overrides

gen_%.c : %.defs
	( \
     $(PHP) $(top_srcdir)/generator/generator.php \
	 	-l $(@D)/gen_$(*F).log \
        -r $(*D)/atk-types.defs \
        -r $(*D)/pango-types.defs \
        -r $(*D)/gdk-types.defs \
        -r $(*D)/gtk-types.defs \
        -o $*.overrides \
        -p $(*F) \
        -f $@ $*.defs \
     && grep -h "^PHP_GTK_EXPORT_CE" $@ | sed -e "s!^!extern !" > $(@D)/gen_$(*F).h \
	)


#version 140
in vec2 tex_coord;
out vec3 color;
uniform isampler2D low;
uniform isampler2D high;
void main() {
  int s=int(tex_coord.s);
  int t=int(tex_coord.t);
  float y;
  float v;
  if ((t&0x4)==0) {
    y=float(texelFetch(low, ivec2(s,t>>3),0)[t&3])+128;
  }
  else {
    y=float(texelFetch(high, ivec2(s,t>>3),0)[t&3])+128;
  }
  color=vec3(y,y,y)/255.0;
}

Remove unused variable in ungrey fragment shader.

#version 140
in vec2 tex_coord;
out vec3 color;
uniform isampler2D low;
uniform isampler2D high;
void main() {
  int s=int(tex_coord.s);
  int t=int(tex_coord.t);
  float y;
  if ((t&0x4)==0) {
    y=float(texelFetch(low, ivec2(s,t>>3),0)[t&3])+128;
  }
  else {
    y=float(texelFetch(high, ivec2(s,t>>3),0)[t&3])+128;
  }
  color=vec3(y,y,y)/255.0;
}


//=========== Copyright © 2018, Planimeter, All rights reserved. =============//
//
// Purpose:
//
//============================================================================//

#version 330

uniform mat4 view;
uniform mat4 projection;

in vec3 position;
in vec3 texcoord;

out vec3 TexCoord;

void main()
{
	TexCoord    = texcoord;
	vec4 pos    = projection * view * vec4( position, 1.0 );
	gl_Position = pos.xyww;
}

Fix `TexCoord` variable definition in skybox shader

//=========== Copyright © 2018, Planimeter, All rights reserved. =============//
//
// Purpose:
//
//============================================================================//

#version 330

uniform mat4 view;
uniform mat4 projection;

in vec3 position;
in vec3 texcoord;

out vec3 TexCoord;

void main()
{
	TexCoord    = position;
	vec4 pos    = projection * view * vec4( position, 1.0 );
	gl_Position = pos.xyww;
}


#version 450

layout(binding = 0) uniform sampler2D uSamp;
layout(binding = 1) uniform sampler2DShadow uSampShadow;

layout(location = 0) out vec4 FragColor;
layout(location = 0) in vec3 vUV;

void main()
{
    FragColor = textureGather(uSamp, vUV.xy, 0);
    FragColor += textureGather(uSamp, vUV.xy, 1);
    FragColor += textureGather(uSampShadow, vUV.xy, vUV.z);
}

Update texture gather test result.

#version 450

layout(binding = 0) uniform sampler2D uSamp;
layout(binding = 1) uniform sampler2DShadow uSampShadow;

layout(location = 0) out vec4 FragColor;
layout(location = 0) in vec3 vUV;

void main()
{
    FragColor = textureGather(uSamp, vUV.xy);
    FragColor += textureGather(uSamp, vUV.xy, 1);
    FragColor += textureGather(uSampShadow, vUV.xy, vUV.z);
}


(function (root, factory) {
    if (typeof Livefyre === 'object' && typeof Livefyre.define === 'function' && Livefyre.define.amd) {
        // Livefyre.define is defined by https://github.com/Livefyre/require
        // which is packaged into Livefyre.js,
        // so if define is defined the we don't need to load Livefyre.js again
        return;

    } else if (typeof Livefyre !== 'object' && typeof root['define'] === 'function' && root['define'].amd) {
        //Allow using this built library as an AMD module
        //in another project. That other project will only
        //see this AMD call, not the internal modules in
        //the closure below.
        root['define']([], factory);

    } else {
        //Browser globals case. Just assign the
        //result to a property on the global.
        var f = factory();
        root.Livefyre = root.Livefyre || {};

        for (var module in f) {
            if (f.hasOwnProperty(module)) {
                root.Livefyre[module] = f[module];
            }
        }
    }
}(this, function () {
    //almond, and your modules will be inlined here

Configure require to skip data main

(function (root, factory) {
    if (typeof Livefyre === 'object' && typeof Livefyre.define === 'function' && Livefyre.define.amd) {
        // Livefyre.define is defined by https://github.com/Livefyre/require
        // which is packaged into Livefyre.js,
        // so if define is defined the we don't need to load Livefyre.js again
        return;

    } else if (typeof Livefyre !== 'object' && typeof root['define'] === 'function' && root['define'].amd) {
        //Allow using this built library as an AMD module
        //in another project. That other project will only
        //see this AMD call, not the internal modules in
        //the closure below.
        root['define']([], factory);

    } else {
        //Browser globals case. Just assign the
        //result to a property on the global.
        var f = factory();
        root.Livefyre = root.Livefyre || {};

        for (var module in f) {
            if (f.hasOwnProperty(module)) {
                root.Livefyre[module] = f[module];
            }
        }
    }
}(this, function () {
    //almond, and your modules will be inlined here
    // configure require, ghetto style
    require = {
        skipDataMain: true
    };


/**
 * Compositing for Weighted Blended Order-Independent Transparency. See:
 * http://jcgt.org/published/0002/02/09/
 */

uniform sampler2D u_opaque;
uniform sampler2D u_accumulation;
uniform sampler2D u_revealage;

varying vec2 v_textureCoordinates;

void main()
{
    vec4 opaque = texture2D(u_opaque, v_textureCoordinates);
    vec4 accum = texture2D(u_accumulation, v_textureCoordinates);
    float r = texture2D(u_revealage, v_textureCoordinates).r;

#ifdef MRT
    vec4 transparent = vec4(accum.rgb / clamp(r, 1e-4, 5e4), accum.a);
#else
    vec4 transparent = vec4(accum.rgb / clamp(accum.a, 1e-4, 5e4), r);
#endif

    gl_FragColor = (1.0 - transparent.a) * transparent + transparent.a * opaque;
}

Adjust brightness of translucent geometry proportional to the alpha.

/**
 * Compositing for Weighted Blended Order-Independent Transparency. See:
 * http://jcgt.org/published/0002/02/09/
 */

uniform sampler2D u_opaque;
uniform sampler2D u_accumulation;
uniform sampler2D u_revealage;

varying vec2 v_textureCoordinates;

void main()
{
    vec4 opaque = texture2D(u_opaque, v_textureCoordinates);
    vec4 accum = texture2D(u_accumulation, v_textureCoordinates);
    float r = texture2D(u_revealage, v_textureCoordinates).r;

#ifdef MRT
    vec4 transparent = vec4(accum.rgb / clamp(r, 1e-4, 5e4), accum.a);
#else
    vec4 transparent = vec4(accum.rgb / clamp(accum.a, 1e-4, 5e4), r);
#endif

    transparent.rgb = mix(vec3(0.0), transparent.rgb, 1.0 - transparent.a);
    gl_FragColor = (1.0 - transparent.a) * transparent + transparent.a * opaque;
}


attribute vec4 attrib0;
attribute vec4 attrib1;

uniform mat4 projection;
uniform mat4 view;
uniform mat4 model;
uniform float tileCount;

varying vec3  normal;
varying vec2  tileCoord;
varying vec2  texCoord;
varying float ambientOcclusion;

void main() {
  //Compute position
  vec3 position = attrib0.xyz;

  //Compute ambient occlusion
  ambientOcclusion = attrib0.w / 255.0;

  //Extracted packed bits of normal. GLSL 1.0 doesn't support bitfieldExtract or even bitwise operations :(
  int packedNormal = int(attrib1.x);
  int nx = packedNormal / 16;               // xx____
  int ny = packedNormal / 4 - nx * 4;       // __xx__
  int nz = packedNormal - nx * 16 - ny * 4; // ____xx

  normal = 128.0 - vec3(nx + 127, ny + 127, nz + 127);

  //Compute texture coordinate
  texCoord = vec2(dot(position, vec3(normal.y-normal.z, 0, normal.x)),
                  dot(position, vec3(0, -abs(normal.x+normal.z), normal.y)));

  //Compute tile coordinate
  float tx    = attrib1.w / tileCount;
  tileCoord.x = floor(tx);
  tileCoord.y = fract(tx) * tileCount;

  gl_Position = projection * view * model * vec4(position, 1.0);
}

Read 16-bit texture IDs from mesher

attribute vec4 attrib0;
attribute vec4 attrib1;

uniform mat4 projection;
uniform mat4 view;
uniform mat4 model;
uniform float tileCount;

varying vec3  normal;
varying vec2  tileCoord;
varying vec2  texCoord;
varying float ambientOcclusion;

void main() {
  //Compute position
  vec3 position = attrib0.xyz;

  //Compute ambient occlusion
  ambientOcclusion = attrib0.w / 255.0;

  //Extracted packed bits of normal. GLSL 1.0 doesn't support bitfieldExtract or even bitwise operations :(
  int packedNormal = int(attrib1.x);
  int nx = packedNormal / 16;               // xx____
  int ny = packedNormal / 4 - nx * 4;       // __xx__
  int nz = packedNormal - nx * 16 - ny * 4; // ____xx

  normal = 128.0 - vec3(nx + 127, ny + 127, nz + 127);

  //Compute texture coordinate
  texCoord = vec2(dot(position, vec3(normal.y-normal.z, 0, normal.x)),
                  dot(position, vec3(0, -abs(normal.x+normal.z), normal.y)));

  //Compute tile coordinate
  float tx    = (attrib1.z * 256.0 + attrib1.w) / tileCount; // 16-bit
  tileCoord.x = floor(tx);
  tileCoord.y = fract(tx) * tileCount;

  gl_Position = projection * view * model * vec4(position, 1.0);
}


#version 330

// Input: position in model space
in INTERFACE {
	vec3 position;
} In ;

uniform samplerCube textureCubeMap;

// Output: the fragment color
layout (location = 0) out vec4 fragColor;
layout (location = 1) out vec3 fragNormal;
layout (location = 2) out vec3 fragEffects;

void main(){

	fragColor.rgb = texture(textureCubeMap,In.position).rgb;
	fragColor.a = 0.0;
	fragNormal = vec3(0.0);
	fragEffects = vec3(0.0);

}

Set Skybox normal to 0

#version 330

// Input: position in model space
in INTERFACE {
	vec3 position;
} In ;

uniform samplerCube textureCubeMap;

// Output: the fragment color
layout (location = 0) out vec4 fragColor;
layout (location = 1) out vec3 fragNormal;
layout (location = 2) out vec3 fragEffects;

void main(){

	fragColor.rgb = texture(textureCubeMap,In.position).rgb;
	fragColor.a = 0.0;
	fragNormal = vec3(0.5);
	fragEffects = vec3(0.0);

}


#ifdef GL_ES
precision highp float;
#define GLSLIFY 1
#endif

//Based on Filmic Tonemapping Operators http://filmicgames.com/archives/75
vec3 tonemapFilmic(vec3 color) {
    vec3 x = max(vec3(0.0), color - 0.004);
    return (x * (6.2 * x + 0.5)) / (x * (6.2 * x + 1.7) + 0.06);
}

const float gamma = 2.2;

float toGamma(float v) {
  return pow(v, 1.0 / gamma);
}

vec2 toGamma(vec2 v) {
  return pow(v, vec2(1.0 / gamma));
}

vec3 toGamma(vec3 v) {
  return pow(v, vec3(1.0 / gamma));
}

vec4 toGamma(vec4 v) {
  return vec4(toGamma(v.rgb), v.a);
}

uniform sampler2D tex0;
uniform float uExposure;

varying vec2 vTexCoord;

void main() {
    vec3 color = texture2D(tex0, vTexCoord).rgb;
    color *= uExposure;
    color = tonemapFilmic(color); //filmic has built-in gamma
    gl_FragColor.rgb = color;
    gl_FragColor.a = 1.0;
}

Add gamma correction on output

#ifdef GL_ES
precision highp float;
#define GLSLIFY 1
#endif

//Based on Filmic Tonemapping Operators http://filmicgames.com/archives/75
vec3 tonemapFilmic(vec3 color) {
    vec3 x = max(vec3(0.0), color - 0.004);
    return (x * (6.2 * x + 0.5)) / (x * (6.2 * x + 1.7) + 0.06);
}

const float gamma = 2.2;

float toGamma(float v) {
  return pow(v, 1.0 / gamma);
}

vec2 toGamma(vec2 v) {
  return pow(v, vec2(1.0 / gamma));
}

vec3 toGamma(vec3 v) {
  return pow(v, vec3(1.0 / gamma));
}

vec4 toGamma(vec4 v) {
  return vec4(toGamma(v.rgb), v.a);
}

uniform sampler2D tex0;
uniform float uExposure;

varying vec2 vTexCoord;

void main() {
    vec3 color = texture2D(tex0, vTexCoord).rgb;
    color *= uExposure;
    color = tonemapFilmic(color); //filmic has built-in gamma
    gl_FragColor.rgb = toGamma(color);
    gl_FragColor.a = 1.0;
}


[general]
precision: single

[space]
crs:      4326
origin_x: -80.6026408
origin_y: 26.04083782
rotation: 0
units:    ft

[time]
units:    days
base:     1996-01-01

[output]
head:     Results/UMD.hds
cbud:     Results/UMD.CBC.bin

Change Miami-Date test to use meters

[general]
precision: single

[space]
crs:      4326
origin_x: -80.6026408
origin_y: 26.04083782
rotation: 0
units:    meters

[time]
units:    days
base:     1996-01-01

[output]
head:     Results/UMD.hds
cbud:     Results/UMD.CBC.bin


#version 150

/* Cel shading fragment program for single-pass rendering */
uniform vec4 diffuse;
uniform vec4 specular;
uniform sampler1D diffuseRamp;
uniform sampler1D specularRamp;
uniform sampler1D edgeRamp;

in float diffuseIn;
in float specularIn;
in float edge;

out vec4 fragColour;

uniform lighting
{
	vec4 diffuse;
	vec4 specular;
} LightingParams;

void main()
{
	// Step functions from textures
	float diffuseStep = texture(diffuseRamp, diffuseIn).x;
	float specularStep = texture(specularRamp, specularIn).x;
	float edgeStep = texture(edgeRamp, edge).x;

//	fragColour = edgeStep * ((diffuse * diffuseStep) +
//                            (specular * specularStep));
	fragColour = edgeStep * ((LightingParams.diffuse * diffuseStep) +
                        (LightingParams.specular * specularStep));
}

Fix the Cel shading demo shader

#version 150

/* Cel shading fragment program for single-pass rendering */
uniform vec4 diffuse;
uniform vec4 specular;
uniform sampler1D diffuseRamp;
uniform sampler1D specularRamp;
uniform sampler1D edgeRamp;

in float diffuseIn;
in float specularIn;
in float edge;

out vec4 fragColour;

/*uniform lighting
{
	vec4 diffuse;
	vec4 specular;
} LightingParams;*/

void main()
{
	// Step functions from textures
	float diffuseStep = texture(diffuseRamp, diffuseIn).x;
	float specularStep = texture(specularRamp, specularIn).x;
	float edgeStep = texture(edgeRamp, edge).x;

	fragColour = edgeStep * ((diffuse * diffuseStep) +
                            (specular * specularStep));
//	fragColour = edgeStep * ((LightingParams.diffuse * diffuseStep) +
//                        (LightingParams.specular * specularStep));
}


float quadrant(float coord) {
	coord = sign(coord);
	return -1.0 * sign(coord * (coord - 1.0)) * 3.1415;
}

void main(void)
{
	vec2 uv = gl_FragCoord.xy / resolution.xy;
  vec2 audioUv = abs(2.0*(uv-0.5));

  float scaledResolution = 0.33;

  vec4 t1 = texture2D(audioTexture, vec2(audioUv[0] * scaledResolution, 0.1));
  vec4 t2 = texture2D(audioTexture, vec2(audioUv[1] * scaledResolution, 0.1));

  float fft = t1[0] * t2[0];

	vec2 cuv = uv - vec2(0.5);
	float offset = 0.0;
	if(cuv.x < 0.0) {
		offset = radians(180.0);
	}
	else if (cuv.y < 0.0) {
		offset = 2.0 * radians(180.0);
	}

	float a = atan(cuv.x, cuv.y) + radians(90.0);
	float r = length(cuv);

	r = r - fft * 0.2;

	uv = vec2(r * cos(a), r * sin(a)) + vec2(0.5);

  vec4 cam = texture2D(camera, uv);

  gl_FragColor = cam;
}

Apply hue shift to video

float quadrant(float coord) {
	coord = sign(coord);
	return -1.0 * sign(coord * (coord - 1.0)) * 3.1415;
}

void main(void)
{
	vec2 uv = gl_FragCoord.xy / resolution.xy;
  vec2 audioUv = abs(2.0*(uv-0.5));

  float scaledResolution = 0.33;

  vec4 t1 = texture2D(audioTexture, vec2(audioUv[0] * scaledResolution, 0.1));
  vec4 t2 = texture2D(audioTexture, vec2(audioUv[1] * scaledResolution, 0.1));

  float fft = t1[0] * t2[0];

	vec2 cuv = uv - vec2(0.5);
	float offset = 0.0;
	if(cuv.x < 0.0) {
		offset = radians(180.0);
	}
	else if (cuv.y < 0.0) {
		offset = 2.0 * radians(180.0);
	}

	float a = atan(cuv.x, cuv.y) + radians(90.0);
	float r = length(cuv);

	r = r - fft * 0.2;

	uv = vec2(r * cos(a), r * sin(a)) + vec2(0.5);

  vec4 cam = texture2D(camera, uv);

  gl_FragColor = applyHueShift(cam);
}


#version 400 core

uniform mat4 g_mWorldViewProjection;

// GLSL tessellation evaluation shader (domain shader in HLSL).
layout(triangles, equal_spacing, cw) in;
void main()
{
    // Baricentric interpolation
    vec3 finalPos = (gl_TessCoord.x * gl_in[0].gl_Position + gl_TessCoord.y * gl_in[1].gl_Position + gl_TessCoord.z * gl_in[2].gl_Position).xyz;
    gl_Position = g_mWorldViewProjection * vec4(finalPos, 1.0);
}

Fix implicit vec 3 to vec4 conversion in Tessellation sample GLSL shader

#version 400 core

uniform mat4 g_mWorldViewProjection;

// GLSL tessellation evaluation shader (domain shader in HLSL).
layout(triangles, equal_spacing, cw) in;
void main()
{
    // Baricentric interpolation
    vec3 finalPos = vec3(gl_TessCoord.x * gl_in[0].gl_Position +
                         gl_TessCoord.y * gl_in[1].gl_Position +
                         gl_TessCoord.z * gl_in[2].gl_Position);
    gl_Position = g_mWorldViewProjection * vec4(finalPos, 1.0);
}


#version 330 core

in vec2 tex_coords;

out vec4 frag_color;

uniform sampler2D tex;

void main()
{
	frag_color = texture2D(tex, tex_coords);
}

Fix texture call in GLSL

#version 330 core

in vec2 tex_coords;

out vec4 frag_color;

uniform sampler2D tex;

void main()
{
	frag_color = texture(tex, tex_coords);
}


#pragma glslify: applyMaterial = require(./chunks/applyMaterial)
#pragma glslify: applyLight = require(./chunks/applyLight)

void main() {
    vec3 material = baseColor.r >= 0.0 ? baseColor : applyMaterial(baseColor);

    bool lightsEnabled = u_LightColor.r > 0.0 || u_LightColor.g > 0.0 || u_LightColor.b > 0.0;
    vec3 color = lightsEnabled ? applyLight(material) : material;

    bool ambianceEnabled = u_AmbientLight.r > 0.0 || u_AmbientLight.g > 0.0 || u_AmbientLight.b > 0.0;
    vec3 ambience = u_AmbientLight * material;
    vec3 finalColor = ambianceEnabled ? ambience + color : color;

    gl_FragColor = vec4(finalColor, opacity);
}

Add flat shading to unique meshes

#pragma glslify: applyMaterial = require(./chunks/applyMaterial)
#pragma glslify: applyLight = require(./chunks/applyLight)

void main() {
    vec3 material = baseColor.r >= 0.0 ? baseColor : applyMaterial(baseColor);

    bool lightsEnabled = u_FlatShading < 1.0 && (u_LightColor.r > 0.0 || u_LightColor.g > 0.0 || u_LightColor.b > 0.0);
    vec3 color = lightsEnabled ? applyLight(material) : material;

    bool ambianceEnabled = u_AmbientLight.r > 0.0 || u_AmbientLight.g > 0.0 || u_AmbientLight.b > 0.0;
    vec3 ambience = u_AmbientLight * material;
    vec3 finalColor = ambianceEnabled ? ambience + color : color;

    gl_FragColor = vec4(finalColor, opacity);
}


varying highp vec2 sampleCoord;
varying highp vec2 shiftedSampleCoord;

uniform sampler2D _qt_texture;
uniform lowp vec4 color;
uniform lowp vec4 styleColor;
uniform mediump float alphaMin;
uniform mediump float alphaMax;

void main()
{
    highp float a = smoothstep(alphaMin, alphaMax, texture2D(_qt_texture, sampleCoord).a);
    highp vec4 shifted = styleColor * smoothstep(alphaMin,
                                                 alphaMax,
                                                 texture2D(_qt_texture, shiftedSampleCoord).a);
    gl_FragColor = mix(shifted, color, a);
}

Set sampler precision in shifted distance field text shader

varying highp vec2 sampleCoord;
varying highp vec2 shiftedSampleCoord;

uniform mediump sampler2D _qt_texture;
uniform lowp vec4 color;
uniform lowp vec4 styleColor;
uniform mediump float alphaMin;
uniform mediump float alphaMax;

void main()
{
    highp float a = smoothstep(alphaMin, alphaMax, texture2D(_qt_texture, sampleCoord).a);
    highp vec4 shifted = styleColor * smoothstep(alphaMin,
                                                 alphaMax,
                                                 texture2D(_qt_texture, shiftedSampleCoord).a);
    gl_FragColor = mix(shifted, color, a);
}


#if VX_SHADER == VX_VERTEX_SHADER

layout(location = 0) in vec2 a_position;
layout(location = 1) in vec2 a_uv;
layout(location = 2) in vec4 a_color;

layout(binding = 1, column_major) uniform global_constants
{
    mat4 u_projection;
};

out vec2 v_frag_uv;
out vec4 v_frag_color;

void main()
{
    v_frag_uv = a_uv;
    v_frag_color = a_color;
    gl_Position = u_projection * vec4(a_position.xy, 0, 1);
}

#elif VX_SHADER == VX_FRAGMENT_SHADER

uniform sampler2D u_texture;

in vec2 v_frag_uv;
in vec4 v_frag_color;

out vec4 frag_color;

void main()
{
    frag_color = v_frag_color * texture(u_texture, v_frag_uv.st);
}

#endif

Fix ImGui regression in OpenGL backend

#if VX_SHADER == VX_VERTEX_SHADER

layout(location = 0) in vec2 a_position;
layout(location = 1) in vec2 a_uv;
layout(location = 2) in vec4 a_color;

layout(binding = 1, column_major) buffer global_constants
{
    mat4 u_projection;
};

out vec2 v_frag_uv;
out vec4 v_frag_color;

void main()
{
    v_frag_uv = a_uv;
    v_frag_color = a_color;
    gl_Position = u_projection * vec4(a_position.xy, 0, 1);
}

#elif VX_SHADER == VX_FRAGMENT_SHADER

uniform sampler2D u_texture;

in vec2 v_frag_uv;
in vec4 v_frag_color;

out vec4 frag_color;

void main()
{
    frag_color = v_frag_color * texture(u_texture, v_frag_uv.st);
}

#endif


---
base: RenderStages/PostPhysicalGeometry.shader
modules:
  - type: Vertex
    path: Additive.Vertex.glsl
  - type: Fragment
    path: Additive.Fragment.glsl
uniforms:
  - name: modelViewProjection
    binding: ModelViewProjectionMatrix
  - name: additiveTexture
    type: Texture2
  - name: intensity
    type: Float
    value: 1
depthTested: false
blendMode:
  sourceFactor: One
  destinationFactor: One

Revert "Seeing if recent Valgrind failure is false"

---
base: RenderStages/PostPhysicalGeometry.shader
modules:
  - type: Vertex
    path: Additive.Vertex.glsl
  - type: Fragment
    path: Additive.Fragment.glsl
uniforms:
  - name: modelViewProjection
    binding: ModelViewProjectionMatrix
  - name: additiveTexture
    type: Texture2
  - name: intensity
    type: Float
    value: 1.0
depthTested: false
blendMode:
  sourceFactor: One
  destinationFactor: One


precision highp float;

uniform float tileSize;
uniform sampler2D tileMap;

varying vec3  normal;
varying vec2  tileCoord;
varying vec2  texCoord;
varying float ambientOcclusion;

void main() {

  vec2 uv      = texCoord;
  vec4 color   = vec4(0,0,0,0);
  float weight = 0.0;

  vec2 tileOffset = 2.0 * tileSize * tileCoord;
  float denom     = 2.0 * tileSize * 16.0;

  for(int dx=0; dx<2; ++dx) {
    for(int dy=0; dy<2; ++dy) {
      vec2 offset = 2.0 * fract(0.5 * (uv + vec2(dx, dy)));
      float w = pow(1.0 - max(abs(offset.x-1.0), abs(offset.y-1.0)), 16.0);

      vec2 tc = (tileOffset + tileSize * offset) / denom;
      color  += w * texture2D(tileMap, tc);
      weight += w;
    }
  }
  color /= weight;

  if(color.w < 0.5) {
    discard;
  }

  float light = ambientOcclusion + max(0.15*dot(normal, vec3(1,1,1)), 0.0);

  gl_FragColor = vec4(color.xyz * light, 1.0);
}

Add tileCount uniform to fragment shader

precision highp float;

uniform float tileSize;
uniform sampler2D tileMap;
uniform float tileCount;

varying vec3  normal;
varying vec2  tileCoord;
varying vec2  texCoord;
varying float ambientOcclusion;

void main() {

  vec2 uv      = texCoord;
  vec4 color   = vec4(0,0,0,0);
  float weight = 0.0;

  vec2 tileOffset = 2.0 * tileSize * tileCoord;
  float denom     = 2.0 * tileSize * tileCount;

  for(int dx=0; dx<2; ++dx) {
    for(int dy=0; dy<2; ++dy) {
      vec2 offset = 2.0 * fract(0.5 * (uv + vec2(dx, dy)));
      float w = pow(1.0 - max(abs(offset.x-1.0), abs(offset.y-1.0)), 16.0);

      vec2 tc = (tileOffset + tileSize * offset) / denom;
      color  += w * texture2D(tileMap, tc);
      weight += w;
    }
  }
  color /= weight;

  if(color.w < 0.5) {
    discard;
  }

  float light = ambientOcclusion + max(0.15*dot(normal, vec3(1,1,1)), 0.0);

  gl_FragColor = vec4(color.xyz * light, 1.0);
}


varying lowp vec2 var_texcoord0;
varying lowp vec4 var_face_color;

uniform lowp vec4 texture_size_recip;
uniform lowp sampler2D texture;

void main()
{
    lowp vec2 t = texture2D(texture, var_texcoord0.xy).xy;
    gl_FragColor = vec4(var_face_color.xyz, 1.0);
}

Fix High Performance Simple Font Material Shader

varying lowp vec2 var_texcoord0;
varying lowp vec4 var_face_color;

uniform lowp vec4 texture_size_recip;
uniform lowp sampler2D texture;

void main()
{
    gl_FragColor = vec4(var_face_color.xyz, 1.0) * texture2D(texture, var_texcoord0.xy).x * var_face_color.w;
}


/**
 * @file impostorF.glsl
 *
 * Copyright (c) 2007-$CurrentYear$, Linden Research, Inc.
 * $License$
 */

uniform sampler2D diffuseMap;
uniform sampler2D normalMap;
uniform sampler2D specularMap;

void main()
{
	gl_FragData[0] = texture2D(diffuseMap, gl_TexCoord[0].xy);
	gl_FragData[1] = texture2D(specularMap, gl_TexCoord[0].xy);
	gl_FragData[2] = vec4(texture2D(normalMap, gl_TexCoord[0].xy).xyz, 0.0);
}

Fix for impostors being fullbright when deferred rendering enabled.

/**
 * @file impostorF.glsl
 *
 * Copyright (c) 2007-$CurrentYear$, Linden Research, Inc.
 * $License$
 */

uniform sampler2D diffuseMap;
uniform sampler2D normalMap;
uniform sampler2D specularMap;

void main()
{
	vec4 col = texture2D(diffuseMap, gl_TexCoord[0].xy);
	gl_FragData[0] = vec4(col.rgb, col.a <= 0.5 ? 0.0 : 0.005);
	gl_FragData[1] = texture2D(specularMap, gl_TexCoord[0].xy);
	gl_FragData[2] = vec4(texture2D(normalMap, gl_TexCoord[0].xy).xyz, 0.0);
}


varying vec3 N;
varying vec3 p;

uniform vec3 light_pos;

/*
	Injected by Three.js
	uniform mat4 viewMatrix;
	uniform vec3 cameraPosition;
*/

void main()
{
	vec3 V = normalize(viewMatrix * vec4(cameraPosition, 1.0)).xyz;
	vec3 Lp = (viewMatrix * vec4(light_pos, 1.0)).xyz;
	vec3 L = normalize(p - Lp);
	vec3 H = normalize(L + V);
	vec3 Nn = normalize(N);

	vec3 diffuse = dot(Nn, L) * vec3(0.4, 0.1, 1.0);
	vec3 spec = pow(max(0.0, dot(H, Nn)), 50.0) * vec3(0.6);
		 spec+= pow(max(0.0, dot(H, Nn)), 20.0) * vec3(0.3);
		 spec+= pow(max(0.0, dot(H, Nn)),  2.0) * vec3(0.1);
	gl_FragColor = vec4(diffuse + spec, 1.0);
}

Comment on var Nn in Fragment Shader.

varying vec3 N;
varying vec3 p;

uniform vec3 light_pos;

/*
	Injected by Three.js
	uniform mat4 viewMatrix;
	uniform vec3 cameraPosition;
*/

void main()
{
	vec3 V = normalize(viewMatrix * vec4(cameraPosition, 1.0)).xyz;
	vec3 Lp = (viewMatrix * vec4(light_pos, 1.0)).xyz;
	vec3 L = normalize(p - Lp);
	vec3 H = normalize(L + V);
	// The normalized-normal, interpolated normals
	// might not be unit vectors.
	vec3 Nn = normalize(N);

	vec3 diffuse = dot(Nn, L) * vec3(0.4, 0.1, 1.0);
	vec3 spec = pow(max(0.0, dot(H, Nn)), 50.0) * vec3(0.6);
		 spec+= pow(max(0.0, dot(H, Nn)), 20.0) * vec3(0.3);
		 spec+= pow(max(0.0, dot(H, Nn)),  2.0) * vec3(0.1);
	gl_FragColor = vec4(diffuse + spec, 1.0);
}


#version 450
precision highp float;
precision highp int;

layout(location = 0) in vec3 normal;
layout(location = 1) in vec2 uv;

uniform sampler2D s0;	// albedo.

uniform bool hasAlbedo;

layout(location = 0) out vec4 outColor;

void main()
{
	if (hasAlbedo) {
		outColor = texture2D(s0, uv);
	}
	else {
		// TODO
		outColor = vec4(normal, 1);
	}
}

Modify to draw constant color if there is no albedo texture.

#version 450
precision highp float;
precision highp int;

layout(location = 0) in vec3 normal;
layout(location = 1) in vec2 uv;

uniform sampler2D s0;	// albedo.

uniform bool hasAlbedo;

layout(location = 0) out vec4 outColor;

void main()
{
	if (hasAlbedo) {
		outColor = texture2D(s0, uv);
	}
	else {
		// TODO
		outColor = vec4(1, 1, 1, 1);
	}
}


#version 120

uniform sampler2DRect AccumulationSampler;
uniform sampler2DRect RevealageSampler;

void main()
{
    vec4 Accumulation = texture2DRect(AccumulationSampler, gl_FragCoord.xy);
    float Revealage = Accumulation.a;
    Accumulation.a = texture2DRect(RevealageSampler, gl_FragCoord.xy).r;

    vec3 Color = Accumulation.rgb / max(Accumulation.a, 0.00001);

    gl_FragColor = vec4(Color, 1.0) * (1.0 - Revealage);
}

Order Independent Transparency for old graphics card

#version 120
#extension GL_ARB_texture_rectangle : enable

uniform sampler2DRect AccumulationSampler;
uniform sampler2DRect RevealageSampler;

void main()
{
    vec4 Accumulation = texture2DRect(AccumulationSampler, gl_FragCoord.xy);
    float Revealage = Accumulation.a;
    Accumulation.a = texture2DRect(RevealageSampler, gl_FragCoord.xy).r;

    vec3 Color = Accumulation.rgb / max(Accumulation.a, 0.00001);

    gl_FragColor = vec4(Color, 1.0) * (1.0 - Revealage);
}


#ifdef GL_FRAGMENT_PRECISION_HIGH
precision highp float;
#else
precision mediump float;
#endif

uniform float time;
uniform int pointerCount;
uniform vec3 pointers[10];
uniform vec2 resolution;

void main(void) {
	float mx = max(resolution.x, resolution.y);
	vec2 uv = gl_FragCoord.xy / mx;
	vec3 color = vec3(
		uv,
		0.25 + 0.5 * sin(time) );

	for (int n = 0; n < pointerCount; ++n) {
		vec3 hole = vec3(sin(1.5 - distance(
			uv,
			pointers[n].xy / mx) * 8.0));

		color = mix(color, hole, -0.5);
	}

	gl_FragColor = vec4(color, 1.0);
}

Remove excess space character from default sample

#ifdef GL_FRAGMENT_PRECISION_HIGH
precision highp float;
#else
precision mediump float;
#endif

uniform float time;
uniform int pointerCount;
uniform vec3 pointers[10];
uniform vec2 resolution;

void main(void) {
	float mx = max(resolution.x, resolution.y);
	vec2 uv = gl_FragCoord.xy / mx;
	vec3 color = vec3(
		uv,
		0.25 + 0.5 * sin(time));

	for (int n = 0; n < pointerCount; ++n) {
		vec3 hole = vec3(sin(1.5 - distance(
			uv,
			pointers[n].xy / mx) * 8.0));

		color = mix(color, hole, -0.5);
	}

	gl_FragColor = vec4(color, 1.0);
}


#version 150

uniform vec3 lightdata; //for now rg is pos, b is radius, a is intensity
uniform vec3 lightcolor;
uniform vec3 ambient;
uniform float ambientmult;

in vec2 fragtexcoord;

in vec2 pixpos;
uniform sampler2D texture0; //only one texture for now, we can get creative later

out vec4 fragColor;

void main(){
		vec4 difcolor = texture(texture0, fragtexcoord);

		vec2 lightpos = lightdata.xy;
		vec2 deltapos = lightpos - pixpos;
		float lightdist = length(deltapos);
		float lsize = lightdata.b;
		float attenuation = clamp(1.0 - lightdist*lightdist/(lsize*lsize), 0.0, 1.0);
		attenuation *= attenuation;

		vec3 lightout = attenuation * lightcolor;
		vec3 ambientout = ambient * ambientmult;

		fragColor.rgb = (lightout + ambientout) * difcolor.rgb;
		fragColor.a = ambientmult * difcolor.a;
//		fragColor = vec4(1.0);
}

Fix provided by roboman for sprites with alpha

#version 150

uniform vec3 lightdata; //for now rg is pos, b is radius, a is intensity
uniform vec3 lightcolor;
uniform vec3 ambient;
uniform float ambientmult;

in vec2 fragtexcoord;

in vec2 pixpos;
uniform sampler2D texture0; //only one texture for now, we can get creative later

out vec4 fragColor;

void main(){
		vec4 difcolor = texture(texture0, fragtexcoord);

		vec2 lightpos = lightdata.xy;
		vec2 deltapos = lightpos - pixpos;
		float lightdist = length(deltapos);
		float lsize = lightdata.b;
		float attenuation = clamp(1.0 - lightdist*lightdist/(lsize*lsize), 0.0, 1.0);
		attenuation *= attenuation;

		vec3 lightout = attenuation * lightcolor;
		vec3 ambientout = ambient * ambientmult;

		fragColor.rgb = (lightout + ambientout) * difcolor.rgb * difcolor.a;
		fragColor.a = ambientmult * difcolor.a;
//		fragColor = vec4(1.0);
}


#version 440
#extension GL_NV_gpu_shader5 : enable

coherent uniform
    uint64_t *u_Records;  // all fragment records (<depth|pointer> pairs)
coherent uniform uint32_t *u_Counts;  // auxiliary counters

uniform uint u_NumRecords;
uniform uint u_ScreenSz;

in vec4 u_Pos;
out vec4 o_PixColor;

void main()
{
  o_PixColor = vec4(0);

  // Ignore helper pixels
  if (gl_SampleMaskIn[0] == 0)
    discard;

  uvec2 ij = uvec2(gl_FragCoord.xy);

  // Hashed-lists
  // clear all records
  for (uint o = ij.x + ij.y * u_ScreenSz; o < u_NumRecords;
       o += u_ScreenSz * u_ScreenSz)
  {
    u_Records[o] = uint64_t(0);
  }

  // clear max age table (max age = 0)
  u_Counts[ij.x + ij.y * u_ScreenSz] = 0u;

  if (ij.x == 0 && ij.y == 0)
  {
    u_Counts[u_ScreenSz * u_ScreenSz] = uint32_t(0);
  }

  discard;
}

Remove output variable from clear shader, because all pixels are discarded.

#version 440
#extension GL_NV_gpu_shader5 : enable

coherent uniform
    uint64_t *u_Records;  // all fragment records (<depth|pointer> pairs)
coherent uniform uint32_t *u_Counts;  // auxiliary counters

uniform uint u_NumRecords;
uniform uint u_ScreenSz;

in vec4 u_Pos;

void main()
{
  // Ignore helper pixels
  if (gl_SampleMaskIn[0] == 0)
    discard;

  uvec2 ij = uvec2(gl_FragCoord.xy);

  // Hashed-lists
  // clear all records
  for (uint o = ij.x + ij.y * u_ScreenSz; o < u_NumRecords;
       o += u_ScreenSz * u_ScreenSz)
  {
    u_Records[o] = uint64_t(0);
  }

  // clear max age table (max age = 0)
  u_Counts[ij.x + ij.y * u_ScreenSz] = 0u;

  if (ij.x == 0 && ij.y == 0)
  {
    u_Counts[u_ScreenSz * u_ScreenSz] = uint32_t(0);
  }

  discard;
}


#version 410

uniform sampler2D tex;

in vec2 fragTexCoord;

out vec4 outputColor;
in vec4 position;

void main() {
    outputColor = texture(tex, fragTexCoord);
	//outputColor = vec4(position.x*0.25, position.y*0.75, position.z, 0);
}

Set back face of triangles to render as orange

#version 410

uniform sampler2D tex;

in vec2 fragTexCoord;

out vec4 outputColor;
in vec4 position;

void main() {
	if(gl_FrontFacing)
    	outputColor = texture(tex, fragTexCoord);
	else
		outputColor = vec4(1.0, 0.5,0.0,0.0);
	//outputColor = vec4(position.x*0.25, position.y*0.75, position.z, 0);
}


Shader "TES Unity/Standard Blended"
{
	Properties
	{
		_Color ("Color", Color) = (1,1,1,1)
		_MainTex ("Albedo (RGB)", 2D) = "white" {}
		_Glossiness ("Smoothness", Range(0,1)) = 0.5
		_Metallic ("Metallic", Range(0,1)) = 0.0

		[HideInInspector] _SrcBlend("__src", Float) = 1.0
		[HideInInspector] _DstBlend("__dst", Float) = 0.0
	}
	SubShader
	{
		Tags { "RenderType"="Transparent" "Queue"="Transparent" }
		Blend[_SrcBlend][_DstBlend]
		ZWrite Off

		CGPROGRAM
		#pragma surface surf Standard alpha:fade
		#pragma target 3.0

		sampler2D _MainTex;

		struct Input
		{
			float2 uv_MainTex;
		};

		fixed _Cutoff;
		half _Glossiness;
		half _Metallic;
		half4 _Color;

		void surf (Input i, inout SurfaceOutputStandard o)
		{
			half4 c = tex2D (_MainTex, i.uv_MainTex) * _Color;

			//if ( c.a <= 0.0 ) discard;

			o.Albedo = c.rgb;
			o.Metallic = _Metallic;
			o.Smoothness = _Glossiness;
			o.Alpha = c.a;
		}
		ENDCG
	}
	FallBack "Diffuse"
}

Fix for transparent material shadows. Alpha blended material + alpha tested shadows

Shader "TES Unity/Standard Blended"
{
	Properties
	{
		_Color ("Color", Color) = (1,1,1,1)
		_MainTex ("Albedo (RGB)", 2D) = "white" {}
		_Glossiness ("Smoothness", Range(0,1)) = 0.5
		_Metallic ("Metallic", Range(0,1)) = 0.0

		[HideInInspector] _SrcBlend("__src", Float) = 1.0
		[HideInInspector] _DstBlend("__dst", Float) = 0.0
		[HideInInspector]_Cutoff("cutoff", Float) = 0.5
	}
	SubShader
	{
		Tags { "RenderType"="Transparent" "Queue"="Transparent" }
		Blend[_SrcBlend][_DstBlend]
		ZWrite Off

		CGPROGRAM
		#pragma surface surf Standard alpha:fade
		#pragma target 3.0

		sampler2D _MainTex;

		struct Input
		{
			float2 uv_MainTex;
		};

		half _Glossiness;
		half _Metallic;
		half4 _Color;

		void surf (Input i, inout SurfaceOutputStandard o)
		{
			half4 c = tex2D (_MainTex, i.uv_MainTex) * _Color;

			o.Albedo = c.rgb;
			o.Metallic = _Metallic;
			o.Smoothness = _Glossiness;
			o.Alpha = c.a;
		}
		ENDCG
	}
	FallBack "Transparent/Cutout/Diffuse"
}


Shader "Hidden/Temporal"
{
	Properties
	{
		_MainTex ("Texture", 2D) = "white" {}
	}

	CGINCLUDE
		#include "UnityCG.cginc"

		struct Input
		{
			float4 position : POSITION;
			float2 uv : TEXCOORD0;
		};

		struct Varyings
		{
			float4 position : SV_POSITION;
			float2 uv : TEXCOORD0;
		};

		Varyings vertex(Input input)
		{
			Varyings output;
			output.position = mul(UNITY_MATRIX_MVP, input.position);
			output.uv = input.uv;

			return output;
		}

		sampler2D _MainTex;
		sampler2D _HistoryTex;

		sampler2D _CameraMotionVectorsTexture;

		float4 fragment(Varyings input) : SV_Target
		{
			float2 motion = tex2D(_CameraMotionVectorsTexture, input.uv).xy;

			float4 color = tex2D(_MainTex, input.uv);
			float4 history = tex2D(_HistoryTex, input.uv + motion);

			return lerp(color, history, .5);
		}
	ENDCG

	SubShader
	{
		Cull Off ZWrite Off ZTest Always

		Pass
		{
			CGPROGRAM
				#pragma vertex vertex
				#pragma fragment fragment
			ENDCG
		}
	}
}

Fix the direction of the motion vector offset

Shader "Hidden/Temporal"
{
	Properties
	{
		_MainTex ("Texture", 2D) = "white" {}
	}

	CGINCLUDE
		#include "UnityCG.cginc"

		struct Input
		{
			float4 position : POSITION;
			float2 uv : TEXCOORD0;
		};

		struct Varyings
		{
			float4 position : SV_POSITION;
			float2 uv : TEXCOORD0;
		};

		Varyings vertex(Input input)
		{
			Varyings output;
			output.position = mul(UNITY_MATRIX_MVP, input.position);
			output.uv = input.uv;

			return output;
		}

		sampler2D _MainTex;
		sampler2D _HistoryTex;

		sampler2D _CameraMotionVectorsTexture;

		float4 fragment(Varyings input) : SV_Target
		{
			float2 motion = tex2D(_CameraMotionVectorsTexture, input.uv).xy;

			float4 color = tex2D(_MainTex, input.uv);
			float4 history = tex2D(_HistoryTex, input.uv - motion);

			return lerp(color, history, .5);
		}
	ENDCG

	SubShader
	{
		Cull Off ZWrite Off ZTest Always

		Pass
		{
			CGPROGRAM
				#pragma vertex vertex
				#pragma fragment fragment
			ENDCG
		}
	}
}


#version 330

// Input: UV coordinates
in INTERFACE {
	vec2 uv;
} In ;

// Uniforms.
uniform sampler2D depthTexture;
uniform sampler2D normalTexture;

uniform vec2 inverseScreenSize;
uniform mat4 projectionMatrix;

uniform sampler2D noiseTexture; // 5x5 3-components texture with float precision.
uniform vec3 samples[16];

// Output: the fragment color
out float fragColor;

void main(){

	vec3 n = normalize(2.0 * texture(normalTexture,In.uv).rgb - 1.0);

	// If normal is null, this is the background, no AO.
	if(length(n) < 0.1){
		fragColor = 1.0;
		return;
	}

	fragColor = 0.0;
}

Add function to linearize depth and compute view-space position

#version 330

// Input: UV coordinates
in INTERFACE {
	vec2 uv;
} In ;

// Uniforms.
uniform sampler2D depthTexture;
uniform sampler2D normalTexture;

uniform vec2 inverseScreenSize;
uniform mat4 projectionMatrix;

uniform sampler2D noiseTexture; // 5x5 3-components texture with float precision.
uniform vec3 samples[16];

// Output: the fragment color
out float fragColor;

float linearizeDepth(float depth){
	float depth2 = 2.0*depth-1.0; // Move from [0,1] to [-1,1].
	float viewDepth = - projectionMatrix[3][2] / (depth2 + projectionMatrix[2][2] );
	return viewDepth;
}

vec3 positionFromUV(vec2 uv){
	// Linearize depth -> in view space.
	float depth = texture(depthTexture, uv).r;
	float viewDepth = linearizeDepth(depth);
	// Compute the x and y components in view space.
	vec2 ndcPos = 2.0 * uv - 1.0;
	return vec3(- ndcPos * viewDepth / vec2(projectionMatrix[0][0], projectionMatrix[1][1] ) , viewDepth);
}

void main(){

	vec3 n = normalize(2.0 * texture(normalTexture,In.uv).rgb - 1.0);

	// If normal is null, this is the background, no AO.
	if(length(n) < 0.1){
		fragColor = 1.0;
		return;
	}

	fragColor = 0.0;
}


// by cacheflowe

#ifdef GL_ES
precision mediump float;
precision mediump int;
#endif

#define PROCESSING_TEXTURE_SHADER

uniform sampler2D texture;
uniform sampler2D textureDupe;              // uv multiplication gets weird and buggy on original texture
varying vec4 vertColor;
varying vec4 vertTexCoord;
uniform float zoom = 1.;

void main()
{
	vec2 uv = vertTexCoord.xy - 0.5;            // center coords
    uv *= 2. * zoom;						    // scale down. use 2 as base to make fit quad (4x)
    // uv = fract(abs(uv));					    // always positive values for p coords (old/basic style)
    uv = fract(uv);								// repeat
    uv = abs((uv - 0.5) * 2.);		            // remap to center of repeated coords
    vec4 color = texture2D(textureDupe, uv);	// grab texture pixels
    gl_FragColor = color;
}

Fix mirror quad filter offset

// by cacheflowe

#ifdef GL_ES
precision mediump float;
precision mediump int;
#endif

#define PROCESSING_TEXTURE_SHADER

uniform sampler2D texture;
uniform sampler2D textureDupe;              // uv multiplication gets weird and buggy on original texture
varying vec4 vertColor;
varying vec4 vertTexCoord;
uniform float zoom = 1.;

void main()
{
	vec2 uv = vertTexCoord.xy - 0.5;            // center coords
    uv *= 2. * zoom;						    // scale down. use 2 as base to make fit quad (4x)
    // uv = fract(abs(uv));					    // always positive values for p coords (old/basic style)
    uv = fract(uv - 0.5);						// repeat
    uv = abs((uv - 0.5) * 2.);		            // remap to center of repeated coords
    gl_FragColor = texture2D(textureDupe, uv);	// grab texture pixels
}


#version 330

varying vec2 texCoord;

uniform sampler2D texture;

void main() {
    gl_FragColor = texture(texture, texCoord);
}

Fix fragment shader on AMD/NVIDIA cards

#version 330

varying vec2 texCoord;

uniform sampler2D texture;

void main() {
    gl_FragColor = texture2D(texture, texCoord);
}


uniform sampler2D uTexture;

varying highp vec3 vFragPosition;
varying mediump vec2 vFragTextureCoords;

uniform highp vec3 uRippleOrigin;
uniform highp float uRippleRadius;

#define kFrequency .05
#define kMaxAmplitude .02

mediump vec2 modulateUVAlongAxis(in mediump vec2 uv, in highp vec2 axis, in highp float modulator);

void main()
{
    //vector from ripple origin to current fragment
    highp vec3 radial = vFragPosition - uRippleOrigin;
    //Distance from fragment to ripple orgin
    highp float dCenter = length(radial);
    //Distance from fragment to wave edge
    highp float dEdge = uRippleRadius - dCenter;
    highp float radialTextureOffset = sin(dEdge * kFrequency) * kMaxAmplitude;
    highp vec2 modUV = modulateUVAlongAxis(vFragTextureCoords, radial.xy, radialTextureOffset);
    gl_FragColor = texture2D(uTexture, modUV);
}

mediump vec2 modulateUVAlongAxis(in mediump vec2 uv, in highp vec2 axis, in highp float modulator)
{
    highp vec2 nAxis = normalize(axis);
    return uv + nAxis * modulator;
}

Make ripple emanate from the ripple origin

uniform sampler2D uTexture;

varying highp vec3 vFragPosition;
varying mediump vec2 vFragTextureCoords;

uniform highp vec3 uRippleOrigin;
uniform highp float uRippleRadius;

#define kFrequency .05
#define kMaxAmplitude .02

mediump vec2 modulateUVAlongAxis(in mediump vec2 uv, in highp vec2 axis, in highp float modulator);

void main()
{
    //vector from ripple origin to current fragment
    highp vec3 radial = vFragPosition - uRippleOrigin;
    //Distance from fragment to ripple orgin
    highp float dCenter = length(radial);
    //Distance from fragment to wave edge
    highp float dEdge = uRippleRadius - dCenter;
    highp float radialTextureOffset = sin(dEdge * kFrequency) * kMaxAmplitude;
    highp vec2 modUV = modulateUVAlongAxis(vFragTextureCoords, radial.xy, radialTextureOffset);
    gl_FragColor = texture2D(uTexture, modUV);

    if (dCenter > uRippleRadius)
    {
        gl_FragColor = texture2D(uTexture, vFragTextureCoords);
    } else {
        gl_FragColor = texture2D(uTexture, modUV);
    }
}

mediump vec2 modulateUVAlongAxis(in mediump vec2 uv, in highp vec2 axis, in highp float modulator)
{
    highp vec2 nAxis = normalize(axis);
    return uv + nAxis * modulator;
}


/*

ALCHEMY AO

Projects random points to screen space, and uses the average unoccluded vector
to approximate AO.

*/

const int num_samples = GET_SETTING(AO, alchemy_num_samples);
float max_dist = GET_SETTING(AO, alchemy_max_distance) ;
float accum = 0.0;
float accum_count = 0;

for (int i = 0; i < num_samples; ++i) {

    // Get random texcoord offset
    vec2 offset = poisson_disk_2D_32[i] + noise_vec.xy * 0.2;
    vec2 offcoord = texcoord + offset * pixel_size * sample_radius * kernel_scale;

    // Get view position at that offset
    vec3 off_pos = get_view_pos_at(offcoord);

    // Get the vector s-p to that sample position
    vec3 sample_vec = normalize(off_pos - pixel_view_pos);

    // Check if the distance matches, discard matches which are too far away
    if (distance(off_pos, pixel_view_pos) < max_dist) {

        // Weight sample by the angle
        accum += max(0, dot(pixel_normal, sample_vec));
    }

}

// Normalize values
accum /= num_samples;
result = vec4(1 - saturate(accum));

Add missing divide to the alchemy AO

/*

ALCHEMY AO

Projects random points to screen space, and uses the average unoccluded vector
to approximate AO.

*/

const int num_samples = GET_SETTING(AO, alchemy_num_samples);
float max_dist = GET_SETTING(AO, alchemy_max_distance) ;
float accum = 0.0;
float accum_count = 0;

for (int i = 0; i < num_samples; ++i) {

    // Get random texcoord offset
    vec2 offset = poisson_disk_2D_32[i] + noise_vec.xy * 0.2;
    vec2 offcoord = texcoord + offset * pixel_size * sample_radius * kernel_scale;

    // Get view position at that offset
    vec3 off_pos = get_view_pos_at(offcoord);

    // Get the vector s-p to that sample position
    vec3 sample_vec = normalize(off_pos - pixel_view_pos);

    // Check if the distance matches, discard matches which are too far away
    float dist = distance(off_pos, pixel_view_pos) / max_dist;
    if (dist < 1.0) {

        // Weight sample by the angle
        accum += max(0, dot(pixel_normal, sample_vec)) / dist;
    }

}

// Normalize values
accum /= num_samples;
accum *= 0.5;
result = vec4(1 - saturate(accum));


/*
 * This file contains functions related to tone mapping.
 */

#ifndef _TONE_MAPPING_GLSL
#define _TONE_MAPPING_GLSL

vec3 simpleReinhardToneMap(in vec3 hdrColor)
{
	return (hdrColor / (hdrColor + vec3(1.0)));
}

vec3 uncharted2_ToneMap(in vec3 hdrColor)
{
    const float A = 0.15;
	const float B = 0.50;
	const float C = 0.10;
	const float D = 0.20;
	const float E = 0.02;
	const float F = 0.30;

    return ((hdrColor * (A * hdrColor + C * B) + D * E) / (hdrColor * (A * hdrColor + B) + D * F)) - E / F;
}

#endif // _TONE_MAPPING_GLSL

Increase the exposure so that it's not so dark

/*
 * This file contains functions related to tone mapping.
 */

#ifndef _TONE_MAPPING_GLSL
#define _TONE_MAPPING_GLSL

vec3 simpleReinhardToneMap(in vec3 hdrColor)
{
	return (hdrColor / (hdrColor + vec3(1.0)));
}

vec3 uncharted2_ToneMap(in vec3 hdrColor)
{
	const float A = 0.15;
	const float B = 0.50;
	const float C = 0.10;
	const float D = 0.20;
	const float E = 0.02;
	const float F = 0.30;

	const vec3 exposureBias = vec3(3.0);
	hdrColor *= exposureBias;

	return ((hdrColor * (A * hdrColor + C * B) + D * E) / (hdrColor * (A * hdrColor + B) + D * F)) - E / F;
}

#endif // _TONE_MAPPING_GLSL


/* PASS */

vec4 foo(float x, float y, float z, float w)
{
  vec4 v;
  v.x = x;
  v.y = y;
  v.z = z;
  v.w = w;
  return v;
}

void main()
{
  gl_Position = foo(1.0, 1.0, 1.0, 0.0);
}

Add 'in' to some parameters of the function

/* PASS */

vec4 foo(in float x, in float y, float z, float w)
{
  vec4 v;
  v.x = x;
  v.y = y;
  v.z = z;
  v.w = w;
  return v;
}

void main()
{
  gl_Position = foo(1.0, 1.0, 1.0, 0.0);
}


uniform vec4 color;
uniform vec2 center;
uniform float radiusNear;
uniform float radiusFar;
uniform sampler2D texture;

void main() {
  vec2 pos = gl_TexCoord[0].xy;
  vec4 originalColor = texture2D(texture, pos);
  float dist = distance(vec2(gl_FragCoord), center);

  if (dist > radiusFar) {
    gl_FragColor = vec4(originalColor);
	return;
  }

  float strength = clamp(1.0 - ((dist - radiusNear) / (radiusFar - radiusNear)), 0.0, 1.0);
  gl_FragColor = vec4(originalColor.r + color.r * strength,
					  originalColor.g + color.g * strength,
					  originalColor.b + color.b * strength,
					  originalColor.a * (1 - strength) + color.a * strength);
}

Fix lighting shader on Linux (or VMware hosting Linux)

uniform vec4 color;
uniform vec2 center;
uniform float radiusNear;
uniform float radiusFar;
uniform sampler2D texture;

void main() {
  vec2 pos = gl_TexCoord[0].xy;
  vec4 originalColor = texture2D(texture, pos);
  float dist = distance(vec2(gl_FragCoord), center);

  if (dist > radiusFar) {
    gl_FragColor = vec4(originalColor);
	return;
  }

  float strength = clamp(1.0 - ((dist - radiusNear) / (radiusFar - radiusNear)), 0.0, 1.0);
  gl_FragColor = vec4(originalColor.r + color.r * strength,
					  originalColor.g + color.g * strength,
					  originalColor.b + color.b * strength,
					  originalColor.a * (1.0 - strength) + color.a * strength);
}


#version 440
#extension GL_NV_gpu_shader5 : enable

coherent uniform
    uint64_t *u_Records;  // all fragment records (<depth|pointer> pairs)
coherent uniform uint32_t *u_Counts;  // auxiliary counters

uniform uint u_NumRecords;
uniform uint u_ScreenSz;
uniform uint u_HashSz;

in vec4 u_Pos;
out vec4 o_PixColor;

void main()
{
  o_PixColor = vec4(0);

  // Ignore helper pixels
  if (gl_SampleMaskIn[0] == 0)
    discard;

  uvec2 ij = uvec2(gl_FragCoord.xy);

  // Hashed-lists
  // clear all records
  for (uint o = ij.x + ij.y * u_ScreenSz; o < u_NumRecords;
       o += u_ScreenSz * u_ScreenSz)
  {
    u_Records[o] = uint64_t(0);
  }

  // clear max age table (max age = 0)
  u_Counts[ij.x + ij.y * u_ScreenSz] = 0u;

  if (ij.x == 0 && ij.y == 0)
  {
    u_Counts[u_ScreenSz * u_ScreenSz] = uint32_t(0);
  }

  discard;
}

Remove unused uniform from clear shader.

#version 440
#extension GL_NV_gpu_shader5 : enable

coherent uniform
    uint64_t *u_Records;  // all fragment records (<depth|pointer> pairs)
coherent uniform uint32_t *u_Counts;  // auxiliary counters

uniform uint u_NumRecords;
uniform uint u_ScreenSz;

in vec4 u_Pos;
out vec4 o_PixColor;

void main()
{
  o_PixColor = vec4(0);

  // Ignore helper pixels
  if (gl_SampleMaskIn[0] == 0)
    discard;

  uvec2 ij = uvec2(gl_FragCoord.xy);

  // Hashed-lists
  // clear all records
  for (uint o = ij.x + ij.y * u_ScreenSz; o < u_NumRecords;
       o += u_ScreenSz * u_ScreenSz)
  {
    u_Records[o] = uint64_t(0);
  }

  // clear max age table (max age = 0)
  u_Counts[ij.x + ij.y * u_ScreenSz] = 0u;

  if (ij.x == 0 && ij.y == 0)
  {
    u_Counts[u_ScreenSz * u_ScreenSz] = uint32_t(0);
  }

  discard;
}


uniform sampler2D tex, pallet;
varying float fwidth, fprogress;
uniform float decay, noise;

void main() {
  float dist_from_centre = 2.0f * abs(gl_TexCoord[0].s - 0.5f) / fwidth;
  float progress = fprogress*fprogress;
  progress -= 0.8f;
  progress *= 5.0f;
  progress = max(0.0f, progress);

  float val = texture2D(tex, gl_TexCoord[0].st).r;
  val = noise * val + (1.0f - noise);
  val -= decay * gl_TexCoord[0].t * (0.25f + dist_from_centre*0.75f) *
    texture2D(tex, vec2(gl_TexCoord[0].s,
                        gl_TexCoord[0].t * 2.0f + 0.5f)).r;

  if (val < progress) discard;

  gl_FragColor = texture2D(pallet, vec2(1.0f - val, 0.0f));
}

Remove glbrush colour dependence on dist_from_centre.

uniform sampler2D tex, pallet;
varying float fwidth, fprogress;
uniform float decay, noise;

void main() {
  float dist_from_centre = 2.0f * abs(gl_TexCoord[0].s - 0.5f) / fwidth;
  float progress = fprogress*fprogress;
  progress -= 0.5f;
  progress *= 2.0f;
  progress = max(0.0f, progress);

  float val = texture2D(tex, gl_TexCoord[0].st).r;
  val = noise * val + (1.0f - noise);
  if (val < progress) discard;

  gl_FragColor = texture2D(pallet, vec2(1.0f - val, 0.0f));
  val -= decay * gl_TexCoord[0].t * (0.25f + dist_from_centre*0.75f) *
    texture2D(tex, vec2(gl_TexCoord[0].s,
                        gl_TexCoord[0].t * 2.0f + 0.5f)).r;

  if (val < 0.0f) discard;
}


/* #include "perspective.glsl" */

uniform float noise_amplitude;
uniform vec2 noise_freq;

varying float scaled_noise_amplitude;

void main() {
  vec4 proj;
  vec2 texc;

  proj = perspective_proj(gl_Vertex);
  gl_Position = gl_ModelViewProjectionMatrix * proj;
  texc = gl_Vertex.xy / METRE / 4.0f;
  texc.s += gl_Vertex.z / METRE / 4.0f;
  texc *= noise_freq;
  gl_TexCoord[0] = vec4(texc.s, texc.t, 0.0f, 1.0f);
  scaled_noise_amplitude = noise_amplitude - noise_amplitude * clamp(
    abs(proj.z) / METRE / 256.0f, 0.0f, 1.0f);
}

Improve manifold texture coordinate generation.

/* #include "perspective.glsl" */

uniform float noise_amplitude;
uniform vec2 noise_freq;

varying float scaled_noise_amplitude;

void main() {
  vec4 proj;
  vec2 texc;

  proj = perspective_proj(gl_Vertex);
  gl_Position = gl_ModelViewProjectionMatrix * proj;
  texc = gl_Vertex.xy / METRE / 4.0f;
  texc.s += gl_Vertex.z / METRE / 4.0f;
  texc.t += cos(gl_Vertex.z / METRE / 16.0f * 3.14159f);
  texc *= noise_freq;
  gl_TexCoord[0] = vec4(texc.s, texc.t, 0.0f, 1.0f);
  scaled_noise_amplitude = noise_amplitude - noise_amplitude * clamp(
    abs(proj.z) / METRE / 256.0f, 0.0f, 1.0f);
}


#version 330

uniform sampler2D positionMap;
uniform sampler2D colorMap;
uniform sampler2D normalMap;
uniform sampler2D depthMap;

uniform vec2 screenSize;
uniform vec3 lightDirection;

out vec4 fragColour;

void main()
{
   	vec2 TexCoord = gl_FragCoord.xy / screenSize;
   	vec3 pos = texture(positionMap, TexCoord).xyz;
   	vec3 color = texture(colorMap, TexCoord).xyz;
   	vec3 Normal = texture(normalMap, TexCoord).xyz;

    float specPow = 5.;

    vec3 N = normalize(Normal);
    vec3 L = normalize(-lightDirection);
    vec3 E = normalize(-pos);
    vec3 R = normalize(reflect(-L,N));

    // Calculate colour
    float ambient = 0.2;
    float diffuse = clamp( max(dot(N,L), 0.0) , 0.0, 1.0 );
    float spec = clamp ( pow(max(dot(R,E), 0.0), specPow) , 0.0, 1.0 );
    fragColour = vec4(color * (ambient + diffuse + spec), 1.);
    gl_FragDepth = texture(depthMap, TexCoord).r;
}

Discard fragments in the light pass that are not hit in the geometry pass.

#version 330

uniform sampler2D positionMap;
uniform sampler2D colorMap;
uniform sampler2D normalMap;
uniform sampler2D depthMap;

uniform vec2 screenSize;
uniform vec3 lightDirection;

out vec4 fragColour;

void main()
{
   	vec2 uv = gl_FragCoord.xy / screenSize;
    float depth = texture(depthMap, uv).r;
    if(depth == 1.)
        discard;

   	vec3 pos = texture(positionMap, uv).xyz;
   	vec3 color = texture(colorMap, uv).xyz;
   	vec3 Normal = texture(normalMap, uv).xyz;

    float specPow = 5.;

    vec3 N = normalize(Normal);
    vec3 L = normalize(-lightDirection);
    vec3 E = normalize(-pos);
    vec3 R = normalize(reflect(-L,N));

    // Calculate colour
    float ambient = 0.2;
    float diffuse = clamp( max(dot(N,L), 0.0) , 0.0, 1.0 );
    float spec = clamp ( pow(max(dot(R,E), 0.0), specPow) , 0.0, 1.0 );
    fragColour = vec4(color * (ambient + diffuse + spec), 1.);
    gl_FragDepth = depth;
}


void silhouetteStage(out vec4 color) {
    if(model_silhouettePass) {
        color = czm_gammaCorrect(model_silhouetteColor);
    }
}

Fix rendering bug on Linux

void silhouetteStage(inout vec4 color) {
    if(model_silhouettePass) {
        color = czm_gammaCorrect(model_silhouetteColor);
    }
}


uniform sampler2D texture_diff;
uniform sampler2D texture_nrm;

uniform highp vec3 lightDir;

varying highp vec2 texCoord;

varying highp mat3 N;

void main() {
    vec3 normal = N * (texture2D(texture_nrm, texCoord).rgb * 2.0 - 1.0);

    float light = max(dot(lightDir, normal), 0.0) + 0.2;

    gl_FragColor = vec4(vec3(light) * texture2D(texture_diff, texCoord).rgb, 1.0);
}

Add slight highlight around edges of planets.

uniform sampler2D texture_diff;
uniform sampler2D texture_nrm;

uniform highp vec3 lightDir;

varying highp vec2 texCoord;

varying highp mat3 N;

void main() {
    vec3 normal = N * (texture2D(texture_nrm, texCoord).rgb * 2.0 - 1.0);

    float light = max(dot(lightDir, normal), 0.0) + 0.1 + max(0.2 - normal.z * 0.2, 0.0);

    gl_FragColor = vec4(vec3(light) * texture2D(texture_diff, texCoord).rgb, 1.0);
}


/**
 * @file objectSkinV.glsl
 *
 * Copyright (c) 2007-$CurrentYear$, Linden Research, Inc.
 * $License$
 */

#version 120

attribute vec4 object_weight;

uniform mat4 matrixPalette[64];

mat4 getObjectSkinnedTransform()
{
	int i;

	vec4 w = fract(object_weight);
	vec4 index = floor(object_weight);

	float scale = 1.0/(w.x+w.y+w.z+w.w);
	w *= scale;

	mat4 mat = matrixPalette[int(index.x)]*w.x;
	mat += matrixPalette[int(index.y)]*w.y;
	mat += matrixPalette[int(index.z)]*w.z;
	mat += matrixPalette[int(index.w)]*w.w;

	return mat;
}

Reduce number of potential joints in a rigged mesh to 32 for backwards compatibility with ATI X1950

/**
 * @file objectSkinV.glsl
 *
 * Copyright (c) 2007-$CurrentYear$, Linden Research, Inc.
 * $License$
 */

#version 120

attribute vec4 object_weight;

uniform mat4 matrixPalette[32];

mat4 getObjectSkinnedTransform()
{
	int i;

	vec4 w = fract(object_weight);
	vec4 index = floor(object_weight);

	float scale = 1.0/(w.x+w.y+w.z+w.w);
	w *= scale;

	mat4 mat = matrixPalette[int(index.x)]*w.x;
	mat += matrixPalette[int(index.y)]*w.y;
	mat += matrixPalette[int(index.z)]*w.z;
	mat += matrixPalette[int(index.w)]*w.w;

	return mat;
}


#version 450

layout (push_constant) uniform PushConstants
{
	layout (offset = 0) mat4 view;
	layout (offset = 64) mat4 proj;
} pushConstants;

layout (binding = 0) uniform UBODynamic
{
	mat4 model;
	vec4 colorMultiplier;
	bool enableAlbedoSampler;
} uboDynamic;

layout (location = 0) in vec3 in_Position;
layout (location = 1) in vec2 in_TexCoord;

layout (location = 0) out vec2 ex_TexCoord;

void main()
{
	ex_TexCoord = in_TexCoord;
	vec4 worldPos = vec4(in_Position, 1) * uboDynamic.model;

	gl_Position = (pushConstants.proj * pushConstants.view) * worldPos;
}

Fix sprite transformation issue in Vulkan

#version 450

layout (push_constant) uniform PushConstants
{
	layout (offset = 0) mat4 view;
	layout (offset = 64) mat4 proj;
} pushConstants;

layout (binding = 0) uniform UBODynamic
{
	mat4 model;
	vec4 colorMultiplier;
	bool enableAlbedoSampler;
} uboDynamic;

layout (location = 0) in vec3 in_Position;
layout (location = 1) in vec2 in_TexCoord;

layout (location = 0) out vec2 ex_TexCoord;

void main()
{
	ex_TexCoord = in_TexCoord;
	vec4 worldPos = uboDynamic.model * vec4(in_Position, 1);

	gl_Position = (pushConstants.proj * pushConstants.view) * worldPos;
}


/******************************************************************************
 * The MIT License (MIT)
 *
 * Copyright (c) 2015-2018 Baldur Karlsson
 *
 * Permission is hereby granted, free of charge, to any person obtaining a copy
 * of this software and associated documentation files (the "Software"), to deal
 * in the Software without restriction, including without limitation the rights
 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
 * copies of the Software, and to permit persons to whom the Software is
 * furnished to do so, subject to the following conditions:
 *
 * The above copyright notice and this permission notice shall be included in
 * all copies or substantial portions of the Software.
 *
 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
 * THE SOFTWARE.
 ******************************************************************************/

layout (location = 0) in float pixarea;

layout (location = 0) out vec4 color_out;

void main(void)
{
	color_out = vec4(max(pixarea, 0.001f).xxx, 1.0f);
}

Fix fragment shader compile error

/******************************************************************************
 * The MIT License (MIT)
 *
 * Copyright (c) 2015-2018 Baldur Karlsson
 *
 * Permission is hereby granted, free of charge, to any person obtaining a copy
 * of this software and associated documentation files (the "Software"), to deal
 * in the Software without restriction, including without limitation the rights
 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
 * copies of the Software, and to permit persons to whom the Software is
 * furnished to do so, subject to the following conditions:
 *
 * The above copyright notice and this permission notice shall be included in
 * all copies or substantial portions of the Software.
 *
 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
 * THE SOFTWARE.
 ******************************************************************************/

layout (location = 0) in float pixarea;

layout (location = 0) out vec4 color_out;

void main(void)
{
	float area = max(pixarea, 0.001f);
	color_out = vec4(area, area, area, 1.0f);
}


varying vec3 v_cubeMapCoordinates;
uniform samplerCube cubeMap;

void main()
{
    vec4 rgbm = textureCube(cubeMap, v_cubeMapCoordinates);
    float m = rgbm.a * 49.0;
    vec3 r = rgbm.rgb * m;
    gl_FragColor = vec4(r, 1.0);
}

Fix decoding for RGBM textures which is different for the tool used than the paper.

varying vec3 v_cubeMapCoordinates;
uniform samplerCube cubeMap;

void main()
{
    vec4 rgbm = textureCube(cubeMap, v_cubeMapCoordinates);
    float m = rgbm.a * 16.0;
    vec3 r = rgbm.rgb * m;
    gl_FragColor = vec4(r * r, 1.0);
}


uniform sampler2D u_atlas;

varying vec2 v_textureCoordinates;

#ifdef RENDER_FOR_PICK
varying vec4 v_pickColor;
#else
varying vec4 v_color;
#endif

void main()
{
#ifdef RENDER_FOR_PICK
    gl_FragColor = v_pickColor;
#else
    gl_FragColor = texture2D(u_atlas, v_textureCoordinates) * v_color;
#endif
}

Discard fragments with an alpha of 0.

uniform sampler2D u_atlas;

varying vec2 v_textureCoordinates;

#ifdef RENDER_FOR_PICK
varying vec4 v_pickColor;
#else
varying vec4 v_color;
#endif

void main()
{
#ifdef RENDER_FOR_PICK
    vec4 vertexColor = vec4(1.0, 1.0, 1.0, 1.0);
#else
    vec4 vertexColor = v_color;
#endif

    vec4 color = texture2D(u_atlas, v_textureCoordinates) * vertexColor;
    if (color.a == 0.0)
    {
        discard;
    }

#ifdef RENDER_FOR_PICK
    gl_FragColor = v_pickColor;
#else
    gl_FragColor = color;
#endif
}


precision mediump float;

varying vec2 vTextureCoord;
varying vec4 vColor;

uniform float noise;
uniform sampler2D uSampler;

float rand(vec2 co)
{
    return fract(sin(dot(co.xy, vec2(12.9898, 78.233))) * 43758.5453);
}

void main()
{
    vec4 color = texture2D(uSampler, vTextureCoord);

    float diff = (rand(vTextureCoord) - 0.5) * noise;

    color.r += diff;
    color.g += diff;
    color.b += diff;

    gl_FragColor = color;
}

Fix a display bug on iOS

precision highp float;

varying vec2 vTextureCoord;
varying vec4 vColor;

uniform float noise;
uniform sampler2D uSampler;

float rand(vec2 co)
{
    return fract(sin(dot(co.xy, vec2(12.9898, 78.233))) * 43758.5453);
}

void main()
{
    vec4 color = texture2D(uSampler, vTextureCoord);

    float diff = (rand(vTextureCoord) - 0.5) * noise;

    color.r += diff;
    color.g += diff;
    color.b += diff;

    gl_FragColor = color;
}