mirror of
https://github.com/scratchfoundation/bgfx.git
synced 2024-11-25 17:18:12 -05:00
78 lines
2.4 KiB
Text
78 lines
2.4 KiB
Text
#include <metal_stdlib>
|
|
using namespace metal;
|
|
struct xlatMtlShaderInput {
|
|
float4 _uv0;
|
|
half3 _uv1;
|
|
half3 _uv2;
|
|
half3 _uv3;
|
|
};
|
|
struct xlatMtlShaderOutput {
|
|
half4 _fragData [[color(0)]];
|
|
};
|
|
struct xlatMtlShaderUniform {
|
|
half4 _Color;
|
|
half4 _LightColor0;
|
|
float _Shininess;
|
|
half4 _SpecColor;
|
|
};
|
|
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;
|
|
half3 tmpvar_2;
|
|
half tmpvar_3;
|
|
half4 tmpvar_4;
|
|
tmpvar_4 = _MainTex.sample(_mtlsmp__MainTex, (float2)(_mtl_i._uv0.xy));
|
|
tmpvar_2 = (tmpvar_4.xyz * _mtl_u._Color.xyz);
|
|
tmpvar_3 = (tmpvar_4.w * _mtl_u._Color.w);
|
|
half4 tmpvar_5;
|
|
tmpvar_5 = _BumpMap.sample(_mtlsmp__BumpMap, (float2)(_mtl_i._uv0.zw));
|
|
half4 packednormal_6;
|
|
packednormal_6 = tmpvar_5;
|
|
half4 normal_7;
|
|
normal_7.xy = ((packednormal_6.wy * (half)2.0) - (half)1.0);
|
|
normal_7.z = sqrt((((half)1.0 -
|
|
(normal_7.x * normal_7.x)
|
|
) - (normal_7.y * normal_7.y)));
|
|
half4 c_8;
|
|
half spec_9;
|
|
half tmpvar_10;
|
|
float y_11;
|
|
y_11 = (_mtl_u._Shininess * 128.0);
|
|
tmpvar_10 = ((half)pow ((float)max ((half)0.0, dot (normal_7.xyz,
|
|
normalize((_mtl_i._uv2 + normalize(_mtl_i._uv1)))
|
|
)), y_11));
|
|
spec_9 = (tmpvar_10 * tmpvar_4.w);
|
|
c_8.xyz = (((
|
|
(tmpvar_2 * _mtl_u._LightColor0.xyz)
|
|
*
|
|
max ((half)0.0, dot (normal_7.xyz, _mtl_i._uv2))
|
|
) + (
|
|
(_mtl_u._LightColor0.xyz * _mtl_u._SpecColor.xyz)
|
|
* spec_9)) * (half)2.0);
|
|
c_8.w = (tmpvar_3 + ((_mtl_u._LightColor0.w * _mtl_u._SpecColor.w) * spec_9));
|
|
c_1.xyz = (c_8.xyz + (tmpvar_2 * _mtl_i._uv3));
|
|
c_1.w = tmpvar_3;
|
|
half4 tmpvar_12;
|
|
tmpvar_12 = c_1;
|
|
_mtl_o._fragData = tmpvar_12;
|
|
return _mtl_o;
|
|
}
|
|
|
|
|
|
// stats: 30 alu 2 tex 0 flow
|
|
// inputs: 4
|
|
// #0: _uv0 (high float) 4x1 [-1]
|
|
// #1: _uv1 (medium float) 3x1 [-1]
|
|
// #2: _uv2 (medium float) 3x1 [-1]
|
|
// #3: _uv3 (medium float) 3x1 [-1]
|
|
// uniforms: 4 (total size: 32)
|
|
// #0: _Color (medium float) 4x1 [-1] loc 0
|
|
// #1: _LightColor0 (medium float) 4x1 [-1] loc 8
|
|
// #2: _Shininess (high float) 1x1 [-1] loc 16
|
|
// #3: _SpecColor (medium float) 4x1 [-1] loc 24
|
|
// textures: 2
|
|
// #0: _BumpMap (low 2d) 0x0 [-1] loc 0
|
|
// #1: _MainTex (low 2d) 0x0 [-1] loc 1
|