mirror of
https://github.com/scratchfoundation/bgfx.git
synced 2024-11-25 09:08:22 -05:00
43 lines
1.4 KiB
Text
43 lines
1.4 KiB
Text
#include <metal_stdlib>
|
|
using namespace metal;
|
|
struct xlatMtlShaderInput {
|
|
float2 xlv_uv;
|
|
half3 xlv_nl;
|
|
};
|
|
struct xlatMtlShaderOutput {
|
|
half4 _fragData [[color(0)]];
|
|
};
|
|
struct xlatMtlShaderUniform {
|
|
half4 _TerrainTreeLightColors[4];
|
|
};
|
|
fragment xlatMtlShaderOutput xlatMtlMain (xlatMtlShaderInput _mtl_i [[stage_in]], constant xlatMtlShaderUniform& _mtl_u [[buffer(0)]]
|
|
, texture2d<half> _MainTex [[texture(0)]], sampler _mtlsmp__MainTex [[sampler(0)]])
|
|
{
|
|
xlatMtlShaderOutput _mtl_o;
|
|
half4 tmpvar_1;
|
|
half3 light_2;
|
|
half4 tmpvar_3;
|
|
tmpvar_3 = _MainTex.sample(_mtlsmp__MainTex, (float2)(_mtl_i.xlv_uv));
|
|
if ((tmpvar_3.w < (half)0.5)) {
|
|
discard_fragment();
|
|
};
|
|
light_2 = ((tmpvar_3.xyz * _mtl_i.xlv_nl.x) * _mtl_u._TerrainTreeLightColors[0].xyz);
|
|
light_2 = (light_2 + ((tmpvar_3.xyz * _mtl_i.xlv_nl.y) * _mtl_u._TerrainTreeLightColors[1].xyz));
|
|
light_2 = (light_2 + ((tmpvar_3.xyz * _mtl_i.xlv_nl.z) * _mtl_u._TerrainTreeLightColors[2].xyz));
|
|
half4 tmpvar_4;
|
|
tmpvar_4.w = half(1.0);
|
|
tmpvar_4.xyz = light_2;
|
|
tmpvar_1 = tmpvar_4;
|
|
_mtl_o._fragData = tmpvar_1;
|
|
return _mtl_o;
|
|
}
|
|
|
|
|
|
// stats: 10 alu 2 tex 1 flow
|
|
// inputs: 2
|
|
// #0: xlv_uv (high float) 2x1 [-1]
|
|
// #1: xlv_nl (medium float) 3x1 [-1]
|
|
// uniforms: 1 (total size: 32)
|
|
// #0: _TerrainTreeLightColors (medium float) 4x1 [4] loc 0
|
|
// textures: 1
|
|
// #0: _MainTex (low 2d) 0x0 [-1] loc 0
|