Last active
August 29, 2015 14:01
-
-
Save JayFoxRox/ace9c8cc64106cb48c95 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#version 110 | |
vec4 R0,R1,R2,R3,R4,R5,R6,R7,R8,R9,R10,R11; | |
#define R12 oPos /* R12 is a mirror of oPos */ | |
int A0; | |
attribute vec4 v0; | |
attribute vec4 v1; | |
attribute vec4 v2; | |
attribute vec4 v3; | |
attribute vec4 v4; | |
attribute vec4 v5; | |
attribute vec4 v6; | |
attribute vec4 v7; | |
attribute vec4 v8; | |
attribute vec4 v9; | |
attribute vec4 v10; | |
attribute vec4 v11; | |
attribute vec4 v12; | |
attribute vec4 v13; | |
attribute vec4 v14; | |
attribute vec4 v15; | |
vec4 oPos = vec4(0.0,0.0,0.0,1.0); | |
vec4 oD0 = vec4(0.0,0.0,0.0,1.0); | |
vec4 oD1 = vec4(0.0,0.0,0.0,1.0); | |
vec4 oB0 = vec4(0.0,0.0,0.0,1.0); | |
vec4 oB1 = vec4(0.0,0.0,0.0,1.0); | |
vec4 oPts = vec4(0.0,0.0,0.0,1.0); | |
vec4 oFog = vec4(0.0,0.0,0.0,1.0); | |
vec4 oT0 = vec4(0.0,0.0,0.0,1.0); | |
vec4 oT1 = vec4(0.0,0.0,0.0,1.0); | |
vec4 oT2 = vec4(0.0,0.0,0.0,1.0); | |
vec4 oT3 = vec4(0.0,0.0,0.0,1.0); | |
uniform vec4 c[192]; | |
uniform vec4 viewport_scale; | |
uniform vec4 viewport_offset; | |
/* LUT to convert write mask to same amount of components */ | |
#define COMPONENTS_w x | |
#define COMPONENTS_z x | |
#define COMPONENTS_y x | |
#define COMPONENTS_x x | |
#define COMPONENTS_zw xy | |
#define COMPONENTS_yw xy | |
#define COMPONENTS_yz xy | |
#define COMPONENTS_xw xy | |
#define COMPONENTS_xz xy | |
#define COMPONENTS_xy xy | |
#define COMPONENTS_yzw xyz | |
#define COMPONENTS_xzw xyz | |
#define COMPONENTS_xyw xyz | |
#define COMPONENTS_xyz xyz | |
#define COMPONENTS_ xyzw | |
#define COMPONENTS_xyzw xyzw | |
#define MOV(dest,mask, src) dest.mask = _MOV(vec4(src)).COMPONENTS_ ## mask | |
vec4 _MOV(vec4 src) | |
{ | |
return src;} | |
#define MUL(dest,mask, src0, src1) dest.mask = _MUL(vec4(src0), vec4(src1)).COMPONENTS_ ## mask | |
vec4 _MUL(vec4 src0, vec4 src1) | |
{ | |
return src0 * src1; | |
} | |
#define ADD(dest,mask, src0, src1) dest.mask = _ADD(vec4(src0), vec4(src1)).COMPONENTS_ ## mask | |
vec4 _ADD(vec4 src0, vec4 src1) | |
{ | |
return src0 + src1; | |
} | |
#define MAD(dest,mask, src0, src1, src2) dest.mask = _MAD(vec4(src0), vec4(src1), vec4(src2)).COMPONENTS_ ## mask | |
vec4 _MAD(vec4 src0, vec4 src1, vec4 src2) | |
{ | |
return src0 * src1 + src2; | |
} | |
#define DP3(dest,mask, src0, src1) dest.mask = _DP3(vec4(src0), vec4(src1)).COMPONENTS_ ## mask | |
vec4 _DP3(vec4 src0, vec4 src1) | |
{ | |
return vec4(dot(src0.xyz, src1.xyz)); | |
} | |
#define DPH(dest,mask, src0, src1) dest.mask = _DPH(vec4(src0), vec4(src1)).COMPONENTS_ ## mask | |
vec4 _DPH(vec4 src0, vec4 src1) | |
{ | |
return vec4(dot(vec4(src0.xyz,1.0), src1)); | |
} | |
#define DP4(dest,mask, src0, src1) dest.mask = _DP4(vec4(src0), vec4(src1)).COMPONENTS_ ## mask | |
vec4 _DP4(vec4 src0, vec4 src1) | |
{ | |
return vec4(dot(src0, src1)); | |
} | |
#define DST(dest,mask, src0, src1) dest.mask = _DST(vec4(src0), vec4(src1)).COMPONENTS_ ## mask | |
vec4 _DST(vec4 src0, vec4 src1) | |
{ | |
return vec4(1.0, | |
src0.y * src1.y, | |
src0.z, | |
src1.w); | |
} | |
#define MIN(dest,mask, src0, src1) dest.mask = _MIN(vec4(src0), vec4(src1)).COMPONENTS_ ## mask | |
vec4 _MIN(vec4 src0, vec4 src1) | |
{ | |
return min(src0, src1); | |
} | |
#define MAX(dest,mask, src0, src1) dest.mask = _MAX(vec4(src0), vec4(src1)).COMPONENTS_ ## mask | |
vec4 _MAX(vec4 src0, vec4 src1) | |
{ | |
return max(src0, src1); | |
} | |
#define SLT(dest,mask, src0, src1) dest.mask = _SLT(vec4(src0), vec4(src1)).COMPONENTS_ ## mask | |
vec4 _SLT(vec4 src0, vec4 src1) | |
{ | |
return vec4(src0.x < src1.x ? 1.0 : 0.0, | |
src0.y < src1.y ? 1.0 : 0.0, | |
src0.z < src1.z ? 1.0 : 0.0, | |
src0.w < src1.w ? 1.0 : 0.0); | |
} | |
#define ARL(dest,mask, src) dest = _ARL(vec4(src).x) | |
int _ARL(float src) | |
{ | |
return int(src); | |
} | |
#define SGE(dest,mask, src0, src1) dest.mask = _SGE(vec4(src0), vec4(src1)).COMPONENTS_ ## mask | |
vec4 _SGE(vec4 src0, vec4 src1) | |
{ | |
return vec4(src0.x >= src1.x ? 1.0 : 0.0, | |
src0.y >= src1.y ? 1.0 : 0.0, | |
src0.z >= src1.z ? 1.0 : 0.0, | |
src0.w >= src1.w ? 1.0 : 0.0); | |
} | |
#define RCP(dest,mask, src) dest.mask = _RCP(vec4(src).x).COMPONENTS_ ## mask | |
vec4 _RCP(float src) | |
{ | |
return vec4(1.0 / src); | |
} | |
#define RCC(dest,mask, src) dest.mask = _RCC(vec4(src).x).COMPONENTS_ ## mask | |
vec4 _RCC(float src) | |
{ | |
float t = 1.0 / src; | |
if (t > 0.0) { | |
t = min(t,1.884467e+019); | |
t = max(t,5.42101e-020); | |
} else { | |
t = max(t,-1.884467e+019); | |
t = min(t,-5.42101e-020); | |
} | |
return vec4(t); | |
} | |
#define RSQ(dest,mask, src) dest.mask = _RSQ(vec4(src).x).COMPONENTS_ ## mask | |
vec4 _RSQ(float src) | |
{ | |
return vec4(1.0 / sqrt(src)); | |
} | |
#define EXP(dest,mask, src) dest.mask = _EXP(vec4(src).x).COMPONENTS_ ## mask | |
vec4 _EXP(float src) | |
{ | |
return vec4(exp2(src)); | |
} | |
#define LOG(dest,mask, src) dest.mask = _LOG(vec4(src).x).COMPONENTS_ ## mask | |
vec4 _LOG(float src) | |
{ | |
return vec4(log2(src)); | |
} | |
#define LIT(dest,mask, src) dest.mask = _LIT(vec4(src)).COMPONENTS_ ## mask | |
vec4 _LIT(vec4 src) | |
{ | |
vec4 t = vec4(1.0,0.0,0.0,1.0); | |
float power = src.w; | |
if (src.x > 0.0) { | |
t.y = src.x; | |
if (src.y > 0.0) { | |
t.z = pow(src.y, power); | |
} | |
} | |
return t; | |
} | |
/* Debug stuff */ | |
varying vec4 outValue; | |
void main(void) | |
{ | |
/* Slot 0: 0x00000000 0x00EFC01B 0x0836186C 0x20708800 */ | |
DP4(oPos,x, v0, c[126] /*126*/); | |
/* Slot 1: 0x00000000 0x00EFE01B 0x0836186C 0x20704800 */ | |
DP4(oPos,y, v0, c[127] /*127*/); | |
/* Slot 2: 0x00000000 0x00F0001B 0x0836186C 0x20702800 */ | |
DP4(oPos,z, v0, c[128] /*128*/); | |
/* Slot 3: 0x00000000 0x00F0201B 0x0836186C 0x20701800 */ | |
DP4(oPos,w, v0, c[129] /*129*/); | |
/* Slot 4: 0x00000000 0x00B1061B 0x0836186C 0x28200FF8 */ | |
DP3(R2,x, v3, c[136] /*136*/); | |
/* Slot 5: 0x00000000 0x0031401B 0x0C36106C 0x2070F818 */ | |
MOV(oD0,xyzw, c[138] /*138*/); | |
/* Slot 6: 0x00000000 0x00512000 0x2436186C 0x2070F820 */ | |
MUL(oD1,xyzw, R2.xxxx, c[137] /*137*/); | |
/* Slot 7: 0x00000000 0x00200C1B 0x0836106C 0x2070C848 */ | |
MOV(oT0,xy, v6); | |
/* Slot 8: 0x00000000 0x00518000 0x0C54106C 0x2C300FF8 */ | |
MUL(R3,xy, c[140] /*140*/.xxxx, v0.xzzz); | |
/* Slot 9: 0x00000000 0x00718015 0x343612A8 0x3070C850 */ | |
ADD(oT1,xy, R3.xyyy, c[140] /*140*/.zzzz); | |
/* Slot 10: 0x00000000 0x00F2401B 0x0836186C 0x28400FF8 */ | |
DP4(R4,x, v0, c[146] /*146*/); | |
/* Slot 11: 0x00000000 0x00F2601B 0x0836186C 0x24400FF8 */ | |
DP4(R4,y, v0, c[147] /*147*/); | |
/* Slot 12: 0x00000000 0x00F2801B 0x0836186C 0x22500FF8 */ | |
DP4(R5,z, v0, c[148] /*148*/); | |
/* Slot 13: 0x00000000 0x009161AA 0xC5541954 0x30708828 */ | |
MAD(oFog,x, -R12.zzzz, c[139] /*139*/.zzzz, c[139] /*139*/.yyyy); | |
/* Slot 14: 0x00000000 0x0400001B 0x083612A9 0x50120FF8 */ | |
RCP(R1,z, R5.zzzz); | |
/* Slot 15: 0x00000000 0x0647401B 0xC4361BFF 0x1018E800 */ | |
MUL(oPos,xyz, R12, c[58] /*58*/); | |
RCC(R1,x, R12.wwww); | |
/* Slot 16: 0x00000000 0x00400015 0x4554286C 0x2070C858 */ | |
MUL(oT2,xy, R4.xyyy, R1.zzzz); | |
/* Slot 17: 0x00000000 0x0087601B 0xC400286C 0x3070E801 */ | |
MAD(oPos,xyz, R12, R1.xxxx, c[59] /*59*/); | |
/* Un-screenspace transform */ | |
R12 = R12 - viewport_offset; | |
R1.x = 1.0 / viewport_scale.x; | |
R1.y = 1.0 / viewport_scale.y; | |
R1.z = abs(viewport_scale.z); | |
R1.z = (R1.z <= 0.0) ? 1.0 : 0.0; | |
R1.z = R1.z + viewport_scale.z; | |
R1.z = 1.0 / R1.z; | |
R12.xyz = R12.xyz * R1.xyz; | |
R12.w = 1.0; | |
/* Debug stuff */ outValue = R12; /* Set outputs */ | |
gl_Position = oPos; | |
gl_FrontColor = oD0; | |
gl_FrontSecondaryColor = oD1; | |
gl_BackColor = oB0; | |
gl_BackSecondaryColor = oB1; | |
gl_PointSize = oPts.x; | |
gl_FogFragCoord = oFog.x; | |
gl_TexCoord[0] = oT0; | |
gl_TexCoord[1] = oT1; | |
gl_TexCoord[2] = oT2; | |
gl_TexCoord[3] = oT3; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment