LYGIA Shader Library

point (lygia/draw/point)

Draws all the digits of a matrix, useful for debugging.

Dependencies:

Use:

<vec4> point(<vec2> st, <vec2> pos)
<vec4> point(<vec2> st, <mat4> P, <mat4> V, <vec3> pos)

Check it on Github




#ifndef FNC_DRAW_POINT
#define FNC_DRAW_POINT

vec4 point(in vec2 st, vec2 pos, vec3 color, float radius) {
    vec4 rta = vec4(0.0);
    vec2 st_p = st - pos;

    rta += vec4(color, 1.0) * circle(st_p + 0.5, radius);
    st_p -= DIGITS_SIZE * vec2(0.0, 0.5);
    vec2 size = DIGITS_SIZE * abs(DIGITS_VALUE_OFFSET) * vec2(2.0, 0.5);
    rta.a += 0.5 * step(0.0, st_p.x) * step(st_p.x, size.x) * step(-DIGITS_SIZE.y * 0.5, st_p.y) * step(st_p.y, size.y);
    rta += digits(st_p, pos);

    return rta;
}

vec4 point(in vec2 st, mat4 M, vec3 pos, vec3 color, float radius) {
    vec4 rta = vec4(0.0);
    vec4 pos4 = M * vec4(pos, 1.0);
    vec2 p = pos4.xy / pos4.w;

    #ifdef DEBUG_FLIPPED_SPACE
    vec2 st_p = st + (p.xy * 0.5 - 0.5);
    #else
    vec2 st_p = st - (p.xy * 0.5 + 0.5);
    #endif

    rta += vec4(color, 1.0) * circle(st_p + 0.5, radius);
    st_p -= DIGITS_SIZE * vec2(0.0, 0.5);
    vec2 size = DIGITS_SIZE * abs(DIGITS_VALUE_OFFSET) * vec2(3.0, 0.5);
    rta.a += 0.5 * step(0.0, st_p.x) * step(st_p.x, size.x) * step(-DIGITS_SIZE.y * 0.5, st_p.y) * step(st_p.y, size.y);
    rta += digits(st_p, pos);

    return rta;
}

vec4 point(in vec2 st, vec2 pos) { return point(st, pos, vec3(1.0, 0.0, 0.0), 0.02); }
vec4 point(in vec2 st, mat4 M, vec3 pos) { return point(st, M, pos, vec3(1.0, 0.0, 0.0), 0.02); }

#endif

Dependencies:

Use:

<float4> point(<float2> st, <float2> pos)
<float4> point(<float2> st, <float4x4> P, <float4x4> V, <float3> pos)

Check it on Github




#ifndef FNC_DRAW_POINT
#define FNC_DRAW_POINT

float4 point(in float2 st, float2 pos, float3 color, float radius) {
    float4 rta = float4(0.0, 0.0, 0.0, 0.0);
    float2 st_p = st - pos;

    rta += float4(color, 1.0) * circle(st_p + 0.5, radius);
    st_p -= DIGITS_SIZE * float2(0.0, 0.5);
    float2 size = DIGITS_SIZE * abs(DIGITS_VALUE_OFFSET) * float2(2.0, 0.5);
    rta.a += 0.5 * step(0.0, st_p.x) * step(st_p.x, size.x) * step(-DIGITS_SIZE.y * 0.5, st_p.y) * step(st_p.y, size.y);
    rta += digits(st_p, pos);

    return rta;
}

float4 point(in float2 st, float4x4 P, float4x4 V, float3 pos, float3 color, float radius) {
    float4 rta = float4(0.0, 0.0, 0.0, 0.0);
    float4 pos4 = mult(P, mult(V * float4(pos, 1.0)));
    float2 p = pos4.xy / pos4.w;

    #ifdef DEBUG_FLIPPED_SPACE
    float2 st_p = st + (p.xy * 0.5 - 0.5);
    #else
    float2 st_p = st - (p.xy * 0.5 + 0.5);
    #endif

    rta += float4(color, 1.0) * circle(st_p + 0.5, radius);
    st_p -= DIGITS_SIZE * float2(0.0, 0.5);
    float2 size = DIGITS_SIZE * abs(DIGITS_VALUE_OFFSET) * float2(3.0, 0.5);
    rta.a += 0.5 * step(0.0, st_p.x) * step(st_p.x, size.x) * step(-DIGITS_SIZE.y * 0.5, st_p.y) * step(st_p.y, size.y);
    rta += digits(st_p, pos);

    return rta;
}

float4 point(in float2 st, float2 pos) { return point(st, pos, float3(1.0, 0.0, 0.0), 0.02); }
float4 point(in float2 st, float4x4 P, float4x4 V, float3 pos) { return point(st, P, V, pos, float3(1.0, 0.0, 0.0), 0.02); }

#endif

Dependencies:

Use:

<float4> point(<float2> st, <float2> pos)
<float4> point(<float2> st, <float4x4> P, <float4x4> V, <float3> pos)

Check it on Github




#ifndef FNC_DRAW_POINT
#define FNC_DRAW_POINT

float4 point(in float2 st, float2 pos, float3 color, float radius) {
    float4 rta = float4(0.0, 0.0, 0.0, 0.0);
    float2 st_p = st - pos;

    rta += float4(color, 1.0) * circle(st_p + 0.5, radius);
    st_p -= DIGITS_SIZE * float2(0.0, 0.5);
    float2 size = DIGITS_SIZE * abs(DIGITS_VALUE_OFFSET) * float2(2.0, 0.5);
    rta.a += 0.5 * step(0.0, st_p.x) * step(st_p.x, size.x) * step(-DIGITS_SIZE.y * 0.5, st_p.y) * step(st_p.y, size.y);
    rta += digits(st_p, pos);

    return rta;
}

float4 point(in float2 st, float4x4 P, float4x4 V, float3 pos, float3 color, float radius) {
    float4 rta = float4(0.0, 0.0, 0.0, 0.0);
    float4 pos4 = mult(P, mult(V * float4(pos, 1.0)));
    float2 p = pos4.xy / pos4.w;

    #ifdef DEBUG_FLIPPED_SPACE
    float2 st_p = st + (p.xy * 0.5 - 0.5);
    #else
    float2 st_p = st - (p.xy * 0.5 + 0.5);
    #endif

    rta += float4(color, 1.0) * circle(st_p + 0.5, radius);
    st_p -= DIGITS_SIZE * float2(0.0, 0.5);
    float2 size = DIGITS_SIZE * abs(DIGITS_VALUE_OFFSET) * float2(3.0, 0.5);
    rta.a += 0.5 * step(0.0, st_p.x) * step(st_p.x, size.x) * step(-DIGITS_SIZE.y * 0.5, st_p.y) * step(st_p.y, size.y);
    rta += digits(st_p, pos);

    return rta;
}

float4 point(in float2 st, float2 pos) { return point(st, pos, float3(1.0, 0.0, 0.0), 0.02); }
float4 point(in float2 st, float4x4 P, float4x4 V, float3 pos) { return point(st, P, V, pos, float3(1.0, 0.0, 0.0), 0.02); }

#endif

Licenses

LYGIA is dual-licensed under the Prosperity License and the Patron License for sponsors and contributors.

Sponsors and contributors are automatically added to the Patron License and they can ignore the any non-commercial rule of the Prosperity Licensed software (please take a look to the exception).

It's also possible to get a permanent comercial license hook to a single and specific version of LYGIA.

Get the latest news and releases

Sign up for the news letter bellow, joing the LYGIA's channel on Discord or follow the Github repository