Shader cleanup
This commit is contained in:
@@ -16,7 +16,7 @@ function make_brush_run(kong: node_shader_t) {
|
||||
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);");
|
||||
node_shader_write_frag(kong, "var winp: float4 = float4(float2(constants.inp.x, 1.0 - constants.inp.y) * 2.0 - 1.0, depth, 1.0);");
|
||||
node_shader_write_frag(kong, "winp = constants.invVP * winp;");
|
||||
node_shader_write_frag(kong, "winp.xyz = winp.xyz / winp.w;");
|
||||
kong.frag_wposition = true;
|
||||
@@ -43,7 +43,7 @@ function make_brush_run(kong: node_shader_t) {
|
||||
|
||||
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, "var winplast: float4 = float4(float2(constants.inplast.x, 1.0 - constants.inplast.y) * 2.0 - 1.0, depthlast, 1.0);");
|
||||
node_shader_write_frag(kong, "winplast = constants.invVP * winplast;");
|
||||
node_shader_write_frag(kong, "winplast.xyz = winplast.xyz / winplast.w;");
|
||||
|
||||
|
||||
@@ -110,7 +110,9 @@ function make_paint_run(data: material_t, matcon: material_context_t): node_shad
|
||||
node_shader_add_out(kong, "ndc: float4");
|
||||
node_shader_write_attrib_vert(kong, "output.ndc = constants.WVP * float4(input.pos.xyz, 1.0);");
|
||||
|
||||
node_shader_write_attrib_frag(kong, "var sp: float3 = (input.ndc.xyz / input.ndc.w) * 0.5 + 0.5;");
|
||||
node_shader_write_attrib_frag(kong, "var sp: float3 = (input.ndc.xyz / input.ndc.w);");
|
||||
node_shader_write_attrib_frag(kong, "sp.x = sp.x * 0.5 + 0.5;");
|
||||
node_shader_write_attrib_frag(kong, "sp.y = sp.y * 0.5 + 0.5;");
|
||||
node_shader_write_attrib_frag(kong, "sp.y = 1.0 - sp.y;");
|
||||
node_shader_write_attrib_frag(kong, "sp.z -= 0.0001;"); // small bias
|
||||
|
||||
|
||||
@@ -216,7 +216,6 @@ function node_shader_get(raw: node_shader_t): string {
|
||||
s += raw.vert_normal;
|
||||
s += raw.vert;
|
||||
s += raw.vert_end;
|
||||
s += "\toutput.pos.z = (output.pos.z + output.pos.w) * 0.5;\n"; ////
|
||||
if (raw.consts.length == 0) {
|
||||
s += "\toutput.empty = constants.empty;\n";
|
||||
}
|
||||
|
||||
@@ -371,7 +371,7 @@ fun envmap_sample(lod: float, coord: float2): float3 { \
|
||||
let str_get_pos_nor_from_depth: string = "\
|
||||
fun get_pos_from_depth(uv: float2, invVP: float4x4): float3 { \
|
||||
var depth: float = sample_lod(gbufferD, sampler_linear, float2(uv.x, 1.0 - uv.y), 0.0).r; \
|
||||
var wpos: float4 = float4(uv * 2.0 - 1.0, depth * 2.0 - 1.0, 1.0); \
|
||||
var wpos: float4 = float4(uv * 2.0 - 1.0, depth, 1.0); \
|
||||
wpos = invVP * wpos; \
|
||||
return wpos.xyz / wpos.w; \
|
||||
} \
|
||||
|
||||
Reference in New Issue
Block a user