mirror of
https://github.com/scratchfoundation/bgfx.git
synced 2024-11-25 17:18:12 -05:00
384 lines
9.5 KiB
Text
384 lines
9.5 KiB
Text
struct v2f_surf {
|
|
vec4 pos;
|
|
float fog;
|
|
vec4 hip_pack0;
|
|
vec4 hip_pack1;
|
|
vec2 hip_pack2;
|
|
vec3 normal;
|
|
vec3 vlight;
|
|
vec4 _ShadowCoord;
|
|
};
|
|
struct appdata_full {
|
|
vec4 vertex;
|
|
vec4 tangent;
|
|
vec3 normal;
|
|
vec4 texcoord;
|
|
vec4 texcoord1;
|
|
vec4 color;
|
|
};
|
|
uniform vec4 _Control_ST;
|
|
uniform mat4 _Object2World;
|
|
uniform vec4 _ProjectionParams;
|
|
uniform vec4 _Splat0_ST;
|
|
uniform vec4 _Splat1_ST;
|
|
uniform vec4 _Splat2_ST;
|
|
uniform vec4 _Splat3_ST;
|
|
uniform vec4 unity_4LightAtten0;
|
|
uniform vec4 unity_4LightPosX0;
|
|
uniform vec4 unity_4LightPosY0;
|
|
uniform vec4 unity_4LightPosZ0;
|
|
uniform vec3 unity_LightColor0;
|
|
uniform vec3 unity_LightColor1;
|
|
uniform vec3 unity_LightColor2;
|
|
uniform vec3 unity_LightColor3;
|
|
uniform vec4 unity_SHAb;
|
|
uniform vec4 unity_SHAg;
|
|
uniform vec4 unity_SHAr;
|
|
uniform vec4 unity_SHBb;
|
|
uniform vec4 unity_SHBg;
|
|
uniform vec4 unity_SHBr;
|
|
uniform vec4 unity_SHC;
|
|
uniform vec4 unity_Scale;
|
|
attribute vec4 TANGENT;
|
|
varying vec4 xlv_FOG;
|
|
mat3 xll_constructMat3 (
|
|
in mat4 m_1
|
|
)
|
|
{
|
|
vec3 tmpvar_2;
|
|
tmpvar_2 = m_1[0].xyz;
|
|
vec3 tmpvar_3;
|
|
tmpvar_3 = m_1[1].xyz;
|
|
vec3 tmpvar_4;
|
|
tmpvar_4 = m_1[2].xyz;
|
|
mat3 tmpvar_5;
|
|
vec3 tmpvar_6;
|
|
tmpvar_6 = tmpvar_2;
|
|
tmpvar_5[0] = tmpvar_6;
|
|
vec3 tmpvar_7;
|
|
tmpvar_7 = tmpvar_3;
|
|
tmpvar_5[1] = tmpvar_7;
|
|
vec3 tmpvar_8;
|
|
tmpvar_8 = tmpvar_4;
|
|
tmpvar_5[2] = tmpvar_8;
|
|
return tmpvar_5;
|
|
}
|
|
|
|
vec3 ShadeSH9 (
|
|
in vec4 normal_9
|
|
)
|
|
{
|
|
vec3 x3_10;
|
|
float vC_11;
|
|
vec3 x2_12;
|
|
vec4 vB_13;
|
|
vec3 x1_14;
|
|
float tmpvar_15;
|
|
tmpvar_15 = dot (unity_SHAr, normal_9);
|
|
float tmpvar_16;
|
|
tmpvar_16 = tmpvar_15;
|
|
x1_14.x = tmpvar_16;
|
|
float tmpvar_17;
|
|
tmpvar_17 = dot (unity_SHAg, normal_9);
|
|
float tmpvar_18;
|
|
tmpvar_18 = tmpvar_17;
|
|
x1_14.y = vec2(tmpvar_18).y;
|
|
float tmpvar_19;
|
|
tmpvar_19 = dot (unity_SHAb, normal_9);
|
|
float tmpvar_20;
|
|
tmpvar_20 = tmpvar_19;
|
|
x1_14.z = vec3(tmpvar_20).z;
|
|
vec4 tmpvar_21;
|
|
tmpvar_21 = (normal_9.xyzz * normal_9.yzzx);
|
|
vB_13 = tmpvar_21;
|
|
float tmpvar_22;
|
|
tmpvar_22 = dot (unity_SHBr, vB_13);
|
|
float tmpvar_23;
|
|
tmpvar_23 = tmpvar_22;
|
|
x2_12.x = tmpvar_23;
|
|
float tmpvar_24;
|
|
tmpvar_24 = dot (unity_SHBg, vB_13);
|
|
float tmpvar_25;
|
|
tmpvar_25 = tmpvar_24;
|
|
x2_12.y = vec2(tmpvar_25).y;
|
|
float tmpvar_26;
|
|
tmpvar_26 = dot (unity_SHBb, vB_13);
|
|
float tmpvar_27;
|
|
tmpvar_27 = tmpvar_26;
|
|
x2_12.z = vec3(tmpvar_27).z;
|
|
float tmpvar_28;
|
|
tmpvar_28 = ((normal_9.x * normal_9.x) - (normal_9.y * normal_9.y));
|
|
vC_11 = tmpvar_28;
|
|
vec3 tmpvar_29;
|
|
tmpvar_29 = (unity_SHC.xyz * vC_11);
|
|
x3_10 = tmpvar_29;
|
|
return ((x1_14 + x2_12) + x3_10);
|
|
}
|
|
|
|
vec3 Shade4PointLights (
|
|
in vec4 lightPosX_30,
|
|
in vec4 lightPosY_31,
|
|
in vec4 lightPosZ_32,
|
|
in vec3 lightColor0_33,
|
|
in vec3 lightColor1_34,
|
|
in vec3 lightColor2_35,
|
|
in vec3 lightColor3_36,
|
|
in vec4 lightAttenSq_37,
|
|
in vec3 pos_38,
|
|
in vec3 normal_39
|
|
)
|
|
{
|
|
vec3 col_40;
|
|
vec4 diff_41;
|
|
vec4 atten_42;
|
|
vec4 corr_43;
|
|
vec4 ndotl_44;
|
|
vec4 lengthSq_45;
|
|
vec4 toLightZ_46;
|
|
vec4 toLightY_47;
|
|
vec4 toLightX_48;
|
|
vec4 tmpvar_49;
|
|
tmpvar_49 = (lightPosX_30 - pos_38.x);
|
|
toLightX_48 = tmpvar_49;
|
|
vec4 tmpvar_50;
|
|
tmpvar_50 = (lightPosY_31 - pos_38.y);
|
|
toLightY_47 = tmpvar_50;
|
|
vec4 tmpvar_51;
|
|
tmpvar_51 = (lightPosZ_32 - pos_38.z);
|
|
toLightZ_46 = tmpvar_51;
|
|
vec4 tmpvar_52;
|
|
tmpvar_52 = vec4(0.0, 0.0, 0.0, 0.0);
|
|
lengthSq_45 = tmpvar_52;
|
|
vec4 tmpvar_53;
|
|
tmpvar_53 = (lengthSq_45 + (toLightX_48 * toLightX_48));
|
|
lengthSq_45 = tmpvar_53;
|
|
vec4 tmpvar_54;
|
|
tmpvar_54 = (lengthSq_45 + (toLightY_47 * toLightY_47));
|
|
lengthSq_45 = tmpvar_54;
|
|
vec4 tmpvar_55;
|
|
tmpvar_55 = (lengthSq_45 + (toLightZ_46 * toLightZ_46));
|
|
lengthSq_45 = tmpvar_55;
|
|
vec4 tmpvar_56;
|
|
tmpvar_56 = vec4(0.0, 0.0, 0.0, 0.0);
|
|
ndotl_44 = tmpvar_56;
|
|
vec4 tmpvar_57;
|
|
tmpvar_57 = (ndotl_44 + (toLightX_48 * normal_39.x));
|
|
ndotl_44 = tmpvar_57;
|
|
vec4 tmpvar_58;
|
|
tmpvar_58 = (ndotl_44 + (toLightY_47 * normal_39.y));
|
|
ndotl_44 = tmpvar_58;
|
|
vec4 tmpvar_59;
|
|
tmpvar_59 = (ndotl_44 + (toLightZ_46 * normal_39.z));
|
|
ndotl_44 = tmpvar_59;
|
|
vec4 tmpvar_60;
|
|
tmpvar_60 = inversesqrt (lengthSq_45);
|
|
vec4 tmpvar_61;
|
|
tmpvar_61 = tmpvar_60;
|
|
corr_43 = tmpvar_61;
|
|
vec4 tmpvar_62;
|
|
tmpvar_62 = max (vec4(0.0, 0.0, 0.0, 0.0), (ndotl_44 * corr_43));
|
|
vec4 tmpvar_63;
|
|
tmpvar_63 = tmpvar_62;
|
|
ndotl_44 = tmpvar_63;
|
|
vec4 tmpvar_64;
|
|
tmpvar_64 = (1.0 / (1.0 + (lengthSq_45 * lightAttenSq_37)));
|
|
atten_42 = tmpvar_64;
|
|
vec4 tmpvar_65;
|
|
tmpvar_65 = (ndotl_44 * atten_42);
|
|
diff_41 = tmpvar_65;
|
|
vec3 tmpvar_66;
|
|
tmpvar_66 = vec3(0.0, 0.0, 0.0);
|
|
col_40 = tmpvar_66;
|
|
vec3 tmpvar_67;
|
|
tmpvar_67 = (col_40 + (lightColor0_33 * diff_41.x));
|
|
col_40 = tmpvar_67;
|
|
vec3 tmpvar_68;
|
|
tmpvar_68 = (col_40 + (lightColor1_34 * diff_41.y));
|
|
col_40 = tmpvar_68;
|
|
vec3 tmpvar_69;
|
|
tmpvar_69 = (col_40 + (lightColor2_35 * diff_41.z));
|
|
col_40 = tmpvar_69;
|
|
vec3 tmpvar_70;
|
|
tmpvar_70 = (col_40 + (lightColor3_36 * diff_41.w));
|
|
col_40 = tmpvar_70;
|
|
return col_40;
|
|
}
|
|
|
|
void PositionFog (
|
|
in vec4 v_71,
|
|
out vec4 pos_72,
|
|
out float fog_73
|
|
)
|
|
{
|
|
vec4 tmpvar_74;
|
|
tmpvar_74 = (gl_ModelViewProjectionMatrix * v_71);
|
|
pos_72 = tmpvar_74;
|
|
float tmpvar_75;
|
|
tmpvar_75 = pos_72.z;
|
|
fog_73 = tmpvar_75;
|
|
}
|
|
|
|
vec4 ComputeScreenPos (
|
|
in vec4 pos_76
|
|
)
|
|
{
|
|
vec4 o_77;
|
|
vec4 tmpvar_78;
|
|
tmpvar_78 = (pos_76 * 0.5);
|
|
o_77 = tmpvar_78;
|
|
vec2 tmpvar_79;
|
|
tmpvar_79.x = o_77.x;
|
|
tmpvar_79.y = (o_77.y * _ProjectionParams.x);
|
|
vec2 tmpvar_80;
|
|
tmpvar_80 = (tmpvar_79 + o_77.w);
|
|
o_77.xy = tmpvar_80.xy.xy;
|
|
vec2 tmpvar_81;
|
|
tmpvar_81 = pos_76.zw;
|
|
o_77.zw = tmpvar_81.xxxy.zw;
|
|
return o_77;
|
|
}
|
|
|
|
v2f_surf vert_surf (
|
|
in appdata_full v_82
|
|
)
|
|
{
|
|
vec3 worldPos_83;
|
|
vec3 shlight_84;
|
|
vec3 worldN_85;
|
|
v2f_surf o_86;
|
|
PositionFog (v_82.vertex, o_86.pos, o_86.fog);
|
|
vec2 tmpvar_87;
|
|
tmpvar_87 = ((v_82.texcoord.xy * _Control_ST.xy) + _Control_ST.zw);
|
|
o_86.hip_pack0.xy = tmpvar_87.xy.xy;
|
|
vec2 tmpvar_88;
|
|
tmpvar_88 = ((v_82.texcoord.xy * _Splat0_ST.xy) + _Splat0_ST.zw);
|
|
o_86.hip_pack0.zw = tmpvar_88.xxxy.zw;
|
|
vec2 tmpvar_89;
|
|
tmpvar_89 = ((v_82.texcoord.xy * _Splat1_ST.xy) + _Splat1_ST.zw);
|
|
o_86.hip_pack1.xy = tmpvar_89.xy.xy;
|
|
vec2 tmpvar_90;
|
|
tmpvar_90 = ((v_82.texcoord.xy * _Splat2_ST.xy) + _Splat2_ST.zw);
|
|
o_86.hip_pack1.zw = tmpvar_90.xxxy.zw;
|
|
vec2 tmpvar_91;
|
|
tmpvar_91 = ((v_82.texcoord.xy * _Splat3_ST.xy) + _Splat3_ST.zw);
|
|
o_86.hip_pack2 = tmpvar_91.xy.xy;
|
|
mat3 tmpvar_92;
|
|
tmpvar_92 = xll_constructMat3 (_Object2World);
|
|
vec3 tmpvar_93;
|
|
tmpvar_93 = (tmpvar_92 * (v_82.normal * unity_Scale.w));
|
|
worldN_85 = tmpvar_93;
|
|
vec3 tmpvar_94;
|
|
tmpvar_94 = worldN_85;
|
|
o_86.normal = tmpvar_94;
|
|
vec4 tmpvar_95;
|
|
tmpvar_95.w = 1.0;
|
|
tmpvar_95.xyz = worldN_85.xyz;
|
|
vec3 tmpvar_96;
|
|
tmpvar_96 = ShadeSH9 (tmpvar_95);
|
|
vec3 tmpvar_97;
|
|
tmpvar_97 = tmpvar_96;
|
|
shlight_84 = tmpvar_97;
|
|
vec3 tmpvar_98;
|
|
tmpvar_98 = shlight_84;
|
|
o_86.vlight = tmpvar_98;
|
|
vec3 tmpvar_99;
|
|
tmpvar_99 = (_Object2World * v_82.vertex).xyz;
|
|
worldPos_83 = tmpvar_99;
|
|
vec3 tmpvar_100;
|
|
tmpvar_100 = Shade4PointLights (unity_4LightPosX0, unity_4LightPosY0, unity_4LightPosZ0, unity_LightColor0, unity_LightColor1, unity_LightColor2, unity_LightColor3, unity_4LightAtten0, worldPos_83, worldN_85);
|
|
vec3 tmpvar_101;
|
|
tmpvar_101 = (o_86.vlight + tmpvar_100);
|
|
o_86.vlight = tmpvar_101;
|
|
vec4 tmpvar_102;
|
|
tmpvar_102 = ComputeScreenPos (o_86.pos);
|
|
vec4 tmpvar_103;
|
|
tmpvar_103 = tmpvar_102;
|
|
o_86._ShadowCoord = tmpvar_103;
|
|
return o_86;
|
|
}
|
|
|
|
void main ()
|
|
{
|
|
appdata_full xlt_v_104;
|
|
v2f_surf xl_retval_105;
|
|
vec4 tmpvar_106;
|
|
tmpvar_106 = gl_Vertex.xyzw;
|
|
vec4 tmpvar_107;
|
|
tmpvar_107 = tmpvar_106;
|
|
xlt_v_104.vertex = tmpvar_107;
|
|
vec4 tmpvar_108;
|
|
tmpvar_108 = TANGENT.xyzw;
|
|
vec4 tmpvar_109;
|
|
tmpvar_109 = tmpvar_108;
|
|
xlt_v_104.tangent = tmpvar_109;
|
|
vec3 tmpvar_110;
|
|
tmpvar_110 = gl_Normal.xyz;
|
|
vec3 tmpvar_111;
|
|
tmpvar_111 = tmpvar_110;
|
|
xlt_v_104.normal = tmpvar_111;
|
|
vec4 tmpvar_112;
|
|
tmpvar_112 = gl_MultiTexCoord0.xyzw;
|
|
vec4 tmpvar_113;
|
|
tmpvar_113 = tmpvar_112;
|
|
xlt_v_104.texcoord = tmpvar_113;
|
|
vec4 tmpvar_114;
|
|
tmpvar_114 = gl_MultiTexCoord1.xyzw;
|
|
vec4 tmpvar_115;
|
|
tmpvar_115 = tmpvar_114;
|
|
xlt_v_104.texcoord1 = tmpvar_115;
|
|
vec4 tmpvar_116;
|
|
tmpvar_116 = gl_Color.xyzw;
|
|
vec4 tmpvar_117;
|
|
tmpvar_117 = tmpvar_116;
|
|
xlt_v_104.color = tmpvar_117;
|
|
v2f_surf tmpvar_118;
|
|
tmpvar_118 = vert_surf (xlt_v_104);
|
|
v2f_surf tmpvar_119;
|
|
tmpvar_119 = tmpvar_118;
|
|
xl_retval_105 = tmpvar_119;
|
|
vec4 tmpvar_120;
|
|
tmpvar_120 = xl_retval_105.pos.xyzw;
|
|
vec4 tmpvar_121;
|
|
tmpvar_121 = tmpvar_120;
|
|
gl_Position = tmpvar_121;
|
|
vec4 tmpvar_122;
|
|
tmpvar_122.yzw = vec3(0.0, 0.0, 0.0);
|
|
tmpvar_122.x = xl_retval_105.fog;
|
|
vec4 tmpvar_123;
|
|
tmpvar_123 = tmpvar_122;
|
|
xlv_FOG = tmpvar_123;
|
|
vec4 tmpvar_124;
|
|
tmpvar_124 = xl_retval_105.hip_pack0.xyzw;
|
|
vec4 tmpvar_125;
|
|
tmpvar_125 = tmpvar_124;
|
|
gl_TexCoord[0] = tmpvar_125;
|
|
vec4 tmpvar_126;
|
|
tmpvar_126 = xl_retval_105.hip_pack1.xyzw;
|
|
vec4 tmpvar_127;
|
|
tmpvar_127 = tmpvar_126;
|
|
gl_TexCoord[1] = tmpvar_127;
|
|
vec4 tmpvar_128;
|
|
tmpvar_128.zw = vec2(0.0, 0.0);
|
|
tmpvar_128.xy = xl_retval_105.hip_pack2.xy;
|
|
vec4 tmpvar_129;
|
|
tmpvar_129 = tmpvar_128;
|
|
gl_TexCoord[2] = tmpvar_129;
|
|
vec4 tmpvar_130;
|
|
tmpvar_130.w = 0.0;
|
|
tmpvar_130.xyz = xl_retval_105.normal.xyz;
|
|
vec4 tmpvar_131;
|
|
tmpvar_131 = tmpvar_130;
|
|
gl_TexCoord[3] = tmpvar_131;
|
|
vec4 tmpvar_132;
|
|
tmpvar_132.w = 0.0;
|
|
tmpvar_132.xyz = xl_retval_105.vlight.xyz;
|
|
vec4 tmpvar_133;
|
|
tmpvar_133 = tmpvar_132;
|
|
gl_TexCoord[4] = tmpvar_133;
|
|
vec4 tmpvar_134;
|
|
tmpvar_134 = xl_retval_105._ShadowCoord.xyzw;
|
|
vec4 tmpvar_135;
|
|
tmpvar_135 = tmpvar_134;
|
|
gl_TexCoord[5] = tmpvar_135;
|
|
}
|
|
|