kong test
This commit is contained in:
@@ -283,9 +283,10 @@ function make_paint_run(data: material_t, matcon: material_context_t): node_shad
|
||||
context_raw.tool == workspace_tool_t.PARTICLE ||
|
||||
decal)) {
|
||||
node_shader_add_texture(kong, "texbrushstencil", "_texbrushstencil");
|
||||
node_shader_add_constant(kong, "texbrushstencil_size: float2", "_size(texbrushstencil)");
|
||||
node_shader_add_constant(kong, "stencil_transform: float4", "_stencil_transform");
|
||||
node_shader_write_frag(kong, "var stencil_uv: float2 = float2((sp.xy - constants.stencil_transform.xy) / constants.stencil_transform.z * float2(constants.aspect_ratio, 1.0));");
|
||||
node_shader_write_frag(kong, "var stencil_size: float2 = float2(textureSize(texbrushstencil, 0));");
|
||||
node_shader_write_frag(kong, "var stencil_size: float2 = constants.texbrushstencil_size;");
|
||||
node_shader_write_frag(kong, "var stencil_ratio: float = stencil_size.y / stencil_size.x;");
|
||||
node_shader_write_frag(kong, "stencil_uv -= float2(0.5 / stencil_ratio, 0.5);");
|
||||
node_shader_write_frag(kong, "stencil_uv = float2(stencil_uv.x * cos(constants.stencil_transform.w) - stencil_uv.y * sin(constants.stencil_transform.w),\
|
||||
|
||||
@@ -13,7 +13,9 @@ function make_brush_run(kong: node_shader_t) {
|
||||
|
||||
node_shader_add_constant(kong, "W: float4x4", "_world_matrix");
|
||||
|
||||
node_shader_write_attrib_frag(kong, "var wposition: float3 = (constants.W * texpaint_undo[int2(tex_coord.x * textureSize(texpaint_undo, 0).x, tex_coord.y * textureSize(texpaint_undo, 0).y)]).xyz;");
|
||||
node_shader_add_constant(kong, "texpaint_undo_size: float2", "_size(texpaint_undo)");
|
||||
|
||||
node_shader_write_attrib_frag(kong, "var wposition: float3 = (constants.W * texpaint_undo[int2(tex_coord.x * constants.texpaint_undo_size.x, tex_coord.y * constants.texpaint_undo_size.y)]).xyz;");
|
||||
|
||||
node_shader_write_frag(kong, "var depthlast: float = sample_lod(gbufferD, gbufferD_sampler, constants.inplast.xy, 0.0).r;");
|
||||
|
||||
|
||||
@@ -40,7 +40,8 @@ function make_mesh_run(data: material_t, layer_pass: i32 = 0): node_shader_conte
|
||||
node_shader_add_constant(kong, "WVP: float4x4", "_world_view_proj_matrix");
|
||||
let lid: i32 = project_layers[0].id;
|
||||
node_shader_add_texture(kong, "texpaint_vert", "_texpaint_vert" + lid);
|
||||
node_shader_write_vert(kong, "var meshpos: float3 = sample_lod(texpaint_vert, texpaint_vert_sampler, int2(gl_VertexID % textureSize(texpaint_vert, 0).x, gl_VertexID / textureSize(texpaint_vert, 0).y), 0).xyz;");
|
||||
node_shader_add_constant(kong, "texpaint_vert_size: float2", "_size(texpaint_vert" + lid + ")");
|
||||
node_shader_write_vert(kong, "var meshpos: float3 = sample_lod(texpaint_vert, texpaint_vert_sampler, int2(gl_VertexID % constants.texpaint_vert_size.x, gl_VertexID / constants.texpaint_vert_size.y), 0).xyz;");
|
||||
// + input.pos.xyz * 0.000001
|
||||
node_shader_write_vert(kong, "output.pos = constants.WVP * float4(meshpos.xyz, 1.0);");
|
||||
|
||||
@@ -54,9 +55,9 @@ function make_mesh_run(data: material_t, layer_pass: i32 = 0): node_shader_conte
|
||||
node_shader_write_attrib_vert(kong, "var base_vertex0: int = gl_VertexID - (gl_VertexID % 3);");
|
||||
node_shader_write_attrib_vert(kong, "var base_vertex1: int = base_vertex0 + 1;");
|
||||
node_shader_write_attrib_vert(kong, "var base_vertex2: int = base_vertex0 + 2;");
|
||||
node_shader_write_attrib_vert(kong, "var meshpos0: float3 = sample_lod(texpaint_vert, texpaint_vert_sampler, int2(base_vertex0 % textureSize(texpaint_vert, 0).x, base_vertex0 / textureSize(texpaint_vert, 0).y), 0).xyz;");
|
||||
node_shader_write_attrib_vert(kong, "var meshpos1: float3 = sample_lod(texpaint_vert, texpaint_vert_sampler, int2(base_vertex1 % textureSize(texpaint_vert, 0).x, base_vertex1 / textureSize(texpaint_vert, 0).y), 0).xyz;");
|
||||
node_shader_write_attrib_vert(kong, "var meshpos2: float3 = sample_lod(texpaint_vert, texpaint_vert_sampler, int2(base_vertex2 % textureSize(texpaint_vert, 0).x, base_vertex2 / textureSize(texpaint_vert, 0).y), 0).xyz;");
|
||||
node_shader_write_attrib_vert(kong, "var meshpos0: float3 = sample_lod(texpaint_vert, texpaint_vert_sampler, int2(base_vertex0 % constants.texpaint_vert_size.x, base_vertex0 / constants.texpaint_vert_size.y), 0).xyz;");
|
||||
node_shader_write_attrib_vert(kong, "var meshpos1: float3 = sample_lod(texpaint_vert, texpaint_vert_sampler, int2(base_vertex1 % constants.texpaint_vert_size.x, base_vertex1 / constants.texpaint_vert_size.y), 0).xyz;");
|
||||
node_shader_write_attrib_vert(kong, "var meshpos2: float3 = sample_lod(texpaint_vert, texpaint_vert_sampler, int2(base_vertex2 % constants.texpaint_vert_size.x, base_vertex2 / constants.texpaint_vert_size.y), 0).xyz;");
|
||||
node_shader_write_attrib_vert(kong, "var meshnor: float3 = normalize(cross(meshpos2 - meshpos1, meshpos0 - meshpos1));");
|
||||
node_shader_write_attrib_vert(kong, "output.wnormal = constants.N * meshnor;");
|
||||
node_shader_write_attrib_frag(kong, "var n: float3 = normalize(input.wnormal);");
|
||||
|
||||
@@ -90,6 +90,7 @@ static char *function_string(name_id func) {
|
||||
}
|
||||
|
||||
static void write_bytecode(char *hlsl, char *directory, const char *filename, const char *name, uint8_t *output, size_t output_size) {
|
||||
|
||||
char full_filename[512];
|
||||
|
||||
{
|
||||
@@ -1387,6 +1388,38 @@ static void write_functions(char *hlsl, size_t *offset, shader_stage stage, func
|
||||
*offset += sprintf(&hlsl[*offset], "%s _%" PRIu64 " = max(_%" PRIu64 ", _%" PRIu64 ");\n", type_string(o->op_call.var.type.type),
|
||||
o->op_call.var.index, o->op_call.parameters[0].index, o->op_call.parameters[1].index);
|
||||
}
|
||||
else if (o->op_call.func == add_name("step3")) { ////
|
||||
*offset += sprintf(&hlsl[*offset], "%s _%" PRIu64 " = step(_%" PRIu64 ", _%" PRIu64 ");\n", type_string(o->op_call.var.type.type),
|
||||
o->op_call.var.index, o->op_call.parameters[0].index, o->op_call.parameters[1].index);
|
||||
}
|
||||
else if (o->op_call.func == add_name("pow3")) { ////
|
||||
*offset += sprintf(&hlsl[*offset], "%s _%" PRIu64 " = pow(_%" PRIu64 ", _%" PRIu64 ");\n", type_string(o->op_call.var.type.type),
|
||||
o->op_call.var.index, o->op_call.parameters[0].index, o->op_call.parameters[1].index);
|
||||
}
|
||||
else if (o->op_call.func == add_name("floor3")) { ////
|
||||
*offset += sprintf(&hlsl[*offset], "%s _%" PRIu64 " = floor(_%" PRIu64 ", _%" PRIu64 ");\n", type_string(o->op_call.var.type.type),
|
||||
o->op_call.var.index, o->op_call.parameters[0].index, o->op_call.parameters[1].index);
|
||||
}
|
||||
else if (o->op_call.func == add_name("ceil3")) { ////
|
||||
*offset += sprintf(&hlsl[*offset], "%s _%" PRIu64 " = ceil(_%" PRIu64 ", _%" PRIu64 ");\n", type_string(o->op_call.var.type.type),
|
||||
o->op_call.var.index, o->op_call.parameters[0].index, o->op_call.parameters[1].index);
|
||||
}
|
||||
else if (o->op_call.func == add_name("ddx2")) { ////
|
||||
*offset += sprintf(&hlsl[*offset], "%s _%" PRIu64 " = ddx(_%" PRIu64 ");\n", type_string(o->op_call.var.type.type),
|
||||
o->op_call.var.index, o->op_call.parameters[0].index);
|
||||
}
|
||||
else if (o->op_call.func == add_name("ddy2")) { ////
|
||||
*offset += sprintf(&hlsl[*offset], "%s _%" PRIu64 " = ddx(_%" PRIu64 ");\n", type_string(o->op_call.var.type.type),
|
||||
o->op_call.var.index, o->op_call.parameters[0].index);
|
||||
}
|
||||
else if (o->op_call.func == add_name("ddx3")) { ////
|
||||
*offset += sprintf(&hlsl[*offset], "%s _%" PRIu64 " = ddx(_%" PRIu64 ");\n", type_string(o->op_call.var.type.type),
|
||||
o->op_call.var.index, o->op_call.parameters[0].index);
|
||||
}
|
||||
else if (o->op_call.func == add_name("ddy3")) { ////
|
||||
*offset += sprintf(&hlsl[*offset], "%s _%" PRIu64 " = ddx(_%" PRIu64 ");\n", type_string(o->op_call.var.type.type),
|
||||
o->op_call.var.index, o->op_call.parameters[0].index);
|
||||
}
|
||||
else if (o->op_call.func == add_name("trace_ray")) {
|
||||
check(o->op_call.parameters_size == 3, context, "trace_ray requires three parameters");
|
||||
*offset += sprintf(&hlsl[*offset], "TraceRay(_%" PRIu64 ", RAY_FLAG_NONE, 0xFF, 0, 0, 0, _%" PRIu64 ", _%" PRIu64 ");\n",
|
||||
@@ -1930,3 +1963,115 @@ void hlsl_export(char *directory, api_kind d3d, bool debug) {
|
||||
hlsl_export_all_ray_shaders(directory, debug);
|
||||
}
|
||||
}
|
||||
|
||||
static char *hlsl_export_vertex2(api_kind d3d, function *main, bool debug) {
|
||||
char *hlsl = (char *)calloc(1024 * 1024, 1);
|
||||
size_t offset = 0;
|
||||
|
||||
assert(main->parameters_size > 0);
|
||||
type_id vertex_inputs[64];
|
||||
for (size_t input_index = 0; input_index < main->parameters_size; ++input_index) {
|
||||
vertex_inputs[input_index] = main->parameter_types[input_index].type;
|
||||
}
|
||||
type_id vertex_output = main->return_type.type;
|
||||
|
||||
debug_context context = {0};
|
||||
check(main->parameters_size > 0, context, "vertex input missing");
|
||||
check(vertex_output != NO_TYPE, context, "vertex output missing");
|
||||
|
||||
write_types(hlsl, &offset, SHADER_STAGE_VERTEX, vertex_inputs, main->parameters_size, vertex_output, main, NULL, 0);
|
||||
write_globals(hlsl, &offset, main, NULL, 0);
|
||||
write_functions(hlsl, &offset, SHADER_STAGE_VERTEX, main, NULL, 0);
|
||||
return hlsl;
|
||||
}
|
||||
|
||||
static char *hlsl_export_fragment2(api_kind d3d, function *main, bool debug) {
|
||||
char *hlsl = (char *)calloc(1024 * 1024, 1);
|
||||
size_t offset = 0;
|
||||
|
||||
assert(main->parameters_size > 0);
|
||||
type_id pixel_input = main->parameter_types[0].type;
|
||||
|
||||
debug_context context = {0};
|
||||
check(pixel_input != NO_TYPE, context, "fragment input missing");
|
||||
|
||||
write_types(hlsl, &offset, SHADER_STAGE_FRAGMENT, &pixel_input, 1, NO_TYPE, main, NULL, 0);
|
||||
write_globals(hlsl, &offset, main, NULL, 0);
|
||||
write_functions(hlsl, &offset, SHADER_STAGE_FRAGMENT, main, NULL, 0);
|
||||
return hlsl;
|
||||
}
|
||||
|
||||
void hlsl_export2(char **vs, char **fs, api_kind d3d, bool debug) {
|
||||
static_array(function *, shaders, 256);
|
||||
|
||||
shaders vertex_shaders;
|
||||
shaders fragment_shaders;
|
||||
|
||||
static_array_init(vertex_shaders);
|
||||
static_array_init(fragment_shaders);
|
||||
|
||||
for (type_id i = 0; get_type(i) != NULL; ++i) {
|
||||
type *t = get_type(i);
|
||||
if (!t->built_in && has_attribute(&t->attributes, add_name("pipe"))) {
|
||||
name_id vertex_shader_name = NO_NAME;
|
||||
name_id fragment_shader_name = NO_NAME;
|
||||
|
||||
for (size_t j = 0; j < t->members.size; ++j) {
|
||||
if (t->members.m[j].name == add_name("vertex")) {
|
||||
vertex_shader_name = t->members.m[j].value.identifier;
|
||||
}
|
||||
else if (t->members.m[j].name == add_name("fragment")) {
|
||||
fragment_shader_name = t->members.m[j].value.identifier;
|
||||
}
|
||||
}
|
||||
|
||||
debug_context context = {0};
|
||||
|
||||
function *vertex_shader = NULL;
|
||||
function *fragment_shader = NULL;
|
||||
|
||||
for (function_id i = 0; get_function(i) != NULL; ++i) {
|
||||
function *f = get_function(i);
|
||||
if (vertex_shader_name != NO_NAME && f->name == vertex_shader_name) {
|
||||
vertex_shader = f;
|
||||
static_array_push(vertex_shaders, f);
|
||||
}
|
||||
if (f->name == fragment_shader_name) {
|
||||
fragment_shader = f;
|
||||
static_array_push(fragment_shaders, f);
|
||||
}
|
||||
}
|
||||
|
||||
global_array all_globals = {0};
|
||||
|
||||
if (vertex_shader != NULL) {
|
||||
find_referenced_globals(vertex_shader, &all_globals);
|
||||
}
|
||||
if (fragment_shader != NULL) {
|
||||
find_referenced_globals(fragment_shader, &all_globals);
|
||||
}
|
||||
|
||||
for (size_t global_index = 0; global_index < all_globals.size; ++global_index) {
|
||||
global *g = get_global(all_globals.globals[global_index]);
|
||||
for (size_t set_index = 0; set_index < g->sets_count; ++set_index) {
|
||||
bool found = false;
|
||||
|
||||
for (size_t all_sets_index = 0; all_sets_index < all_descriptor_sets_count; ++all_sets_index) {
|
||||
if (all_descriptor_sets[all_sets_index] == g->sets[set_index]) {
|
||||
found = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (!found) {
|
||||
all_descriptor_sets[all_descriptor_sets_count] = g->sets[set_index];
|
||||
all_descriptor_sets_count += 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
*vs = hlsl_export_vertex2(d3d, vertex_shaders.values[0], debug);
|
||||
*fs = hlsl_export_fragment2(d3d, fragment_shaders.values[0], debug);
|
||||
}
|
||||
|
||||
@@ -389,6 +389,74 @@ void functions_init(void) {
|
||||
f->block = NULL;
|
||||
}
|
||||
|
||||
{
|
||||
function_id func = add_function(add_name("float2x2"));
|
||||
function *f = get_function(func);
|
||||
init_type_ref(&f->return_type, add_name("float2x2"));
|
||||
f->return_type.type = find_type_by_ref(&f->return_type);
|
||||
f->parameter_names[0] = add_name("x");
|
||||
init_type_ref(&f->parameter_types[0], add_name("float2"));
|
||||
f->parameter_types[0].type = find_type_by_ref(&f->parameter_types[0]);
|
||||
|
||||
f->parameter_names[1] = add_name("y");
|
||||
init_type_ref(&f->parameter_types[1], add_name("float2"));
|
||||
f->parameter_types[1].type = find_type_by_ref(&f->parameter_types[1]);
|
||||
|
||||
f->parameters_size = 2;
|
||||
|
||||
f->block = NULL;
|
||||
}
|
||||
|
||||
{
|
||||
function_id func = add_function(add_name("float3x3"));
|
||||
function *f = get_function(func);
|
||||
init_type_ref(&f->return_type, add_name("float3x3"));
|
||||
f->return_type.type = find_type_by_ref(&f->return_type);
|
||||
|
||||
f->parameter_names[0] = add_name("x");
|
||||
init_type_ref(&f->parameter_types[0], add_name("float3"));
|
||||
f->parameter_types[0].type = find_type_by_ref(&f->parameter_types[0]);
|
||||
|
||||
f->parameter_names[1] = add_name("y");
|
||||
init_type_ref(&f->parameter_types[1], add_name("float3"));
|
||||
f->parameter_types[1].type = find_type_by_ref(&f->parameter_types[1]);
|
||||
|
||||
f->parameter_names[2] = add_name("z");
|
||||
init_type_ref(&f->parameter_types[2], add_name("float3"));
|
||||
f->parameter_types[2].type = find_type_by_ref(&f->parameter_types[2]);
|
||||
|
||||
f->parameters_size = 3;
|
||||
|
||||
f->block = NULL;
|
||||
}
|
||||
|
||||
{
|
||||
function_id func = add_function(add_name("float4x4"));
|
||||
function *f = get_function(func);
|
||||
init_type_ref(&f->return_type, add_name("float4x4"));
|
||||
f->return_type.type = find_type_by_ref(&f->return_type);
|
||||
|
||||
f->parameter_names[0] = add_name("x");
|
||||
init_type_ref(&f->parameter_types[0], add_name("float4"));
|
||||
f->parameter_types[0].type = find_type_by_ref(&f->parameter_types[0]);
|
||||
|
||||
f->parameter_names[1] = add_name("y");
|
||||
init_type_ref(&f->parameter_types[1], add_name("float4"));
|
||||
f->parameter_types[1].type = find_type_by_ref(&f->parameter_types[1]);
|
||||
|
||||
f->parameter_names[2] = add_name("z");
|
||||
init_type_ref(&f->parameter_types[2], add_name("float4"));
|
||||
f->parameter_types[2].type = find_type_by_ref(&f->parameter_types[2]);
|
||||
|
||||
f->parameter_names[3] = add_name("w");
|
||||
init_type_ref(&f->parameter_types[3], add_name("float4"));
|
||||
f->parameter_types[3].type = find_type_by_ref(&f->parameter_types[3]);
|
||||
|
||||
f->parameters_size = 4;
|
||||
|
||||
f->block = NULL;
|
||||
}
|
||||
|
||||
{
|
||||
function_id func = add_function(add_name("int"));
|
||||
function *f = get_function(func);
|
||||
@@ -703,8 +771,6 @@ void functions_init(void) {
|
||||
add_func_int("instance_id");
|
||||
|
||||
add_func_float_float_float_float("lerp");
|
||||
add_func_float3_float3_float3_float("lerp3"); ////
|
||||
add_func_float4_float4_float4_float("lerp4"); ////
|
||||
add_func_float3("world_ray_origin");
|
||||
add_func_float3("world_ray_direction");
|
||||
add_func_float("ray_length");
|
||||
@@ -720,23 +786,18 @@ void functions_init(void) {
|
||||
add_func_uint3("ray_index");
|
||||
add_func_float3("ray_dimensions");
|
||||
add_func_float_float("frac");
|
||||
add_func_float3_float3("frac3"); ////
|
||||
add_func_float3x3("object_to_world3x3");
|
||||
add_func_float3_float3_float3("reflect");
|
||||
add_func_uint("primitive_index");
|
||||
add_func_float_float("abs");
|
||||
add_func_float3_float3("abs3"); ////
|
||||
add_func_float_float_float("floor");
|
||||
add_func_float_float_float("ceil");
|
||||
add_func_float_float_float("round");
|
||||
add_func_float_float_float("sqrt");
|
||||
add_func_float_float_float("rsqrt");
|
||||
add_func_float_float_float("min");
|
||||
add_func_float3_float3_float3("min3"); ////
|
||||
add_func_float_float_float("max");
|
||||
add_func_float3_float3_float3("max3"); ////
|
||||
add_func_float_float_float_float("clamp");
|
||||
add_func_float3_float3_float_float("clamp3"); ////
|
||||
add_func_float_float_float("step");
|
||||
add_func_float_float_float("smoothstep");
|
||||
add_func_float_float_float("pow");
|
||||
@@ -744,6 +805,23 @@ void functions_init(void) {
|
||||
add_func_float3_float3_float3("cross");
|
||||
add_func_float3_float3("saturate3");
|
||||
add_func_float_float("saturate");
|
||||
add_func_float_float("ddx");
|
||||
add_func_float_float("ddy");
|
||||
add_func_float_float("ddx2"); ////
|
||||
add_func_float_float("ddy2"); ////
|
||||
add_func_float_float("ddx3"); ////
|
||||
add_func_float_float("ddy3"); ////
|
||||
add_func_float3_float3_float_float("clamp3"); ////
|
||||
add_func_float3_float3_float3("min3"); ////
|
||||
add_func_float3_float3_float3("max3"); ////
|
||||
add_func_float3_float3_float3("step3"); ////
|
||||
add_func_float3_float3_float3("pow3"); ////
|
||||
add_func_float3_float3_float3("floor3"); ////
|
||||
add_func_float3_float3_float3("ceil3"); ////
|
||||
add_func_float3_float3("abs3"); ////
|
||||
add_func_float3_float3("frac3"); ////
|
||||
add_func_float3_float3_float3_float("lerp3"); ////
|
||||
add_func_float4_float4_float4_float("lerp4"); ////
|
||||
|
||||
add_func_void_uint_uint("set_mesh_output_counts");
|
||||
|
||||
|
||||
@@ -87,15 +87,6 @@ function node_shader_add_constant(raw: node_shader_t, s: string, link: string =
|
||||
if (utype == "float4x4") utype = "mat4";
|
||||
////
|
||||
|
||||
// if (ar[0] == "float" && string_index_of(ar[1], "[") >= 0) {
|
||||
// ar[0] = "floats";
|
||||
// ar[1] = string_split(ar[1], "[")[0];
|
||||
// }
|
||||
// else if (ar[0] == "vec4" && string_index_of(ar[1], "[") >= 0) {
|
||||
// ar[0] = "floats";
|
||||
// ar[1] = string_split(ar[1], "[")[0];
|
||||
// }
|
||||
|
||||
array_push(raw.constants, s);
|
||||
node_shader_context_add_constant(raw.context, utype, uname, link);
|
||||
}
|
||||
|
||||
@@ -655,11 +655,12 @@ function parser_material_parse_vector(node: ui_node_t, socket: ui_node_socket_t)
|
||||
let steps: string = "int(" + strength + " * 10 + 1)";
|
||||
let tex_name: string = "texblur_" + parser_material_node_name(node);
|
||||
node_shader_add_texture(parser_material_kong, "" + tex_name, "_" + tex_name);
|
||||
node_shader_add_constant(parser_material_kong, "" + tex_name + "_size: float2", "_size(" + tex_name + ")");
|
||||
let store: string = parser_material_store_var_name(node);
|
||||
parser_material_write(parser_material_kong, "var " + store + "_res: float3 = float3(0.0, 0.0, 0.0);");
|
||||
parser_material_write(parser_material_kong, "for (var i: int = -" + steps + "; i <= " + steps + "; i += 1) {");
|
||||
parser_material_write(parser_material_kong, "for (var j: int = -" + steps + "; j <= " + steps + "; j += 1) {");
|
||||
parser_material_write(parser_material_kong, store + "_res += sample(" + tex_name + ", " + tex_name + "_sampler, tex_coord + float2(i, j) / float2(textureSize(" + tex_name + ", 0))).rgb;");
|
||||
parser_material_write(parser_material_kong, store + "_res += sample(" + tex_name + ", " + tex_name + "_sampler, tex_coord + float2(i, j) / constants." + tex_name + "_size).rgb;");
|
||||
parser_material_write(parser_material_kong, "}");
|
||||
parser_material_write(parser_material_kong, "}");
|
||||
parser_material_write(parser_material_kong, store + "_res /= (" + steps + " * 2 + 1) * (" + steps + " * 2 + 1);");
|
||||
@@ -1881,7 +1882,8 @@ function parser_material_texture_store(node: ui_node_t, tex: bind_tex_t, tex_nam
|
||||
let tex_store: string = parser_material_store_var_name(node);
|
||||
|
||||
if (parser_material_sample_keep_aspect) {
|
||||
parser_material_write(parser_material_kong, "var " + tex_store + "_size: float2 = float2(textureSize(" + tex_name + ", 0));");
|
||||
node_shader_add_constant(parser_material_kong, tex_name + "_size: float2", "_size(" + tex_name + ")");
|
||||
parser_material_write(parser_material_kong, "var " + tex_store + "_size: float2 = constants." + tex_name + "_size;");
|
||||
parser_material_write(parser_material_kong, "var " + tex_store + "_ax: float = " + tex_store + "_size.x / " + tex_store + "_size.y;");
|
||||
parser_material_write(parser_material_kong, "var " + tex_store + "_ay: float = " + tex_store + "_size.y / " + tex_store + "_size.x;");
|
||||
parser_material_write(parser_material_kong, "var " + tex_store + "_uv: float2 = ((" + uv_name + ".xy / " + parser_material_sample_uv_scale + " - float2(0.5, 0.5)) * float2(max(" + tex_store + "_ay, 1.0), max(" + tex_store + "_ax, 1.0))) + float2(0.5, 0.5);");
|
||||
|
||||
Reference in New Issue
Block a user