diff --git a/base/sources/libs/kong/backends/hlsl.c b/base/sources/libs/kong/backends/hlsl.c index 745f0121..1dce3239 100644 --- a/base/sources/libs/kong/backends/hlsl.c +++ b/base/sources/libs/kong/backends/hlsl.c @@ -856,7 +856,7 @@ static void write_functions(char *hlsl, size_t *offset, shader_stage stage, func sprintf(&hlsl[*offset], ", %s _%" PRIu64, type_string(f->parameter_types[parameter_index].type), parameter_ids[parameter_index]); } } - *offset += sprintf(&hlsl[*offset], ") {\n"); + *offset += sprintf(&hlsl[*offset], ", in uint _kong_vertex_id : SV_VertexID) {\n"); } else if (stage == SHADER_STAGE_FRAGMENT) { if (get_type(f->return_type.type)->array_size > 0) { @@ -1338,6 +1338,10 @@ static void write_functions(char *hlsl, size_t *offset, shader_stage stage, func check(o->op_call.parameters_size == 0, context, "instance_id can not have a parameter"); *offset += sprintf(&hlsl[*offset], "%s _%" PRIu64 " = InstanceID();\n", type_string(o->op_call.var.type.type), o->op_call.var.index); } + else if (o->op_call.func == add_name("vertex_id")) { + check(o->op_call.parameters_size == 0, context, "vertex_id can not have a parameter"); + *offset += sprintf(&hlsl[*offset], "%s _%" PRIu64 " = _kong_vertex_id;\n", type_string(o->op_call.var.type.type), o->op_call.var.index); + } else if (o->op_call.func == add_name("world_ray_direction")) { check(o->op_call.parameters_size == 0, context, "world_ray_direction can not have a parameter"); *offset += sprintf(&hlsl[*offset], "%s _%" PRIu64 " = WorldRayDirection();\n", type_string(o->op_call.var.type.type), o->op_call.var.index); diff --git a/base/sources/libs/kong/functions.c b/base/sources/libs/kong/functions.c index 2a173f84..06110fa2 100644 --- a/base/sources/libs/kong/functions.c +++ b/base/sources/libs/kong/functions.c @@ -785,6 +785,7 @@ void functions_init(void) { add_func_uint3("dispatch_thread_id"); add_func_int("group_index"); add_func_int("instance_id"); + add_func_int("vertex_id"); //// // add_func_float3_float_float_float("lerp");