Draw 3d brush cursor procedurally
This commit is contained in:
@@ -189,8 +189,6 @@ function render_path_paint_draw_cursor(mx: f32, my: f32, radius: f32, tint_r: f3
|
||||
|
||||
render_path_set_target("");
|
||||
g4_set_pipeline(pipes_cursor);
|
||||
let img: image_t = resource_get("cursor.k");
|
||||
g4_set_tex(pipes_cursor_tex, img);
|
||||
let gbuffer0: render_target_t = map_get(render_path_render_targets, "gbuffer0");
|
||||
g4_set_tex_depth(pipes_cursor_gbufferd, gbuffer0._image);
|
||||
g4_set_float2(pipes_cursor_mouse, mx, my);
|
||||
|
||||
@@ -488,10 +488,6 @@ function render_path_paint_draw_cursor(mx: f32, my: f32, radius: f32, tint_r: f3
|
||||
|
||||
render_path_set_target("");
|
||||
g4_set_pipeline(pipes_cursor);
|
||||
let decal: bool = context_is_decal();
|
||||
let decal_mask: bool = context_is_decal_mask();
|
||||
let img: image_t = (decal && !decal_mask) ? context_raw.decal_image : resource_get("cursor.k");
|
||||
g4_set_tex(pipes_cursor_tex, img);
|
||||
let rt: render_target_t = map_get(render_path_render_targets, "gbuffer0");
|
||||
let gbuffer0: image_t = rt._image;
|
||||
g4_set_tex_depth(pipes_cursor_gbufferd, gbuffer0);
|
||||
|
||||
Executable
BIN
Binary file not shown.
|
After Width: | Height: | Size: 16 KiB |
@@ -1,15 +1,15 @@
|
||||
#version 450
|
||||
|
||||
uniform vec3 tint;
|
||||
#ifdef SPIRV
|
||||
uniform sampler2D gbufferD; // vulkan unit align
|
||||
#endif
|
||||
uniform sampler2D tex;
|
||||
|
||||
in vec2 tex_coord;
|
||||
out vec4 frag_color;
|
||||
|
||||
void main() {
|
||||
vec4 col = texture(tex, tex_coord);
|
||||
frag_color = vec4((col.rgb / col.a) * tint, col.a);
|
||||
float radius = 0.45;
|
||||
float thickness = 0.03;
|
||||
float dist = distance(tex_coord, vec2(0.5, 0.5));
|
||||
float ring = smoothstep(radius - thickness, radius, dist) -
|
||||
smoothstep(radius, radius + thickness, dist);
|
||||
frag_color = vec4(tint, min(ring, 0.6));
|
||||
}
|
||||
|
||||
@@ -7,10 +7,6 @@ uniform vec2 tex_step;
|
||||
uniform float radius;
|
||||
uniform vec3 camera_right;
|
||||
uniform sampler2D gbufferD;
|
||||
#ifdef HLSL
|
||||
// direct3d12 unit align
|
||||
uniform sampler2D texa;
|
||||
#endif
|
||||
|
||||
#ifdef HLSL
|
||||
in vec4 pos;
|
||||
@@ -21,8 +17,7 @@ out vec2 tex_coord;
|
||||
|
||||
vec3 get_pos(vec2 uv) {
|
||||
#ifdef HLSL
|
||||
float keep = textureLod(texa, vec2(0.0, 0.0), 0.0).r; // direct3d12 unit align
|
||||
float keep2 = pos.x + nor.x;
|
||||
float keep = pos.x + nor.x;
|
||||
#endif
|
||||
|
||||
#ifdef GLSL
|
||||
|
||||
@@ -47,7 +47,6 @@ let pipes_cursor_tex_step: kinc_const_loc_t;
|
||||
let pipes_cursor_radius: kinc_const_loc_t;
|
||||
let pipes_cursor_camera_right: kinc_const_loc_t;
|
||||
let pipes_cursor_tint: kinc_const_loc_t;
|
||||
let pipes_cursor_tex: kinc_tex_unit_t;
|
||||
let pipes_cursor_gbufferd: kinc_tex_unit_t;
|
||||
|
||||
function _pipes_make_merge(red: bool, green: bool, blue: bool, alpha: bool): pipeline_t {
|
||||
@@ -287,6 +286,5 @@ function pipes_init() {
|
||||
pipes_cursor_camera_right = g4_pipeline_get_const_loc(pipes_cursor, "camera_right");
|
||||
pipes_cursor_tint = g4_pipeline_get_const_loc(pipes_cursor, "tint");
|
||||
pipes_cursor_gbufferd = g4_pipeline_get_tex_unit(pipes_cursor, "gbufferD");
|
||||
pipes_cursor_tex = g4_pipeline_get_tex_unit(pipes_cursor, "tex");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1364,7 +1364,7 @@ function ui_base_render_cursor() {
|
||||
}
|
||||
|
||||
let cursor_img: image_t = resource_get("cursor.k");
|
||||
let psize: i32 = math_floor(cursor_img.width * (context_raw.brush_radius * context_raw.brush_nodes_radius) * ui_SCALE(ui_base_ui));
|
||||
let psize: i32 = math_floor(182 * (context_raw.brush_radius * context_raw.brush_nodes_radius) * ui_SCALE(ui_base_ui));
|
||||
|
||||
// Clone source cursor
|
||||
if (context_raw.tool == workspace_tool_t.CLONE && !keyboard_down("alt") && (mouse_down() || pen_down())) {
|
||||
|
||||
Reference in New Issue
Block a user