bgfx/3rdparty/glsl-optimizer/tests/fragment/zun-SSAO8-irES.txt
2014-03-29 16:26:01 -07:00

355 lines
8.8 KiB
Text

struct v2f_ao {
highp vec4 pos;
highp vec2 uv;
highp vec2 uvr;
};
uniform sampler2D _CameraDepthNormalsTexture;
uniform sampler2D _RandomTexture;
uniform highp vec4 _Params;
uniform highp vec4 _ProjectionParams;
varying highp vec2 xlv_TEXCOORD0;
varying highp vec2 xlv_TEXCOORD1;
mediump float xll_saturate_f (
in mediump float x_1
)
{
mediump float tmpvar_2;
tmpvar_2 = clamp (x_1, 0.0, 1.0);
return tmpvar_2;
}
mediump vec2 xll_saturate_vf2 (
in mediump vec2 x_3
)
{
mediump vec2 tmpvar_4;
tmpvar_4 = clamp (x_3, 0.0, 1.0);
return tmpvar_4;
}
mediump vec3 xll_saturate_vf3 (
in mediump vec3 x_5
)
{
mediump vec3 tmpvar_6;
tmpvar_6 = clamp (x_5, 0.0, 1.0);
return tmpvar_6;
}
mediump vec4 xll_saturate_vf4 (
in mediump vec4 x_7
)
{
mediump vec4 tmpvar_8;
tmpvar_8 = clamp (x_7, 0.0, 1.0);
return tmpvar_8;
}
mediump mat2 xll_saturate_mf2x2 (
in mediump mat2 m_9
)
{
mediump vec2 tmpvar_10;
tmpvar_10 = clamp (m_9[0], 0.0, 1.0);
mediump vec2 tmpvar_11;
tmpvar_11 = clamp (m_9[1], 0.0, 1.0);
mediump mat2 tmpvar_12;
mediump vec2 tmpvar_13;
tmpvar_13 = tmpvar_10;
tmpvar_12[0] = tmpvar_13;
mediump vec2 tmpvar_14;
tmpvar_14 = tmpvar_11;
tmpvar_12[1] = tmpvar_14;
return tmpvar_12;
}
mediump mat3 xll_saturate_mf3x3 (
in mediump mat3 m_15
)
{
mediump vec3 tmpvar_16;
tmpvar_16 = clamp (m_15[0], 0.0, 1.0);
mediump vec3 tmpvar_17;
tmpvar_17 = clamp (m_15[1], 0.0, 1.0);
mediump vec3 tmpvar_18;
tmpvar_18 = clamp (m_15[2], 0.0, 1.0);
mediump mat3 tmpvar_19;
mediump vec3 tmpvar_20;
tmpvar_20 = tmpvar_16;
tmpvar_19[0] = tmpvar_20;
mediump vec3 tmpvar_21;
tmpvar_21 = tmpvar_17;
tmpvar_19[1] = tmpvar_21;
mediump vec3 tmpvar_22;
tmpvar_22 = tmpvar_18;
tmpvar_19[2] = tmpvar_22;
return tmpvar_19;
}
mediump mat4 xll_saturate_mf4x4 (
in mediump mat4 m_23
)
{
mediump vec4 tmpvar_24;
tmpvar_24 = clamp (m_23[0], 0.0, 1.0);
mediump vec4 tmpvar_25;
tmpvar_25 = clamp (m_23[1], 0.0, 1.0);
mediump vec4 tmpvar_26;
tmpvar_26 = clamp (m_23[2], 0.0, 1.0);
mediump vec4 tmpvar_27;
tmpvar_27 = clamp (m_23[3], 0.0, 1.0);
mediump mat4 tmpvar_28;
mediump vec4 tmpvar_29;
tmpvar_29 = tmpvar_24;
tmpvar_28[0] = tmpvar_29;
mediump vec4 tmpvar_30;
tmpvar_30 = tmpvar_25;
tmpvar_28[1] = tmpvar_30;
mediump vec4 tmpvar_31;
tmpvar_31 = tmpvar_26;
tmpvar_28[2] = tmpvar_31;
mediump vec4 tmpvar_32;
tmpvar_32 = tmpvar_27;
tmpvar_28[3] = tmpvar_32;
return tmpvar_28;
}
float DecodeFloatRG (
in highp vec2 enc_33
)
{
highp vec2 kDecodeDot_34;
mediump vec2 tmpvar_35;
tmpvar_35 = vec2(1.0, 0.00392157);
kDecodeDot_34 = tmpvar_35;
highp float tmpvar_36;
tmpvar_36 = dot (enc_33, kDecodeDot_34);
return tmpvar_36;
}
vec3 DecodeViewNormalStereo (
in highp vec4 enc4_37
)
{
highp vec3 n_38;
highp float g_39;
highp vec3 nn_40;
highp float kScale_41;
mediump float tmpvar_42;
tmpvar_42 = 1.7777;
kScale_41 = tmpvar_42;
highp vec3 tmpvar_43;
tmpvar_43.z = 0.0;
tmpvar_43.x = (2.0 * kScale_41);
tmpvar_43.y = (2.0 * kScale_41);
highp vec3 tmpvar_44;
tmpvar_44.z = 1.0;
tmpvar_44.x = -(kScale_41);
tmpvar_44.y = -(kScale_41);
highp vec3 tmpvar_45;
tmpvar_45 = ((enc4_37.xyz * tmpvar_43) + tmpvar_44);
nn_40 = tmpvar_45;
highp float tmpvar_46;
tmpvar_46 = dot (nn_40.xyz, nn_40.xyz);
highp float tmpvar_47;
tmpvar_47 = (2.0 / tmpvar_46);
g_39 = tmpvar_47;
highp vec2 tmpvar_48;
tmpvar_48 = (g_39 * nn_40.xy);
n_38.xy = tmpvar_48.xy.xy;
highp float tmpvar_49;
tmpvar_49 = (g_39 - 1.0);
n_38.z = vec3(tmpvar_49).z;
return n_38;
}
void DecodeDepthNormal (
in highp vec4 enc_50,
out highp float depth_51,
out highp vec3 normal_52
)
{
highp float tmpvar_53;
tmpvar_53 = DecodeFloatRG (enc_50.zw);
highp float tmpvar_54;
tmpvar_54 = tmpvar_53;
depth_51 = tmpvar_54;
highp vec3 tmpvar_55;
tmpvar_55 = DecodeViewNormalStereo (enc_50);
highp vec3 tmpvar_56;
tmpvar_56 = tmpvar_55;
normal_52 = tmpvar_56;
}
mediump float frag_ao (
in v2f_ao i_57,
in int sampleCount_58,
in highp vec3 samples_59[8]
)
{
int s_60;
highp float occ_61;
highp float scale_62;
highp float depth_63;
highp vec3 viewNorm_64;
highp vec4 depthnormal_65;
mediump vec3 randN_66;
lowp vec4 tmpvar_67;
tmpvar_67 = texture2D (_RandomTexture, i_57.uvr);
lowp vec3 tmpvar_68;
tmpvar_68 = ((tmpvar_67.xyz * 2.0) - 1.0);
randN_66 = tmpvar_68;
lowp vec4 tmpvar_69;
tmpvar_69 = texture2D (_CameraDepthNormalsTexture, i_57.uv);
lowp vec4 tmpvar_70;
tmpvar_70 = tmpvar_69;
depthnormal_65 = tmpvar_70;
DecodeDepthNormal (depthnormal_65, depth_63, viewNorm_64);
highp float tmpvar_71;
tmpvar_71 = (depth_63 * _ProjectionParams.z);
depth_63 = tmpvar_71;
highp float tmpvar_72;
tmpvar_72 = (_Params.x / depth_63);
scale_62 = tmpvar_72;
mediump float tmpvar_73;
tmpvar_73 = 0.0;
occ_61 = tmpvar_73;
int tmpvar_74;
tmpvar_74 = 0;
s_60 = tmpvar_74;
while (true) {
highp float zd_75;
highp vec3 sampleN_76;
highp float sampleD_77;
highp vec4 sampleND_78;
highp float sD_79;
highp vec2 offset_80;
mediump float flip_81;
mediump vec3 randomDir_82;
if (!((s_60 < sampleCount_58))) {
break;
};
highp vec3 tmpvar_83;
tmpvar_83 = reflect (samples_59[s_60], randN_66);
highp vec3 tmpvar_84;
tmpvar_84 = tmpvar_83;
randomDir_82 = tmpvar_84;
highp float tmpvar_85;
tmpvar_85 = dot (viewNorm_64, randomDir_82);
mediump float tmpvar_86;
if ((tmpvar_85 < 0.0)) {
tmpvar_86 = 1.0;
} else {
tmpvar_86 = -(1.0);
};
mediump float tmpvar_87;
tmpvar_87 = tmpvar_86;
flip_81 = tmpvar_87;
mediump vec3 tmpvar_88;
tmpvar_88 = (randomDir_82 * -(flip_81));
randomDir_82 = tmpvar_88;
highp vec3 tmpvar_89;
tmpvar_89 = (randomDir_82 + (viewNorm_64 * 0.3));
randomDir_82 = tmpvar_89;
highp vec2 tmpvar_90;
tmpvar_90 = (randomDir_82.xy * scale_62);
offset_80 = tmpvar_90;
highp float tmpvar_91;
tmpvar_91 = (depth_63 - (randomDir_82.z * _Params.x));
sD_79 = tmpvar_91;
lowp vec4 tmpvar_92;
tmpvar_92 = texture2D (_CameraDepthNormalsTexture, (i_57.uv + offset_80));
lowp vec4 tmpvar_93;
tmpvar_93 = tmpvar_92;
sampleND_78 = tmpvar_93;
DecodeDepthNormal (sampleND_78, sampleD_77, sampleN_76);
highp float tmpvar_94;
tmpvar_94 = (sampleD_77 * _ProjectionParams.z);
sampleD_77 = tmpvar_94;
mediump float tmpvar_95;
tmpvar_95 = xll_saturate_f ((sD_79 - sampleD_77));
mediump float tmpvar_96;
tmpvar_96 = tmpvar_95;
zd_75 = tmpvar_96;
if ((zd_75 > _Params.y)) {
highp float tmpvar_97;
tmpvar_97 = pow ((1.0 - zd_75), _Params.z);
highp float tmpvar_98;
tmpvar_98 = (occ_61 + tmpvar_97);
occ_61 = tmpvar_98;
};
int tmpvar_99;
tmpvar_99 = (s_60 + 1);
s_60 = tmpvar_99;
};
highp float tmpvar_100;
tmpvar_100 = (occ_61 / float(sampleCount_58));
occ_61 = tmpvar_100;
return (1.0 - occ_61);
}
mediump vec4 xlat_main (
in v2f_ao i_101
)
{
highp vec3 RAND_SAMPLES_102[8];
mediump vec3 tmpvar_103;
tmpvar_103 = vec3(0.0130572, 0.587232, -0.119337);
RAND_SAMPLES_102[0] = tmpvar_103;
mediump vec3 tmpvar_104;
tmpvar_104 = vec3(0.323078, 0.0220727, -0.418873);
RAND_SAMPLES_102[1] = tmpvar_104;
mediump vec3 tmpvar_105;
tmpvar_105 = vec3(-0.310725, -0.191367, 0.0561369);
RAND_SAMPLES_102[2] = tmpvar_105;
mediump vec3 tmpvar_106;
tmpvar_106 = vec3(-0.479646, 0.0939877, -0.580265);
RAND_SAMPLES_102[3] = tmpvar_106;
mediump vec3 tmpvar_107;
tmpvar_107 = vec3(0.139999, -0.33577, 0.559679);
RAND_SAMPLES_102[4] = tmpvar_107;
mediump vec3 tmpvar_108;
tmpvar_108 = vec3(-0.248458, 0.255532, 0.348944);
RAND_SAMPLES_102[5] = tmpvar_108;
mediump vec3 tmpvar_109;
tmpvar_109 = vec3(0.18719, -0.702764, -0.231748);
RAND_SAMPLES_102[6] = tmpvar_109;
mediump vec3 tmpvar_110;
tmpvar_110 = vec3(0.884915, 0.284208, 0.368524);
RAND_SAMPLES_102[7] = tmpvar_110;
mediump float tmpvar_111;
tmpvar_111 = frag_ao (i_101, 8, RAND_SAMPLES_102);
mediump vec4 tmpvar_112;
tmpvar_112 = vec4(tmpvar_111);
return tmpvar_112;
}
void main ()
{
v2f_ao xlt_i_113;
mediump vec4 xl_retval_114;
mediump vec4 tmpvar_115;
tmpvar_115 = vec4(0.0, 0.0, 0.0, 0.0);
xlt_i_113.pos = tmpvar_115;
highp vec2 tmpvar_116;
tmpvar_116 = xlv_TEXCOORD0.xy;
highp vec2 tmpvar_117;
tmpvar_117 = tmpvar_116;
xlt_i_113.uv = tmpvar_117;
highp vec2 tmpvar_118;
tmpvar_118 = xlv_TEXCOORD1.xy;
highp vec2 tmpvar_119;
tmpvar_119 = tmpvar_118;
xlt_i_113.uvr = tmpvar_119;
mediump vec4 tmpvar_120;
tmpvar_120 = xlat_main (xlt_i_113);
mediump vec4 tmpvar_121;
tmpvar_121 = tmpvar_120;
xl_retval_114 = tmpvar_121;
mediump vec4 tmpvar_122;
tmpvar_122 = xl_retval_114.xyzw;
mediump vec4 tmpvar_123;
tmpvar_123 = tmpvar_122;
gl_FragData[0] = tmpvar_123;
}