mirror of
https://github.com/scratchfoundation/bgfx.git
synced 2024-12-04 21:31:11 -05:00
179 lines
5.6 KiB
Text
179 lines
5.6 KiB
Text
|
#include <metal_stdlib>
|
||
|
using namespace metal;
|
||
|
struct xlatMtlShaderInput {
|
||
|
float4 _inVertex [[attribute(0)]];
|
||
|
half3 _inNormal [[attribute(1)]];
|
||
|
float4 _uv0 [[attribute(2)]];
|
||
|
float4 _uv1 [[attribute(3)]];
|
||
|
half4 _color [[attribute(4)]];
|
||
|
};
|
||
|
struct xlatMtlShaderOutput {
|
||
|
float4 xlv_SV_POSITION;
|
||
|
float2 xlv_TEXCOORD0;
|
||
|
half4 xlv_TEXCOORD1;
|
||
|
};
|
||
|
struct xlatMtlShaderUniform {
|
||
|
float _Bias;
|
||
|
float _BlinkingTimeOffsScale;
|
||
|
float4 _Color;
|
||
|
float _FadeOutDistFar;
|
||
|
float _FadeOutDistNear;
|
||
|
float _MaxGrowSize;
|
||
|
float _Multiplier;
|
||
|
float _NoiseAmount;
|
||
|
float _SizeGrowEndDist;
|
||
|
float _SizeGrowStartDist;
|
||
|
float4 _Time;
|
||
|
float _TimeOffDuration;
|
||
|
float _TimeOnDuration;
|
||
|
float _VerticalBillboarding;
|
||
|
float4x4 _World2Object;
|
||
|
float3 _WorldSpaceCameraPos;
|
||
|
float4x4 glstate_matrix_mvp;
|
||
|
};
|
||
|
vertex xlatMtlShaderOutput xlatMtlMain (xlatMtlShaderInput _mtl_i [[stage_in]], constant xlatMtlShaderUniform& _mtl_u [[buffer(0)]])
|
||
|
{
|
||
|
xlatMtlShaderOutput _mtl_o;
|
||
|
float3 tmpvar_1;
|
||
|
float4 tmpvar_2;
|
||
|
tmpvar_1 = float3(_mtl_i._inNormal);
|
||
|
tmpvar_2 = float4(_mtl_i._color);
|
||
|
half4 tmpvar_3;
|
||
|
float noiseWave_4;
|
||
|
float noiseTime_5;
|
||
|
float wave_6;
|
||
|
float time_7;
|
||
|
float3 BBLocalPos_8;
|
||
|
float3 localDir_9;
|
||
|
float3 centerLocal_10;
|
||
|
float3 centerOffs_11;
|
||
|
float3 tmpvar_12;
|
||
|
tmpvar_12.z = 0.0;
|
||
|
tmpvar_12.xy = (float2(0.5, 0.5) - tmpvar_2.xy);
|
||
|
centerOffs_11 = (tmpvar_12 * _mtl_i._uv1.xyy);
|
||
|
centerLocal_10 = (_mtl_i._inVertex.xyz + centerOffs_11);
|
||
|
float4 tmpvar_13;
|
||
|
tmpvar_13.w = 1.0;
|
||
|
tmpvar_13.xyz = _mtl_u._WorldSpaceCameraPos;
|
||
|
localDir_9 = ((_mtl_u._World2Object * tmpvar_13).xyz - centerLocal_10);
|
||
|
localDir_9.y = (localDir_9.y * _mtl_u._VerticalBillboarding);
|
||
|
float tmpvar_14;
|
||
|
tmpvar_14 = sqrt(dot (localDir_9, localDir_9));
|
||
|
float3 dir_15;
|
||
|
dir_15 = (localDir_9 / tmpvar_14);
|
||
|
float tmpvar_16;
|
||
|
tmpvar_16 = abs(dir_15.y);
|
||
|
float3 tmpvar_17;
|
||
|
if ((tmpvar_16 > 0.999)) {
|
||
|
tmpvar_17 = float3(0.0, 0.0, 1.0);
|
||
|
} else {
|
||
|
tmpvar_17 = float3(0.0, 1.0, 0.0);
|
||
|
};
|
||
|
float3 tmpvar_18;
|
||
|
tmpvar_18 = normalize(((tmpvar_17.yzx * dir_15.zxy) - (tmpvar_17.zxy * dir_15.yzx)));
|
||
|
float3 tmpvar_19;
|
||
|
tmpvar_19 = ((dir_15.yzx * tmpvar_18.zxy) - (dir_15.zxy * tmpvar_18.yzx));
|
||
|
float tmpvar_20;
|
||
|
tmpvar_20 = min ((max (
|
||
|
(tmpvar_14 - _mtl_u._SizeGrowStartDist)
|
||
|
, 0.0) / _mtl_u._SizeGrowEndDist), 1.0);
|
||
|
BBLocalPos_8 = ((centerLocal_10 - (
|
||
|
(tmpvar_18 * centerOffs_11.x)
|
||
|
+
|
||
|
(tmpvar_19 * centerOffs_11.y)
|
||
|
)) + ((
|
||
|
(tmpvar_18 * tmpvar_1.x)
|
||
|
+
|
||
|
(tmpvar_19 * tmpvar_1.y)
|
||
|
) * (
|
||
|
(tmpvar_20 * tmpvar_20)
|
||
|
*
|
||
|
(_mtl_u._MaxGrowSize * tmpvar_2.w)
|
||
|
)));
|
||
|
time_7 = (_mtl_u._Time.y + (_mtl_u._BlinkingTimeOffsScale * tmpvar_2.z));
|
||
|
float y_21;
|
||
|
y_21 = (_mtl_u._TimeOnDuration + _mtl_u._TimeOffDuration);
|
||
|
float tmpvar_22;
|
||
|
tmpvar_22 = (time_7 / y_21);
|
||
|
float tmpvar_23;
|
||
|
tmpvar_23 = (fract(abs(tmpvar_22)) * y_21);
|
||
|
float tmpvar_24;
|
||
|
if ((tmpvar_22 >= 0.0)) {
|
||
|
tmpvar_24 = tmpvar_23;
|
||
|
} else {
|
||
|
tmpvar_24 = -(tmpvar_23);
|
||
|
};
|
||
|
float tmpvar_25;
|
||
|
tmpvar_25 = clamp ((tmpvar_24 / (_mtl_u._TimeOnDuration * 0.25)), 0.0, 1.0);
|
||
|
float edge0_26;
|
||
|
edge0_26 = (_mtl_u._TimeOnDuration * 0.75);
|
||
|
float tmpvar_27;
|
||
|
tmpvar_27 = clamp (((tmpvar_24 - edge0_26) / (_mtl_u._TimeOnDuration - edge0_26)), 0.0, 1.0);
|
||
|
wave_6 = ((tmpvar_25 * (tmpvar_25 *
|
||
|
(3.0 - (2.0 * tmpvar_25))
|
||
|
)) * (1.0 - (tmpvar_27 *
|
||
|
(tmpvar_27 * (3.0 - (2.0 * tmpvar_27)))
|
||
|
)));
|
||
|
noiseTime_5 = (time_7 * (6.28319 / _mtl_u._TimeOnDuration));
|
||
|
noiseWave_4 = ((_mtl_u._NoiseAmount * (
|
||
|
sin(noiseTime_5)
|
||
|
*
|
||
|
((0.5 * cos((
|
||
|
(noiseTime_5 * 0.6366)
|
||
|
+ 56.7272))) + 0.5)
|
||
|
)) + (1.0 - _mtl_u._NoiseAmount));
|
||
|
float tmpvar_28;
|
||
|
if ((_mtl_u._NoiseAmount < 0.01)) {
|
||
|
tmpvar_28 = wave_6;
|
||
|
} else {
|
||
|
tmpvar_28 = noiseWave_4;
|
||
|
};
|
||
|
wave_6 = (tmpvar_28 + _mtl_u._Bias);
|
||
|
float4 tmpvar_29;
|
||
|
tmpvar_29.w = 1.0;
|
||
|
tmpvar_29.xyz = BBLocalPos_8;
|
||
|
float ffadeout_30;
|
||
|
float nfadeout_31;
|
||
|
float tmpvar_32;
|
||
|
tmpvar_32 = clamp ((tmpvar_14 / _mtl_u._FadeOutDistNear), 0.0, 1.0);
|
||
|
ffadeout_30 = (1.0 - clamp ((
|
||
|
max ((tmpvar_14 - _mtl_u._FadeOutDistFar), 0.0)
|
||
|
* 0.2), 0.0, 1.0));
|
||
|
ffadeout_30 = (ffadeout_30 * ffadeout_30);
|
||
|
nfadeout_31 = (tmpvar_32 * tmpvar_32);
|
||
|
nfadeout_31 = (nfadeout_31 * nfadeout_31);
|
||
|
nfadeout_31 = (nfadeout_31 * ffadeout_30);
|
||
|
tmpvar_3 = half4(((nfadeout_31 * _mtl_u._Color) * (_mtl_u._Multiplier * wave_6)));
|
||
|
_mtl_o.xlv_SV_POSITION = (_mtl_u.glstate_matrix_mvp * tmpvar_29);
|
||
|
_mtl_o.xlv_TEXCOORD0 = _mtl_i._uv0.xy;
|
||
|
_mtl_o.xlv_TEXCOORD1 = tmpvar_3;
|
||
|
return _mtl_o;
|
||
|
}
|
||
|
|
||
|
|
||
|
// stats: 95 alu 0 tex 3 flow
|
||
|
// inputs: 5
|
||
|
// #0: _inVertex (high float) 4x1 [-1] loc 0
|
||
|
// #1: _inNormal (medium float) 3x1 [-1] loc 1
|
||
|
// #2: _uv0 (high float) 4x1 [-1] loc 2
|
||
|
// #3: _uv1 (high float) 4x1 [-1] loc 3
|
||
|
// #4: _color (low float) 4x1 [-1] loc 4
|
||
|
// uniforms: 17 (total size: 240)
|
||
|
// #0: _Bias (high float) 1x1 [-1] loc 0
|
||
|
// #1: _BlinkingTimeOffsScale (high float) 1x1 [-1] loc 4
|
||
|
// #2: _Color (high float) 4x1 [-1] loc 16
|
||
|
// #3: _FadeOutDistFar (high float) 1x1 [-1] loc 32
|
||
|
// #4: _FadeOutDistNear (high float) 1x1 [-1] loc 36
|
||
|
// #5: _MaxGrowSize (high float) 1x1 [-1] loc 40
|
||
|
// #6: _Multiplier (high float) 1x1 [-1] loc 44
|
||
|
// #7: _NoiseAmount (high float) 1x1 [-1] loc 48
|
||
|
// #8: _SizeGrowEndDist (high float) 1x1 [-1] loc 52
|
||
|
// #9: _SizeGrowStartDist (high float) 1x1 [-1] loc 56
|
||
|
// #10: _Time (high float) 4x1 [-1] loc 64
|
||
|
// #11: _TimeOffDuration (high float) 1x1 [-1] loc 80
|
||
|
// #12: _TimeOnDuration (high float) 1x1 [-1] loc 84
|
||
|
// #13: _VerticalBillboarding (high float) 1x1 [-1] loc 88
|
||
|
// #14: _World2Object (high float) 4x4 [-1] loc 96
|
||
|
// #15: _WorldSpaceCameraPos (high float) 3x1 [-1] loc 160
|
||
|
// #16: glstate_matrix_mvp (high float) 4x4 [-1] loc 176
|