CrossHairPoint (Round) : Godot 4.3

This shader is designed to create a circular crosshair in the form of a dot. It allows you to customize the size, color, and transparency of the crosshair.

 

**How to add the shader:**

1. Create a new shader resource in Godot and select the “CanvasItem” shader type.

2. Copy and paste the shader code into the shader editor.

3. Apply the shader to a ColorRect or any other 2D node that supports shaders.

Shader code
shader_type canvas_item;

// Crosshair Color
uniform vec4 crosshair_color : source_color = vec4(1.0, 1.0, 1.0, 1.0); // Crosshair color
uniform float radius : hint_range(0.0, 0.15, 0.001) = 0.05; // Radius of the crosshair
uniform float opacity : hint_range(0.0, 1.0, 0.01) = 1.0; // Opacity of the crosshair

void fragment() {
    // Get normalized fragment coordinates
    vec2 uv = UV - vec2(0.5); // Center UV (from -0.5 to 0.5)
    float dist = length(uv); // Calculate distance from the center

    // If the distance is less than the radius, display the crosshair color
    if (dist < radius) {
        COLOR = vec4(crosshair_color.rgb, crosshair_color.a * opacity); // Set crosshair color with opacity
    } else {
        discard; // Ignore fragments outside the circle
    }
}
Tags
crosshair, CrossHairPoint, Point
The shader code and all code snippets in this post are under CC0 license and can be used freely without the author's permission. Images and videos, and assets depicted in those, do not fall under this license. For more info, see our License terms.

More from AivanWorld

Pixelate 3D Effect

Related shaders

Fnaf / Clickteam perspective (displacement) – Godot 4.2

3d Pixel Sway – Godot 4

Glitch Effect Shader for Godot Engine 4

Subscribe
Notify of
guest

0 Comments
Oldest
Newest Most Voted
Inline Feedbacks
View all comments