#version 420 #extension GL_ARB_texture_gather : enable // shader 986b29629873321d /// AO 1st pass detection //2 = 8, 3 = 16 const float AOScale = 1.5; // AO detail vs volume 1.5 as a compromise 1.0 default. Scale to res = 100% detail but sharp and tiny. lines 357, 360 for comments: Needs blur++ const float noiseScale = 4.5; // 8 banding for vertical objects, 4 is more random,less details //const float noiseScale = 4.0; //multiple of noise texture samples ie banding vs details uniform ivec4 uf_remappedPS[4]; layout(binding = 0) uniform sampler2D textureUnitPS0;// Tex0 addr 0xf5f0a000 res 640x360x1 dim 1 tm: 4 format 080e compSel: 0 4 4 5 mipView: 0x0 (num 0x1) sliceView: 0x0 (num 0x1) Sampler0 ClampX/Y/Z: 2 2 2 border: 0 layout(binding = 1) uniform sampler2D textureUnitPS1;// Tex1 addr 0xf5984000 res 4x4x1 dim 1 tm: 2 format 081e compSel: 0 1 4 5 mipView: 0x0 (num 0x1) sliceView: 0x0 (num 0x1) Sampler1 ClampX/Y/Z: 0 0 0 border: 0 layout(location = 0) in vec4 passParameterSem0; layout(location = 0) out vec4 passPixelColor0; uniform vec2 uf_fragCoordScale; int clampFI32(int v) { if( v == 0x7FFFFFFF ) return floatBitsToInt(1.0); else if( v == 0xFFFFFFFF ) return floatBitsToInt(0.0); return floatBitsToInt(clamp(intBitsToFloat(v), 0.0, 1.0)); } float mul_nonIEEE(float a, float b){ return min(a*b,min(abs(a)*3.40282347E+38F,abs(b)*3.40282347E+38F)); } void main() { ivec4 R0i = ivec4(0); ivec4 R1i = ivec4(0); ivec4 R2i = ivec4(0); ivec4 R3i = ivec4(0); ivec4 R4i = ivec4(0); ivec4 R5i = ivec4(0); ivec4 R6i = ivec4(0); ivec4 R7i = ivec4(0); ivec4 R8i = ivec4(0); ivec4 R9i = ivec4(0); ivec4 R10i = ivec4(0); ivec4 R11i = ivec4(0); ivec4 R12i = ivec4(0); ivec4 R13i = ivec4(0); ivec4 R14i = ivec4(0); ivec4 R15i = ivec4(0); ivec4 R16i = ivec4(0); ivec4 R17i = ivec4(0); ivec4 R18i = ivec4(0); ivec4 R19i = ivec4(0); ivec4 R20i = ivec4(0); ivec4 R21i = ivec4(0); ivec4 R22i = ivec4(0); ivec4 R23i = ivec4(0); ivec4 R24i = ivec4(0); ivec4 R25i = ivec4(0); ivec4 R26i = ivec4(0); ivec4 R27i = ivec4(0); ivec4 R28i = ivec4(0); ivec4 R29i = ivec4(0); ivec4 R30i = ivec4(0); ivec4 R31i = ivec4(0); ivec4 R32i = ivec4(0); ivec4 R33i = ivec4(0); ivec4 R34i = ivec4(0); ivec4 R35i = ivec4(0); ivec4 R36i = ivec4(0); ivec4 R37i = ivec4(0); ivec4 R38i = ivec4(0); ivec4 R39i = ivec4(0); ivec4 R40i = ivec4(0); ivec4 R41i = ivec4(0); ivec4 R42i = ivec4(0); ivec4 R43i = ivec4(0); ivec4 R44i = ivec4(0); ivec4 R45i = ivec4(0); ivec4 R46i = ivec4(0); ivec4 R47i = ivec4(0); ivec4 R48i = ivec4(0); ivec4 R49i = ivec4(0); ivec4 R50i = ivec4(0); ivec4 R51i = ivec4(0); ivec4 R52i = ivec4(0); ivec4 R53i = ivec4(0); ivec4 R54i = ivec4(0); ivec4 R55i = ivec4(0); ivec4 R56i = ivec4(0); ivec4 R57i = ivec4(0); ivec4 R58i = ivec4(0); ivec4 R59i = ivec4(0); ivec4 R60i = ivec4(0); ivec4 R61i = ivec4(0); ivec4 R62i = ivec4(0); ivec4 R63i = ivec4(0); ivec4 R64i = ivec4(0); ivec4 R65i = ivec4(0); ivec4 R66i = ivec4(0); ivec4 R67i = ivec4(0); ivec4 R68i = ivec4(0); ivec4 R69i = ivec4(0); ivec4 R70i = ivec4(0); ivec4 R71i = ivec4(0); ivec4 R72i = ivec4(0); ivec4 R73i = ivec4(0); ivec4 R74i = ivec4(0); ivec4 R75i = ivec4(0); ivec4 R76i = ivec4(0); ivec4 R77i = ivec4(0); ivec4 R78i = ivec4(0); ivec4 R79i = ivec4(0); ivec4 R80i = ivec4(0); ivec4 R81i = ivec4(0); ivec4 R82i = ivec4(0); ivec4 R83i = ivec4(0); ivec4 R84i = ivec4(0); ivec4 R85i = ivec4(0); ivec4 R86i = ivec4(0); ivec4 R87i = ivec4(0); ivec4 R88i = ivec4(0); ivec4 R89i = ivec4(0); ivec4 R90i = ivec4(0); ivec4 R91i = ivec4(0); ivec4 R92i = ivec4(0); ivec4 R93i = ivec4(0); ivec4 R94i = ivec4(0); ivec4 R95i = ivec4(0); ivec4 R96i = ivec4(0); ivec4 R97i = ivec4(0); ivec4 R98i = ivec4(0); ivec4 R99i = ivec4(0); ivec4 R100i = ivec4(0); ivec4 R101i = ivec4(0); ivec4 R102i = ivec4(0); ivec4 R103i = ivec4(0); ivec4 R104i = ivec4(0); ivec4 R105i = ivec4(0); ivec4 R106i = ivec4(0); ivec4 R107i = ivec4(0); ivec4 R108i = ivec4(0); ivec4 R109i = ivec4(0); ivec4 R110i = ivec4(0); ivec4 R111i = ivec4(0); ivec4 R112i = ivec4(0); ivec4 R113i = ivec4(0); ivec4 R114i = ivec4(0); ivec4 R115i = ivec4(0); ivec4 R116i = ivec4(0); ivec4 R117i = ivec4(0); ivec4 R118i = ivec4(0); ivec4 R119i = ivec4(0); ivec4 R120i = ivec4(0); ivec4 R121i = ivec4(0); ivec4 R122i = ivec4(0); ivec4 R123i = ivec4(0); ivec4 R124i = ivec4(0); ivec4 R125i = ivec4(0); ivec4 R126i = ivec4(0); ivec4 R127i = ivec4(0); int backupReg0i, backupReg1i, backupReg2i, backupReg3i, backupReg4i; ivec4 PV0i = ivec4(0), PV1i = ivec4(0); int PS0i = 0, PS1i = 0; ivec4 tempi = ivec4(0); float tempResultf; int tempResulti; ivec4 ARi = ivec4(0); bool predResult = true; bool activeMaskStack[2]; bool activeMaskStackC[3]; activeMaskStack[0] = false; activeMaskStackC[0] = false; activeMaskStackC[1] = false; activeMaskStack[0] = true; activeMaskStackC[0] = true; activeMaskStackC[1] = true; vec3 cubeMapSTM; int cubeMapFaceId; R0i = floatBitsToInt(passParameterSem0 ); if( activeMaskStackC[1] == true ) { R9i.xy = floatBitsToInt(texture(textureUnitPS0, intBitsToFloat(R0i.xy) ).xx); } if( activeMaskStackC[1] == true ) { R1i.x = 0xbe000000; R1i.y = 0x3e5db3c0 ; // to be tweaked later, cut off points R0i.z = floatBitsToInt(intBitsToFloat(uf_remappedPS[0].z) * intBitsToFloat(0x3c75c28f)); //n PV0i.z = R0i.z; R2i.x = 0xbe800000; PS0i = R2i.x; // 1 R3i.x = 0x3f400000; R2i.y = 0xbeddb3e1; // NNN R0i.w = floatBitsToInt((intBitsToFloat(uf_remappedPS[1].w) * intBitsToFloat(0x3c75c28f) + intBitsToFloat(PV0i.z))); //n R3i.y = 0x3f000000; PS1i = R3i.y; R4i.x = 0x3dff4eb9 ; // to be tweaked later, cut off points 0x3e304eb9 R5i.x = 0x3e474d45; PS0i = R5i.x; // 3 R6i.x = 0x3e157895; //NN PS1i = floatBitsToInt(1.0 / intBitsToFloat(uf_remappedPS[0].x));//n PS1i = floatBitsToInt(intBitsToFloat(PS1i) / 2.0); // 4 R10i.x = 0x3ff7d5aa; R123i.w = floatBitsToInt((intBitsToFloat(R0i.x) * intBitsToFloat(uf_remappedPS[0].x) + -(intBitsToFloat(PS1i))));//N PV0i.w = R123i.w; PS0i = floatBitsToInt(1.0 / intBitsToFloat(uf_remappedPS[0].y)); PS0i = floatBitsToInt(intBitsToFloat(PS0i) / 2.0); // 5 R7i.x = 0x3fdda0c7; R1i.z = floatBitsToInt((intBitsToFloat(R0i.y) * intBitsToFloat(uf_remappedPS[0].y) + -(intBitsToFloat(PS0i))));//N R4i.w = floatBitsToInt(intBitsToFloat(PV0i.w) * 0.25*noiseScale); //NNN R8i.x = 0x3fa95400; /// to be tweaked later, cut off points PS1i = R8i.x; // 6 R13i.x = R1i.x; R13i.y = R1i.y; // 7 R14i.x = R2i.x; R14i.y = R2i.y; // 8 R15i.x = R3i.x; R15i.y = R3i.y; // 9 R16i.x = R4i.x; // 10 R17i.x = R5i.x; // 11 R18i.x = R6i.x; // 12 R19i.x = R10i.x; // 13 R20i.x = R7i.x; // 14 R4i.y = floatBitsToInt(intBitsToFloat(R1i.z) * 0.25*noiseScale); } if( activeMaskStackC[1] == true ) { R3i.xy = floatBitsToInt(texture(textureUnitPS1, intBitsToFloat(R4i.wy)).xy);// insert better noise here.. some day } if( activeMaskStackC[1] == true ) { activeMaskStack[1] = activeMaskStack[0]; activeMaskStackC[2] = activeMaskStackC[1]; // 0 R21i.x = R8i.x; // 1 R4i.x = floatBitsToInt(-(intBitsToFloat(R3i.x))); //pos R1i.y = R3i.y ; //Don't scale here // 2 predResult = (intBitsToFloat(R9i.x) >= intBitsToFloat(R0i.w)); activeMaskStack[1] = predResult; activeMaskStackC[2] = predResult == true && activeMaskStackC[1] == true; } else { activeMaskStack[1] = false; activeMaskStackC[2] = false; } if( activeMaskStackC[2] == true ) { // 0 R0i.x = 0x3f800000; R0i.y = 0; } activeMaskStack[1] = activeMaskStack[1] == false; activeMaskStackC[2] = activeMaskStack[1] == true && activeMaskStackC[1] == true; if( activeMaskStackC[2] == true ) { // 0 R127i.x = floatBitsToInt(intBitsToFloat(R9i.y) + 1.0); PV0i.y = floatBitsToInt(intBitsToFloat(R9i.y) * intBitsToFloat(uf_remappedPS[2].z));//n PV0i.z = uf_remappedPS[2].y;//n PV0i.z = floatBitsToInt(intBitsToFloat(PV0i.z) / 2.0); R5i.x = 0; PS0i = R5i.x; // 1 R6i.x = PV0i.z; PV1i.y = floatBitsToInt(max(intBitsToFloat(PV0i.y), intBitsToFloat(uf_remappedPS[2].z)));//n R6i.y = PV0i.z; PS1i = R6i.y; // 2 R0i.w = floatBitsToInt(min(intBitsToFloat(PV1i.y), intBitsToFloat(0x42c80000))); PS0i = floatBitsToInt(1.0 / intBitsToFloat(R127i.x)); // 3 PV1i.y = floatBitsToInt(intBitsToFloat(PS0i) * intBitsToFloat(uf_remappedPS[1].x));//prob R3i.w = floatBitsToInt(intBitsToFloat(PS0i) * intBitsToFloat(uf_remappedPS[1].z)); //*4 prob R3i.w = clampFI32(R3i.w); // 4 PV0i.z = floatBitsToInt(max(intBitsToFloat(PV1i.y), intBitsToFloat(0x3cf5c28f))); // 5 R3i.z = floatBitsToInt(min(intBitsToFloat(PV0i.z), intBitsToFloat(0x3e19999a))); } while( activeMaskStackC[2] == true ) { if( activeMaskStackC[2] == true ) { // 0 R1i.z = (0x00000003 > R5i.x)?int(0xFFFFFFFF):int(0x0); // 1 predResult = (R1i.z != 0); if( predResult == false ) break; } if( activeMaskStackC[2] == true ) { // 0 R2i.x = R5i.x; R1i.x = R5i.x + 0x00000006; //5? PS0i = R1i.x; // 1 tempResulti = R2i.x; tempResulti = clamp(tempResulti, -256, 255); ARi.x = tempResulti; PV1i.x = tempResulti; // 2 R2i.x = ((ARi.x==0)?R13i.x:(ARi.x==1)?R14i.x:(ARi.x==2)?R15i.x:(ARi.x==3)?R16i.x:(ARi.x==4)?R17i.x:(ARi.x==5)?R18i.x:(ARi.x==6)?R19i.x:(ARi.x==7)?R20i.x:(ARi.x==8)?R21i.x:(ARi.x==110)?R123i.x:(ARi.x==113)?R126i.x:(ARi.x==114)?R127i.x:0); R2i.y = ((ARi.x==0)?R13i.y:(ARi.x==1)?R14i.y:(ARi.x==2)?R15i.y:(ARi.x==3)?R16i.y:(ARi.x==4)?R17i.y:(ARi.x==5)?R18i.y:(ARi.x==6)?R19i.y:(ARi.x==7)?R20i.y:(ARi.x==8)?R21i.y:(ARi.x==110)?R123i.y:(ARi.x==113)?R126i.y:(ARi.x==114)?R127i.y:0); // 3 tempResulti = R1i.x; tempResulti = clamp(tempResulti, -256, 255); ARi.x = tempResulti; PV1i.x = tempResulti; // 4 R1i.x = ((ARi.x==0)?R13i.x:(ARi.x==1)?R14i.x:(ARi.x==2)?R15i.x:(ARi.x==3)?R16i.x:(ARi.x==4)?R17i.x:(ARi.x==5)?R18i.x:(ARi.x==6)?R19i.x:(ARi.x==7)?R20i.x:(ARi.x==8)?R21i.x:(ARi.x==110)?R123i.x:(ARi.x==113)?R126i.x:(ARi.x==114)?R127i.x:0); // 5 backupReg0i = R0i.w; PV1i.x = floatBitsToInt(intBitsToFloat(R4i.x) * intBitsToFloat(R2i.y)); PV1i.y = R1i.x; PV1i.w = floatBitsToInt(intBitsToFloat(R1i.y) * intBitsToFloat(R2i.y)); R2i.w = floatBitsToInt(1.0 / intBitsToFloat(backupReg0i)); PS1i = R2i.w; // 6 backupReg0i = R5i.x; R1i.x = R5i.x + 0x00000003; // //3 R123i.y = floatBitsToInt((intBitsToFloat(R2i.x) * intBitsToFloat(R3i.x) + intBitsToFloat(PV1i.w))); PV0i.y = R123i.y; R123i.z = floatBitsToInt((intBitsToFloat(R2i.x) * intBitsToFloat(R3i.y) + intBitsToFloat(PV1i.x))); PV0i.z = R123i.z; PV0i.w = floatBitsToInt(intBitsToFloat(R3i.z) * intBitsToFloat(PV1i.y)); R5i.x = backupReg0i + int(1); PS0i = R5i.x; // 7 PV1i.z = PV0i.y; PV1i.w = floatBitsToInt(intBitsToFloat(PV0i.z) * intBitsToFloat(uf_remappedPS[1].y)/AOScale); PS1i = floatBitsToInt(1.0 / intBitsToFloat(PV0i.w)); // 8 //scale here PV0i.x = floatBitsToInt(intBitsToFloat(R3i.z) * intBitsToFloat(PV1i.w) / AOScale); PV0i.z = floatBitsToInt(intBitsToFloat(PS1i) * intBitsToFloat(0x40400000) * AOScale);//intensity PV0i.w = floatBitsToInt(intBitsToFloat(R3i.z) * intBitsToFloat(PV1i.z) / AOScale); // // 9 R2i.x = floatBitsToInt(intBitsToFloat(R0i.x) + intBitsToFloat(PV0i.x) / AOScale); R2i.y = floatBitsToInt(intBitsToFloat(R0i.y) + intBitsToFloat(PV0i.w) / AOScale); // R1i.z = floatBitsToInt(intBitsToFloat(R0i.x) + -(intBitsToFloat(PV0i.x) / AOScale)); R1i.w = floatBitsToInt(intBitsToFloat(R0i.y) + -(intBitsToFloat(PV0i.w) / AOScale)); R2i.z = floatBitsToInt(intBitsToFloat(R3i.w) * intBitsToFloat(PV0i.z)* AOScale); PS1i = R2i.z; } if( activeMaskStackC[2] == true ) { R2i.x = floatBitsToInt(texture(textureUnitPS0, intBitsToFloat(R2i.xy)).x); R2i.y = floatBitsToInt(texture(textureUnitPS0, intBitsToFloat(R1i.zw)).x); } if( activeMaskStackC[2] == true ) { // 0 tempResulti = R1i.x; tempResulti = clamp(tempResulti, -256, 255); ARi.x = tempResulti; PV0i.x = tempResulti; // 1 R1i.x = ((ARi.x==0)?R13i.x:(ARi.x==1)?R14i.x:(ARi.x==2)?R15i.x:(ARi.x==3)?R16i.x:(ARi.x==4)?R17i.x:(ARi.x==5)?R18i.x:(ARi.x==6)?R19i.x:(ARi.x==7)?R20i.x:(ARi.x==8)?R21i.x:(ARi.x==110)?R123i.x:(ARi.x==113)?R126i.x:(ARi.x==114)?R127i.x:0); // 2 PV0i.y = floatBitsToInt(-(intBitsToFloat(R9i.y)) + intBitsToFloat(R2i.x)); PV0i.w = floatBitsToInt(-(intBitsToFloat(R9i.y)) + intBitsToFloat(R2i.y)); // 3 R127i.x = floatBitsToInt((intBitsToFloat(R2i.z) * intBitsToFloat(PV0i.y) + 0.5)); R127i.x = clampFI32(R127i.x); PV1i.x = R127i.x; R127i.y = floatBitsToInt((intBitsToFloat(R2i.z) * intBitsToFloat(PV0i.w) + 0.5)); R127i.y = clampFI32(R127i.y); PV1i.y = R127i.y; PV1i.z = floatBitsToInt(max(intBitsToFloat(PV0i.w), -(intBitsToFloat(PV0i.w)))); PV1i.w = floatBitsToInt(max(intBitsToFloat(PV0i.y), -(intBitsToFloat(PV0i.y)))); // 4 PV0i.x = floatBitsToInt(intBitsToFloat(R0i.w) + -(intBitsToFloat(PV1i.w))); PV0i.y = floatBitsToInt(intBitsToFloat(R0i.w) + -(intBitsToFloat(PV1i.z))); PV0i.z = floatBitsToInt(-(intBitsToFloat(PV1i.y)) + 1.0); PV0i.w = floatBitsToInt(-(intBitsToFloat(PV1i.x)) + 1.0); // 5 R126i.x = floatBitsToInt(intBitsToFloat(PV0i.y) * intBitsToFloat(R2i.w)); R126i.x = clampFI32(R126i.x); PV1i.x = R126i.x; PV1i.y = floatBitsToInt(intBitsToFloat(PV0i.z) + -(0.5)); R127i.z = floatBitsToInt(intBitsToFloat(PV0i.x) * intBitsToFloat(R2i.w)); R127i.z = clampFI32(R127i.z); PV1i.z = R127i.z; PV1i.w = floatBitsToInt(intBitsToFloat(PV0i.w) + -(0.5)); // 6 R126i.y = floatBitsToInt((intBitsToFloat(PV1i.y) * intBitsToFloat(PV1i.x) + 0.5)); PV0i.y = R126i.y; R127i.w = floatBitsToInt((intBitsToFloat(PV1i.w) * intBitsToFloat(PV1i.z) + 0.5)); PV0i.w = R127i.w; // 7 PV1i.y = floatBitsToInt(intBitsToFloat(R127i.y) + -(intBitsToFloat(PV0i.w))); PV1i.z = floatBitsToInt(intBitsToFloat(R127i.x) + -(intBitsToFloat(PV0i.y))); // 8 R123i.z = floatBitsToInt((intBitsToFloat(PV1i.y) * intBitsToFloat(R126i.x) + intBitsToFloat(R127i.w))); PV0i.z = R123i.z; R123i.w = floatBitsToInt((intBitsToFloat(PV1i.z) * intBitsToFloat(R127i.z) + intBitsToFloat(R126i.y))); PV0i.w = R123i.w; // 9 backupReg0i = R6i.x; backupReg1i = R6i.y; R6i.x = floatBitsToInt((intBitsToFloat(PV0i.w) * intBitsToFloat(R1i.x) + intBitsToFloat(backupReg0i))); R6i.y = floatBitsToInt((intBitsToFloat(PV0i.z) * intBitsToFloat(R1i.x) + intBitsToFloat(backupReg1i))); } } if( activeMaskStackC[2] == true ) { // 0 backupReg0i = R0i.z; PV0i.x = floatBitsToInt(intBitsToFloat(R6i.y) + -(0.5)); PV0i.x = floatBitsToInt(intBitsToFloat(PV0i.x) * 2.0); PV0i.x = clampFI32(PV0i.x); PV0i.y = floatBitsToInt(intBitsToFloat(R6i.x) + -(0.5)); PV0i.y = floatBitsToInt(intBitsToFloat(PV0i.y) * 2.0); PV0i.y = clampFI32(PV0i.y); PV0i.z = floatBitsToInt(-(intBitsToFloat(backupReg0i)) + intBitsToFloat(R9i.y)); // 1 PV1i.y = floatBitsToInt(intBitsToFloat(PV0i.z) * intBitsToFloat(uf_remappedPS[3].x) ); //nope PV1i.y = clampFI32(PV1i.y); PV1i.w = floatBitsToInt(intBitsToFloat(PV0i.y) + intBitsToFloat(PV0i.x)); PV1i.w = clampFI32(PV1i.w); // 2 PV0i.x = floatBitsToInt(intBitsToFloat(PV1i.w) + intBitsToFloat(PV1i.y)); PV0i.x = clampFI32(PV0i.x); // 3 tempResultf = log2(intBitsToFloat(PV0i.x)); if( isinf(tempResultf) == true ) tempResultf = -3.40282347E+38F; PS1i = floatBitsToInt(tempResultf); // 4 PV0i.z = floatBitsToInt(intBitsToFloat(PS1i) * intBitsToFloat(uf_remappedPS[2].w)); //nope // 5 R0i.y = 0; R0i.x = floatBitsToInt(exp2(intBitsToFloat(PV0i.z))); PS1i = R0i.x; } activeMaskStackC[1] = activeMaskStack[0] == true && activeMaskStackC[0] == true; // export passPixelColor0 = vec4(intBitsToFloat(R0i.x), intBitsToFloat(R0i.y), intBitsToFloat(R0i.y), intBitsToFloat(R0i.y)); //passPixelColor0 = vec4(intBitsToFloat(R0i.x), intBitsToFloat(R0i.y), intBitsToFloat(R0i.y), intBitsToFloat(R0i.y)); }