mirror of
https://github.com/scratchfoundation/bgfx.git
synced 2024-11-29 02:55:36 -05:00
83 lines
2.8 KiB
Text
83 lines
2.8 KiB
Text
#include <metal_stdlib>
|
|
using namespace metal;
|
|
struct xlatMtlShaderInput {
|
|
float4 attrVertex [[attribute(0)]];
|
|
half3 attrNormal [[attribute(1)]];
|
|
half4 attrTangent [[attribute(2)]];
|
|
};
|
|
struct xlatMtlShaderOutput {
|
|
float4 gl_Position [[position]];
|
|
half3 varWorldN;
|
|
half3 varLightDir;
|
|
half3 varViewDir;
|
|
};
|
|
struct xlatMtlShaderUniform {
|
|
float4x4 glstate_matrix_mvp;
|
|
float4x4 _Object2World;
|
|
float4x4 _World2Object;
|
|
float3 _WorldSpaceCameraPos;
|
|
half4 _WorldSpaceLightPos0;
|
|
float4 unity_Scale;
|
|
};
|
|
vertex xlatMtlShaderOutput xlatMtlMain (xlatMtlShaderInput _mtl_i [[stage_in]], constant xlatMtlShaderUniform& _mtl_u [[buffer(0)]])
|
|
{
|
|
xlatMtlShaderOutput _mtl_o;
|
|
half3 lightDir_1;
|
|
float3 worldN_2;
|
|
half3 tmpvar_3;
|
|
half3 tmpvar_4;
|
|
half3 tmpvar_5;
|
|
float3x3 tmpvar_6;
|
|
tmpvar_6[0] = _mtl_u._Object2World[0].xyz;
|
|
tmpvar_6[1] = _mtl_u._Object2World[1].xyz;
|
|
tmpvar_6[2] = _mtl_u._Object2World[2].xyz;
|
|
half3 tmpvar_7;
|
|
tmpvar_7 = ((half3)(tmpvar_6 * (float3)_mtl_i.attrNormal));
|
|
worldN_2 = float3(tmpvar_7);
|
|
tmpvar_5 = half3(worldN_2);
|
|
half3 tmpvar_8;
|
|
half3 tmpvar_9;
|
|
tmpvar_8 = _mtl_i.attrTangent.xyz;
|
|
tmpvar_9 = (((_mtl_i.attrNormal.yzx * _mtl_i.attrTangent.zxy) - (_mtl_i.attrNormal.zxy * _mtl_i.attrTangent.yzx)) * _mtl_i.attrTangent.w);
|
|
half3x3 tmpvar_10;
|
|
tmpvar_10[0].x = tmpvar_8.x;
|
|
tmpvar_10[0].y = tmpvar_9.x;
|
|
tmpvar_10[0].z = _mtl_i.attrNormal.x;
|
|
tmpvar_10[1].x = tmpvar_8.y;
|
|
tmpvar_10[1].y = tmpvar_9.y;
|
|
tmpvar_10[1].z = _mtl_i.attrNormal.y;
|
|
tmpvar_10[2].x = tmpvar_8.z;
|
|
tmpvar_10[2].y = tmpvar_9.z;
|
|
tmpvar_10[2].z = _mtl_i.attrNormal.z;
|
|
float3 tmpvar_11;
|
|
tmpvar_11 = ((float3)(tmpvar_10 * (half3)(_mtl_u._World2Object * (float4)_mtl_u._WorldSpaceLightPos0).xyz));
|
|
lightDir_1 = half3(tmpvar_11);
|
|
tmpvar_3 = lightDir_1;
|
|
float4 tmpvar_12;
|
|
tmpvar_12.w = 1.0;
|
|
tmpvar_12.xyz = _mtl_u._WorldSpaceCameraPos;
|
|
float3 tmpvar_13;
|
|
tmpvar_13 = normalize(((float3)lightDir_1 + normalize(
|
|
((float3)(tmpvar_10 * (half3)(((_mtl_u._World2Object * tmpvar_12).xyz * _mtl_u.unity_Scale.w) - _mtl_i.attrVertex.xyz)))
|
|
)));
|
|
tmpvar_4 = half3(tmpvar_13);
|
|
_mtl_o.gl_Position = (_mtl_u.glstate_matrix_mvp * _mtl_i.attrVertex);
|
|
_mtl_o.varWorldN = tmpvar_5;
|
|
_mtl_o.varLightDir = tmpvar_3;
|
|
_mtl_o.varViewDir = tmpvar_4;
|
|
return _mtl_o;
|
|
}
|
|
|
|
|
|
// stats: 16 alu 0 tex 0 flow
|
|
// inputs: 3
|
|
// #0: attrVertex (high float) 4x1 [-1] loc 0
|
|
// #1: attrNormal (medium float) 3x1 [-1] loc 1
|
|
// #2: attrTangent (medium float) 4x1 [-1] loc 2
|
|
// uniforms: 6 (total size: 240)
|
|
// #0: glstate_matrix_mvp (high float) 4x4 [-1] loc 0
|
|
// #1: _Object2World (high float) 4x4 [-1] loc 64
|
|
// #2: _World2Object (high float) 4x4 [-1] loc 128
|
|
// #3: _WorldSpaceCameraPos (high float) 3x1 [-1] loc 192
|
|
// #4: _WorldSpaceLightPos0 (low float) 4x1 [-1] loc 208
|
|
// #5: unity_Scale (high float) 4x1 [-1] loc 224
|