Shader fixes
This commit is contained in:
@@ -103,18 +103,16 @@ function uniforms_set_obj_consts(context: shader_context_t, object: object_t) {
|
||||
|
||||
// Texture object constants
|
||||
// External
|
||||
if (uniforms_tex_links != null) {
|
||||
if (context.texture_units != null) {
|
||||
for (let j: i32 = 0; j < context.texture_units.length; ++j) {
|
||||
let tu: tex_unit_t = context.texture_units[j];
|
||||
if (tu.link == null) {
|
||||
continue;
|
||||
}
|
||||
if (uniforms_tex_links != null && context.texture_units != null) {
|
||||
for (let j: i32 = 0; j < context.texture_units.length; ++j) {
|
||||
let tu: tex_unit_t = context.texture_units[j];
|
||||
if (tu.link == null) {
|
||||
continue;
|
||||
}
|
||||
|
||||
let image: gpu_texture_t = uniforms_tex_links(object, current_material(object), tu.link);
|
||||
if (image != null) {
|
||||
gpu_set_texture(context._.tex_units[j], image);
|
||||
}
|
||||
let image: gpu_texture_t = uniforms_tex_links(object, current_material(object), tu.link);
|
||||
if (image != null) {
|
||||
gpu_set_texture(context._.tex_units[j], image);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -316,8 +314,13 @@ function uniforms_set_context_const(location: i32, c: shader_const_t): bool {
|
||||
v.y = (-zfar * znear) / (zfar - znear);
|
||||
}
|
||||
else if (starts_with(c.link, "_size(")) {
|
||||
if (_render_path_bind_params != null) {
|
||||
let tex: string = substring(c.link, 6, c.link.length - 1);
|
||||
let tex: string = substring(c.link, 6, c.link.length - 1);
|
||||
let image: gpu_texture_t = uniforms_tex_links(null, null, tex);
|
||||
if (image != null) {
|
||||
v.x = image.width;
|
||||
v.y = image.height;
|
||||
}
|
||||
else if (_render_path_bind_params != null) {
|
||||
for (let i: i32 = 0; i < math_floor(_render_path_bind_params.length / 2); ++i) {
|
||||
let pos: i32 = i * 2; // bind params = [texture, sampler_id]
|
||||
let sampler_id: string = _render_path_bind_params[pos + 1];
|
||||
|
||||
@@ -654,7 +654,7 @@ function parser_material_parse_vector(node: ui_node_t, socket: ui_node_socket_t)
|
||||
let steps: string = "(" + strength + " * 10.0 + 1.0)";
|
||||
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 + ")");
|
||||
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 = 0; i <= int(" + steps + " * 2.0); i += 1) {");
|
||||
|
||||
Reference in New Issue
Block a user