51 lines
1.2 KiB
Plaintext
51 lines
1.2 KiB
Plaintext
#include <metal_stdlib>
|
|
#include <simd/simd.h>
|
|
|
|
using namespace metal;
|
|
|
|
struct type_TransformBuffer
|
|
{
|
|
float4x4 world_to_projection;
|
|
float4x4 projection_to_world;
|
|
float4x4 world_to_view;
|
|
float4x4 view_to_projection;
|
|
packed_float3 camera_pos_world;
|
|
float viewport_min_z;
|
|
packed_float3 camera_dir_world;
|
|
float viewport_max_z;
|
|
float2 viewport_size;
|
|
float2 viewport_offset;
|
|
float2 render_size;
|
|
float time;
|
|
};
|
|
|
|
struct type_model
|
|
{
|
|
float4x4 model;
|
|
float4 color;
|
|
};
|
|
|
|
struct main0_out
|
|
{
|
|
float2 out_var_TEXCOORD0 [[user(locn0)]];
|
|
float4 out_var_COLOR0 [[user(locn1)]];
|
|
float4 gl_Position [[position]];
|
|
};
|
|
|
|
struct main0_in
|
|
{
|
|
float2 in_var_pos [[attribute(0)]];
|
|
float2 in_var_uv [[attribute(1)]];
|
|
float4 in_var_color [[attribute(2)]];
|
|
};
|
|
|
|
vertex main0_out main0(main0_in in [[stage_in]], constant type_TransformBuffer& TransformBuffer [[buffer(0)]], constant type_model& model [[buffer(1)]])
|
|
{
|
|
main0_out out = {};
|
|
out.gl_Position = TransformBuffer.world_to_projection * (model.model * float4(in.in_var_pos, 0.0, 1.0));
|
|
out.out_var_TEXCOORD0 = in.in_var_uv;
|
|
out.out_var_COLOR0 = in.in_var_color * model.color;
|
|
return out;
|
|
}
|
|
|