Fix grid jump when parsing brush nodes
This commit is contained in:
@@ -37,7 +37,6 @@ function make_mesh_run(data: material_t, layer_pass: i32 = 0): node_shader_conte
|
||||
|
||||
node_shader_add_out(vert, "vec2 tex_coord");
|
||||
frag.wvpposition = true;
|
||||
node_shader_add_out(vert, "vec4 prevwvpposition");
|
||||
node_shader_add_uniform(vert, "mat4 VP", "_view_proj_matrix");
|
||||
node_shader_add_uniform(vert, "mat4 prevWVP", "_prev_world_view_proj_matrix");
|
||||
vert.wposition = true;
|
||||
@@ -78,13 +77,6 @@ function make_mesh_run(data: material_t, layer_pass: i32 = 0): node_shader_conte
|
||||
|
||||
node_shader_write(vert, "gl_Position = mul(vec4(wposition.xyz, 1.0), VP);");
|
||||
node_shader_write(vert, "tex_coord = tex;");
|
||||
if (make_material_height_used && displace_strength > 0) {
|
||||
node_shader_add_uniform(vert, "mat4 invW", "_inv_world_matrix");
|
||||
node_shader_write(vert, "prevwvpposition = mul(mul(vec4(wposition, 1.0), invW), prevWVP);");
|
||||
}
|
||||
else {
|
||||
node_shader_write(vert, "prevwvpposition = mul(vec4(pos.xyz, 1.0), prevWVP);");
|
||||
}
|
||||
|
||||
node_shader_add_out(frag, "vec4 frag_color[3]");
|
||||
frag.n = true;
|
||||
@@ -492,9 +484,7 @@ function make_mesh_run(data: material_t, layer_pass: i32 = 0): node_shader_conte
|
||||
node_shader_write(frag, "frag_color[0] = vec4(n.xy, roughness, pack_f32_i16(metallic, uint(int(matid * 255.0) % 3)));");
|
||||
}
|
||||
|
||||
node_shader_write(frag, "vec2 posa = (wvpposition.xy / wvpposition.w) * 0.5 + 0.5;");
|
||||
node_shader_write(frag, "vec2 posb = (prevwvpposition.xy / prevwvpposition.w) * 0.5 + 0.5;");
|
||||
node_shader_write(frag, "frag_color[2] = vec4(posa - posb, tex_coord.xy);");
|
||||
node_shader_write(frag, "frag_color[2] = vec4(0.0, 0.0, tex_coord.xy);");
|
||||
|
||||
parser_material_finalize(con_mesh);
|
||||
con_mesh.data.shader_from_source = true;
|
||||
|
||||
Binary file not shown.
@@ -1,12 +1,7 @@
|
||||
#version 450
|
||||
|
||||
#define _Veloc
|
||||
|
||||
uniform sampler2D color_tex;
|
||||
uniform sampler2D blend_tex;
|
||||
#ifdef _Veloc
|
||||
uniform sampler2D sveloc;
|
||||
#endif
|
||||
uniform vec2 screen_size_inv;
|
||||
|
||||
in vec2 tex_coord;
|
||||
@@ -21,15 +16,6 @@ vec4 textureLodA_color_tex(sampler2D color_tex, vec2 coords, float lod) {
|
||||
return textureLod(color_tex, coords, lod);
|
||||
}
|
||||
|
||||
vec4 textureLodA_sveloc(sampler2D sveloc, vec2 coords, float lod) {
|
||||
#ifdef GLSL
|
||||
#else
|
||||
coords.y = 1.0 - coords.y;
|
||||
#endif
|
||||
|
||||
return textureLod(sveloc, coords, lod);
|
||||
}
|
||||
|
||||
vec4 smaa_neighborhood_blending_ps(vec2 texcoord, vec4 offset) {
|
||||
vec4 a;
|
||||
a.x = textureLod(blend_tex, offset.xy, 0.0).a; // Right
|
||||
@@ -38,11 +24,6 @@ vec4 smaa_neighborhood_blending_ps(vec2 texcoord, vec4 offset) {
|
||||
|
||||
if (dot(a, vec4(1.0, 1.0, 1.0, 1.0)) < 1e-5) {
|
||||
vec4 color = textureLod(color_tex, texcoord, 0.0);
|
||||
|
||||
#ifdef _Veloc
|
||||
vec2 velocity = textureLod(sveloc, tex_coord, 0.0).rg;
|
||||
color.a = sqrt(5.0 * length(velocity));
|
||||
#endif
|
||||
return color;
|
||||
}
|
||||
else {
|
||||
@@ -72,12 +53,6 @@ vec4 smaa_neighborhood_blending_ps(vec2 texcoord, vec4 offset) {
|
||||
vec4 color = blending_weight.x * textureLodA_color_tex(color_tex, blending_coord.xy, 0.0);
|
||||
color += blending_weight.y * textureLodA_color_tex(color_tex, blending_coord.zw, 0.0);
|
||||
|
||||
#ifdef _Veloc
|
||||
vec2 velocity = blending_weight.x * textureLodA_sveloc(sveloc, blending_coord.xy, 0.0).rg;
|
||||
velocity += blending_weight.y * textureLodA_sveloc(sveloc, blending_coord.zw, 0.0).rg;
|
||||
|
||||
color.a = sqrt(5.0 * length(velocity));
|
||||
#endif
|
||||
return color;
|
||||
}
|
||||
return vec4(0.0, 0.0, 0.0, 0.0);
|
||||
|
||||
@@ -2,31 +2,12 @@
|
||||
|
||||
uniform sampler2D tex;
|
||||
uniform sampler2D tex2;
|
||||
uniform sampler2D sveloc;
|
||||
|
||||
in vec2 tex_coord;
|
||||
out vec4 frag_color;
|
||||
|
||||
const float SMAA_REPROJECTION_WEIGHT_SCALE = 30.0;
|
||||
|
||||
void main() {
|
||||
vec4 current = textureLod(tex, tex_coord, 0.0);
|
||||
|
||||
// Velocity is assumed to be calculated for motion blur, so we need to inverse it for reprojection
|
||||
vec2 velocity = -textureLod(sveloc, tex_coord, 0.0).rg;
|
||||
|
||||
#ifdef GLSL
|
||||
#else
|
||||
velocity.y = -velocity.y;
|
||||
#endif
|
||||
|
||||
// Reproject current coordinates and fetch previous pixel
|
||||
vec4 previous = textureLod(tex2, tex_coord + velocity, 0.0);
|
||||
|
||||
// Attenuate the previous pixel if the velocity is different
|
||||
float delta = abs(current.a * current.a - previous.a * previous.a) / 5.0;
|
||||
float weight = 0.5 * clamp(1.0 - sqrt(delta) * SMAA_REPROJECTION_WEIGHT_SCALE, 0.0, 1.0);
|
||||
|
||||
// Blend the pixels according to the calculated weight:
|
||||
frag_color = vec4(mix(current.rgb, previous.rgb, weight), 1.0);
|
||||
vec4 previous = textureLod(tex2, tex_coord, 0.0);
|
||||
frag_color = vec4(mix(current.rgb, previous.rgb, 0.5), 1.0);
|
||||
}
|
||||
|
||||
@@ -300,17 +300,8 @@ function render_path_base_draw_deferred_light() {
|
||||
// render_path_set_target("buf");
|
||||
// render_path_bind_target("tex", "tex");
|
||||
// render_path_bind_target("gbuffer0", "gbuffer0");
|
||||
// ///if (rp_motionblur == "Camera")
|
||||
// {
|
||||
// render_path_bind_target("_main", "gbufferD");
|
||||
// render_path_draw_shader("shader_datas/motion_blur_pass/motion_blur_pass");
|
||||
// }
|
||||
// ///else
|
||||
// {
|
||||
// render_path_bind_target("gbuffer2", "sveloc");
|
||||
// render_path_draw_shader("shader_datas/motion_blur_veloc_pass/motion_blur_veloc_pass");
|
||||
// }
|
||||
// ///end
|
||||
// render_path_bind_target("_main", "gbufferD");
|
||||
// render_path_draw_shader("shader_datas/motion_blur_pass/motion_blur_pass");
|
||||
// render_path_set_target("tex");
|
||||
// render_path_bind_target("buf", "tex");
|
||||
// render_path_draw_shader("shader_datas/copy_pass/copy_pass");
|
||||
@@ -351,7 +342,6 @@ function render_path_base_draw_taa() {
|
||||
render_path_set_target(current);
|
||||
render_path_bind_target("buf", "color_tex");
|
||||
render_path_bind_target("taa", "blend_tex");
|
||||
render_path_bind_target("gbuffer2", "sveloc");
|
||||
render_path_draw_shader("shader_datas/smaa_neighborhood_blend/smaa_neighborhood_blend");
|
||||
|
||||
let skip_taa: bool = context_raw.split_view;
|
||||
@@ -364,7 +354,6 @@ function render_path_base_draw_taa() {
|
||||
render_path_set_target("taa");
|
||||
render_path_bind_target(current, "tex");
|
||||
render_path_bind_target(last, "tex2");
|
||||
render_path_bind_target("gbuffer2", "sveloc");
|
||||
render_path_draw_shader("shader_datas/taa_pass/taa_pass");
|
||||
}
|
||||
|
||||
|
||||
@@ -230,6 +230,12 @@ function util_render_make_brush_preview() {
|
||||
|
||||
let _material: slot_material_t = context_raw.material;
|
||||
context_raw.material = slot_material_create();
|
||||
|
||||
// Prevent grid jump
|
||||
context_raw.material.nodes.pan_x = context_raw.brush.nodes.pan_x;
|
||||
context_raw.material.nodes.pan_y = context_raw.brush.nodes.pan_y;
|
||||
context_raw.material.nodes.zoom = context_raw.brush.nodes.zoom;
|
||||
|
||||
let _tool: workspace_tool_t = context_raw.tool;
|
||||
context_raw.tool = workspace_tool_t.BRUSH;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user