mirror of
https://github.com/scratchfoundation/bgfx.git
synced 2024-12-01 11:56:58 -05:00
57 lines
1.9 KiB
Text
57 lines
1.9 KiB
Text
#include <metal_stdlib>
|
|
using namespace metal;
|
|
struct xlatMtlShaderInput {
|
|
half2 xlv_TEXCOORD0;
|
|
half3 xlv_TEXCOORD1;
|
|
half3 xlv_TEXCOORD2;
|
|
half3 xlv_TEXCOORD3;
|
|
};
|
|
struct xlatMtlShaderOutput {
|
|
half4 _fragData [[color(0)]];
|
|
};
|
|
struct xlatMtlShaderUniform {
|
|
half4 _LightColor0;
|
|
half _Shininess;
|
|
};
|
|
fragment xlatMtlShaderOutput xlatMtlMain (xlatMtlShaderInput _mtl_i [[stage_in]], constant xlatMtlShaderUniform& _mtl_u [[buffer(0)]]
|
|
, texture2d<half> _BumpMap [[texture(0)]], sampler _mtlsmp__BumpMap [[sampler(0)]]
|
|
, texture2d<half> _MainTex [[texture(1)]], sampler _mtlsmp__MainTex [[sampler(1)]])
|
|
{
|
|
xlatMtlShaderOutput _mtl_o;
|
|
half4 c_1;
|
|
half4 tmpvar_2;
|
|
tmpvar_2 = _MainTex.sample(_mtlsmp__MainTex, (float2)(_mtl_i.xlv_TEXCOORD0));
|
|
half3 tmpvar_3;
|
|
tmpvar_3 = ((_BumpMap.sample(_mtlsmp__BumpMap, (float2)(_mtl_i.xlv_TEXCOORD0)).xyz * (half)2.0) - (half)1.0);
|
|
half3 halfDir_4;
|
|
halfDir_4 = _mtl_i.xlv_TEXCOORD1;
|
|
half4 c_5;
|
|
half spec_6;
|
|
half tmpvar_7;
|
|
tmpvar_7 = max ((half)0.0, dot (tmpvar_3, halfDir_4));
|
|
half tmpvar_8;
|
|
tmpvar_8 = pow (tmpvar_7, (_mtl_u._Shininess * (half)128.0));
|
|
spec_6 = (tmpvar_8 * tmpvar_2.w);
|
|
c_5.xyz = (((
|
|
(tmpvar_2.xyz * max ((half)0.0, dot (tmpvar_3, _mtl_i.xlv_TEXCOORD2)))
|
|
+ spec_6) * _mtl_u._LightColor0.xyz) * (half)2.0);
|
|
c_5.w = half(0.0);
|
|
c_1.w = c_5.w;
|
|
c_1.xyz = (c_5.xyz + (tmpvar_2.xyz * _mtl_i.xlv_TEXCOORD3));
|
|
_mtl_o._fragData = c_1;
|
|
return _mtl_o;
|
|
}
|
|
|
|
|
|
// stats: 16 alu 2 tex 0 flow
|
|
// inputs: 4
|
|
// #0: xlv_TEXCOORD0 (medium float) 2x1 [-1]
|
|
// #1: xlv_TEXCOORD1 (medium float) 3x1 [-1]
|
|
// #2: xlv_TEXCOORD2 (low float) 3x1 [-1]
|
|
// #3: xlv_TEXCOORD3 (low float) 3x1 [-1]
|
|
// uniforms: 2 (total size: 10)
|
|
// #0: _LightColor0 (low float) 4x1 [-1] loc 0
|
|
// #1: _Shininess (medium float) 1x1 [-1] loc 8
|
|
// textures: 2
|
|
// #0: _BumpMap (low 2d) 0x0 [-1] loc 0
|
|
// #1: _MainTex (low 2d) 0x0 [-1] loc 1
|