#[Archive] The Shader Hole

1 messages · Page 1 of 1 (latest)

graceful lynx
#

Sure is shady in here.

#

Shaders? In my Garry's Mod?

It's more likely than you think thanks to @jovial tide's neat sdk_screenspace_shaders project available on GitHub Here

There is currently an open request to add official support for loading custom shaders via whitelisting a file path, available Here

GitHub

Screenspace pixel shader SDK for Source games. Contribute to ficool2/sdk_screenspace_shaders development by creating an account on GitHub.

finite quarry
#

Anyone got any working on models in GMod? I wanna try making one but that issue that one person has on the github makes me wonder if I should even bother

snow cradle
graceful lynx
#

Fuckin' weird art, but art

graceful lynx
warm sparrow
#

nope i was doing screenspace

finite quarry
#

talking bout this

jovial tide
#

it works on models

#

needs another mesh with WriteZ shader for depth though

finite quarry
#

simplest of grayscales (i am not a graphics programmer so this is kinda cool for me)

graceful lynx
#

Share it

#

Sounds like a good "Hello world" example, honestly

snow cradle
finite quarry
snow cradle
#

some ViewProj info:

float4x4 ViewProj = {
    r0,  0,  0,  0,
    0, g1, 0, 0,
    0, 0, b2, 0,
    r3, g3, b3, 1,
}
finite quarry
#
#include "common.hlsl"

float4 main( PS_INPUT i ) : COLOR
{
    float4 tex = tex2D(TexBase, i.uv.xy);
    float3 greyscale = float3(.5, .5, .5);
    float3 dotty = dot( float3(tex.r, tex.g, tex.b), greyscale );
    float3 clr = float3(dotty.r, dotty.g, dotty.b);

    return float4( clr.r, clr.g, clr.b, tex.a );
}
finite quarry
#

same thing but lerped with depth

#

oh man the bitrate does not do it justice

graceful lynx
#

That video doesn't want to play on my end

#

Worked after I downloaded it

graceful lynx
obsidian merlin
#

make everything older as you get near it

finite quarry
#

admin he's doing it sideways

obsidian merlin
#

lol, actually you could probably expand that into a cool concept, where things turn more "filmic" and "vintage" as you get closer.

finite quarry
#

wonder how that would work if it kept track of what's been "touched" already

#

i guess some rendertargets

graceful lynx
#

How would you track that with a render target?

finite quarry
#

it'd be 2d

#

top down i guess

#

sample render target

#

dunno if we can get pixel's world coords

#

but if so

#

check if x and y are in area that's white in the rendertarget

#

set color accordingly

#

this is all off the top of my head and i am definitely not a programming prodigy so i am not certain how feasible it is

wispy quartz
# graceful lynx ## Shaders? In my Garry's Mod? It's more likely than you think thanks to <@2194...

Looks like there is arleady a page about that in gmod wiki. Funny that this page is 2nd in my duck duck go search except github links. (So little info bout that lol)
https://wiki.facepunch.com/gmod/Shaders/screenspace_general

finite quarry
graceful lynx
#

It would be cool to have that effect radiate outward from an entity/entities

finite quarry
#

yeah i thought about that as well

#

can we somehow get an ent's coordinates in the shader?

wispy quartz
finite quarry
#

yeah i know i just couldn't be bothered

#

speaking of SSAO, i hope someone way more talented than me makes a basic SSAO shader sometime soon

#

would love to see all my scenebuilds with at least some semblance of lighting

snow cradle
#

finally. shadows

snow cradle
graceful lynx
#

Very interesting

#

It looks a bit grainy/static-y

#

What's the cause of that?

snow cradle
#

SSGI + SSS

finite quarry
#

screenspace shadows?

snow cradle
#

SSAO + SSS + SSGI

snow cradle
finite quarry
#

nice

#

is this with EGSM or screenspace_general

snow cradle
#

I just covered myself with shaders

snow cradle
#

SSAO can be maked on vcs on 8 samples (16 default)

graceful lynx
graceful lynx
#

Call it a "stylistic choice"

snow cradle
finite quarry
#

how are you determining what's a light source

#

for the SSS

snow cradle
# finite quarry for the SSS

I will define the sun as the light source. But if you get bored, you can choose the nearest env_sprite (which is a flash for a light bulb) as a light source.

raw sand
#

Sup shader crew

warm sparrow
finite quarry
snow cradle
snow cradle
blazing mason
#

so is this just for custom postprocessing shaders? or does it also allow for custom per-object shaders that we can reference in .vmts?

jovial tide
#

both

#

the latter is not too practical right now (but will be in the future if rubat accepts an extension)

blazing mason
#

yeah my thinking behind that question is recreating some functionality from the l4d2 infected shader

jovial tide
#

stay tuned on that because I want to make a 1:1 recreation of that shader

blazing mason
#

for me personally it's not about using the l4d2 models ingame, but rather using the functionality of the palette gradients

jovial tide
#

this should be possible if custom vertex shaders are accepted into gmod

graceful lynx
#

@misty surge Post your shader business here

graceful lynx
#

@warm sparrow You've got an issue on line 17 of your screenspace shader code

#

currentRT vs CurrentRT

warm sparrow
warm sparrow
#

I were rendering it outside doing rendertargets

#

i should PROBABLY have tested that

graceful lynx
#

Also, you should be caching the mesh

#

There's no need to recreate it from scratch every frame

warm sparrow
#

i were too lazy sorry

finite quarry
#

is that just for drawing a screen sized quad with the shader?

#

if so you don't need all that

#

you can just render.DrawQuad it

#

don't even need to create a material ingame

icy plume
#

Garry mod shader revolution is upon us

jovial tide
#

January 6th, 2025

warm sparrow
#

that or i forgot i didnt actually want to pass a color

finite quarry
#

lol

#

happens

#

i only know because i quickly prototype shit in Starfall and it's texturedrect function draws a quad

misty surge
#

The shader hole? Lmaoo

#

Yep, having issues with the view matrix recompiled. Can someone please help me with my function here:

@jovial tide How does one rebuild the viewmatrix? Here's my code:

float4x4 ComputeViewMatrix(float3 eyePos, float3 eyeDir)
{
    float3 up = float3(0.0, 1.0, 0.0); // World up

    // Ensure eyeDir is normalized
    float3 zAxis = normalize(eyeDir);

    // Handle the case where eyeDir is parallel to up
    if (abs(dot(zAxis, up)) > 0.999f)
    {
        up = float3(1.0, 0.0, 0.0); // Switch to another up vector
    }

    // Compute the right vector
    float3 xAxis = normalize(cross(up, zAxis));

    // Compute the corrected up vector
    float3 yAxis = cross(zAxis, xAxis);

    // Construct the view matrix
    float4x4 viewMatrix = float4x4(
        float4(xAxis.x, yAxis.x, -zAxis.x, 0.0f), // First column
        float4(xAxis.y, yAxis.y, -zAxis.y, 0.0f), // Second column
        float4(xAxis.z, yAxis.z, -zAxis.z, 0.0f), // Third column
        //float4(-dot(xAxis, eyePos), -dot(yAxis, eyePos), dot(zAxis, eyePos), 1.0f) // Fourth column
        float4(0,0,0,1.0f)
    );

    return viewMatrix;
}

All I have included are eyepos and eyedir.

Shader Hole unite!!

jovial tide
#

i wouldnt bother reconstructing, wait for vertex shader support

misty surge
#

Ok ;-; let me hold my breathe lol

misty surge
#

Vertex stuff would be amazing!! It’s the only thing that is bottlenecking me rn. @snow cradle is helping me resolve issues with rebuilding it. 🙂

graceful lynx
#

What is your shader intended to do?

misty surge
#

