mirror of
https://github.com/scratchfoundation/bgfx.git
synced 2024-11-25 17:18:12 -05:00
95 lines
3.2 KiB
Text
95 lines
3.2 KiB
Text
|
uniform sampler2D _CameraDepthNormalsTexture;
|
||
|
uniform sampler2D _RandomTexture;
|
||
|
uniform highp vec4 _Params;
|
||
|
uniform highp vec4 _ProjectionParams;
|
||
|
varying highp vec2 xlv_TEXCOORD0;
|
||
|
varying highp vec2 xlv_TEXCOORD1;
|
||
|
void main ()
|
||
|
{
|
||
|
highp vec3 RAND_SAMPLES_1[8];
|
||
|
RAND_SAMPLES_1[0] = vec3(0.0130572, 0.587232, -0.119337);
|
||
|
RAND_SAMPLES_1[1] = vec3(0.323078, 0.0220727, -0.418873);
|
||
|
RAND_SAMPLES_1[2] = vec3(-0.310725, -0.191367, 0.0561369);
|
||
|
RAND_SAMPLES_1[3] = vec3(-0.479646, 0.0939877, -0.580265);
|
||
|
RAND_SAMPLES_1[4] = vec3(0.139999, -0.33577, 0.559679);
|
||
|
RAND_SAMPLES_1[5] = vec3(-0.248458, 0.255532, 0.348944);
|
||
|
RAND_SAMPLES_1[6] = vec3(0.18719, -0.702764, -0.231748);
|
||
|
RAND_SAMPLES_1[7] = vec3(0.884915, 0.284208, 0.368524);
|
||
|
mediump float tmpvar_2;
|
||
|
highp vec2 tmpvar_3;
|
||
|
tmpvar_3 = xlv_TEXCOORD0;
|
||
|
highp vec3 samples_4[8];
|
||
|
samples_4[0]=RAND_SAMPLES_1[0];samples_4[1]=RAND_SAMPLES_1[1];samples_4[2]=RAND_SAMPLES_1[2];samples_4[3]=RAND_SAMPLES_1[3];samples_4[4]=RAND_SAMPLES_1[4];samples_4[5]=RAND_SAMPLES_1[5];samples_4[6]=RAND_SAMPLES_1[6];samples_4[7]=RAND_SAMPLES_1[7];
|
||
|
highp float occ_6;
|
||
|
highp float scale_7;
|
||
|
highp float depth_8;
|
||
|
highp vec3 viewNorm_9;
|
||
|
highp vec4 depthnormal_10;
|
||
|
mediump vec3 randN_11;
|
||
|
lowp vec3 tmpvar_12;
|
||
|
tmpvar_12 = ((texture2D (_RandomTexture, xlv_TEXCOORD1).xyz * 2.0) - 1.0);
|
||
|
randN_11 = tmpvar_12;
|
||
|
lowp vec4 tmpvar_13;
|
||
|
tmpvar_13 = texture2D (_CameraDepthNormalsTexture, xlv_TEXCOORD0);
|
||
|
depthnormal_10 = tmpvar_13;
|
||
|
highp vec3 n_14;
|
||
|
highp vec3 tmpvar_15;
|
||
|
tmpvar_15 = ((depthnormal_10.xyz * vec3(3.5554, 3.5554, 0.0)) + vec3(-1.7777, -1.7777, 1.0));
|
||
|
highp float tmpvar_16;
|
||
|
tmpvar_16 = (2.0 / dot (tmpvar_15, tmpvar_15));
|
||
|
n_14.xy = (tmpvar_16 * tmpvar_15.xy);
|
||
|
n_14.z = (tmpvar_16 - 1.0);
|
||
|
viewNorm_9 = n_14;
|
||
|
highp float tmpvar_17;
|
||
|
tmpvar_17 = (dot (depthnormal_10.zw, vec2(1.0, 0.00392157)) * _ProjectionParams.z);
|
||
|
depth_8 = tmpvar_17;
|
||
|
scale_7 = (_Params.x / tmpvar_17);
|
||
|
occ_6 = 0.0;
|
||
|
for (int s_5 = 0; s_5 < 8; s_5++) {
|
||
|
highp vec4 sampleND_18;
|
||
|
mediump vec3 randomDir_19;
|
||
|
highp vec3 tmpvar_20;
|
||
|
highp vec3 I_21;
|
||
|
I_21 = samples_4[s_5];
|
||
|
tmpvar_20 = (I_21 - (2.0 * (
|
||
|
dot (randN_11, I_21)
|
||
|
* randN_11)));
|
||
|
randomDir_19 = tmpvar_20;
|
||
|
highp float tmpvar_22;
|
||
|
tmpvar_22 = dot (viewNorm_9, randomDir_19);
|
||
|
mediump float tmpvar_23;
|
||
|
if ((tmpvar_22 < 0.0)) {
|
||
|
tmpvar_23 = 1.0;
|
||
|
} else {
|
||
|
tmpvar_23 = -1.0;
|
||
|
};
|
||
|
mediump vec3 tmpvar_24;
|
||
|
tmpvar_24 = (randomDir_19 * -(tmpvar_23));
|
||
|
highp vec3 tmpvar_25;
|
||
|
tmpvar_25 = (tmpvar_24 + (viewNorm_9 * 0.3));
|
||
|
randomDir_19 = tmpvar_25;
|
||
|
lowp vec4 tmpvar_26;
|
||
|
highp vec2 P_27;
|
||
|
P_27 = (tmpvar_3 + (randomDir_19.xy * scale_7));
|
||
|
tmpvar_26 = texture2D (_CameraDepthNormalsTexture, P_27);
|
||
|
sampleND_18 = tmpvar_26;
|
||
|
highp float tmpvar_28;
|
||
|
tmpvar_28 = clamp (((depth_8 -
|
||
|
(randomDir_19.z * _Params.x)
|
||
|
) - (
|
||
|
dot (sampleND_18.zw, vec2(1.0, 0.00392157))
|
||
|
* _ProjectionParams.z)), 0.0, 1.0);
|
||
|
if ((tmpvar_28 > _Params.y)) {
|
||
|
occ_6 = (occ_6 + pow ((1.0 - tmpvar_28), _Params.z));
|
||
|
};
|
||
|
};
|
||
|
highp float tmpvar_29;
|
||
|
tmpvar_29 = (occ_6 / 8.0);
|
||
|
occ_6 = tmpvar_29;
|
||
|
tmpvar_2 = (1.0 - tmpvar_29);
|
||
|
gl_FragData[0] = vec4(tmpvar_2);
|
||
|
}
|
||
|
|
||
|
|
||
|
// inputs: 2, stats: 49 alu 3 tex 4 flow
|