mirror of
https://github.com/scratchfoundation/bgfx.git
synced 2024-12-04 21:31:11 -05:00
86 lines
2.3 KiB
Text
86 lines
2.3 KiB
Text
|
#include <metal_stdlib>
|
||
|
using namespace metal;
|
||
|
struct xlatMtlShaderInput {
|
||
|
float4 _glesVertex [[attribute(0)]];
|
||
|
float3 _glesNormal [[attribute(1)]];
|
||
|
};
|
||
|
struct xlatMtlShaderOutput {
|
||
|
float4 gl_Position [[position]];
|
||
|
half4 xlv_COLOR0;
|
||
|
};
|
||
|
struct xlatMtlShaderUniform {
|
||
|
half4 unity_LightColor[8];
|
||
|
float4 unity_LightPosition[8];
|
||
|
int4 unity_VertexLightParams;
|
||
|
};
|
||
|
vertex xlatMtlShaderOutput xlatMtlMain (xlatMtlShaderInput _mtl_i [[stage_in]], constant xlatMtlShaderUniform& _mtl_u [[buffer(0)]])
|
||
|
{
|
||
|
xlatMtlShaderOutput _mtl_o;
|
||
|
float3 tmpvar_1;
|
||
|
tmpvar_1 = _mtl_i._glesVertex.xyz;
|
||
|
int j_2;
|
||
|
int j_3;
|
||
|
int il_4;
|
||
|
half3 lcolor_5;
|
||
|
half3 eyeNormal_6;
|
||
|
half4 color_7;
|
||
|
half4 tmpvar_8;
|
||
|
color_7 = half4(float4(0.0, 0.0, 0.0, 1.1));
|
||
|
eyeNormal_6 = half3(_mtl_i._glesNormal);
|
||
|
lcolor_5 = half3(float3(0.0, 0.0, 0.0));
|
||
|
il_4 = 0;
|
||
|
while (true) {
|
||
|
float tmpvar_9;
|
||
|
tmpvar_9 = min (8.0, float(_mtl_u.unity_VertexLightParams.x));
|
||
|
if ((float(il_4) >= tmpvar_9)) {
|
||
|
break;
|
||
|
};
|
||
|
float3 tmpvar_10;
|
||
|
tmpvar_10 = _mtl_u.unity_LightPosition[il_4].xyz;
|
||
|
half3 dirToLight_11;
|
||
|
dirToLight_11 = half3(tmpvar_10);
|
||
|
lcolor_5 = (lcolor_5 + min ((
|
||
|
(max (dot (eyeNormal_6, dirToLight_11), (half)0.0) * _mtl_u.unity_LightColor[il_4].xyz)
|
||
|
* (half)0.5), (half3)float3(1.0, 1.0, 1.0)));
|
||
|
il_4++;
|
||
|
};
|
||
|
color_7.xyz = lcolor_5;
|
||
|
j_3 = 0;
|
||
|
while (true) {
|
||
|
float tmpvar_12;
|
||
|
tmpvar_12 = min (float(_mtl_u.unity_VertexLightParams.y), 4.0);
|
||
|
if ((j_3 >= int(tmpvar_12))) {
|
||
|
break;
|
||
|
};
|
||
|
color_7.xyz = (color_7.xyz + _mtl_u.unity_LightColor[j_3].xyz);
|
||
|
j_3++;
|
||
|
};
|
||
|
j_2 = 0;
|
||
|
while (true) {
|
||
|
int tmpvar_13;
|
||
|
tmpvar_13 = min (_mtl_u.unity_VertexLightParams.y, 4);
|
||
|
if ((j_2 >= tmpvar_13)) {
|
||
|
break;
|
||
|
};
|
||
|
color_7.xyz = (color_7.xyz * _mtl_u.unity_LightColor[j_2].xyz);
|
||
|
j_2++;
|
||
|
};
|
||
|
tmpvar_8 = color_7;
|
||
|
float4 tmpvar_14;
|
||
|
tmpvar_14.w = 1.0;
|
||
|
tmpvar_14.xyz = tmpvar_1;
|
||
|
_mtl_o.xlv_COLOR0 = tmpvar_8;
|
||
|
_mtl_o.gl_Position = tmpvar_14;
|
||
|
return _mtl_o;
|
||
|
}
|
||
|
|
||
|
|
||
|
// stats: 27 alu 0 tex 6 flow
|
||
|
// inputs: 2
|
||
|
// #0: _glesVertex (high float) 4x1 [-1] loc 0
|
||
|
// #1: _glesNormal (high float) 3x1 [-1] loc 1
|
||
|
// uniforms: 3 (total size: 208)
|
||
|
// #0: unity_LightColor (medium float) 4x1 [8] loc 0
|
||
|
// #1: unity_LightPosition (high float) 4x1 [8] loc 64
|
||
|
// #2: unity_VertexLightParams (high int) 4x1 [-1] loc 192
|