Nothing crazy, just wanted to obtain a rebuilt Viewmatrix. I think I got it figured out last night. I’ll share tn

misty surge
#
function GetViewMatrix()
    local ply = LocalPlayer()
    if not IsValid(ply) then return nil end

    -- Get the eye position and view angles
    local eyePos = ply:EyePos()
    local eyeAngles = ply:EyeAngles()

    -- Calculate the forward, right, and up vectors
    local forward = eyeAngles:Forward()
    local right = eyeAngles:Right()
    local up = eyeAngles:Up()

    -- Build the view matrix manually
    local viewMatrix = Matrix()
    viewMatrix:SetForward(forward)
    viewMatrix:SetRight(right)
    viewMatrix:SetUp(up)
    viewMatrix:SetTranslation(-eyePos) -- Translate the camera to origin

    return viewMatrix
end

Incase anyone needed this... Best results are here.

wispy quartz
#

Hi @jovial tide
Have you tried binding lightmap texture to your's modified screenspace_general shader?
And if it is - does it work well?

jovial tide
#

yes

snow cradle
graceful lynx
#

Very nice

#

I assume that's parallax depth, not "real" depth

snow cradle
#

Screen space decals

jovial tide
misty surge
#

Vertex Shaders ;~;

blazing mason
#

So with currently known/available methods, we can only use up to 4 textures for custom shaders?

finite quarry
#

yyea

jovial tide
misty surge
#

Does the fragment pos ever populate in shader 2.0? I noticed it’s there but it’s not usable.

jovial tide
#

it only exists in SM3

misty surge
#

Finally got the matrix math done right. Time to call it a day. All fragment shaders, I used two depths to capture this SSAO.

graceful lynx
#

@jovial tide Pack a shader into a map and upload it to the workshop

#

Be first to market on this

jovial tide
#

sure

graceful lynx
#

