the.bay.news

[shader] Magnify mouse

programming.dev
[shader] Magnify mouse
##### JSON for importing shader json { "display_title": "HiddenTitleBar", "aspect_ratio": { "MaintainAspectRatio": [ "Scale", "SizeMatchesMirrorAspect" ] }, "frame_transparency": 100.0, "green_screen": "None", "window_background": "Transparent", "postprocessor": "fn postprocess(in_color: vec4<f32>, in: VertexOutput, data: UiRenderData) -> vec4<f32> {\n\t\n\t// ----------------------------------------------------------------------------------------------\n\t// These values are intended to be user adjustable. \n\t//\n\t// Percent of the smallest of the width and height\n\tvar size = 0.1;\n\t \n\t// The magnification is double the normal size \n\tvar zoom: f32 = 2.0;\n\t \n\t// Everything below this line is to make the shader work. Nothing\n\t// else is intended for configuration.\n\t// ----------------------------------------------------------------------------------------------\n\n\tvar color = in_color;\n\tvar mxx: f32 = f32(data.mouse_x);\n\tvar myy: f32 = f32(data.mouse_y);\n\tvar width = f32(data.surface_width);\n\tvar height = f32(data.surface_height);\n\tvar smallest = min(width, height);\n\tvar box_length = size * smallest;\n\tvar box_w = box_length / width;\n\tvar box_h = box_length / height;\n\tvar mx = mxx / width;\n\tvar my = myy / height;\n\tvar px = in.tex_coords.x;\n\tvar py = in.tex_coords.y;\n\n\tvar xx = u32(in.tex_coords.x * width);\n\tvar yy = u32(in.tex_coords.y * height);\n\n\tvar mxxx = u32(data.mouse_x);\n\tvar myyy = u32(data.mouse_y);\n\n\tif px - box_w < mx && px + box_w > mx && py - box_h < my && py + box_h > my {\n\t\tvar zoom_x = (mx - ((mx - px) / zoom));\n\t\tvar zoom_y = (my - ((my - py) / zoom));\n\n\t\tcolor = alpha_sample(vec2(zoom_x, zoom_y));\n\t}\n\n\tvar pixels = u32(box_w * width);\n\n\tif u32(max(xx, mxxx) - min(xx, mxxx)) == pixels && u32(max(yy, myyy) - min(yy, myyy)) <= pixels || u32(max(yy, myyy) - min(yy, myyy)) == pixels && u32(max(xx, mxxx) - min(xx, mxxx)) <= pixels {\n\t\tcolor = vec4(1, 1, 1, 1);\n\t}\n\n\treturn color;\n}", "magnify_filter": "nearest", "minify_filter": "linear", "window_interactions": "Interactable", "present": "Fifo", "render_mode": "Continuous" }

0 comments

Sign in to join the discussion — your thebay.events account works here.

No comments yet.