mirror of
https://github.com/scratchfoundation/bgfx.git
synced 2024-11-25 17:18:12 -05:00
94 lines
4.1 KiB
Text
94 lines
4.1 KiB
Text
|
uniform vec4 _ProjectionParams;
|
||
|
uniform sampler2D _CameraDepthNormalsTexture;
|
||
|
uniform sampler2D _RandomTexture;
|
||
|
uniform vec4 _Params;
|
||
|
varying vec2 xlv_TEXCOORD0;
|
||
|
varying vec2 xlv_TEXCOORD1;
|
||
|
void main ()
|
||
|
{
|
||
|
vec3 RAND_SAMPLES_1[24];
|
||
|
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);
|
||
|
RAND_SAMPLES_1[8] = vec3(0.0130572, 0.587232, -0.119337);
|
||
|
RAND_SAMPLES_1[9] = vec3(0.323078, 0.0220727, -0.418873);
|
||
|
RAND_SAMPLES_1[10] = vec3(-0.310725, -0.191367, 0.0561369);
|
||
|
RAND_SAMPLES_1[11] = vec3(-0.479646, 0.0939877, -0.580265);
|
||
|
RAND_SAMPLES_1[12] = vec3(0.139999, -0.33577, 0.559679);
|
||
|
RAND_SAMPLES_1[13] = vec3(-0.248458, 0.255532, 0.348944);
|
||
|
RAND_SAMPLES_1[14] = vec3(0.18719, -0.702764, -0.231748);
|
||
|
RAND_SAMPLES_1[15] = vec3(0.884915, 0.284208, 0.368524);
|
||
|
RAND_SAMPLES_1[16] = vec3(0.0130572, 0.587232, -0.119337);
|
||
|
RAND_SAMPLES_1[17] = vec3(0.323078, 0.0220727, -0.418873);
|
||
|
RAND_SAMPLES_1[18] = vec3(-0.310725, -0.191367, 0.0561369);
|
||
|
RAND_SAMPLES_1[19] = vec3(-0.479646, 0.0939877, -0.580265);
|
||
|
RAND_SAMPLES_1[20] = vec3(0.139999, -0.33577, 0.559679);
|
||
|
RAND_SAMPLES_1[21] = vec3(-0.248458, 0.255532, 0.348944);
|
||
|
RAND_SAMPLES_1[22] = vec3(0.18719, -0.702764, -0.231748);
|
||
|
RAND_SAMPLES_1[23] = vec3(0.884915, 0.284208, 0.368524);
|
||
|
vec2 tmpvar_2;
|
||
|
tmpvar_2 = xlv_TEXCOORD0;
|
||
|
vec3 samples_3[24];
|
||
|
samples_3[0]=RAND_SAMPLES_1[0];samples_3[1]=RAND_SAMPLES_1[1];samples_3[2]=RAND_SAMPLES_1[2];samples_3[3]=RAND_SAMPLES_1[3];samples_3[4]=RAND_SAMPLES_1[4];samples_3[5]=RAND_SAMPLES_1[5];samples_3[6]=RAND_SAMPLES_1[6];samples_3[7]=RAND_SAMPLES_1[7];samples_3[8]=RAND_SAMPLES_1[8];samples_3[9]=RAND_SAMPLES_1[9];samples_3[10]=RAND_SAMPLES_1[10];samples_3[11]=RAND_SAMPLES_1[11];samples_3[12]=RAND_SAMPLES_1[12];samples_3[13]=RAND_SAMPLES_1[13];samples_3[14]=RAND_SAMPLES_1[14];samples_3[15]=RAND_SAMPLES_1[15];samples_3[16]=RAND_SAMPLES_1[16];samples_3[17]=RAND_SAMPLES_1[17];samples_3[18]=RAND_SAMPLES_1[18];samples_3[19]=RAND_SAMPLES_1[19];samples_3[20]=RAND_SAMPLES_1[20];samples_3[21]=RAND_SAMPLES_1[21];samples_3[22]=RAND_SAMPLES_1[22];samples_3[23]=RAND_SAMPLES_1[23];
|
||
|
float occ_5;
|
||
|
float scale_6;
|
||
|
float depth_7;
|
||
|
vec3 viewNorm_8;
|
||
|
vec3 randN_9;
|
||
|
randN_9 = ((texture2D (_RandomTexture, xlv_TEXCOORD1).xyz * 2.0) - 1.0);
|
||
|
vec4 tmpvar_10;
|
||
|
tmpvar_10 = texture2D (_CameraDepthNormalsTexture, xlv_TEXCOORD0);
|
||
|
vec3 n_11;
|
||
|
vec3 tmpvar_12;
|
||
|
tmpvar_12 = ((tmpvar_10.xyz * vec3(3.5554, 3.5554, 0.0)) + vec3(-1.7777, -1.7777, 1.0));
|
||
|
float tmpvar_13;
|
||
|
tmpvar_13 = (2.0 / dot (tmpvar_12, tmpvar_12));
|
||
|
n_11.xy = (tmpvar_13 * tmpvar_12.xy);
|
||
|
n_11.z = (tmpvar_13 - 1.0);
|
||
|
viewNorm_8 = n_11;
|
||
|
float tmpvar_14;
|
||
|
tmpvar_14 = (dot (tmpvar_10.zw, vec2(1.0, 0.00392157)) * _ProjectionParams.z);
|
||
|
depth_7 = tmpvar_14;
|
||
|
scale_6 = (_Params.x / tmpvar_14);
|
||
|
occ_5 = 0.0;
|
||
|
for (int s_4 = 0; s_4 < 24; s_4++) {
|
||
|
vec3 tmpvar_15;
|
||
|
vec3 I_16;
|
||
|
I_16 = samples_3[s_4];
|
||
|
tmpvar_15 = (I_16 - (2.0 * (
|
||
|
dot (randN_9, I_16)
|
||
|
* randN_9)));
|
||
|
float tmpvar_17;
|
||
|
tmpvar_17 = dot (viewNorm_8, tmpvar_15);
|
||
|
float tmpvar_18;
|
||
|
if ((tmpvar_17 < 0.0)) {
|
||
|
tmpvar_18 = 1.0;
|
||
|
} else {
|
||
|
tmpvar_18 = -1.0;
|
||
|
};
|
||
|
vec3 tmpvar_19;
|
||
|
tmpvar_19 = ((tmpvar_15 * -(tmpvar_18)) + (viewNorm_8 * 0.3));
|
||
|
float tmpvar_20;
|
||
|
tmpvar_20 = clamp (((depth_7 -
|
||
|
(tmpvar_19.z * _Params.x)
|
||
|
) - (
|
||
|
dot (texture2D (_CameraDepthNormalsTexture, (tmpvar_2 + (tmpvar_19.xy * scale_6))).zw, vec2(1.0, 0.00392157))
|
||
|
* _ProjectionParams.z)), 0.0, 1.0);
|
||
|
if ((tmpvar_20 > _Params.y)) {
|
||
|
occ_5 = (occ_5 + pow ((1.0 - tmpvar_20), _Params.z));
|
||
|
};
|
||
|
};
|
||
|
float tmpvar_21;
|
||
|
tmpvar_21 = (occ_5 / 24.0);
|
||
|
occ_5 = tmpvar_21;
|
||
|
gl_FragData[0] = vec4((1.0 - tmpvar_21));
|
||
|
}
|
||
|
|
||
|
|
||
|
// inputs: 2, stats: 65 alu 3 tex 4 flow
|