(Plus I want to see shaders and I haven't done any of the work required to set that up myself yet)

glossy sorrel
#

It works, somewhat.

#include "common.hlsl"

#define Color          Constants0
#define Corners        Constants1
#define Width          Constants2.x
#define Height         Constants2.y
#define EdgeBlurSize   Constants2.z
#define BorderWidth    Constants2.w
#define BorderColor    Constants3

static const float4 ZERO   = float4(0.0, 0.0, 0.0, 0.0);
static const float2 CENTER = float2(0.5, 0.5);

float rounded_box_sdf_individual_corners(float2 sample_at, float2 size, float4 radius) {
    radius.xy = (sample_at.x > 0.0) ? radius.xy : radius.zw;
    radius.x  = (sample_at.y > 0.0) ? radius.x  : radius.y;
    float2 q = abs(sample_at) - size + radius.x;
    return min(max(q.x, q.y), 0.0) + length(max(q, 0.0)) - radius.x;
}

float4 main( PS_INPUT i ) : COLOR
{
    float2 size         = float2(Width, Height);
    float  distance     = rounded_box_sdf_individual_corners(i.uv * size - CENTER * size, size / 2, Corners);
    float  rect_alpha   = 1.0 - smoothstep(0.0, EdgeBlurSize, distance);
    float  border_alpha = 1.0 - smoothstep(BorderWidth - EdgeBlurSize, BorderWidth, abs(distance));
    
    return lerp(ZERO, lerp(Color, BorderColor, border_alpha), rect_alpha);
}
wispy quartz
wispy quartz
glossy sorrel
#

I mean these.

wispy quartz
#

gonna download that and test

glossy sorrel
#

I don't see smoothing in the shader, at least.

wispy quartz
glossy sorrel
wispy quartz
glossy sorrel
wispy quartz
glossy sorrel
#

Wait for the MSDF fonts!

glossy sorrel
wispy quartz
glossy sorrel
#

You can use these, yes.

cosmic perch
glossy sorrel
#

But sadly you can't use more than one UV channel there.

wispy quartz
#

Sad

cosmic perch
#

Mom

glossy sorrel
wispy quartz
cosmic perch
#

BETTER FONTS TOO?

glossy sorrel
cosmic perch
#

🥹

#

does it support working with any characters

#

or got the same limit

#

as source engine one

wispy quartz
cosmic perch
#

damn

#

will be ready to make a textentry/label off it 😋

glossy sorrel
cosmic perch
#

1,046,528 left to fully support utf8

glossy sorrel
#

So, probably no surrogate pairs for you.
Probably.

cosmic perch
#

😋

glossy sorrel
wispy quartz
#

I'm sure you wont use all 65k characters

cosmic perch
#

oh yeah ur right

#

a player picks the language he wants

#

boom generate it for him

glossy sorrel
glossy sorrel
#

ASM.js. LOL

#

Wait. wasm2lua can help too.

cosmic perch
#

its not complete i think?

glossy sorrel
#

I dunno. But it works. I have compiled bullet3 once.

cosmic perch
#

oh nice

cosmic perch
#

but its slow

wispy quartz
cosmic perch
wispy quartz
#

Probably it can be backported from modern Typescript to ancient awesomium JS

cosmic perch
#

i tried doing that

#

awesomium is just so old

wispy quartz
cosmic perch
#

after some research, they drop really old browsers

#

we use rust to wasm to lua

glossy sorrel
# wispy quartz Sad

Yeah, but you can make some crutches with a texture that "indexes" another one.

glossy sorrel
cosmic perch
#

the generation process?

glossy sorrel
#

No, I mean, code that is generated by wasm2lua.

cosmic perch
#

ok another plan

#

we use js ye

#

but wasm to js to make sure that it works

#

as js has too many features polyfing just fails

glossy sorrel
#

And it will work much better than lua variant :P

cosmic perch
#

so we use wasm to make sure it uses pure js

#

its on a diff thread

glossy sorrel
#

Also true.

cosmic perch
glossy sorrel
#

WAIT A SECOND.
Multithreading. Using fucking lua VM witten in js.

cosmic perch
#

awesmium the beast will tell u no

#

communication with js is fucking trash

glossy sorrel
#

It will tell me yes. LuaVM is not that complex.

cosmic perch
#

depends on what futures of js it uses really

glossy sorrel
cosmic perch
#

so many plans 🥹

weak egret
cosmic perch
glossy sorrel
misty surge
glossy sorrel
misty surge
#

So far this came out pretty solid. Going to work on Normals to correct some of the edge cases.

jovial tide
#

its Over.

jovial tide
#

we're back.

leaden wasp
#

i already did this last night

#

however..

#

its not public and it doesnt work because it says the shader version is wrong

leaden wasp
misty surge
# jovial tide we're back.

Is that also Custom vertex shaders? Or is that simply fragment only? Shader 3.0 sounds awesome right about now 🙂

lavish robin
#

What's stopping model texture shaders from working in alien swarm+ engine branches? Especially sfm?
Is it possible to fix through the sdk?

#

I'm also curious about the vertex shader implementation as I couldn't find any examples

jovial tide
#

i have researched it and got it working but havent published it

#

a problem with the alien swarm branches is lack of texture resolution constants

#

its not exposed anywhere

#

so no screen resolution is available

lavish robin
#

ah, would that be possible to fix through the sdk? wondering if I could patch sfm for that

jovial tide
#

yes

#

you can just load custom shader dlls in sfm

#

dont need to patch

lavish robin
#

oh? I had no idea haha
I assumed the screenspace workaround was the only way

jovial tide
#

i mean why couldnt you since all memory is accessible anyway

lavish robin
#

true although I am a little worried about the sdk differences and sfm's specific engine branch
I'll definitely check that out though, you mean game_shader_* right?

jovial tide
#

yes

#

just use the alien swarm sdk

#

it will work

lavish robin
#

thank you!

snow cradle
#

world (brushes) bump render target using nik naks (lua only)

cunning crow
#

hello chat

#

so from what I understand, these shaders won't work on maps uploaded to the workshop until they update the game right?

#

thought it was just funny effects on screen but the playermodel shaders got me interested

cunning crow
#

we wait

#

let's hope it is coming soon

finite quarry
cunning crow
#

yeah that makes sense

misty surge
#

$vertexshader lets gooo!!

finite quarry
#

is there an easy way to get screen res for the shader, or should i supply that from lua?

finite quarry
#

those are just globals i can freely access?

keen coral
finite quarry
#

do we have a way to do tex2dlod in sm2, and does the frame buffer even have mipmaps?

finite quarry
#

doesn't matter anymore

jovial tide
#

see common.hlsl

#

if you are tight on textures then pass it from lua instead

finite quarry
#

i assume these from the spin shader are it?

jovial tide
#

yes

finite quarry
#

cool thanks

jovial tide
#

but it depends which texture you bind it frm

#

theres 4 to choose from

#

if its $texture3 then you use Tex3Size instead for example

finite quarry
#

yeah i figured that out but thanks anyway

leaden wasp
#

so what does the vertex shader allow for?

jovial tide
#

parallax cubemaps

#

goldsrc-style water displacement

graceful lynx
jovial tide
#

its not just moving stuff, you can also pass more data like the ones required for parallax cubemaps

graceful lynx
#

What about a vertex shader allows for more data to be passed?

jovial tide
#

for parallax cubemaps you need the direction vector to the pixel from the eye

#

so in the vertex shader you calculate that then pass it to the pixel shader via an unused register, like texcoords

misty surge
#

Have you guys tried $vertexshader yet? I'm not sure if we're able to unless I'm doing it completely wrong.

jovial tide
#

you are very likely doing it wrong

#

its not the same as pixel shaders when it comes to input/output, you also need different compiler flags

#

i will update the repo with the correct setup for it

leaden wasp
zenith bear
#

Finally joined here, very passionate about this

#

I wanted to ask, will something like CSGO's implementation of CSM be possible with vertex shaders?

#

For example, is it possible to recreate this volumetric fog and sunlight with the shaders?
This one here just uses projectedtextures and that lua based volumetric fog from workshop

misty surge
#

In theory, CSM needs to have multiple depth passes, so if you were to use projectedtexture with some tweaking, you can probably get this done.

zenith bear
#

Someone did mention it on GitHub that if we were able to change projectedtexture's update rate it would improve performance

#

Because at the moment it updates every frame and that's one of the main reasons why it causes such a performance hit in the long run.

misty surge
#

Yeah, it’s very easy to cause fps drops via CSM. Shaders is probably the best way to do it now that we have access. Before this, CSM isn’t as perfected as it can be.

wispy quartz
finite quarry
wispy quartz
#

But therefore the easiest way is for Rubat to make resolved frame depth RT use IMAGE_FORMAT_R32F

wispy quartz
#

Didn't see that, sry

finite quarry
#

Np

glossy sorrel
#

screenspaceeffect_vs20 was updated.
And it has now slightly different VS_OUTPUT structure. And that means PS_INPUT should be different too.
If I understand it correctly, then vertex shader is not passing zeros and texcoord2 anymore, and color has now TEXCOORD1 slot, rather than TEXCOORD3

tawdry rose
#

I wanted to ask, anyone here who is writing shaders?

#

Im looking for someone who can make a shader for me

graceful lynx
#

No one here can make a shader for you

#

They might be able to give you information that you can use to make your own shader

tawdry rose
graceful lynx
#

Why would they?

tawdry rose
#

what makes them incapable of making a shader for me?

livid cliff
#

It's not that they are incapable, it's that they wish to not spoon feed, no offense

tawdry rose
#

why would it be spoon feeding? I am willing to pay, within reason

graceful lynx
#

Offers for paid work are explicitly not allowed here

livid cliff
tawdry rose
#

I dont have the time, patience or skill with coding to do that

#

otherwise I wouldn't be asking for someone to make one for me

livid cliff
#

Well unfortunately this is not the place to ask for paid work

graceful lynx
tawdry rose
livid cliff
tawdry rose
livid cliff
#

👍

wispy quartz
jovial tide
#

you do not need that anymore

#

gmod's screenspace has $writedepth 1 now

wispy quartz
wispy quartz
jovial tide
#

you also need to do depthtest

#

$depthtest 1

wispy quartz
jovial tide
wispy quartz
#

I'm on dev branch, vertex shaders do work, just used default one rn

wispy quartz
wispy quartz
#

Looks like it writes it's depth as 0, making that ignorez or smth like that

wispy quartz
# wispy quartz

@agile turret $writedepth with $depthtest is not working pls fix 🙏

jovial tide
#

dont ping him for this stuff, i'll take a look

wispy quartz
misty surge
#

So hyped, I’m waiting patiently for vertex shader support. As soon as it’s available I’m in it. Finally can obtain fragpos instead of recompiling it.

misty surge
#

Please enlighten me

jovial tide
misty surge
#

I meant to say the compiler, is that been updated?

#

:0

wispy quartz
jovial tide
#

i have to reorganize the repository for verrtex shaders

#

so it will take a bit longer

wispy quartz
misty surge
#

Gotcha, I hear ya

jovial tide
#

but in the mean time label your filenames as _vs20

#

or _vs30

wispy quartz
#

Got can use that

jovial tide
#

and it will compile as vertex shader if you wanna experiment

misty surge
#

Copy, and this only works on dev rn?

jovial tide
#

yes

misty surge
#

What’s uh, the standard vertex, screenspace_general in source GitHub?

glossy sorrel
jovial tide
#

one secf

misty surge
#

Maybe, I’ll have to find out myself. I got common_vs from source.

wispy quartz
# misty surge Copy, and this only works on dev rn?

Yes
this is common_vs.hlsl

// common data shared among all screenspace shaders

// up to four textures available for sampling
sampler TexBase : register( s0 ); // $basetexture
sampler Tex1    : register( s1 ); // $texture1
sampler Tex2    : register( s2 ); // $texture2
sampler Tex3    : register( s3 ); // $texture3

// normalized dimensions for each texture above
// (x = 1.0 / width, y = 1.0 / height)

// customizable parameters $c0, $c1, $c2, $c3
const float4 Constants0 : register( c0 );
const float4 Constants1 : register( c1 );
const float4 Constants2 : register( c2 );
const float4 Constants3 : register( c3 );

const float4x4 cModelViewProj            : register(c4);
const float4x4 cViewProj                : register(c8);

// interpolated vertex data from vertex shader, do not change
struct VS_INPUT
{
    float4 pos            : POSITION;
    // texture coordinates
    float2 uv            : TEXCOORD0;
    // vertex color (if mesh has one)
    float4 color        : COLOR0;
    
    float4 normal       : NORMAL;
};

struct VS_OUTPUT
{
    float4 projPos                    : POSITION;
    float2 uv                : TEXCOORD0;
    float4 color                : TEXCOORD1;
};

This is a simple passthrough shader that works on models, etc

#include "common_vs.hlsl"


VS_OUTPUT main( const VS_INPUT v )
{
    VS_OUTPUT o = ( VS_OUTPUT )0;

    o.projPos.xyzw = mul( float4( v.pos.xyz, 1.0f ), cModelViewProj );
    o.uv = v.uv;
    o.color.rgba = v.color.rgba;

    return o;
}
jovial tide
#
// Example shader that is a functionally similar to the stock screenspace vertex shader
// Use this if you want SM3 pixel shaders to work

#include "../common.hlsl"

// TODO does this go into common?
struct VS_INPUT
{
    float3 pos        : POSITION;
    float2 uv        : TEXCOORD0;
    float4 color    : COLOR0;
};

struct VS_OUTPUT
{
    float4 pos        : POSITION;    
    float2 uv        : TEXCOORD0;
    float4 color    : TEXCOORD3;
};

VS_OUTPUT main( const VS_INPUT v )
{
    VS_OUTPUT o = (VS_OUTPUT)0;
    
    o.pos = mul(float4(v.pos.xyz, 1.0f), cModelViewProj);
    o.uv = v.uv;
    o.color = v.color;    

    return o;
}
misty surge
#

Ooo

jovial tide
#

if you want to get started

misty surge
#

Love you

jovial tide
#

use that

misty surge
#

I will when I arrive home from work. Love you guys.

jovial tide
#

common.hlsl```js
const float4 cEyePosWaterZ : register(c2);
#define cEyePos cEyePosWaterZ.xyz

const float4x4 cModelViewProj : register(c4);
const float4x4 cViewProj : register(c8);
const float4 cModelViewProjZ : register(c12);
const float4x3 cModel[53] : register(c58);

wispy quartz
jovial tide
#

note this is a mess, i am cleaning it up for the repo n

misty surge
#

Amazinggggggg

glossy sorrel
#

Is const float4x3 cModel[53] : register(c58); used for the bones?

misty surge
#

I’ll see what I can do with it. I appreciate it a lot. Finally depth shading without recomputing lollololol

glossy sorrel
#

And it seems like a lot of data to be passed.

wispy quartz
misty surge
#

Copy copy

misty surge
#

Oh man, I’m so hyped lol

jovial tide
#

i have an example for doing skinned models

wispy quartz
# wispy quartz Yes this is common_vs.hlsl ```hlsl // common data shared among all screenspace s...
#include "common_vs.hlsl"


VS_OUTPUT main( const VS_INPUT v )
{
    VS_OUTPUT o = ( VS_OUTPUT )0;

    o.projPos.xyzw = mul( float4( v.pos.xyz, 1.0f ), cModelViewProj );
    o.uv = v.uv;
    o.color.rgba = v.normal;

    return o;
}

This should work for normals, it will write worldspace normals iirc as vertex color.
Note that vertex color is TEXCOORD1 instead of TEXCOORD4 as in ficool2's sdk, since screenspace_generic update

glossy sorrel
glossy sorrel
jovial tide
#

yes

#

you can

#

so PS_INPUT can now be custom too

glossy sorrel
wispy quartz
jovial tide
#

TEXCOORD0 to TEXC0ORD7

jovial tide
wispy quartz
jovial tide
#

then pixel shader will work as sm3

wispy quartz
#

ah Good

jovial tide
#

i have not tested COLOR registers past 0

glossy sorrel
wispy quartz
jovial tide
#

no you shouldnt have to do this

#

i am investigating it

#

when i implemented custom screenspace_general, depth writes worked

glossy sorrel
#

I'm currently rendering simple quad inside of 3D2D context.

wispy quartz
normal sapphire
#

I'm starting to try out source shader editor, and my question is, does it work with Gmod?

wispy quartz
#

It behaves properly with me too, when i disable $writedepth
But it involves into models not writing depth, and behaving like that

glossy sorrel
wispy quartz
jovial tide
#

the name is misleading

#

its for creating materials

normal sapphire
#

uhh which channel is it then?

wispy quartz
#

It's shader hole

glossy sorrel
wispy quartz
#

Ahh, did you set $softwareskin 1?

#
screenspace_general
{
    $pixshader "passthrough3_ps20"
    $vertexshader "passthrough2_vs20"
    
    $softwareskin 1
    $basetexture "models/props_wasteland/wood_fence01a"
    $texture1    ""
    $texture2    ""
    $texture3    ""

    $x360appchooser 1
    $vertexcolor 1
    $vertextransform 1
    "<dx90"
    {
        $no_draw 1
    }
    $model 0

    $copyalpha                 0
    $alpha_blend_color_overlay 0
    $alpha_blend               0
    $linearwrite               1
    $linearread_basetexture    0
    $linearread_texture1       0
    $linearread_texture2       0
    $linearread_texture3       0
    $CULL 1
    $WRITEALPHA 1
}```
#

That's what i have been having

glossy sorrel
wispy quartz
glossy sorrel
# wispy quartz ```vmt screenspace_general { $pixshader "passthrough3_ps20" $vertexshade...

Nope, just empty spot.

local material = CreateMaterial("surrogate_rounded_box" .. math.floor(CurTime()), "screenspace_general", util.KeyValuesToTable([[
screenspace_general
{
    $pixshader "surrogate_rounded_rect_sdf_corners_14_ps20"

    $basetexture "plain_texture" // UVs are fuckedup without this? (256x256 texture)

    $VERTEXCOLOR     1
    $VERTEXTRANSFORM 1
    $WRITEALPHA      0
    $ALPHABLEND      1
    $depthtest       1
    $softwareskin    1
    
    // Corners
    $c0_x     0.0
    $c0_y     0.0
    $c0_z     0.0
    $c0_w     0.0
    // Params
    $c1_x     512.0 // Width
    $c1_y     256.0 // Height
    $c1_z     0.0   // Edge blur
    $c1_w     0.0   // unused
    // unused
    $c2_x     0.0   // Border width
    $c2_y     0.0   // Border blur
    $c2_z     0.0
    $c2_w     0.0
    // Border Color
    $c3_x     0.0
    $c3_y     0.0
    $c3_z     0.0
    $c3_w     0.0
}
]]))

this.RenderOverride = function(self, flags)
    render.MaterialOverride(material)
    self:DrawModel(flags)
    render.MaterialOverride()
end
#

Wait, you have $model 0

wispy quartz
glossy sorrel
#

Funny.

wispy quartz
#
local mat = Material('test/vsshader')

local ent = LocalPlayer():GetEyeTrace().Entity

function ent:Draw()
    render.MaterialOverride(mat)
    self:DrawModel()
    render.MaterialOverride(nil)
end
glossy sorrel
#

Box is being rendered trough the world, but at the same time, quad that is rendered in the 3D2D context is being rendered correctly.

wispy quartz
# glossy sorrel Funny.

Yeah, as you see, it's the issue it's having without $writedepth
But with $writedepth set to 1, it becomes worse, since it makes them ignore depth

glossy sorrel
glossy sorrel
wispy quartz
wispy quartz
#

Aka anticorrect this by 0.5 / 32 (32 is error texture size)

wispy quartz
glossy sorrel
#

Two separate shaders then.
Just like with TexturedRect and basic Rect.

wispy quartz
#

Although, you can basically use mesh library and make your custom quad.
If you draw meshes, it wont fuck up UV for some reasons

wispy quartz
glossy sorrel
wispy quartz
glossy sorrel
#

These two things are basically the same.

glossy sorrel
wispy quartz
wispy quartz
#

Aka sdf antialiasing is possible

glossy sorrel
wispy quartz
glossy sorrel
cosmic perch
#

stupid issue, drawing an image without "no clamp" does that, and clamp for some reasons adds some weird fucking effects

cosmic perch
#

is that with noclamp

#

with noclamp i had like weird small blur that happens, without it it would do some weird stretching

#

had to apply that uv fix

snow cradle
#

@jovial tide can i get WorldNormals and WorldPos? (for pp shader)

#

unique Vertex Shader for Post-processing


const float4x4 cViewProj        : register(c8);
const float4 cViewProjZ       : register(c12);

struct VS_INPUT
{
    float4 vPos            : POSITION;
    float2 uv            : TEXCOORD0;
};

struct VS_OUTPUT
{
    float4 projPos                    : POSITION;
    float2 uv                : TEXCOORD0;
};

VS_OUTPUT main( const VS_INPUT v )
{
    VS_OUTPUT o = ( VS_OUTPUT )0;

    float4 vProjPos = mul(  v.vPos, cViewProj );
    vProjPos.z = dot( v.vPos, cViewProjZ );
    o.projPos = vProjPos;
    o.uv = v.uv;

    return o;
}
glossy sorrel
#

Well, this is cursed.
Models with screenspace_general are only rendered when thier bone-cache was invalidated, but only by moving said object, or by changing animation cycles :/
And only when softwareskin is set to 1

#

No, not even by moving.
But by touching said object when it has disabled motion.

snow cradle
#

_rt_Normal test (wip)

snow cradle
#

how to fix render order?

local world_normals_mat = Material("pp/world_normals")

local function PreDrawEffectsHK()
        render.MaterialOverride( world_normals_mat )
        render.BrushMaterialOverride( world_normals_mat )
        render.WorldMaterialOverride( world_normals_mat )
        render.ModelMaterialOverride( world_normals_mat )

        render.RenderView()
    
end
hook.Add("RenderScreenspaceEffects", "!!!EGSM_ImTooLazy", function() PreDrawEffectsHK() end)
snow cradle
#

idk wtf is going on

snow cradle
snow cradle
#

@jovial tide pls help

#

mb i need to change .vmt params? like ignorez etc...

misty surge
#

Idk why, it looks like depth is reversed, based on what’s served.

wispy quartz
# snow cradle

Screenspace_generic doesn't write depth nor do such stuff

snow cradle
wispy quartz
glossy sorrel
#

I have a fucking question.
screenspace_general sets DepthFunc value to SHADER_DEPTHFUNC_ALWAYS when WRITEDEPTH is set to 1.
But should it not be something like SHADER_DEPTHFUNC_NEARER?

#

Or at least SHADER_DEPTHFUNC_NEAREROREQUAL

jovial tide
#

yes and it looks like the c++ implementation is incorrect

#

and i suspect it was also broken in csgo

glossy sorrel
glossy sorrel
glossy sorrel
#

materialsystem is a spaghetti.

exotic willow
glossy sorrel
glossy sorrel
wispy birch
wispy quartz
jovial tide
#

yes

glossy sorrel
wispy quartz
# jovial tide yes

Good to hear 🙂
What about lightmaps, ambient information and cubemaps then?

#

Are they easy to fix too?

jovial tide
#

yes

#

i added those in my version

wispy quartz
jovial tide
#

im going to propose making a new shader named like CustomGeneric

#

cus it doesnt make sense to add all these features to a shader named screenspace

glossy sorrel
#

True.

glossy sorrel
exotic willow
wispy quartz
graceful lynx
misty surge
#

The depth being limited to 192 is a shame, I have to set my depth bias to like 0.000001 in order to get any detail from full depth. It would be nice to have more detailed depth maps so I that we can avoid using blurs to accomplish reasonable results.

misty surge
#
float ComputeNearDepthFar(float2 uv) {
    // Sample the base depth texture (near depth range)
    float nearDepth = tex2D(TexBase, uv).w;

    //// Sample the secondary depth texture (far depth range)
    float transitionThreshold = 0.85;  //Where transition begins
    float farDepth = tex2D(Tex1, uv).r*256.0f;

    // Define a transition range and threshold
    float transitionRange = 0.00001;  //    Range over which transition occurs

    // Normalize the nearDepth value to be in a comparable range
    // Assuming nearDepth is in the [0, 1] range, but this depends on your depth buffer format
    float normalizedNearDepth = saturate(nearDepth);

    // Calculate the blend factor based on the near depth
    // Ensure the blend factor is clamped between 0 and 1 to avoid overshooting
    float blendFactor = saturate((normalizedNearDepth - transitionThreshold) / transitionRange);

    //Blend the two depth values
    float depth = lerp(nearDepth, farDepth, blendFactor);


    //return (tex2D(TexBase, uv).w + (tex2D(Tex1, uv).r - DepthRange));

    return depth;
    //Return the blended depth value
    
}

What I use to interpolate two depths we have rn.

misty surge
#

Finally got VertexShader working WOOT

#
struct VS_OUTPUT
{
    float4 pos                    : POSITION;
    float4 vPos                : TEXCOORD0;
    float2 uv                : TEXCOORD1;
    
};

Output as texcoord instead of position which is sort of "protected".

misty surge
glossy sorrel
misty surge
#

The solution is clear, for a higher depth, we're going to have to pioneer a way. Shader 3.0 would address the issue I think.

#

EGSM uses 3.0 shaders.

wispy quartz
snow cradle
#

help pls with smaa

wispy quartz
#

For a better way to address multiple (normals, worldpos, etc) buffers issue is to make a function to override SSAO depth pass material (internally it uses DepthWrite material with color_depth 1 i think)
With 3.0 shaders you could in theory write information to multiple rendertargets (probably with render.SetRenderTargetEx)

#

I.e paas depth into depth RT, normals to normals RT, worldpos, tangent space, etc in other RTs. In single pass.

timid pumice
#
surface.DrawTexturedRectUV( -1, -1, 2, 2, 0, 1, 1, 0 )

I truly have no idea why does that works

#

I have tried to "Stack" those but i couldn't make it

#

Btw, we can build custom panels that allows to pass custom settings

graceful lynx
#

This is good work, Gonzo

#

I'm glad someone thought to investigate the UI side of things

timid pumice
#

I'm worried about the language implementation (lang res files) and if rubat and ficool can work to ship those examples

timid pumice
# timid pumice

Otherwise if ficool decides to upload those shaders to workshop and use that implementation I would be proud enough at helping without learning hlsl Pepelove1

misty surge
#

Say for example, I were to export a brand new vcs with the same name as another one inside the folder (let’s say DepthWrite) is it possible to override the original?

jovial tide
#

no, gmod searches for custom shaders only if it doesnt find the original

graceful lynx
snow cradle
timid pumice
#

The flowers reminds me to days gone and the liquid to hl alyx 😍

glossy sorrel
#

Source Engine's software anti aliasing from Engine_Post_dx9 shader using screenspace_general

#

Somewhat parameterized.

timid hedge
#

liquid in bottle shader ala half life alyx when

timid hedge
short dirge
short dirge
short dirge
graceful lynx
short dirge
#

mostly just walking thru sourceengine.vpk picking out interesting textures

#

and black basetexture obvs

dusty linden
#

Not the custom lua ones, the ones that already exist in source.

snow cradle
#

Which matrix contains information about the rotation of the player's camera?

jovial tide
#

the right, up and forward vector of the camera are stored in row 0, row 1 and row 2 of the view matrix

glossy sorrel
#

"Ported" this sky shader
But the limit of 512 instruction slots is a bit restraining.
And this banding is killing me from within.

jovial tide
#

you can get more instructions out of SM3 because it supports loops unlike SM2

glossy sorrel
weak egret
#

vertex shader examples when

jovial tide
#

to compile as SM3 rename the _ps2x to _ps30

#

you will also need a SM3 vertex shader or it will not display (unless you have an nvidia card)

glossy sorrel
jovial tide
#

it does because gmod supports custom vertex shaders now

glossy sorrel
#

I'll try that.

glossy sorrel
#

Now it looks much better, thank you ficool2.

snow cradle
misty surge
#

Multiply ViewProj with inverse Proj to get view.

snow cradle
misty surge
#
float4x4 ExtractViewMatrix(float4x4 viewProjection, float4x4 projection)
{
    // Invert the projection matrix
    float4x4 invProjection = InvertMatrix(projection);

    // Multiply the viewProjection by the inverse of the projection
    float4x4 view = mul(viewProjection, invProjection);

    return view;
}
#

Recalculate the projection

#

Think about matrix like addives.

#

Minus some imprecision perhaps.

snow cradle
finite quarry
snow cradle
misty surge
snow cradle
dusty linden
#

Now add bubbling, foam, ambient lighting 🙂

#

Well done.

graceful lynx
# snow cradle

It's extremely strange to see that kind of thing in Garry's Mod

#

Well done

wispy quartz
#

@jovial tide Have you tried using 3D textures in shaders?
VTF supports 3D textures iirc.
Good to be noted in your SDK i think, if it does work

jovial tide
#

no but i dont see any reason why it wouldnt work

snow cradle
#

tex3D using egsm

#

i think we also can use tex3D in .vcs

#

i can share some 3d textures (vtf)

#

perlin noise etc

wispy quartz
wispy quartz
snow cradle
#

ok

wispy quartz
# snow cradle

When i was asking about that kind of thing, i was intending to check that in volumetric clouds case

snow cradle
#

i can share code shader

#

this is Mee code (gwater founder)

#

i l write it from youtube video

#

and write missing code

wispy quartz
snow cradle
#

ok

misty surge
#

Pre-shader improvements, I took out a lot of the night-time functions I used prior to shader discovery, I'm hoping to enhance this scene up a bit, you guys got some ideas, this is indeed before shaders full-bright. Day/night should lower the colors, but maybe I can make some fake lighting a bit easier.

misty surge
#

Rightside: Shaders, Left none

misty surge
#

Time lapsed

static wedge
#

hello ethan

graceful lynx
finite quarry
#

could also perhaps draw the texture larger at a distance

#

and some fog would help as well

finite quarry
glossy sorrel
# misty surge Time lapsed

Wouldn't it benefit from render.SetLocalModelLights? From a single directional light, I mean.
That is, if you're rendering this yourself as meshes, of course.

finite quarry
#

yeah lighting is too flat

snow cradle
dusty linden
#

Very well done

#

🙂

snow cradle
#

256x256x256 size

snow cradle
exotic willow
glossy sorrel
snow cradle
#

||я это перенесу, как глубину пофиксят - на .vcs. меня тот баг сильно парит||

glossy sorrel
exotic willow
#

||well, need more test)||

snow cradle
exotic willow
snow cradle
#

samples:
8 - normal
16 - hight
etc

#

16 (my options)

#

32... little effect. better not to use

#

8-16 cool

misty surge
#

I wish we had 32bit depth, those SSAOs looks so nice! 🥹

zinc sedge
#

when are we getting orthographic projected textures that cast shadows

misty surge
#

I think ProjectedTextures uses a render target depth buffer, but I’m not sure what that buffer is called.

finite quarry
misty surge
#

I wanted to, but unforunately I did not see any RT at all

finite quarry
#

Huh, weird. I could swear they showed up there.

#

I think there might have been a checkbox you have to click

#

I’ll check in a bit

finite quarry
#

@misty surge did you check this

#

the little square on the top left is clickable

misty surge
#

I don't see that option

misty surge
#
Texture: '__rt_supertexture1' RefCount: 2
Texture: '__rt_supertexture2' RefCount: 1
Texture: '__vgui_texture_1' RefCount: 2
Texture: '_dynamic_cimage_0' RefCount: 1
Texture: '_gmod_frameblend' RefCount: 3
Texture: '_rt_camera' RefCount: 1
Texture: '_rt_eyeglint' RefCount: 1
Texture: '_rt_fullframefb' RefCount: 39
Texture: '_rt_fullframefb1' RefCount: 3
Texture: '_rt_fullscreen' RefCount: 2
Texture: '_rt_poweroftwofb' RefCount: 3
Texture: '_rt_resolvedfullframedepth' RefCount: 1
Texture: '_rt_shadowdepthtexture_0' RefCount: 1
Texture: '_rt_shadowdepthtexture_1' RefCount: 1
Texture: '_rt_shadowdepthtexture_2' RefCount: 1
Texture: '_rt_shadowdepthtexture_3' RefCount: 1
Texture: '_rt_shadowdepthtexture_4' RefCount: 1
Texture: '_rt_shadowdepthtexture_5' RefCount: 1
Texture: '_rt_shadowdepthtexture_6' RefCount: 1
Texture: '_rt_shadowdepthtexture_7' RefCount: 1
Texture: '_rt_shadowdummy' RefCount: 1
Texture: '_rt_shadows' RefCount: 1
Texture: '_rt_smallfb0' RefCount: 6
Texture: '_rt_smallfb1' RefCount: 4
Texture: '_rt_spawnicon' RefCount: 2
Texture: '_rt_teenyfb0' RefCount: 1
Texture: '_rt_teenyfb1' RefCount: 1
Texture: '_rt_teenyfb2' RefCount: 1
finite quarry
#

can you click that

misty surge
finite quarry
#

that's actually not a bad idea

#

i think it should work

misty surge
#

If I get anywhere first thing I’ll do is share

#

Working without dlls is tough, I spent hours researching the topic.

#

Found 2 more shaders that use $pixelshader not documented from that list I posted.

#

Sample4x4 downscales btw. Kinda cool

wispy quartz
wispy birch
#

are you sure that those rendertargets are not available from lua?

#

i dont see a reason why they would not

snow cradle
#

fuck jpeg. nice discord

raw sand
#

this is absolutely incredible

static wedge
#

kinda cursed to see in the source engine for some reason

snow cradle
graceful lynx
graceful lynx
snow cradle
graceful lynx
#

So the light wouldn't cast shadows between the bricks?

snow cradle
graceful lynx
#

I look forward to it! I always enjoy seeing new shader stuff

graceful lynx
# snow cradle 4

FYI if you post images like these all in a single message, it's easy to switch between them with the arrow keys for easier comparison

snow cradle
#

When it becomes possible

leaden wasp
snow cradle
# leaden wasp you can do it through maps right now

I'm waiting for the texture render order bug to be fixed so I can create the technical textures required to create shaders.

I found bugs, told about them -> I'm waiting for fixes. I sit quietly and wait.

#

Until the bugs are fixed and I have the opportunity to create technical textures, I do not compile shaders.

leaden wasp
#

🥺

misty surge
#

If we had a custom 3.0 shader to work with, depth would be calculated properly. With screen space, you sort of limit depth when you attribute it to a mesh.

#

I think with some fog and some trickery I can fake a depth map. Hopefully it’ll be good.

snow cradle
zinc sedge
#

this will be garrys mod in 2012

snow cradle
static wedge
#

this will be garrys mod in 2013

misty surge
#

Fake Depth WIP RN, already can gain so much detail here

misty surge
#

The problem: Zbuffer or depth is also limited via fog. (8bit limits cannot go full detail no matter what).
This does looks a bit nicer butit includes all effects

#

I just used paint and bucket, as you can see, the depth capturing looks to be good, but 8 bit depth, with some masking.

wispy quartz
#

It would allow you to double depth prescision (from 256 or 8 bits it will be 65k ir 16 bits)

misty surge
#

I’ll try that thank you

misty surge
#

I am only using new shaders, (no dlls rn)

snow cradle
zinc sedge
#

i didn't even think about how cool stormfox could become with custom shaders

zinc sedge
#

oh and dynamic volumetric clouds that change depending on weather

bronze epoch
snow cradle
#

lightmap rendertarget (lua only)

snow cradle
finite quarry
#

neat

#

i assume it's drawn with render.WorldMaterialOverride and render.MaterialOverride?

analog hornet
#

Ay nice shader

cosmic perch
analog hornet
# cosmic perch ur done

Nah, I've always supported alternatives to SF, even helped a few. Hope this is the start of an awesome mod act_dance

snow cradle
snow cradle
#

Parallax mapping + Snow shader

raw sand
#

im attracted to you personally

snow cradle
wispy quartz
misty surge
leaden wasp
wispy birch
snow cradle
dusty linden
#

Awesome

#

🙂

short dirge
#

the snow looks funny to me, because it seems to have an opposite effect.
as a uniformly distributed powder, it would visibly accumulate more on raised surfaces than lowered troughs, especially when those troughs are still somewhat warm.
https://fxtwitter.com/paytonmalonewx/status/1881860133422293164.mp4
it makes sense for troughs of snow to be left behind after the wind has blown & the sun has melted away the top layers.
still, this is probably fine for gameplay or perf reasons.
maybe two variables controlling snow height, a "leader" and "follower."
this matters less as the angle between the world sky and the surface becomes greater, and a different algorithm could be mixed in its placed. (yes, more perf overhead)

#

that is just one form of snow, though. There are some more that I don't have an example to show for.

snow cradle
#

texture snow uv = worldpos

#

parallax uv = cEyePos - worldPos

#

What the fuck should I do?

short dirge
#

probably two layers that's assuming you have vertex shading to blow up the surface

#

though you wouldn't necessarily need to have it volumetric, I think. just a modifier for which height range the snow is drawn instead of the brick

snow cradle
#

like a shit

wispy quartz
misty surge
#

Good! I’ll share a pic

#

Problem I have is not the depth, but the ranges it provides. DepthWrite does its job for uh showcasing depth better than FrameBuffer and the SSAO, but the ssao quality I have still suffers from z fighting, which happens when I convert depth back into world coords.

graceful lynx
jovial tide
#

no

graceful lynx
#

I'd like to learn the very basics of screenspace and vertex shaders for Garry's Mod so I can later document them on the wiki, but I haven't been keeping track of all the changes that have happened recently

graceful lynx
# jovial tide no

If you find the time to update it, it would be very helpful to me (and others, I'm sure) as I believe you currently have the most up-to-date documentation on custom shaders right now

misty surge
#

$vertexshader stuff, that’s the only thing I think that’s not documented

jovial tide
#

some parameters added from csgo are non functional since gmod just copy pasted the code (it was also bugged in csgo)

#

so i want to forward a fix for that first

snow cradle
graceful lynx
snow cradle
#

i use snow mask to lerp framebuffer to snow_color

#

snow_color = tex2D(SnowTexture, worldpos.xy);

#

i use wp as texcords because i make shader as pp. i think i have no chance to make it by something other

#

pp - post processing

#

also i have parallax. i l write height texture with parallax uv to rt

#

also i use ut how mask to snow texture

misty surge
#

SSAO works, but uh...

#

Not using $texture1 "_rt_ResolvedFullFrameDepth", rather just DepthWrite

#
local dw = CreateMaterial("DW1323", "DepthWrite", {
    ["$no_fullbright"] = "1",
    ["$color_depth"] = "1",
    ["$alpha_test"] = "1"
})
#

DepthWrite > _rt_ResolvedFullFrameDepth

snow cradle
misty surge
#

I cannot convert GetRenderTargetEx to 16bits which is very odd

misty surge
#

16bit rendertarget! I Got it working!!! YEEE

keen coral
snow cradle
misty surge
#

Incase someone wanted better DepthMaps without the use of a custom shader.

misty surge
#

Unforunately you cannot convert into ortho using RenderView D:< DepthWrite does not support Ortho which is kinda lame D:

wispy quartz
snow cradle
#
local TEXTURE_PAGE_SIZE = 1024
SHADOW_C_RT = GetRenderTargetEx("_rt_Shadows", TEXTURE_PAGE_SIZE, TEXTURE_PAGE_SIZE,
    RT_SIZE_NO_CHANGE, MATERIAL_RT_DEPTH_NONE, 0,
    0, IMAGE_FORMAT_ARGB8888)
#

rt shadows from shadow_controller. With parameters as in Source SDK
But I can't quite understand what it shows.

I tried clearing it in some hooks. But it just displays squares. And that's not always the case. I don't understand

snow cradle
#

depth buffer on world from sun (camera) view (non ortro. just test)

graceful lynx
#

Orthographic views can be simulated via a narrow FOV from very far away, right?

#

Not sure what you need orthographic views for, but that's one way to emulate them I think

snow cradle
graceful lynx
#

I understand what an orthographic view is, and that the depth buffer doesn't get created when using the orthographic view

#

I just don't know what specific shader application requires an orthographic depth buffer

#

Realtime sun shadows is my guess

finite quarry
#

And yes, sun shadows, since the sun is so far away and so large, the shadows need to be orthographic

graceful lynx
#

As far as I know, the depth buffer's values are intended to be between the near and far clipping plane, so even if you positioned the camera very far away, you could adjust the near/far clipping planes to still get depth values that are in the same range as an orthographic render would produce

finite quarry
#

Yeah just gotta raise znear and zfar

snow cradle
snow cradle
#

depth -> worldpos -> screen

snow cradle
snow cradle
#

now i will make otho depth from shadow map

misty surge
#

Renderview doesn’t work ortho and DepthWrite I assume because of how it’s written.

misty surge
wispy quartz
snow cradle
#

How to add camera rotate to LUA ViewMatrix?

local viewMatrix = Matrix()
viewMatrix:SetTranslation(pos)
--viewMatrix:Rotate( ang/180*math.pi ); //mb this?
--viewMatrix:Rotate( ang ) // or like that??
viewMatrix:Invert()
finite quarry
snow cradle
leaden wasp
#

marry me

misty surge
#

Gmod update broke EGSM. They gotta update to new signatures.

bronze epoch
obsidian merlin
#

all of this stuff makes me want to map again

mint widget
#

Hey, I believe I know the answer however how can I upload shaders to the steam workshop?
You can do it by packing it to the map apparently but would that allow me to be able to use the shader material on ANYTHING and is not limited to the overlay entity. Like being able to use the shader on a rect using surface.SetMaterial.

Second question, is it able to update a shader's textures? I am planning to use em as buffers for what I am doing, is it possible?

misty surge
snow cradle
#

64 bit chromium

#

works only 64 chrom

raw sand
#

Gods work

misty surge
#

Start my 3.0 when I’m done with my 2.0

cosmic perch
#

how would i draw a PS inside hudpaint? using r_screenoverlay works but trying to draw inside hudpaint does nothing

finite quarry
#

draw a screen quad with the material

cosmic perch
glossy sorrel
cosmic perch
#

SetVector4D with optional param will be nice

glossy sorrel
#

For example.
I have done this, and I'm not changing every parameter every time.

#define Corners        Constants0
#define Width          Constants1.x
#define Height         Constants1.y
#define EdgeBlurSize   Constants1.z

#define BorderWidth    Constants2.x
#define BorderBlurSize Constants2.y
#define BorderColor    Constants3

For example, EdgeBlurSize which is $c1_z. And I am not changing it that often.

cosmic perch
#

the performance hit im having rn is insane

#

dont get me wrong, its still faster than drawing a rounded image

#

but the C calls are heavier than the drawing shader itself

cosmic perch
#

i have similar code to urs

#

but doing outline as a second shader

glossy sorrel
cosmic perch
#

yeah, its still gonna be faster

#

but its insanely faster if we have a way to batch the calls

glossy sorrel
cosmic perch
#

im using ai with some shader toy code

#

so i dont want to complicate it anymore lol

#

it wont matter anyway as the amount of times needed to draw outlines is not a lot

#

and its still gonna be fast

glossy sorrel
cosmic perch
#

why dont u like SetVector4D?

#

adding optional param to it wont break anything

glossy sorrel
cosmic perch
#

every c call i remove adds like 20% boost lol

#
1: 3.5318022000001s (Average: 0.0035318057318059ms)
2: 2.5726947000003s (Average: 0.0025726972726976ms)
Difference: 37%

second is shaders

#

first one is drawing with my png way

glossy sorrel
#

Yeah, I had the same problem, but not with shaders though.

cosmic perch
#

with what?

glossy sorrel
#

Vectors. I have my own implementation.
And as the bonus - I have double precision. LOL

cosmic perch
#

lmao

#

its unforun that every op in them is a c call

glossy sorrel
#

And matrices. But not a full implementation. Only a partial one.

cosmic perch
#

but they cant easily change that

glossy sorrel
#

One can only hope. :(

cosmic perch
#

we both know that can never happen

#

other methods of changing how vectors work wont work

#

unless u know when to update to c side

#

and ofc that cant be changed for compat reasons lol

#

are u using sm3 or 2?

cosmic perch
#

why didnt u switch to sm3?

#

for fwidth

glossy sorrel
cosmic perch
#

i will be releasing my one soon

#

just making sure i finish circles @errant nacelle

glossy sorrel
cosmic perch
#

nor me i was using ai haha

glossy sorrel
#

And now we have at least three different implementations of rounded boxes using shaders.
This is acually nice.

cosmic perch
#

ay i stole some from rboxes

glossy sorrel
#

But you have modified it to suit your needs.
Such as vertex-colors and uv-mapping.

cosmic perch
#

with some stuff from rboxes

#

and some help from svetov

#

with some help from ai

glossy sorrel
#

I presume you have encountered a problem with premultiplied alpha and color-darkening?

cosmic perch
#

no

#

not yet at least?

glossy sorrel
#

I mean this.

#

And it should look like this.

cosmic perch
#

is that blur or AA

glossy sorrel
#

Neither.

cosmic perch
#

im confused

wispy birch
glossy sorrel
cosmic perch
#

1 small mistake = $1m profit

snow cradle
glossy sorrel
cosmic perch
#

no whats the usecase

glossy sorrel
cosmic perch
#

to do glow
?

glossy sorrel
wispy birch
glossy sorrel
raw sand
#

i would love to learn to write shaders for gmod but i have no idea where to even begin here

#

ive only written simple shaders for stuff outside of gmod

cosmic perch
glossy sorrel
#

Also, I have somehow messed up the border colors, and the border alpha takes precedence over the vertex color.

wispy birch
glossy sorrel
raw sand
#

never seen the book of shaders before this looks nice

#

that moon is absolutely insane

cosmic perch
#

holy moly disabling gamma correction is insane

#

this is bs lol

glossy sorrel
#

linearwrite?

cosmic perch
#

linearread_basetexture for textures

#

man i got used to gmod colors, my eyes cant adapt to the nice colors

wispy birch
#

source gamma correction is shit

cosmic perch
#

no wonder i was going insane that different colors are too similar

wispy birch
cosmic perch
#

agreed it has no ears now lol

wispy birch
#

ah, the other way then, i guess

graceful lynx
cosmic perch
#

No gamma image looks exactly the same as I have it here in discord

cosmic perch
#

@jovial tide
for some reason with using

Proxies
    {
        // Updates the framebuffer
        // You only need this if you are going to be *reading* the framebuffer
        // If you aren't using the framebuffer, or are only fetching its dimensions,
        // you DON'T need this and it will save you some performance
        Equals
        {
            srcVar1            $fix_fb
            resultVar        $flags2
        }
    }

does not update the buffer, i have to call
https://gmodwiki.com/render.UpdateScreenEffectTexture
for it to update, am i doing something wrong? using sm3

jovial tide
#

if you are rendering from lua then just call UpdateScreenEffectTexture, dont use that hack

cosmic perch
#

i hate calling that as its really heavy

jovial tide
#

that proxy does the same thing

cosmic perch
#

ah

snow cradle
#

Will it be possible to make outputs from pixel shader?

@jovial tide

jovial tide
#

well you can do that if you allocate a rendertarget and then control rendering order with lua, so later materials can read the rendertarget

snow cradle
wispy birch
snow cradle
# wispy birch what do you mean by four outputs?
struct PS_OUT
{
    float4 c0             : COLOR0;
    float4 c1            : COLOR1;
    float4 c2            : COLOR2;
    float4 c3            : COLOR3;
};

PS_OUT main(PS_IN i )
{
    float4 c = tex2D(FrameBuffer, i.vTexCoord);
    PS_OUT l = (PS_OUT)0;
    //c.rgb = (vel/500+0.1)-c.rgb;
    l.c0 = c;
    l.c1 = i.color;
    l.c2 = float4(i.vTexCoord,0,1);
    l.c3 = float4(1/i.wPos,1);
    return l;
};
wispy birch
#

ah, you tryna do 4 rts?
if source engine itself binds several rts to the shader, this might be possible

#

this miiight be it

snow cradle
snow cradle
#

we can render only first COLOR0

#

what about 1-3?

wispy birch
#

@snow cradle thats just regular rendertargets

#

so you can simply... use them as is

#

bind a few rts and ur good to go

snow cradle
#

а бля

#

корочн

wispy birch
snow cradle
#

их же надо на луа забиндить

#

т.е. мы сетает рендертаргет экс, рисуем материал?

wispy birch
#

lf

#

da

snow cradle
#

и у нас в рт записывается нужный color?

wispy birch
#

da

snow cradle
#

а ну классно тогда

#

ты сам то вникаешь в шейдеры, пилишь что-то?

wispy birch
#

ща в лс кину

snow cradle
graceful lynx
snow cradle
snow cradle
#

Parallax Occlusion Mapping with self-shadowing

#

A huge distance to the sun, which causes artifacts to appear

snow cradle
snow cradle
snow cradle
surreal parcel
#

bros be making shit like this then its never seen anywhere ever

leaden wasp
#

lol

misty surge
#

Shader stuff in a nut shell.

snow cradle
jovial tide
#

@cosmic perch i suggest adding fallbacks for SM2

#

this is only a problem with people on intel cards because they are forced to sm2

cosmic perch
#

all intel cards?

jovial tide
#

yes

cosmic perch
#

i thought all intel cpus > 2012 have support for sm3

jovial tide
#

yes but the engine forcefully disables it

#

rubat could fix this but if he doesnt, you'll need a fallback

cosmic perch
#

ah shit

jovial tide
#

but its simple anyway, you just need to hardcode a value for antialiasing

#

thats the only thing ur missing on sm2, as it has no derivative functions

cosmic perch
#

yeah i know, but that sucks :(

#

i was like only linux users will not have it working lol

jovial tide
#

oh yea since gmod is still togl you'll need a linux fallback

cosmic perch
#

most of them use wine anyway

jovial tide
#

this isnt documented but the shader compiler has a SHADER_MODEL_PS_X_X define that you can use

#

so you can have a #ifdef to avoid duplicating code

#
// Example shader that shows usage of SM3

#include "../common.hlsl"

float4 main( PS_INPUT i ) : COLOR
{
#ifdef SHADER_MODEL_PS_3_0
    float2 normalized_screen_pos = i.screen_pos * Tex1Size;
    return float4(normalized_screen_pos, 0.0, 1.0);
#else
    return tex2D(TexBase, i.uv);    
#endif
}
cosmic perch
#

damn thank you

#

this makes life way easier

cosmic perch
jovial tide
#

yes

#

you'll need to make a "base" file and then a _ps20 and _ps30 that just #includes that base

#

i am making a new shader repo that has a better build system than this, but for now you'll need to use that

cosmic perch
#

guess i can just automate that using workflows

#

btw there is no way to detect if client supports sm3 or not right?