Use static samplers
This commit is contained in:
@@ -2,14 +2,11 @@
|
||||
#[set(everything)]
|
||||
const tex0: tex2d;
|
||||
|
||||
#[set(everything)]
|
||||
const tex0_sampler: sampler;
|
||||
|
||||
#[set(everything)]
|
||||
const texa: tex2d;
|
||||
|
||||
#[set(everything)]
|
||||
const texa_sampler: sampler;
|
||||
const sampler_linear: sampler;
|
||||
|
||||
struct vert_in {
|
||||
pos: float2;
|
||||
@@ -29,8 +26,8 @@ fun inpaint_preview_vert(input: vert_in): vert_out {
|
||||
}
|
||||
|
||||
fun inpaint_preview_frag(input: vert_out): float4 {
|
||||
var col: float4 = sample_lod(tex0, tex0_sampler, input.tex, 0.0);
|
||||
var mask: float = clamp(sample_lod(texa, texa_sampler, input.tex, 0.0).r + 0.5, 0.0, 1.0);
|
||||
var col: float4 = sample_lod(tex0, sampler_linear, input.tex, 0.0);
|
||||
var mask: float = clamp(sample_lod(texa, sampler_linear, input.tex, 0.0).r + 0.5, 0.0, 1.0);
|
||||
return col * mask;
|
||||
}
|
||||
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
const tex: tex2d;
|
||||
|
||||
#[set(everything)]
|
||||
const tex_sampler: sampler;
|
||||
const sampler_linear: sampler;
|
||||
|
||||
struct vert_in {
|
||||
pos: float2;
|
||||
@@ -23,7 +23,7 @@ fun layer_copy_rrrr_vert(input: vert_in): vert_out {
|
||||
}
|
||||
|
||||
fun layer_copy_rrrr_frag(input: vert_out): float4 {
|
||||
return sample_lod(tex, tex_sampler, input.tex, 0.0).rrrr;
|
||||
return sample_lod(tex, sampler_linear, input.tex, 0.0).rrrr;
|
||||
}
|
||||
|
||||
#[pipe]
|
||||
|
||||
@@ -28,16 +28,6 @@ function make_material_parse_mesh_material() {
|
||||
|
||||
let con: node_shader_context_t = make_mesh_run(mm);
|
||||
let scon: shader_context_t = shader_context_create(con.data);
|
||||
let override_context: _shader_override_t = {};
|
||||
// if (con.kong.shared_samplers.length > 0) {
|
||||
// let sampler: string = con.kong.shared_samplers[0];
|
||||
// override_context.shared_sampler = substring(sampler, string_last_index_of(sampler, " ") + 1, sampler.length);
|
||||
// }
|
||||
if (!context_raw.texture_filter) {
|
||||
override_context.filter = "point";
|
||||
}
|
||||
override_context.addressing = "repeat";
|
||||
scon._.override_context = override_context;
|
||||
array_push(m._.shader.contexts, scon);
|
||||
array_push(m._.shader._.contexts, scon);
|
||||
|
||||
@@ -88,9 +78,6 @@ function make_material_parse_paint_material() {
|
||||
return;
|
||||
}
|
||||
|
||||
let override_context: _shader_override_t = {};
|
||||
override_context.addressing = "repeat";
|
||||
scon2._.override_context = override_context;
|
||||
let mcon3: material_context_t = material_context_create(mcon2);
|
||||
|
||||
array_push(m._.shader.contexts, scon2);
|
||||
|
||||
@@ -88,16 +88,16 @@ function make_mesh_run(data: material_t, layer_pass: i32 = 0): node_shader_conte
|
||||
node_shader_add_texture(kong, "senvmap_radiance", "_envmap_radiance");
|
||||
}
|
||||
|
||||
node_shader_add_shared_sampler(kong, "texpaint");
|
||||
node_shader_write_frag(kong, "texpaint_sample = sample_lod(texpaint, shared_sampler, input.tex_coord, 0.0);");
|
||||
node_shader_add_texture(kong, "texpaint");
|
||||
node_shader_write_frag(kong, "texpaint_sample = sample_lod(texpaint, sampler_linear, input.tex_coord, 0.0);");
|
||||
node_shader_write_frag(kong, "texpaint_opac = texpaint_sample.a;");
|
||||
|
||||
node_shader_write_frag(kong, "basecol = texpaint_sample.rgb * texpaint_opac;");
|
||||
node_shader_add_shared_sampler(kong, "texpaint_nor");
|
||||
node_shader_write_frag(kong, "texpaint_nor_sample = sample_lod(texpaint_nor, shared_sampler, input.tex_coord, 0.0);");
|
||||
node_shader_add_texture(kong, "texpaint_nor");
|
||||
node_shader_write_frag(kong, "texpaint_nor_sample = sample_lod(texpaint_nor, sampler_linear, input.tex_coord, 0.0);");
|
||||
node_shader_write_frag(kong, "ntex = lerp3(ntex, texpaint_nor_sample.rgb, texpaint_opac);");
|
||||
node_shader_add_shared_sampler(kong, "texpaint_pack");
|
||||
node_shader_write_frag(kong, "texpaint_pack_sample = sample_lod(texpaint_pack, shared_sampler, input.tex_coord, 0.0);");
|
||||
node_shader_add_texture(kong, "texpaint_pack");
|
||||
node_shader_write_frag(kong, "texpaint_pack_sample = sample_lod(texpaint_pack, sampler_linear, input.tex_coord, 0.0);");
|
||||
node_shader_write_frag(kong, "occlusion = lerp(occlusion, texpaint_pack_sample.r, texpaint_opac);");
|
||||
node_shader_write_frag(kong, "roughness = lerp(roughness, texpaint_pack_sample.g, texpaint_opac);");
|
||||
node_shader_write_frag(kong, "metallic = lerp(metallic, texpaint_pack_sample.b, texpaint_opac);");
|
||||
@@ -142,7 +142,7 @@ function make_mesh_run(data: material_t, layer_pass: i32 = 0): node_shader_conte
|
||||
node_shader_write_frag(kong, "var wreflect: float3 = reflect(-vvec, n);");
|
||||
node_shader_write_frag(kong, "var envlod: float = roughness * float(constants.envmap_num_mipmaps);");
|
||||
node_shader_add_function(frag, str_envmap_equirect);
|
||||
node_shader_write_frag(kong, "var prefiltered_color: float3 = sample_lod(senvmap_radiance, senvmap_radiance_sampler, envmap_equirect(wreflect, constants.envmap_data.x), envlod).rgb;");
|
||||
node_shader_write_frag(kong, "var prefiltered_color: float3 = sample_lod(senvmap_radiance, sampler_linear, envmap_equirect(wreflect, constants.envmap_data.x), envlod).rgb;");
|
||||
// node_shader_add_constant(kong, "shirr: float4[7]", "_envmap_irradiance");
|
||||
node_shader_add_constant(kong, "shirr0: float4", "_envmap_irradiance0");
|
||||
node_shader_add_constant(kong, "shirr1: float4", "_envmap_irradiance1");
|
||||
|
||||
@@ -54,9 +54,9 @@ function make_paint_run(data: material_t, matcon: material_context_t): node_shad
|
||||
node_shader_add_texture(kong, "texpaint");
|
||||
node_shader_add_texture(kong, "texpaint_nor");
|
||||
node_shader_add_texture(kong, "texpaint_pack");
|
||||
node_shader_write_frag(kong, "output[0] = sample_lod(texpaint, texpaint_sampler, tex_coord_inp, 0.0);");
|
||||
node_shader_write_frag(kong, "output[1] = sample_lod(texpaint_nor, texpaint_nor_sampler, tex_coord_inp, 0.0);");
|
||||
node_shader_write_frag(kong, "output[2] = sample_lod(texpaint_pack, texpaint_pack_sampler, tex_coord_inp, 0.0);");
|
||||
node_shader_write_frag(kong, "output[0] = sample_lod(texpaint, sampler_linear, tex_coord_inp, 0.0);");
|
||||
node_shader_write_frag(kong, "output[1] = sample_lod(texpaint_nor, sampler_linear, tex_coord_inp, 0.0);");
|
||||
node_shader_write_frag(kong, "output[2] = sample_lod(texpaint_pack, sampler_linear, tex_coord_inp, 0.0);");
|
||||
node_shader_write_frag(kong, "output[3].rg = tex_coord_inp.xy;");
|
||||
con_paint.data.shader_from_source = true;
|
||||
gpu_create_shaders_from_kong(node_shader_get(kong), ADDRESS(con_paint.data.vertex_shader), ADDRESS(con_paint.data.fragment_shader));
|
||||
@@ -98,7 +98,7 @@ function make_paint_run(data: material_t, matcon: material_context_t): node_shad
|
||||
|
||||
node_shader_write_frag(kong, "var dist: float = 0.0;");
|
||||
|
||||
node_shader_write_frag(kong, "var depth: float = sample_lod(gbufferD, gbufferD_sampler, constants.inp.xy, 0.0).r;");
|
||||
node_shader_write_frag(kong, "var depth: float = sample_lod(gbufferD, sampler_linear, constants.inp.xy, 0.0).r;");
|
||||
|
||||
node_shader_add_constant(kong, "invVP: float4x4", "_inv_view_proj_matrix");
|
||||
node_shader_write_frag(kong, "var winp: float4 = float4(float2(constants.inp.x, 1.0 - constants.inp.y) * 2.0 - 1.0, depth * 2.0 - 1.0, 1.0);");
|
||||
@@ -106,7 +106,7 @@ function make_paint_run(data: material_t, matcon: material_context_t): node_shad
|
||||
node_shader_write_frag(kong, "winp.xyz /= winp.w;");
|
||||
kong.frag_wposition = true;
|
||||
|
||||
node_shader_write_frag(kong, "var depthlast: float = sample_lod(gbufferD, gbufferD_sampler, constants.inplast.xy, 0.0).r;");
|
||||
node_shader_write_frag(kong, "var depthlast: float = sample_lod(gbufferD, sampler_linear, constants.inplast.xy, 0.0).r;");
|
||||
|
||||
node_shader_write_frag(kong, "var winplast: float4 = float4(float2(constants.inplast.x, 1.0 - constants.inplast.y) * 2.0 - 1.0, depthlast * 2.0 - 1.0, 1.0);");
|
||||
node_shader_write_frag(kong, "winplast = constants.invVP * winplast;");
|
||||
@@ -145,11 +145,11 @@ function make_paint_run(data: material_t, matcon: material_context_t): node_shad
|
||||
node_shader_write_frag(kong, "var sample_tc: float2 = float2(input.wvpposition.xy / input.wvpposition.w) * 0.5 + 0.5;");
|
||||
node_shader_write_frag(kong, "sample_tc.y = 1.0 - sample_tc.y;");
|
||||
node_shader_add_texture(kong, "paintmask");
|
||||
node_shader_write_frag(kong, "var sample_mask: float = sample_lod(paintmask, paintmask_sampler, sample_tc, 0.0).r;");
|
||||
node_shader_write_frag(kong, "var sample_mask: float = sample_lod(paintmask, sampler_linear, sample_tc, 0.0).r;");
|
||||
node_shader_write_frag(kong, "str = max(str, sample_mask);");
|
||||
|
||||
node_shader_add_texture(kong, "texpaint_undo", "_texpaint_undo");
|
||||
node_shader_write_frag(kong, "var sample_undo: float4 = sample_lod(texpaint_undo, texpaint_undo_sampler, sample_tc, 0.0);");
|
||||
node_shader_write_frag(kong, "var sample_undo: float4 = sample_lod(texpaint_undo, sampler_linear, sample_tc, 0.0);");
|
||||
|
||||
if (context_raw.tool == workspace_tool_t.ERASER) {
|
||||
node_shader_write_frag(kong, "output[0] = float4(0.0, 0.0, 0.0, 0.0);");
|
||||
|
||||
Reference in New Issue
Block a user