Skip to content

Instantly share code, notes, and snippets.

@statico
Created May 30, 2014 14:23
Show Gist options
  • Save statico/0625e542a106904159f1 to your computer and use it in GitHub Desktop.
Save statico/0625e542a106904159f1 to your computer and use it in GitHub Desktop.
#ifdef GL_ES
precision highp float;
#endif
#define GLGE_FRAGMENT
uniform float distance;
uniform bool shadowtype;
varying vec3 lightvec0;
varying float lightdist0;
varying vec3 n;
varying vec3 t;
varying vec4 UVCoord;
varying vec3 eyevec;
varying vec3 OBJCoord;
uniform sampler2D TEXTURE0;
uniform vec3 lightcolor0;
uniform vec3 lightAttenuation0;
uniform float spotCosCutOff0;
uniform float spotExp0;
uniform vec3 lightdir0;
uniform mat4 lightmat0;
uniform float shadowbias0;
uniform int shadowsamples0;
uniform float shadowsoftness0;
uniform bool castshadows0;
uniform vec2 shadowoffset0;
varying vec3 textureCoords0;
uniform float layeralpha0;
uniform sampler2D sky;
uniform vec4 baseColor;
uniform vec3 specColor;
uniform float shine;
uniform float specular;
uniform float reflective;
uniform vec3 emit;
uniform float alpha;
uniform vec3 amb;
uniform float fognear;
uniform float fogfar;
uniform int fogtype;
uniform vec3 fogcolor;
uniform float far;
uniform mat4 worldInverseTranspose;
uniform mat4 projection;
uniform bool emitpass;
uniform bool shadeless;
void main(void)
{
float att;
int texture;
float mask=1.0;
float spec=specular;
vec3 specC=specColor;
vec4 view;
vec3 textureCoords=vec3(0.0,0.0,0.0);
float ref=reflective;
float sh=shine;
vec3 em=emit;
float al=alpha;
vec3 amblight=vec3(1.0,1.0,1.0);
vec4 normalmap= vec4(n,0.0);
vec4 color = baseColor;float pheight=0.0;
vec3 textureHeight=vec3(0.0,0.0,0.0);
vec3 normal = normalize(n);
vec3 b = vec3(0.0,0.0,0.0);
textureCoords=textureCoords0+textureHeight;
mask=layeralpha0*mask;
color = color*(1.0-mask) + texture2D(TEXTURE0, textureCoords.xy)*mask;
amblight *= amb;
al = al*(1.0-mask) + texture2D(TEXTURE0, textureCoords.xy).a*al*mask;
if(al==0.0) discard;
vec3 lightvalue=amblight;
float dotN,spotEffect;vec3 lightvec=vec3(0.0,0.0,0.0);vec3 viewvec=vec3(0.0,0.0,0.0);vec3 specvalue=vec3(0.0,0.0,0.0);vec2 scoord=vec2(0.0,0.0);float sDepth=0.0;float d1=0.0;float d2=0.0;float spotmul=0.0;float rnd=0.0;float spotsampleX=0.0;float spotsampleY=0.0;float totalweight=0.0;int cnt=0;float specularSmoothStepValue=.125;
vec2 spotoffset=vec2(0.0,0.0);float dp=0.0;vec4 dist;float depth,m1,m2,prob,variance;
if (normal.z<0.0) {normal.z=0.0;}
float fogfact=1.0;if(fogtype==3 || fogtype==5) fogfact=clamp(pow(max((fogfar - length(eyevec)) / (fogfar - fognear),0.0),2.0),0.0,1.0);
if(fogtype==2 || fogtype==4) fogfact=clamp((fogfar - length(eyevec)) / (fogfar - fognear),0.0,1.0);
float shadowdepth = gl_FragCoord.z;
if(shadowtype) shadowdepth=length(eyevec)/distance;
vec4 rgba=fract(shadowdepth * vec4(16777216.0, 65536.0, 256.0, 1.0));
gl_FragColor=rgba-rgba.rrgb*vec4(0.0,0.00390625,0.00390625,0.00390625);
}
#ifdef GL_ES
precision mediump float;
#endif
#define GLGE_VERTEX
attribute vec3 position;
attribute vec3 normal;
attribute vec4 UV;
attribute vec3 tangent;
uniform mat4 worldView;
uniform mat4 projection;
uniform mat4 worldInverseTranspose;
uniform mat4 envMat;
uniform float cascadeLevel;
uniform vec3 lightpos0;
uniform vec3 lightdir0;
varying vec3 eyevec;
varying vec3 lightvec0;
varying float lightdist0;
uniform mat4 layer0Matrix;
varying vec3 textureCoords0;
varying vec3 n;
varying vec3 t;
varying vec4 UVCoord;
varying vec3 OBJCoord;
void main(void)
{
UVCoord=UV;
OBJCoord = position;
vec3 tang;
vec4 pos = vec4(0.0, 0.0, 0.0, 1.0);
vec4 norm = vec4(0.0, 0.0, 0.0, 1.0);
vec4 tang4 = vec4(0.0, 0.0, 0.0, 1.0);
vec4 pos4=vec4(position,1.0);
pos = worldView * pos4;
norm = worldInverseTranspose * vec4(normal, 1.0);
tang = (worldInverseTranspose*vec4(tangent,1.0)).xyz;
eyevec = -pos.xyz;
t = normalize(tang);n = normalize(norm.rgb);lightvec0 = pos.xyz-lightpos0;
lightdist0 = length(lightpos0.xyz-pos.xyz);
vec4 texturePos;
textureCoords0=vec3(0.0,0.0,0.0);
texturePos=vec4(vec2(UVCoord[0],(1.0-UVCoord[1])),1.0,1.0);
textureCoords0=(layer0Matrix * texturePos).xyz;
gl_Position = projection * pos;
gl_PointSize=1.00000;
}
//normal
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment