mirror of
https://github.com/scratchfoundation/bgfx.git
synced 2024-12-01 11:56:58 -05:00
81 lines
2.6 KiB
Text
81 lines
2.6 KiB
Text
|
#include <metal_stdlib>
|
||
|
using namespace metal;
|
||
|
struct xlatMtlShaderInput {
|
||
|
float2 xlv_TEXCOORD0;
|
||
|
half3 xlv_TEXCOORD1;
|
||
|
float3 xlv_TEXCOORD2;
|
||
|
};
|
||
|
struct xlatMtlShaderOutput {
|
||
|
half4 _glesFragData_0 [[color(0)]];
|
||
|
};
|
||
|
struct xlatMtlShaderUniform {
|
||
|
float4 _WorldSpaceLightPos0;
|
||
|
half4 _LightColor0;
|
||
|
half4x4 _LightMatrix0;
|
||
|
};
|
||
|
fragment xlatMtlShaderOutput xlatMtlMain (xlatMtlShaderInput _mtl_i [[stage_in]], constant xlatMtlShaderUniform& _mtl_u [[buffer(0)]]
|
||
|
, texture2d<half> _LightTexture0 [[texture(0)]], sampler _mtlsmp__LightTexture0 [[sampler(0)]]
|
||
|
, texture2d<half> _LightTextureB0 [[texture(1)]], sampler _mtlsmp__LightTextureB0 [[sampler(1)]]
|
||
|
, texture2d<half> _MainTex [[texture(2)]], sampler _mtlsmp__MainTex [[sampler(2)]])
|
||
|
{
|
||
|
xlatMtlShaderOutput _mtl_o;
|
||
|
half4 c_1;
|
||
|
half atten_2;
|
||
|
half4 lightCoord_3;
|
||
|
float3 tmpvar_4;
|
||
|
tmpvar_4 = normalize((_mtl_u._WorldSpaceLightPos0.xyz - _mtl_i.xlv_TEXCOORD2));
|
||
|
half3 tmpvar_5;
|
||
|
half tmpvar_6;
|
||
|
half4 c_7;
|
||
|
half4 tmpvar_8;
|
||
|
tmpvar_8 = _MainTex.sample(_mtlsmp__MainTex, (float2)(_mtl_i.xlv_TEXCOORD0));
|
||
|
c_7 = tmpvar_8;
|
||
|
tmpvar_5 = c_7.xyz;
|
||
|
tmpvar_6 = c_7.w;
|
||
|
float4 tmpvar_9;
|
||
|
tmpvar_9.w = 1.0;
|
||
|
tmpvar_9.xyz = _mtl_i.xlv_TEXCOORD2;
|
||
|
float4 tmpvar_10;
|
||
|
tmpvar_10 = ((float4)(_mtl_u._LightMatrix0 * (half4)tmpvar_9));
|
||
|
lightCoord_3 = half4(tmpvar_10);
|
||
|
half4 tmpvar_11;
|
||
|
half2 P_12;
|
||
|
P_12 = ((lightCoord_3.xy / lightCoord_3.w) + (half)0.5);
|
||
|
tmpvar_11 = _LightTexture0.sample(_mtlsmp__LightTexture0, (float2)(P_12));
|
||
|
half tmpvar_13;
|
||
|
tmpvar_13 = dot (lightCoord_3.xyz, lightCoord_3.xyz);
|
||
|
half4 tmpvar_14;
|
||
|
tmpvar_14 = _LightTextureB0.sample(_mtlsmp__LightTextureB0, (float2)(half2(tmpvar_13)));
|
||
|
half tmpvar_15;
|
||
|
tmpvar_15 = ((half(
|
||
|
(lightCoord_3.z > (half)0.0)
|
||
|
) * tmpvar_11.w) * tmpvar_14.w);
|
||
|
atten_2 = tmpvar_15;
|
||
|
half3 lightDir_16;
|
||
|
lightDir_16 = half3(tmpvar_4);
|
||
|
half4 c_17;
|
||
|
c_17.xyz = ((tmpvar_5 * _mtl_u._LightColor0.xyz) * ((
|
||
|
max ((half)0.0, dot (_mtl_i.xlv_TEXCOORD1, lightDir_16))
|
||
|
* atten_2) * (half)2.0));
|
||
|
c_17.w = tmpvar_6;
|
||
|
c_1.xyz = c_17.xyz;
|
||
|
c_1.w = half(0.0);
|
||
|
_mtl_o._glesFragData_0 = c_1;
|
||
|
return _mtl_o;
|
||
|
}
|
||
|
|
||
|
|
||
|
// stats: 18 alu 3 tex 0 flow
|
||
|
// inputs: 3
|
||
|
// #0: xlv_TEXCOORD0 (high float) 2x1 [-1]
|
||
|
// #1: xlv_TEXCOORD1 (low float) 3x1 [-1]
|
||
|
// #2: xlv_TEXCOORD2 (high float) 3x1 [-1]
|
||
|
// uniforms: 3 (total size: 56)
|
||
|
// #0: _WorldSpaceLightPos0 (high float) 4x1 [-1] loc 0
|
||
|
// #1: _LightColor0 (low float) 4x1 [-1] loc 16
|
||
|
// #2: _LightMatrix0 (medium float) 4x4 [-1] loc 24
|
||
|
// textures: 3
|
||
|
// #0: _LightTexture0 (low 2d) 0x0 [-1] loc 0
|
||
|
// #1: _LightTextureB0 (low 2d) 0x0 [-1] loc 1
|
||
|
// #2: _MainTex (low 2d) 0x0 [-1] loc 2
|