mirror of
https://github.com/scratchfoundation/bgfx.git
synced 2024-12-11 00:31:28 -05:00
98 lines
3.7 KiB
Text
98 lines
3.7 KiB
Text
#include <metal_stdlib>
|
|
using namespace metal;
|
|
struct xlatMtlShaderInput {
|
|
float4 _glesVertex [[attribute(0)]];
|
|
half3 _glesNormal [[attribute(1)]];
|
|
float4 _glesMultiTexCoord0 [[attribute(2)]];
|
|
};
|
|
struct xlatMtlShaderOutput {
|
|
float4 gl_Position [[position]];
|
|
half4 xlv_COLOR0;
|
|
float2 xlv_TEXCOORD0;
|
|
};
|
|
struct xlatMtlShaderUniform {
|
|
half4 unity_LightColor[8];
|
|
float4 unity_LightPosition[8];
|
|
half4 unity_LightAtten[8];
|
|
float4x4 glstate_matrix_mvp;
|
|
float4x4 glstate_matrix_modelview0;
|
|
float4x4 glstate_matrix_invtrans_modelview0;
|
|
float4 glstate_lightmodel_ambient;
|
|
half4 _Color;
|
|
};
|
|
vertex xlatMtlShaderOutput xlatMtlMain (xlatMtlShaderInput _mtl_i [[stage_in]], constant xlatMtlShaderUniform& _mtl_u [[buffer(0)]])
|
|
{
|
|
xlatMtlShaderOutput _mtl_o;
|
|
float3 tmpvar_1;
|
|
tmpvar_1 = _mtl_i._glesVertex.xyz;
|
|
float3 n_2;
|
|
n_2 = float3(_mtl_i._glesNormal);
|
|
half4 tmpvar_3;
|
|
float4 tmpvar_4;
|
|
tmpvar_4.w = 1.0;
|
|
tmpvar_4.xyz = tmpvar_1;
|
|
float3 lightColor_5;
|
|
float3 viewN_6;
|
|
float3 viewpos_7;
|
|
float4 tmpvar_8;
|
|
tmpvar_8.w = 1.0;
|
|
tmpvar_8.xyz = tmpvar_1;
|
|
viewpos_7 = (_mtl_u.glstate_matrix_modelview0 * tmpvar_8).xyz;
|
|
float3x3 tmpvar_9;
|
|
tmpvar_9[0] = _mtl_u.glstate_matrix_invtrans_modelview0[0].xyz;
|
|
tmpvar_9[1] = _mtl_u.glstate_matrix_invtrans_modelview0[1].xyz;
|
|
tmpvar_9[2] = _mtl_u.glstate_matrix_invtrans_modelview0[2].xyz;
|
|
viewN_6 = (tmpvar_9 * n_2);
|
|
float3 tmpvar_10;
|
|
tmpvar_10 = (_mtl_u.unity_LightPosition[0].xyz - (viewpos_7 * _mtl_u.unity_LightPosition[0].w));
|
|
lightColor_5 = (_mtl_u.glstate_lightmodel_ambient.xyz + ((float3)_mtl_u.unity_LightColor[0].xyz * (
|
|
max (0.0, dot (viewN_6, normalize(tmpvar_10)))
|
|
*
|
|
(1.0/((1.0 + (dot (tmpvar_10, tmpvar_10) * (float)_mtl_u.unity_LightAtten[0].z))))
|
|
)));
|
|
float3 tmpvar_11;
|
|
tmpvar_11 = (_mtl_u.unity_LightPosition[1].xyz - (viewpos_7 * _mtl_u.unity_LightPosition[1].w));
|
|
lightColor_5 = (lightColor_5 + ((float3)_mtl_u.unity_LightColor[1].xyz * (
|
|
max (0.0, dot (viewN_6, normalize(tmpvar_11)))
|
|
*
|
|
(1.0/((1.0 + (dot (tmpvar_11, tmpvar_11) * (float)_mtl_u.unity_LightAtten[1].z))))
|
|
)));
|
|
float3 tmpvar_12;
|
|
tmpvar_12 = (_mtl_u.unity_LightPosition[2].xyz - (viewpos_7 * _mtl_u.unity_LightPosition[2].w));
|
|
lightColor_5 = (lightColor_5 + ((float3)_mtl_u.unity_LightColor[2].xyz * (
|
|
max (0.0, dot (viewN_6, normalize(tmpvar_12)))
|
|
*
|
|
(1.0/((1.0 + (dot (tmpvar_12, tmpvar_12) * (float)_mtl_u.unity_LightAtten[2].z))))
|
|
)));
|
|
float3 tmpvar_13;
|
|
tmpvar_13 = (_mtl_u.unity_LightPosition[3].xyz - (viewpos_7 * _mtl_u.unity_LightPosition[3].w));
|
|
lightColor_5 = (lightColor_5 + ((float3)_mtl_u.unity_LightColor[3].xyz * (
|
|
max (0.0, dot (viewN_6, normalize(tmpvar_13)))
|
|
*
|
|
(1.0/((1.0 + (dot (tmpvar_13, tmpvar_13) * (float)_mtl_u.unity_LightAtten[3].z))))
|
|
)));
|
|
float4 tmpvar_14;
|
|
tmpvar_14.w = 1.0;
|
|
tmpvar_14.xyz = ((lightColor_5 * (float3)_mtl_u._Color.xyz) * 2.0);
|
|
tmpvar_3 = half4(tmpvar_14);
|
|
_mtl_o.gl_Position = (_mtl_u.glstate_matrix_mvp * tmpvar_4);
|
|
_mtl_o.xlv_COLOR0 = tmpvar_3;
|
|
_mtl_o.xlv_TEXCOORD0 = _mtl_i._glesMultiTexCoord0.xy;
|
|
return _mtl_o;
|
|
}
|
|
|
|
|
|
// stats: 56 alu 0 tex 0 flow
|
|
// inputs: 3
|
|
// #0: _glesVertex (high float) 4x1 [-1] loc 0
|
|
// #1: _glesNormal (medium float) 3x1 [-1] loc 1
|
|
// #2: _glesMultiTexCoord0 (high float) 4x1 [-1] loc 2
|
|
// uniforms: 8 (total size: 472)
|
|
// #0: unity_LightColor (medium float) 4x1 [8] loc 0
|
|
// #1: unity_LightPosition (high float) 4x1 [8] loc 64
|
|
// #2: unity_LightAtten (medium float) 4x1 [8] loc 192
|
|
// #3: glstate_matrix_mvp (high float) 4x4 [-1] loc 256
|
|
// #4: glstate_matrix_modelview0 (high float) 4x4 [-1] loc 320
|
|
// #5: glstate_matrix_invtrans_modelview0 (high float) 4x4 [-1] loc 384
|
|
// #6: glstate_lightmodel_ambient (high float) 4x1 [-1] loc 448
|
|
// #7: _Color (medium float) 4x1 [-1] loc 464
|