Source-checkedLibraries & compatibility

GShader Library

by Evgeny Akabenko · for Garry's Mod

GShader Library — a shader library that serves as the foundation for creating [url=https://developer.valvesoftware.com/wiki/Deferred_renderer] Deferred Renderer (shading & lighting) shaders, acting…

306KDownloads
12d agoLast updated
Steam WorkshopSource

About GShader Library

From Steam Workshop

GShader Library — a shader library that serves as the foundation for creating [url=https://developer.valvesoftware.com/wiki/Deferred_renderer] Deferred Renderer (shading & lighting) shaders, acting…

[h1]GShader Library[/h1] — a shader library that serves as the foundation for creating Deferred Renderer (shading & lighting) shaders, acting as a convenient tool for creating advanced post-processing effects.

Brief list of textures in the addon:

  • _rt_WPDepth
  • _rt_NormalsTangents
  • _rt_ResolvedFullFrameDepth
  • _rt_Bumps

The addon includes:

  • Reconstruction of WorldPos, WorldNormals and Tangents from _rt_ResolvedFullFrameDepth.
  • Normal smoothing.
  • Increasing the bit depth of the depth buffer _rt_ResolvedFullFrameDepth.
  • View and projection matrices: View, Proj, ViewProj. For perspective and orthogonal projection.
  • Newly discovered texture formats that allow more flexible work with shaders.
  • Encoding Normals and Tangents into a single texture, packing WorldPos and Depth, which will fit within the 4-texture limit in screenspace_general.
  • Choice of normal reconstruction method: Simple, 3 Tap, Improved, Accurate.
  • Function shaderlib.DrawScreenQuad() with Multiple Render Target support.
  • Function shaderlib.DrawVertexScreenQuad() with input data to vertex shader and MRT support. More info here: Example 6.

Encoding Normals and Tangents

Normals and Tangents are stored in the render target _rt_NormalsTangents, where:

  • .RG — Normals
  • .B — Tangents
  • .A — Sign: A value of 1 or -1. It will help you with lighting and creating Post-Process Parallax Mapping.

Normals are encoded using Octahedron normal vector encoding Normal decoding is done via the function:


float3 Decode(float2 f)
{
    f = f * 2.0 - 1.0;

    // https://twitter.com/Stubbesaurus/status/937994790553227264
    float3 n = float3(f.x, f.y, 1.0 - abs(f.x) - abs(f.y));
    float t = saturate(-n.z);
    n.xy += n.xy >= 0.0 ? -t : t;
    return normalize(n);
}

Tangents are encoded using Diamond Encoding Tangent decoding is done via the function:


float2 decode_diamond(float p)
{
    float2 v;

    // Remap p to the appropriate segment on the diamond
    float p_sign = sign(p - 0.5f);
    v.x = -p_sign * 4.f * p + 1.f + p_sign * 2.f;
    v.y = p_sign * (1.f - abs(v.x));

    // Normalization extends the point on the diamond back to the unit circle
    return normalize(v);
}

float3 decode_tangent(float3 normal, float diamond_tangent)
{
    // As in the encode step, find our canonical tangent basis span(t1, t2)
    float3 t1;
    if (abs(normal.y) > abs(normal.z))
    {
        t1 = float3(normal.y, -normal.x, 0.f);
    }
    else
    {
        t1 = float3(normal.z, 0.f, -normal.x);
    }
    t1 = normalize(t1);

    float3 t2 = cross(t1, normal);

    // Recover the coordinates used with t1 and t2
    float2 packed_tangent = decode_diamond(diamond_tangent);

    return packed_tangent.x * t1 + packed_tangent.y * t2;
}

Example of working with _rt_NormalsTangents:


float4 normals_tangets = tex2D(NormalTangentBuffer,uv);
float flipSign = normals_tangets.a;
float3 worldNormal = Decode(normals_tangets.xy);
float3 tangents = decode_tangent(worldNormal, normals_tangets.z);
float3 binormals = normalize(cross(worldNormal,tangents))* flipSign;

float3x3 TBN = float3x3(tangents, binormals, worldNormal);

Packing WorldPos and Depth

WorldPos and Depth are stored in the render target _rt_WPDepth, where:

  • .RGB — 1/WorldPos: This means that WorldPos is packed into values <1. To unpack, use float3 worldPos = 1/tex2D(WPDepthBuffer,uv).xyz; in the shader.
  • .A — Depth

NOTE:

The depth buffer does not write translucent objects, so you will most likely render shaders in the PreDrawTranslucentRenderables hook.

Special thanks to:

Meetric — WorldPos reconstruction. notunknowndude— the idea to improve the depth buffer. puwada — the tip about texture format compatibility and DirectX. LVutner — implementation Velocity Buffer encoding of CryTeck method. Zaurzo — DynamicLight Wrapper. Blackknight33 — GShader logo. Xenthio — 3D Skybox PVS optimization.

Links:

SHADERS FOR EVERYONE!!!! i have no idea wtf is going on [/quote]

Read the full description on Steam Workshop →

Highlights

From source data

Footprint

Rated a light load on a server.

Last update

Its author last shipped an update 12d ago.

GShader Library on Nxeon

From our catalogue
One-click install
Supported on Nxeon Garry's Mod servers. We download it from Steam Workshop, place it, and restart the server.
Server load
light
Smallest plan we suggest
Garry's Mod — 2 GB (2 GB RAM). This follows our own load rating above, not a benchmark.
Latest build
2026-10-04, released 2026-10-04

Game versions by loader

LoaderGame versionsNewest
Workshop

From 2 recorded builds of GShader Library.

Recent builds

BuildReleasedGame versionsLoaders
2026-10-042026-10-04n/aWorkshop
2026-09-122026-09-12n/aWorkshop

Dependencies

Declared by the newest build that lists any. Required ones are installed with it on one-click installs.

Run GShader Library on a Garry's Mod server

Pick a server or deploy a new one above; it is installed in one click.

What kind of mod it is

From the catalog
Listed on Steam Workshop as “Workshop”

Libraries & compatibility

Foundations and fixes other mods build on. Usually installed because something else needs it.

Compatibility

Game
Garry's Mod

Verified at the source

  • ✓Steam WorkshopOfficial listing, checked 2026-10-10Open ↗
  • ✓AuthorEvgeny Akabenko, as published on Steam Workshop
  • ✓LicenseNot published by the sourceFree

GShader Library, answered

Generated from the mod’s own source data.

Is it free?

Yes. GShader Library is free to download from Steam Workshop.

How do I add it to my Nxeon server?

Use “Add to a server” on this page, or open NxLabs from your dashboard. We install it, restart your server and switch it on.

NxLabs

Run GShader Library on a Garry's Mod server.

Deploy in about a minute from $3.99 a month, then add GShader Library in one click.