mirror of
https://github.com/scratchfoundation/bgfx.git
synced 2024-11-25 09:08:22 -05:00
33 lines
1.5 KiB
Text
33 lines
1.5 KiB
Text
#include <metal_stdlib>
|
|
using namespace metal;
|
|
constexpr sampler _mtl_xl_shadow_sampler(address::clamp_to_edge, filter::linear, compare_func::less);
|
|
struct xlatMtlShaderInput {
|
|
float4 uv;
|
|
};
|
|
struct xlatMtlShaderOutput {
|
|
half4 _fragData [[color(0)]];
|
|
};
|
|
struct xlatMtlShaderUniform {
|
|
};
|
|
fragment xlatMtlShaderOutput xlatMtlMain (xlatMtlShaderInput _mtl_i [[stage_in]], constant xlatMtlShaderUniform& _mtl_u [[buffer(0)]]
|
|
, texture2d<half> tex [[texture(0)]], sampler _mtlsmp_tex [[sampler(0)]]
|
|
, depth2d<float> shadowmap [[texture(1)]], sampler _mtlsmp_shadowmap [[sampler(1)]])
|
|
{
|
|
xlatMtlShaderOutput _mtl_o;
|
|
half4 c_1;
|
|
c_1 = (tex.sample(_mtlsmp_tex, ((float2)(_mtl_i.uv).xy / (float)(_mtl_i.uv).w)) + tex.sample(_mtlsmp_tex, ((float2)(_mtl_i.uv.xyz).xy / (float)(_mtl_i.uv.xyz).z)));
|
|
c_1 = (c_1 + tex.sample(_mtlsmp_tex, ((float2)(_mtl_i.uv).xy / (float)(_mtl_i.uv).w), level(1.0)));
|
|
c_1 = (c_1 + tex.sample(_mtlsmp_tex, ((float2)(_mtl_i.uv.xyz).xy / (float)(_mtl_i.uv.xyz).z), level(1.0)));
|
|
c_1 = (c_1 + half4(shadowmap.sample_compare(_mtl_xl_shadow_sampler, (float2)(_mtl_i.uv.xyz).xy, (float)(_mtl_i.uv.xyz).z)));
|
|
c_1 = (c_1 + half4(shadowmap.sample_compare(_mtl_xl_shadow_sampler, (float2)(_mtl_i.uv).xy / (float)(_mtl_i.uv).w, (float)(_mtl_i.uv).z / (float)(_mtl_i.uv).w)));
|
|
_mtl_o._fragData = c_1;
|
|
return _mtl_o;
|
|
}
|
|
|
|
|
|
// stats: 5 alu 6 tex 0 flow
|
|
// inputs: 1
|
|
// #0: uv (high float) 4x1 [-1]
|
|
// textures: 2
|
|
// #0: tex (low 2d) 0x0 [-1] loc 0
|
|
// #1: shadowmap (low 2dshadow) 0x0 [-1] loc 1
|