#[Archive] The Shader Hole
1 messages · Page 3 of 1
For water stuff? No, it works
I mean, only you have to do is to set $softwareskin to 1
Really? didn't though it would do it
hook.Add( "PostDrawTranslucentRenderables", "A1_RenderTargetTesting_ClearWaterRenderTargets", function()
local renderTargetName = render.GetRenderTarget():GetName()
if renderTargetName == "_rt_waterreflection" or renderTargetName == "_rt_waterrefraction" then
render.Clear( 0, 0, 0, 255, true, true )
end
end )
what is writez shader
For your case you already use lightmap pass which includes your Z buffer values, which you can actually use already
by lightmap pass i mean your's rt_lightmap or how was that called idk
I suggest that since you won't have to do additional render pass
render the shader to screen & grab the pixels
no depth
obv no depth
enable depth
thus you have two rendertargets bound, read both
what
ah, that
yeah
whats ur problem here
get? maybe set?
Sets the render target with the specified index to the specified rt.
yeah, you use that
COLOR0 -> idx 0 rt
COLOR1 -> idx 1 rt
literally just create a rendertarget (three in your case) and set them via
render.SetRenderTargetEx(0, rtWorldNormals)
render.SetRenderTargetEx(1, rtWorldPos)
render.SetRenderTargetEx(2, rtDepth)
rt0 is 1 here? wtf
also are you rendering right away
RenderView might be messing with rts
wdym
show results
you have to restore the rts
at the very least
but thats probably not the issue
this is probably a direct binding to directx set shader api
so uhh
i literally have no idea why it doesnt work unless
a. something is resetting them in renderview
b. something is overwriting your rts before you draw them to screen
nope thats not it
this is literally how it is supposed to work
we have had this before
ah, well still, it should work
you can test it by doing something simpler than a renderview, maybe render a single model and immediately draw the result to screen
ну епта делай что говорю
протестируй на более легком примере
да, просто одну модельку вьеби в рендертаргет и сразу на экран после этого
да похуй, главное вывод на несколько рт проверить
что внутри не так важно
тем, что ты проверишь, баг в самой функции, или в RenderView
это мы и проверяем
пшел тестить
неподатливый какой попался
там есть еще одна проблема, эта хуйня глобальная
так что если что то еще юзает эту хуйню внутри, это вызовет конфликт
и либо тебе в рт ебень запишет какую то, либо просто нахуй пошлет
каво
потому что это не имеет смысла
да потому что они на разные слоты нацелены еб твою мать
есть несколько слотов рендертаргетов
COLORn на них и ссылается
а я о чем
сука ну ты тугой что ли
ты пойми разницу между SetRenderTarget и SetRenderTargetEx
ой бля
щас
секунду
struct PSOutput {
float4 out0 : COLOR0;
float4 out1 : COLOR1;
};
PSOutput main()
{
PSOutput o;
o.out0 = float4(1, 0, 0, 1);
o.out1 = float4(0, 1, 0, 1);
return o;
}
-- rt0 и rt1 создаешь сам
render.SetRenderTarget(rt0)
render.Clear(0, 0, 0, 0)
render.SetRenderTarget(rt1)
render.Clear(0, 0, 0, 0)
render.SetMaterial(matShader) -- тот, который я написал сверху (мб придется подредачить для гмода)
render.SetRenderTargetEx(0, rt0)
render.SetRenderTargetEx(1, rt1)
render.DrawScreenQuad()
render.SetRenderTargetEx(0)
render.SetRenderTargetEx(1)
-- не обязательно сразу, если невозможно, но лучше как можно скорее отрисовать на экран
render.SetMaterial(rt0mat)
render.DrawScreenQuadEx(0, 0, ScrW() / 2, ScrH() / 2)
render.SetMaterial(rt2mat)
render.DrawScreenQuadEx(0, ScrH() / 2, ScrW() / 2, ScrH() / 2)
если один рт красный, а другой зеленый - все работает, как должно
ты ебанутый один и тот же материал использовать?
rt0mat (и 1) должен быть как во втором примере здесь
Creates or gets the rendertarget with the given name.
See GetRenderTargetEx for an advanced version of this function with more options.
This crashes when used on a cubemap texture. Issue Tracker: 2885Rendertargets are not garbage-collected, which means they will remain in memory until you disconnect. So make sure to avoid creating new ones unece...
ты другой материал для рисования на экран использовать должен
да пиздец, всё за тебя сделай
local rt0mat = CreateMaterial("mat_rt0", "UnlitGeneric", {
['$basetexture'] = rt0:GetName(),
["$translucent"] = "1"
})
local rt1mat = CreateMaterial("mat_rt1", "UnlitGeneric", {
['$basetexture'] = rt1:GetName(),
["$translucent"] = "1"
})
ну походу оно в гмоде сломано, хули
других вариантов особо не вижу
хз
так это не шейдер у которого вообще глубина должна быть. говорили же что будет генерал шейдер со всеми приколами
Moon runes
Figures the week I get off of shaders, we got some inspiration lmaoo
sorry the language barrier was way too strong
How do I set the language of the chat to English
Uninstall the monitor I think that fixes it.
Wauterboi and I go way back. Lol out of context
Блять я же писал
Берешь, рисуешь сначала всю сцену с материалом на котором WriteZ шейдер стоит
он тебе просто глубину сцены запишет
потом снова рисуешь ту же самую сцену, но со своим шейдером
И все
Я писал об этом много раз, да даже фикул об этом писал так же
render.Set*Override(writeZMaterial)
render.RenderView()
render.Set*Override(customShaderMaterial)
render.RenderView()```
Потом если тебе прям захочется несколько буфферов сделать, берешь копируешь её через copyRenderTargetToTexture, а потом клираешь (render.Clear(0, 0, 0, 0, false, false)) эту самую ртшку, (но не буффер глубины) и рисуешь заново, ибо глубина осталась. И заного рисуешь своим кастом шейдером
Насчёт render.SetRenderTargetEx() пиши ишью рубату или фикулу.
слушай ты по моему слишком токсичный
тебе помогают, а ты простым инструкциям следовать не можешь, и еще пиздишь в ответ
обьясни мне, какой человек в здравом уме будет писать вот это?
один и тот же материал использовать, т.е. ШЕЙДЕР
рисуя хуету для дебага на экран
ты явно не знаешь, что делаешь
идиот, я тебе дал способ проверить, ошибка в самой функции, или где то внутри
@calm root hey, uhh, this guy right here is being insanely toxic and egoistic for no reason, if not for now, i would want this to be on the record for future encounters with him
it seems he thinks that someone is compelled to commit to help him fully, not just provide a way to do what he wants, but also to do everything up to writing actual code for him
this and the fact that he does not seem to know what he is doing, as is evident from him failing to draw two rendertargets to screen, using his shader to do so instead (and not even linking the rendertarget to the material, bruh), makes me doubt that it is worth dealing with him
i dont want to bear with your toxicity, so i will not even respond
Так блять сложно посмотреть википедию, тупой ты еблан?
Ты долбоеба кусок сам это же используешь когда проход глубины делаешь
Я как понял iq у тебя отрицательное, так шо пошел нахуй, хуесос
Хуй тебе, а не помощь
Я прост скажу так - этот дебил щас кичится тем, что пиздит шейдеры с shadertoy, в гмод перетаскивает только через чужую помощь, и потом пиздит что это его
Его нынешний шейдер ssao это полная калька с туториала 2013 года
Ты взял шейдер с тоя, петух)
Ah, yesss, shader drama.
That's new.
the guy is hypertoxic, and this behavior just keeps people away from this channel, thus impacting shader development badly in general
i really dont think this should go unseen by the mod(s?) tbh
Please ban this ungrateful Akabenko guy pleaseeeeee
He answers toxic stuff in response to our help, really...
@calm root
yeah, that is too far, removed them. You guys can have a dedicated channel once there are enough people who have a clue on how it works and we don't ego over the knowledge
i cannot support people in that channel as i have no bloody clue on how this works yet
I'm assuming there's no generic guide yet on how to get started with shader shenanigans for this sort of stuff yet?
I've seen people occasionally link pre-existing things but uh.
what happened
https://wiki.facepunch.com/gmod/Shaders/screenspace_general
check out the see also section for guides on shador authoring(the valve wiki one) and how to setup the tooling (ficool2 post)
This shader is a wrapper for providing custom pixel and vertex shaders, while it is named screenspace_general there is nothing inherently screenspace only about this shader, it is merely the name that was chosen before it received extra functionality that allowed it to do more than just screenspace work, as such this is a general shader that can...
the wiki page itself documents the shader
what did he say in english
damn...
Roughly, your dad is raped in prison, the insults were hard to translate
damn
lol i bet he cant say that in person without a black eye
nerd coder toughs act in internet
They left and returned
is he already banned or
yeah
i mean hes talented in coding and anyone can appreciate that but why have to insult
I prefer to use terminology like removed instead of banned, but yeah
don't know about talented, going off of what artem was saying about him
might have just been bashing together random code snippets
iirc he did say the volumetric clouds code was just kinda copied from mee's video
i mean the fact he can put it all together
but yeah maybe giving him too much credit isk
I didn't know that page had been made, time to make weapon skin shaders 
Oh no, mesh skinning. This will be kind of tough to do without a reference from the source engine.
the current documentation and examples we have are good for just actual screenspace stuff
but we need some docs on vertex shaders and stuff
and sm3 shaders
since it's possible
Guess I should start smaller with a few basic screenwarps and effects, I have no idea how it works in practice yet
the basics are actually not that complex, i've never dabbled with C in my life but i got the basic gist of HLSL when i toyed around with some of the example shaders we have
also seems like you'd only be able to modify existing vertices, which has limited use case. who knows, maybe someone can tesselate displacements to make them wiggle like you're on acid or something.
well i mean yeah vertex shaders use existing vertices provided by the module
generating geometry would be compute shader territory i think, and that's dx11+
model*
Use RNDX, they have some vs30 example stuff
works fine in something like minecraft where everything is a vertex. not so much in source where most of the world is a flat plane
basically, it's pretty the same except you have 2 additional registers, and availability to use VS_OUTPUT
a really simple way to explain pixel shaders is running math on single pixels in parelell without the ability to store/retrieve data or communicate between those pixels
just pixel value in, pixel value out
I'm currently just trying to figure out the bare minimum stuff I'm gonna need to get started, apparently the fcool2 thing has whatever's needed to create shaders? Or am I gonna need the SCell555 compiler?
you have metadata like position and stuff tho
ficool stuff if youre running it on desktop
VS_OUTPUT is your PS_INPUT stuff, you have vertex shader that gives data to pixel shader.
The pixel shader data is interpolated between several vertices data from vertex shader
Might want to put whatever that extension was in a zip
I mean I use a laptop so I'll do that.
that's the thing
it was a zip
Peacekeeper stops zips I guess, maybe there was some issue on the rust discord
wanted to send the sources for my shaders from my shader adon https://steamcommunity.com/sharedfiles/filedetails/?id=3440271589
the worst part is that he is actually just a paster, he is no talented
Well, not
My friend helped him a lot + a lot of other people, he usually just uses their efforts to help him
He often uses reshade's shaders, shadertoy ones, and the ones that had been implemented by someone arleady
His famous fxaa, ssao were taken from reshade and some source engine ssao tutorial back from 2013
Also, his cd disk shader was also taken from shadertoy + he took mee's volumetric clouds and then made it through workshop, while calling that as 'his' shader
the ssao is pretty bad, it doesn't even work properly with transparency
and it's abnormally (imo) heavy
The problem is with bad depth buffer, since it's DepthWrite hack by Ethan
The best option would be involving rubat to actually fix it
Since default depth buffer lacks prescision + has issues with skybox, etc
ah, because the material override is overriding transparency on the non opaque models right
Yeah, there are no way to actually know if the material is transparent
got it
i think rubat can just make the depth buffer a R32F image format and fix it, so it will have transparent stuff working + better prescision
hmm, wouldn't it be possible to render a custom depth buffer by just drawing the world again with fog?
I mean, hacks are mostly temporary
Well, that way is good, i think Ethan tried to do that
before he got depthwrite shader stuff
Mesh skinning on shader side is impossible right now, as ficool2 suggested
But you can use software skinning on models, via adding #softwareskin 1
Yes, I know that.
Until rubat will add ficool2's CustomShader
Ficool2 managed to make gpu skinning working in his shader
That will be cool, but it is already really good that we have the ability to load custom shaders from addons now.
yeah even if we don't get all that, what we got now is still pretty big for gmod
Even with the crutches that we have to use now.
When you get a basic "Hello, World!" shader working, let me know
I don't think shaders have a "Hello, World!" equivalent.
well the simplest thing would be to just turn the whole screen a certain color i suppose
just output a float4 of like
255,0,0,255
Really basic shader that shades single triangle using some interpolated color values from vertices using vertex colors.
Also, some times called as hello-triangle or something like that.
I'll have to wait and think on it.
The shader wars are over
Should I create a blank addon file sorta thing for testing this or do shenanigans in garrysmod/shaders/fxc?
Now comes a time of peace and prosperity 🙏
There seems to be a lot of different resources online for a hello-triangle typa thing.
It is. This is most basic thing that can be done in computer graphics.
Just like hello world in the programming.
anyone tell me how to drugs shader? idk if it looks like a trip
Is there any particular resource you'd recommend? a lot of these pages are absolutely gigantic, and it sometimes shows results for GLSL too.
I would personally advise you to try using Raylib with any of the Lua bindings.
There are tons of examples for C, but porting them to Lua is as easy as Ctrl+C and Ctrl+V, with only minor adjustments.
Just try writing something - maybe experiment with shaders. There isn’t a significant difference between GLSL and HLSL.
Also, you can read this. https://thebookofshaders.com
Let me rephrase: You’re going through a learning experience that I need to go through. When you understand the basics of shader creation, I’m hoping you can tell them to me (or tell me where you found them) so I can understand the basic elements of the process and begin to document them on the wiki
I clicked on your profile and saw a very strange link.
It is a very weird looking link.
hah
ficool2's thing's apparently supposed to generate vmts? I don't see anything though.
i would rather stick to trustworthy verified safe links
like https://crouton.net/
it does, but if it doesn't work for you, don't fret, it basically copies the template vmt and changes $pixshader to the shader name and the name of the vmt file
Presumably, as long as I haven't messed anything up, I can simply put these files into an addon and go ingame?
yeah, all you need is a shader that compiled successfully and a material that uses the shader
and then of course some lua if you wanna handle drawing the shader on the screen and spawnmenu entries and stuff like that
or r_overlay or something along those lines?
yea that should work too
Gonna try it now, I made one that, presumably, will swap red and blue around.
Huzzah! (I think)
yeah looks like it did exactly what you intended it to do
IIRC unless one uses that weird workaround, there's no real way to change the shader on the fly (and thus I'd need to restart the game)?
(I don't fully know what the workaround is but I do know it involves changing the name of the shader and then reloading materials)
check the see also section of the wiki for gm_shaderbuild
does gm_shaderbuild only function when using the vscode tools?
not sure, @misty surge would know though
anyone know how to code mushroom trip in shaders?
First you must do “research” 

dont got access to them rn🤣
has somebody made any attempt at making shaders for models yet? I haven't kept up with this too much yet
i feel like $writedepth and $depthtest do absolutely nothing
i mean it does something, but not the way it should be
to work on models, there are several things missing
oh, that's unfortunate 😭
they are broken
its an easy fix on the c++ side but i think its better to make a general purpose shader rather than hijacking screenspace_general
Oh my goodness gracious, custom shader incoming?
does he know
It’s a powershell script, it very well can operate anywhere but vscode throws it into one package that’s amazingly easy.
Linux I think I’d have to tailor the concept but I don’t use Linux unless it’s backend related.
If only I knew how to trigger it when it saves, in vscode, that would be ultimately what I’d want.
Has anyone else faced this weird sort of stuff before? I'm trying to make a basic sobel shader
The realistic term is artifacting, it looks like your UVs might be messed up. If you have code I could take a look.
Strange, I'm just using i.uv.xy (I assume that's what to use, anyway?)
yeah it's a UV issue
are you converting a shadertoy/GLSL shader
i.uv returns normalized coordinates (between 0-1)
not the actual resolution
No, it's an old egsm shader I rewrote a little bit.
So does this mean there's something I have to do to i.uv? the above image is when I'm just using i.uv.
remap it to the resolution instead of 0-1 based on what they said?
Originally I thought I had to divide it by the resolution, but it appears that was not the case, lol.
Please either DM the code, both vertex and fragment shader, I’ll tell you right away.
I respect your right to keep it to yourself but, maybe I can help.
actually, that's my plan, but i don't have much knowledge on C++ side of shaders
i want to make some shaders so that Rubat can just add them to the game
I was telling @turbid crystal That AI is now shader capable. I would suggest anyone who’s not using it to start.
The solution the ai in question gave me didn't get any closer to solving the issue, though it did sorta point out a flaw in something I did, but even fixing that didn't fix the issue.
Of course, you’re totally right. We have to realize that it’s a powerful tool for checking your code.
It’s very pragmatic to ask it the right questions, though, that’s very important
I generally don't like using ai for anything more than information, but I wouldn't use it to code directly unless I genuinely couldn't figure something out and have no other choice.
That being said, I'm not sure if its my code or if gmod is just being iffy at this point, it seems to be half-working, its just that the stuff is stretching across the screen.
How can I access the depth information that WriteZ provides on a custom screenspace_general shader? And should I use that same shader in the same pass where render.*MaterialOverride functions for the WriteZ material are used?
Screenspace does not have “depth” so depth functions are useless.
FrameBuffer has depth, but that’s about it. The actual shader itself doesn’t have it.
Oh well, I really only need to store depth as color, in a way that works with a orthographic view
I just didnt understand how to use the WriteZ shader that was suggested by papasoco to do that
wait I think I might have figured out how to write my own DepthWrite shader
it looks like it's going to need separate logic for a perspective and ortho view but it seems to work
almost there, it can even handle custom far plane values now
it does render the world geometry but some brushes and all entities do not show up
ig theres more to it when it comes to rendering props with a custom shader
When you do renderview, you may need to also include the PVS, so the game renders the same bsp data. That part seems to be the issue.
If I turn off the material overrides with the custom depth shader, entities render just fine
its when I use my custom shader on those entities that makes them go away
its basically just a issue of "I dunno how to make screenspace_general work on props"
In order for this shader to run with this setup, is if you reconstruct 2D to 3D. Screenspace doesn’t have 3D (no depth) so you have to “reconstruct” to get the perspective pos.
Without depth, it’s very difficult to calculate it. Unless you chose a simple object like a sphere, block, etc…
The object should just have normal shaders, capture 2nd process. Unfortunately that’s the way we have to go.
You can rely on the depth buffer to offer you the 3D position which is localized but practically helpful for some complex shading.
Another thing I wanna add is, using the shaders with alpha channels instead of depth makes the most sense to me, and then just blend it with the frame buffer.
The WriteZ shader basically does writing to depth
You use it just like a mask
Basically, you can do the same stuff with no material override stuff, with using render override colorwrite
https://gmodwiki.com/render.SetBlend
Check 2nd example, it uses the same method to write depth data
This is news to me, tbh, awesome stuff! 👏🏻
cuz its dont
how do I change the frame of one of the textures? there isn't a VMT parameter is there? and I don't imagine tex2D has a parameter for that, like the Z coordinate
materials with SpriteCard shader use a $frame var that you can change before rendering the material
if I'm doing this strictly in a map and foregoing a Lua environment that narrows my options
you may be able to do something with a matproxy :?
like AnimatedTexture?
yes
that's the normal approach, but it requires a variable to change like $frame
yep, you can just pass that no?
normally you'd use $frame or $bumpframe if you were changing a $bumpmap but I'm not changing that
I'm not changing my $basetexture, I'm changing my $texture2
I could give it a shot, idk if it really matters
wait what
"$basetexture" "_rt_FullFrameFB"
// "$texture1" "effects/3tpeyefx_"
"$texture1" "tools/toolsblack"
"$texture2" "effects/security_noise2"
"$texture3" ""
need to animate $texture1* not $texture2 mb
yeah [as far as I can tell] AnimatedTexture uses AnimatedTextureVar to look at the texture and see how many frames it has, then it increments the AnimatedTextureFrameNumVar you supply (e.g., $frame, $bumpframe) between 0 and the max number of frames it found on AnimatedTextureVar
so if someone can answer whether there's a way for me to set the frame in the shader itself, I could use that to my advantage by setting one of the screenspace_general constants with AnimatedTexture and then doing the minimal side of the animation logic myself in the shader
Frames or $frame controls the frame. We cannot however change from frame to frame in the shader itself, only on the CPU level with parameters.
If you wanna go 3D, you can put tex3D as long as it’s 3.0 shader.
This requires your textures to be 256x256x256, same resolution
If I’m not mistaken, if we could just use tex3D with 3 layers or so, that would be epic, but I haven’t honestly tried/checked if we can differ the resolution this way.
even for $texture1, $texture2 and so forth? not just $basetexture?
I would assume, frame only acts as a direct reference to base… frame is a tool source used to interpolate frames with slices for animations.
Usually you can reference a new texture per frame, and it would work but that is a massive request to be made.
$frame is used to resolve optimizing issues by referencing it statically vs dynamically.
So only basetexture I would assume.
When the new shader comes out, I assume we could go up to 8 samplers. Rn we’re stuck with 4
I say assume a lot, cuz I’m like either not sure or w.e. I don’t wanna steer people in the wrong direction ofc
I was going to say the best case scenario is to make a texture sheet if you’re looking for some more textures I suppose.
New shader?
Ideally, like other games, utilizing the proper 3D geometry into custom shaders. This is something I believe ficool, myself and everyone else are expecting when we talk about “shader stuff”
At the moment, even with limited screenspace, shaders 2D->3D can just be 3D->3D
Since this discovery is relatively new, we’re all catching up to potentially one of the coolest features in gmod in my opinion in a very long time.
I really want to make textures for mappers but everything nowadays uses a PBR workflow
I know PBR is a meme but I'm hoping to see someone put together PBR and Parallax
Right now I'm working on procedural cracks for various materials
Parallax can be done, but it needs a two pass setup. To account for missing depth in screenspace. It has to be converted to 3D, which reduces precision.
Attempts 1 through 3
At the moment, our depth in the frame buffer is relatively 192 units away from the screen, and then depth goes away.
That looks cool!
I have been looking at nothing but cracked tiles for one week
Whatcha working on as a concept? Maybe I can help.
I'm laying down at the moment, but this was my last attempt focusing entirely on the normal and AO. I wasn't satisfied with the cracks
Yeah, that’s very difficult not going to lie, I’d say just rely for now without parallax, until we’re able to write custom 3D shaders, ideally.
I hate using two passes for something that should be quick and painless
Yeah that's all normal and ao
If you’re not concerned with depth, (planes) you can easily do this. Maybe simple geometry like blocks you could calculate the depth using math alone.
Parallax works, just needs depth ;-;
The moment it does, I got parallax shaders ready to go. Lol on GitHub
Would love to see some form of PBR too. The shader that was used in the past wasn’t all that great imo

what do I need to do to get my screenspace_general shader overlay to also render the player's viewmodel? it was working when I was using shader model 2.0b but now that I'm on 3.0 everything works great other than that. _rt_FullFrameFB doesn't include it I guess(?)
though that doesn't explain why it worked on shader model 2.0b
my only guess is it has something to do with my new VMT, which I still need to investigate. only problem is most of the parameters in the old one are a mystery to me
I'm not using Lua in this environment (env_screenoverlay), so hook order isn't a suitable answer.
you need to add $fix_fb and a proxy so it updates the framebuffer
see the examples in the shader sdk
thanks
I know exactly what you're talking about now, just didn't know what it did
isn't that just the ignorez flag?
oh it's a spritecard flag, interesting
I think small things like cracks in tiles might not necessarily need parallax shaders or anything like that. This is specifically trying to do cracks in bathroom tiles
why is it reversed?
Dx9 vs OpenGL :/
Would it be possible to make something comparable to L4D Infected gore/injuries with shaders? Or will I have to lobby for the Infected shader?
Doesn't have to be as extreme, sort of just want to emulate gashes and wounds better
gmod can just add the Infected shader
jokes aside, i don't think that shader can just be added, i think it can be catalogued as a stencil operation along a subset of meshes overlapped, valve really got his hand dirty
actually, they can
No and i have proofs it's impossible to just add those
Can you post those here, or are they already elsewhere
unsure of exactly what the conversation here is ATM but ill just post these random related links:
https://github.com/Facepunch/garrysmod-requests/issues/2230#issuecomment-2711742851
https://www.youtube.com/watch?v=5_G79LJ_l2Y
a capture of some of the technical content behind left 4 dead 2's wounding system.
Details I know that this is a big request but, would it be possible to add in basic support for the Infected Shader that is exclusive for the L4D2 common infected? Support for: General Parameters P...
I was still looking for this video, thank you
damn
We have the tools to begin the process of making our own. I won’t say it’ll look the same because shaders work a lot better than work arounds, but you can add more detail.
does he mean making our own l4d2 gore shaders or just shaders in general
I imply that we can make our own shaders (but lacks 3D construction, depth instead of stencils from screenspace) and lua to make gore appear more realistic. I’ve seen some pretty good ones out there. Until we get proper 3D shaders, 2D reconstruction to 3D is our only option currently.
I see, thank you for explaining
No problem. Any questions you can always ask me here.
Why aren't 3D shaders already available? It would make sense to also have that when releasing shader support for addons
This shader discovery was made around December of last year (new).
We’re in the infancy of shaders in gmod. Rubot and everyone is only just learning about what it can do/not do. Ficool found this out, but the entire concept of shaders is a very verbose and complex system that normally requires a lot of engineering hours, prior to recently.
With AI, now it becomes easier, but ideally no one uncovered the rock but ficool.
Rubot I’m sure knows about this, and has every intention to include it, but he’s tied up.
Once we do, shader 3.0 will properly be supported.
I garentee you, we all want this, everyone. Just not in that phase yet. It’s probably being fast tracked
I really hope and understand the more we understand about this, the quicker the demand will be.
For now, I agree with ficool and stick with this for now 🙂
Will shader 3.0 let us do more than just 3d stuff
lol, what else? 4D? xD
7D...
what do you mean? people have already done this before, just with shaders files and game_shaders_dx9.dll, even i did it, looked at PBR in the game
or wait, what is it about? i think i missed the dialogue and are you talking about something specific?
I am a 5D entity and I feel like gmod doesn't represent those 2 extra dimensions well enough
I hope shaders can fix that
As i have said, it's impossible to port l4d2 shaders into gmod, you haven't read the doc
its not impossible
I feel like there's a lot of missing context. because I don't even know if y'all are talking about the L4D2 infected shader or the L4D2 gore system, Also I don't know if this is about screenspace_general or GMod in it's entirety
That's what I say, gore is not a shader, 4way tinted shader is indeed a shader
i'm sorry, i overlooked it
Do we have the GitHub request for the 3.0 shader implementation? I’d like to upvote it. I’m trying to find it.
If we don’t, maybe we can start talking about it?
I don’t see one. So I guess we should make a request. Since people keep asking, maybe I can ask them to upvote said request. It’s possible, just kind of a large ask.
don't we already have it?
That’s my question, if we have one can you share it?
3.0 already exists
I get that, I mean support for 3.0 such as actual 3D depth supported, not just screenspace itself.
I’m not sure how to ask what I’m asking yet, but ideally allow us to cast meshes with depth pass and custom shaders.
So we can do parallax mapping without resorting to reconstruction.
This for example is what I mean. Our shaders don’t get called in the depth pass. So this is what we’re basically limited to.
@misty surge Hi, i remember you were asking for $c4 and $c5 support, yeah?
So, jaffies (aka mikhail_svetov guy) came up with an idea to get up to more 48 additional constant values
without using textures, and so on.
Basically, he said that you can use $viewprojmat + $invviewproj keyvalues to override the default one matrices in your pixel/vertex shaders
local matrix = Matrix({
{1, 2, 3, 4},
{5, 6, 7, 8},
{9, 10, 11, 12}
{13, 14, 15, 16}
})
material:SetMatrix('$viewprojmat', matrix)
matrial:SetMatrix('$viewprojmat', matrix2)
By that way you can get additional 2 4x4 matrices you can freely use on screen space shaders (which is 32 customizable floats)
there is also the model matrix
Yes, and it can be set with lua via cam.PushModelMatrix
const float4x4 cViewProj : register(c8);
This is for a model matrix
enum
{
// Standard vertex shader constants
VERTEX_SHADER_MATH_CONSTANTS0 = 0,
VERTEX_SHADER_MATH_CONSTANTS1 = 1,
VERTEX_SHADER_CAMERA_POS = 2,
VERTEX_SHADER_FLEXSCALE = 3, // DX9 only
VERTEX_SHADER_LIGHT_INDEX = 3, // DX8 only
VERTEX_SHADER_MODELVIEWPROJ = 4,
VERTEX_SHADER_VIEWPROJ = 8,
VERTEX_SHADER_MODELVIEWPROJ_THIRD_ROW = 12,
VERTEX_SHADER_VIEWPROJ_THIRD_ROW = 13,
VERTEX_SHADER_SHADER_SPECIFIC_CONST_10 = 14,
VERTEX_SHADER_SHADER_SPECIFIC_CONST_11 = 15,
VERTEX_SHADER_FOG_PARAMS = 16,
VERTEX_SHADER_VIEWMODEL = 17,
VERTEX_SHADER_AMBIENT_LIGHT = 21,
VERTEX_SHADER_LIGHTS = 27,
VERTEX_SHADER_LIGHT0_POSITION = 29,
VERTEX_SHADER_MODULATION_COLOR = 47,
VERTEX_SHADER_SHADER_SPECIFIC_CONST_0 = 48,
VERTEX_SHADER_SHADER_SPECIFIC_CONST_1 = 49,
VERTEX_SHADER_SHADER_SPECIFIC_CONST_2 = 50,
VERTEX_SHADER_SHADER_SPECIFIC_CONST_3 = 51,
VERTEX_SHADER_SHADER_SPECIFIC_CONST_4 = 52,
VERTEX_SHADER_SHADER_SPECIFIC_CONST_5 = 53,
VERTEX_SHADER_SHADER_SPECIFIC_CONST_6 = 54,
VERTEX_SHADER_SHADER_SPECIFIC_CONST_7 = 55,
VERTEX_SHADER_SHADER_SPECIFIC_CONST_8 = 56,
VERTEX_SHADER_SHADER_SPECIFIC_CONST_9 = 57,
VERTEX_SHADER_MODEL = 58,
//
// We reserve up through 216 for the 53 bones supported on DX9
//
VERTEX_SHADER_SHADER_SPECIFIC_CONST_13 = 217,
VERTEX_SHADER_SHADER_SPECIFIC_CONST_14 = 218,
VERTEX_SHADER_SHADER_SPECIFIC_CONST_15 = 219,
VERTEX_SHADER_SHADER_SPECIFIC_CONST_16 = 220,
VERTEX_SHADER_SHADER_SPECIFIC_CONST_17 = 221,
VERTEX_SHADER_SHADER_SPECIFIC_CONST_18 = 222,
VERTEX_SHADER_SHADER_SPECIFIC_CONST_19 = 223,
VERTEX_SHADER_SHADER_SPECIFIC_CONST_12 = 224,
// 226 ClipPlane0 |------ OpenGL will jam clip planes into these two
// 227 ClipPlane1 |
VERTEX_SHADER_FLEX_WEIGHTS = 1024,
VERTEX_SHADER_MAX_FLEX_WEIGHT_COUNT = 512,
};```
And this is for viewproj and invviewproj
const float4x4 g_viewProjMatrix : register( c11 );
const float4x4 g_invViewMatrix : register( c15 );
the whole cbuffer is not controllable as a whole, but there are things you control
That’s awesome, I was just told this not too long ago. That’s pretty epic not going to lie.
Although this does let you modify the view matrix, I guess my request extends this by including a depth pass so the meshes drawn are properly using depth as a concept, during runtime.
Well, just for the fun fact: Artemking told that to akabenko yesterday
As well as with the depth thingy obviously
Hmm, this could work. I gotta try it out.
Well, that stuff works, akabenko tried to proove them wrong but eventually it worked in practice
I guess that would work for calculating the depth of the vertices but not the pixel shader right? I’d wanna know if it did
Well, for the part of it:
Although you can alter the depth value via pixel shader
but...l.
Depth func is set to always ($ignorez basically)
Yikes
That's on c++ side though, rubat can fix that
Exactly so do you think we can make a request for something like this. This is what I wanted, but I appreciate shaders rather than nothing so…
like i mentioned its better to make a new general-purpose shader
It woulda be awesome if you could alter that SHADER_DEPTHFUNC_* with a separate material parameter
hijacking a screenspace shader is ugly, and the interfacing issues can be refactored rather than having backwards compatibility
If we had an official request, so that we can upvote it. I 100% agree.
like $c constants should be vector4s not individual floats
mat:SetInt('$depthfunc', DEPTHFUNC_LESSOREQUAL)
i wanted to just email the code
i already made such a general purpose shader
only thing that remains is flashlight support and making examples
Got it. So that’s the missing piece?
yes
I think having more control of a render pass that's used for depth capturing woulda solve that issue from lua side, with some hack i think
another consideration is exposing lua to control the rendering state
so you call pShaderDynamic and pShaderShadow methods
however this is potentially dangerous (and also a lot more work) so i think limiting it via vmt parameter control is the best option
Well, other stuff evolving from that is to restore material:SetShader api
Lol, probably never going to happen. I wish we had that but it’s very crashy
So this general purpose shader, this would also require some C++ correct? Or is it all inline with the tools we have rn?
c++
Gotcha, makes total sense.
i would like to note that a pretty cool shader ide exists, and it supports hlsl
SHADERed is the most powerful shader IDE/editor. It is open-source, cross-platform & has features such as the shader debugger, compute shaders, plugin API, etc...
Which HLSL shader type is most like what's available in Garry's Mod?
vs20b, vs30, ps20b, ps30
Shader compiler is FXC one
do note that this does not support FXC and old shader models, it compiles shaders to spir-v and uses them like that (it also has a debugger tho because of that)
drawpoly > shaders :^)

Psst... Sneaky.. Why not use the mesh library directly for even better results than surface.DrawPoly?
because in most use cases it's worse
wait
psst, why not shaders for even better better results
the only time it's better is when nothing is being changed but if you're using Circles! chances are the circle is being changed every frame
I'm literally incapable of reading non-shader conversation in #1324464901401477191
make vertex shader that does that stuff on gpu woulia
idk how gmod shaders work because nobody will explain it to me and there's no documentation
read rndx loser
no
there was documentation but god took it from us
all I know is where shaders should be but I've got no clue how to actually use them in-game
I'm also in this position, but admittedly I haven't tried very hard to solve it myself. When I understand how to get a shader working, I intend to document it for the wiki
Use RNDX/sdk_screenspace_shader to get that
@errant nacelle I'm pretty sure the answer is:
- Clone https://github.com/ficool2/sdk_screenspace_shaders/
- Use shadersrc/example_wave_ps2x.hlsl as a "Hello World" shader
- Drag
example_wave_ps2x.hlslontobuild_single_shader.bat - There is now a compiled shader in
<cloned location>/shaders/and a corresponding VMT in<cloned location>/materials/effects/shaders/named after the.hlslfile that was compiled - Make an addon with a
addons/<addon name>/shaders/folder containing the compiled shader and aaddons/<addon name>/materials/effects/shaders/folder containing the VMT - See it in-game via
r_screenoverlay effects/shaders/<shader name without an extension or "_ps2x">
I'm in the middle of debugging something so I can't test it right now, but if you have time to try it yourself and report back, that would be appreciated
The problem is that those shaders worked with old screenspace_generic shader, not with updated one
Therefore they need to be edited to use vertex's color as TEXCOORD1 (not 5) or use custom vertex shader.
Also, x360appchoser is not working right now. Use $vertexcolor and $vertextransform
lemme make a github repo based on rndx to help u guys make a wiki based on it if u want
do u want me to include the python generating trick im doing?
What's the trick?
basically i use python to compile shaders inside lua file with a gma, to easily use them
That sounds like something that would be cool to have as a separate thing, but not as a "Baby's first shader" example
so i dont have to manually drag and drop or manually addcsslua
i can make it really simple, i think it will be more user friendly to just handle it all
Sure
I have unintentionally written a VCS disassembler, just wanted to know how the default vertex shader of screenspace_general works 🫠 https://github.com/ZenkakuHiragana/vcs-decompiler
How much is this would be different than the original heh
https://github.com/sr2echa/CSGO-Source-Code/blob/master/cstrike15_src/materialsystem/stdshaders/screenspaceeffect_vs20.fxc
I'll share the results soon. it seems there's no difference I guess, though.
@graceful lynx https://github.com/Srlion/basic-gmod-shader
i think that is as simple as i can get, once u learn some decent stuff, u can do a pr and improve it/make it more simple
unfortunately, it cant be that user friendly that u expecting because shaders aint easy at all at first
Thanks for putting this together!
I got this 👉 Disassembly of screenspaceeffect_vs20
Looks nice
thx
Is there any clue that we can use normal as the vertex shader input? I seefloat4 normal : NORMAL; in Srlion's common_vs.hlsl but I couldn't find it in the CS:GO shader codes (and in my disassembly).
I'm unable to compile the example shader
Compiling shaders...
Compiling 'boom_ps20b.hlsl' with version '20b'
File "boom_ps20b.hlsl" does not exist
File "boom_ps20b.hlsl" does not exist
Failed to parse boom_ps20b.hlsl
File "src" does not exist
Writing to compiled\main.lua
Processing complete.
what is ur pwd
Create a new file in src/ eg. src/boom_psxx.hlsl.
_psxx
u select the version in compile_shader_list.txt
Compiling shaders...
Compiling 'boom_psxx.hlsl' with version '20b'
File "boom_psxx.hlsl" does not exist
File "boom_psxx.hlsl" does not exist
Failed to parse boom_psxx.hlsl
File "src" does not exist
Writing to compiled\main.lua
Processing complete.
are u manually running build_shaders.bat
or using python
cuz u gotta use python build.py
oh thats python
oops
lemme git clone and test
it works on my end
moved them outside util directory
it should work fine now with u
idk why didnt work
why does it say file "src" does not exist wtf
thats even more weird
Something to do with being on the D:\ drive, or having spaces/special characters in the folder path I assume
im literally running it in D:\
has to be some character fukin it up yeah
-shaderpath is not smart
line 50 in build_shaders.bat
Once it's compiled, the instructions just say to move the main.lua file and don't make mention of the .vcs files it produced
Should I be moving those somewhere?
no, python already compiles them into main.lua
u just need to include serverside and clientside
eg.
include("main.lua")
no need to Addcsluafile
Autorun should work fine, then?
yeah
What's the expected output?
for the drawing?
Looks like a black square, right?
draw_my_shader(100, 100, 200, 200, 0, 0, 0, 1)
0, 0, 0, 1 being opaque black
Opaque is the opposite of transparent
Great
u can use it to replace default surface.DrawRect to draw with true colors

the material created, i set it to disable gamma correction
What's up with these UVs?
-0.015625, -0.015625, 1.015625, 1.015625
shapes draw weirdly
kinda like drawing an image without noclamp
u can remove it till u hit the issue i had
Looks normal to me?
no, i meant, size wasnt correct as far as i recall
i cant remember the exact issue, but u can remove till u find that whatever ur drawing looks weird
Thanks for putting this together! When I have more time soon I'll "dissect" it to fully understand how it works
it will be tough at first, but later it will be easy
just find some simple project to learn it
pls update the repo once u learn to make it easier for newbies
ok great
Pass them as TEXCOORD
Thank you, I finally can see this
Without experience in shaders, it would not have been possible to make these clouds. And yes. I restored the Mee volumetric cloud shader. I indicated this in the description of the addon. And also modified it.
This conflict is much deeper. This group of people has been trying to provoke me for a long time. I am hot-tempered, so I fell for it. However, I am glad that the conflict is over. I will not get a black eye.
After this conflict, a group of people started to hate my works. All this is done intentionally.
However, because of my minority, I have to have a sharper tongue than my opponents. But I promise that I won’t behave so aggressively again.
no one was trying to provoke you, especially for a "long time". And i have not even talked to you (well, almost at all) before your "explosion" back then. I would also not think the papasoco guy tried to harass you before that point, so, please, stop trying to make up an excuse for your behavior.
Wanna be here and learn/do shader stuff? Nobody is stopping you, but do not act like you are entitled. Dont stray away people from this relatively new channel, or you risk damaging the whole branch of shader development in gmod, at least, for now.
Point is -- do not be toxic here.
I'm not going to quarrel with you

just calm down
and have fun with shaders
has anyone figured out how to recompile/restructure the PBR shaders to mount them with screenspace_general yet?
I tried to transfer the parallax mapping shader to the screenspace_general. The algorithm itself works fine. BUT:
- Brushes do not have normals if the material is not applied to them via LUA.
- The solution to the problem with the wrong rendering order is still unclear.
In general, things will be the same with PBR. (for brushes, I haven't tested it for models)
Here parallax + shadows
We can do basic PBR.
I had this idea to basically use framebuffer’s depth up to 192 units, then I’d take the depth RT code I posted here to account for the rest of the scene.
The drawback for this, is there isn’t to my knowledge to account for textures with alpha. So they appear as they would if I had covered everything with a flat material.
Reconstruct the data with the proper Viewmatrix and you have quite a simple PBR.
Surface normals can be calculated via depth call using 3 pixels .
Multiply by the inverse view matrix and bam. Easy one, but in my opinion I’d rather wait for standalone shaders with casted depth.
surface normals [like this?](#1324464901401477191 message)
Not quite, unfortunately if we do vertex normals in the vertex, that’s how it should work 100% agree, but if you notice in his photo depth is broken. So honestly it’s a step forward, but we’re stuck with surface normals being slightly inaccurate. It’s tough because it will appear good on flat meshes, it’s when the mesh starts to create complex depth surface normals via clip space to world space may have precision issues. All this to account for the depth pass.
The only way I know of to get surface normals is to transpose and reconstruct it via depth buffer, which probably is what we’re limited to (for now)
eek... at least we have render.GetResolvedFullFrameDepth() (which hardly helps outside Lua contexts)
Yup! I have another solution for the maximum precision for depth (16bits) if you’d like I can show you.
sure, though I can't guarantee my maximum attention
(for the next 30 minutes)
So’k im working so im lerking on my phone
oh there's a shader specifically for writing the depth buffer?
that certainly simplifies things. just use a different image format right?
you can't really get the true benefits from a RGBA16161616f depth buffer that way though
or does it just write it properly automatically? I actually have no idea
You get the true benefits by upping the memory per pixel. The shader will use larger differences which in turn makes your depth higher quality
wouldn't you use the alpha component as an exponent?
You can’t do 32bit because it will ruin the stencil buffer
ah
16 bit is great tho
On very big maps, it can be extremely costly so 8 bits works out too sometimes
trying to find a special depth screenshot I took in helldivers
This uses two depth passes to create depth beyond the 192 using the same idea I posted. This is from @snow cradle but this is the concept going forward as the true depth check.
As you may notice DepthWrite doesn’t account for alpha. So you’ll see what I mean here
strange, I could have sworn my depth buffer screenshots had alpha channels
but they don't
It does! But it’s generated via the pipeline. So in theory framebuffer uses depth that’s been “finished”. We use this to change up the shader. But our screenspace mats do not have proper depth casting
Without depth pass, it’s like only reconstruction basically as the only option. Which would return to us what the GPU does already in its main pass. Therefore making the GPU run twice to do the same effect.
I meant my EXR files
It would work, but layer that with other complex systems, the frames will definitely be worse off
Depth only uses 1 pixel per check afaik.
Not RGB, rather just R
and not alpha as transparency, just a fourth channel to store extra exponent data to squeeze in extra information. like how Valve uses the alpha channel to "compress" their HDR sky textures
to get 32-bit precision in their 16-bit BGRA8888 format
Ahhh! If you’d like to know more I highly recommend you lookup +mat_materialist or w.e. And highlight rendertargets you can see the formats they use.
I forgot the convar but it’s very useful
idk but we can get normals on brushes only using LUA 


normals:
is it possible to use a vertex shader to actually move the vertices of a model
Ye
is there a particular way I'm meant to do it?
render.OverrideBlend(true, BLEND_ZERO, BLEND_ONE, BLENDFUNC_ADD)
render.Override*(depthWriteShaderOrWriteZOrAnyOtherShaders)
render.RenderView()
render.OverrideBlend(false)
render.Override*(customScreenspaceGeneralShader)
render.RenderView()```
Don't forget to set $writez to 0 on screenspace_general one
I could partially fix the broken depth of render.RenderView. It seems helpful to use render.OverrideDepthEnable(true, true) before drawing.
Returning depth value in the pixel shader seems also helpful.
does anyone have any working examples of this?
Just modify the position before multiplying the MVP matrix and that's all
VS_OUTPUT main( const VS_INPUT v ) {
output.projPos = mul( float4( v.pos.xyz + v.normal.xyz * 10, 1.0 ), cModelViewProj );
// ...
}
but I couldn't use material parameters in the vertex shader 🫠
$VERTEXNORMAL 1 add Normal info to brush shader (idk about models)
interesting. I tried this and it wouldn't work for me. what does your VMT look like, by the way? my models also look super messed up whenever I use screenspace_general with them
oh wait you couldn't use material parameters. that would be my problem then
I was multiplying by a constant from the VMT
still, though, what does your VMT look like to not make the model look absolutely messed up to hell and not have screwed depth?
@wispy birch gave a hint that fixing the render order might fixed using SV_Depth from the pixel shader.
I use depth like that:
//vertex shader
float4 vProjPos = mul( float4( worldPos, 1 ), cViewProj );
vProjPos.z = dot( float4( worldPos, 1 ), cViewProjZ );
o.Depth = vProjPos.z;
//pixel shader
struct PS_OUT {
float depth : SV_Depth;
float4 color : SV_Target0;
};
PS_OUT main(PS_IN i )
{
PS_OUT Out = (PS_OUT)0;
//code
Out.color = c;
Out.depth = i.Depth; //There should be a formula to correctly output the depth.
return Out;
};
But some formula is needed to calculate this depth so that it works correctly. Artem suggested that we can try using znear/zfar.
Also it works with params:
//vmt
$WRITEDEPTH 0
$DEPTHTEST 1
@upbeat kernel also suggested using flags2 to apply lightmaps to places in the world where brushes with a screenspace_general shader.
It is possible that this flag also affects the correction of the brush rendering order.
Also, thanks to it, I was able to overlay lightmaps on brushes as through post-processing:
//pixel shader
float2 screen_uv = i.pPos/(1/Tex3Size);
float3 lm = tex2D(LightMap, screen_uv);
I haven't figured it all out yet, but a combination of $flags2 and SV_depth solves the depth problem.
@upbeat kernel's params:
//vmt
$test_flags2 7 //6 or 7
Proxies
{
Equals
{
srcVar1 $test_flags2
resultVar $flags2
}
}
my vmt for parallax brushes
i use $test_flags2 39 (32+7) (MATERIAL_VAR2_NEEDS_TANGENT_SPACES+MATERIAL_VAR2_LIGHTING_MASK)
because i wanted to get tangents but it didn't work. u can use 6 or 7
UPDATE:
--mat proxy
local view = render.GetViewSetup( true )
local znear = view.znear
local zfar = view.zfar
mat:SetFloat("$c2_w", znear)
mat:SetFloat("$c3_w", zfar)
//pixel shader
float znear = Constants2.w;
float zfar = Constants3.w;
float final_depth = (1/i.Depth- 1/znear)/(1/zfar - 1/znear);
Out.depth = final_depth;
||https://community.khronos.org/t/when-and-how-does-opengl-calculate-f-depth-depth-value/106086/32||
bug with particles:
bug #2
so it need other formula
that's a cool hud
arc9
The fog color blinks when shooting. So you can input the fog color through lua.
//fog
local fogstart, fogend = render.GetFogDistances()
fogstart = 1/(fogstart+10)
fogend = 1/fogend
mat:SetFloat("$c0_w", fogend)
mat:SetFloat("$c1_w", fogstart)
local r_fog, g_fog, b_fog = render.GetFogColor()
local mFog = Matrix({
{r_fog/255, 0, 0, 0},
{g_fog/255, 0, 0, 0},
{b_fog/255, 0, 0, 0},
{1/1, 0, 0, 0},
})
mat:SetMatrix('$VIEWPROJMAT', mFog)
//pixel shader
const float4x4 g_viewProjMatrix : register( c11 );
//code
int PIXELFOGTYPE = PIXEL_FOG_TYPE_RANGE;
float fogstart = Constants1.w;
float g_WaterZ2 = 0; //PIXEL_FOG_TYPE_HEIGHT
float fogdesity = g_viewProjMatrix[0].w;
float fogend = Constants0.w;
float4 g_FogParams2 = float4(fogstart, g_WaterZ2, fogdesity, fogend);
float3 fogColor = g_viewProjMatrix[0].rgb;
fogColor = GammaToLinear(fogColor);
float fogFactor = CalcPixelFogFactor( PIXELFOGTYPE, g_FogParams2, EyePosition.z, wp, i.Depth );
color.rgb = BlendPixelFog( color.rgb, fogFactor, fogColor.rgb, PIXELFOGTYPE );
VMT parameters are like this, I forgot which ones were necessary, though.
$vertexcolor "1"
$vertexnormal "0"
$vertextransform "1"
$model "1"
$softwareskin "1"
$translucent "1"
$depthtest "1"
// $writedepth "1"
$writealpha "1"
$cull "1"
$ignorez 0
$copyalpha 0
$alpha_blend_color_overlay 0
$alpha_blend 1
Setting $flags2 to 7 completely fixes the render order issue 🎉
@upbeat kernel thanks!
what steps exactly have you taken to achieve this?
effects/shaders/myshader_1.vmt
screenspace_general
{
$pixshader "2_myshader_1_ps30"
$vertexshader "2_myshader_1_vs30"
$basetexture "metal6"
$cull "1"
$fix_fb "39"
$softwareskin "1"
Proxies
{
// Fixes the material flags
Equals
{
srcVar1 $fix_fb
resultVar $flags2
}
}
}
vertex shader
const float4x4 cModelViewProj : register(c4);
struct VS_INPUT {
float4 pos : POSITION0;
float4 normal : NORMAL0;
float2 uv : TEXCOORD0;
};
struct VS_OUTPUT {
float4 projPos : POSITION;
float2 uv : TEXCOORD0;
float4 depth : TEXCOORD1;
float4 normal : TEXCOORD2;
};
VS_OUTPUT main( const VS_INPUT v ) {
VS_OUTPUT output;
output.projPos.xyzw = mul( float4( v.pos.xyz, 1.0f ), cModelViewProj );
output.uv = v.uv.xy;
output.depth = output.projPos;
output.normal = v.normal;
return output;
}
pixel shader
sampler Tex0 : register( s0 ); // $basetexture
struct PS_INPUT {
float2 pos : VPOS;
float2 uv : TEXCOORD0;
float4 depth : TEXCOORD1;
float4 normal : TEXCOORD2;
};
struct PS_OUTPUT {
float4 color : COLOR0;
float depth : DEPTH0;
};
PS_OUTPUT main( const PS_INPUT i ) {
PS_OUTPUT output;
output.color.xyz = lerp(i.normal.xyz, tex2D(Tex0, i.uv).xyz, 0.25);
output.color.w = 1.0;
output.depth = i.depth.z / i.depth.w;
return output;
}
Lua
local mat = Material "effects/shaders/myshader_1"
hook.Add("HUDPaint", "test", function()
render.WorldMaterialOverride(mat)
render.MaterialOverride(mat)
render.OverrideDepthEnable(true, true)
render.RenderView { drawviewmodel = true }
render.OverrideDepthEnable(false, false)
render.WorldMaterialOverride()
render.MaterialOverride()
end)
also, it was not "completely" fixed actually as it seems the render order is still broken sometimes, but it's getting better I guess.
@graceful lynx i found the issue that made me use that weird uv in surface_DrawTexturedRectUV
notice the weird line
Interesting. I wonder why that is
clamping
i didnt know i can just do this to fix this issue lol
sampler2D TexBase : register(s0) = sampler_state
{
Filter = MIN_MAG_LINEAR_MIP_POINT,
AddressU = MIRROR,
AddressV = MIRROR
};
lemme test if it actually works or not
rip doesnt work
thats only in sm4+
🤬
try this?
#1324464901401477191 message
Tried, but no luck
Cloud update: Added smooth fading of cloud horizon. Parameter is adjustable.
I also managed to compile the shader in a quality cycle on [unroll(57)].
The parameter is also now adjustable. (You can set low settings on weak PCs)
Does anyone know if there's any way to fetch the lightmap supplied by render.SetLightmapTexture()in the shader?
Maybe if you looked into all the RenderTargets being created using +mat_material list you should be able to directly request the rendertarget
yeah. it's probably (virtually certainly) not possible right now to do dynamically (I've been reading source code for 2 days but reserve the right to miss things in the rat's nest that is the Source engine source code), but if you know specifically what brushes you're doing it on you could export your lightmap page(s) for those specific brushes to VTF files (LDR and/or HDR), however if there are multiple pages you'll need a new VMT for each page
using the $flags2 trick @snow cradle mentioned it's definitely possible to pass through the UV texcoord for the correct position on said lightmap page that correlates to each brush, but getting the texture itself won't be so easy.
if you can get the LDR and HDR lightmap pages themselves in their respective VTF image formats, you can use conditional VMT statements to load either one depending on the mode the client is using:
"ldr?$texture1" "lightmap_ldr"
"hdr?$texture1" "lightmap_hdr"
honestly if no one's filed a request for this on garrysmod-requests yet then someone probably should; Rubat is surprisingly responsive to these
but I would take care in considering exactly how to phrase the request, or perhaps how it should be implemented—for ease of implementation. it would probably make more sense (or be easier/quicker) for him to implement this as a Lua-rendertarget feature than a feature of screenspace_general
The implementation is arleady done by ficool2.
what exactly
About the lightmap stuff
👀
so is there no code examples of this?
those shaders, I mean. the vast majority of them rely on data everyone else here seems to be scrambling to find a way to access
which is why I'm somewhat confused
the issue is that lightmaps are possible only if you intrude the c++ side

that's what this whole conversation began as
The best option is literally to just wait, until ficool2's implementation of that shader will be done
well, you can though make it via adding a second mesh with modulate/etc stuff to emulate lightmaps
I do appreciate you making me aware of that—I wasn't aware he was working on more improvements to it
He's working on it rn, he's struggling with flashlight/projected textures working with custom shader rn
that I can understand
SSAO, SMAA, Clouds, Parallax
mb SSAO must be rendered in PostDrawTranslucentRenderables hook
It seems we can get specific lightmap pages according to this comment https://github.com/Facepunch/garrysmod-requests/issues/1665#issuecomment-1000996066
"$basetexture" "\[lightmap0]"
Interesting. I wonder why the escaped backslash is crucial
I guess it's because material system thinks brackets as a vector value
DDOF from stalker
so, no way to get CurrentTime in a vertex shader right now... right?
constants are broken?
u can send CurTime using proxy to pixel shader. btw. I've never seen curtime in a vertex shader.
Proxies
{
CurrentTime
{
resultVar $c0_x
}
}
yes that's what I'm talking about, someone earlier said it didn't work for them and I don't think it works for me either
🤔🤔🤔
Unless if I'm doing something wrong, I noticed that all the $c*/const float4 Constants* variables don't update on the vertex shader. Anyone else had that happen?
I confirmed that it was only happening on the vertex shader after successfully using the same constants (with no changes on the Lua code) on the pixel shader
are you replying to what we were just talking about? or is that a coincidence
pretty sure it doesn't work for vertex shaders
Its kinda both lol
I think they're all zeroed out
actually they could just be frozen like you said
in the situation I was testing it wouldn't be any different
Welp, rip my plans
Oh and, by "don't update" I guess I just meant that they stay all zeroed
were you planning to make stuff jiggle around?
I needed to pass a 4x4 matrix, doing some shadowmap stuff
I see
was going to recommend a stupid but functional solution like passing data via other means such as changing the render color of the object
I think c* constants are not transferred to the vertex shader because SetVertexShaderConstant is not called but SetPixelShaderConstant is
https://github.com/SourceSDK2013Ports/csgo-src/blob/909c38385b5903d5b7ad9b15761068f33dbe27d7/src/materialsystem/stdshaders/screenspace_general.cpp#L344
pShaderAPI->SetPixelShaderConstant( 0, c0, ARRAYSIZE(c0)/4 );
// pShaderAPI->SetVertexShaderConstant( 0, c0, ARRAYSIZE(c0)/4 ); // Probably this should be here as well
Kinda of a bummer, it was the only thing left to do to get it working
wonder if this is one of the improvements @jovial tide is making to the shader code
@rain marten Have you tried working with MRT in gmod?
Shadows need several render targets. And it is better to output them through MRT. Without it, we will lose a lot of fps.
Maybe after I get a single shadowmap working first (although it sounds like that would require changes on the C++ side)
Although its not my first time messing with shaders, and I managed to do a basic game engine with opengl, that was almost 6 years ago so, I'm still rediscovering shaders, especially when it comes to how directx handles things
Honestly same boat, except vulkan API wrappers and what not.
Does the cubemap binding (in hammer) to brush faces work if the brush has a screen space general shader?
If we could that would be cool, I don’t know if that’s the case but if it was that would be awesome.
ok i will try test it
oh hey is there a parallax map shader now
?
I would be a little surprised if it didn't, especially if you manually "pick" those brush faces with the env_cubemap. it just creates new VMTs and inserts the cubemap name where "env_cubemap" currently is written in the brush material's VMT
Sorry I didnt put that message in a reply I meant the screenshots from Evgeny
lol I thought maybe that was what you were talking about
just wanted to be sure
yeah
anyone know if there's a conditional VMT parameter or something [any other means by which I could] make screenspace_general show up in the Hammer editor (or even Hammer++ specifically)? for a model
literally anything is fine, just to get it to render and not be completely invisible and require me to use wireframe view
Maybe change the texture name for development, when ur ready to publish switch it back to the correct name. I don’t think hammer utilities shaders the same way the game does. Best to replace it with a null texture or a similar demo texture, and when you are done with editing that section, switch it back.
I use this approach for models that require internal edits, the big meshes usually block my view, so I set them to like other textures and then put them back when I’m done with editing
Modeling requires everything to be like a handful of meshes, so it’s difficult to combine all the stuff and push rigging, so I sort of work around the idea.
yeah I could probably use postcompiler to pack a different material under the same name at compile time or something
so with the vertex shader problem—it not receiving the VMT constants
I believe I've arrived at a solution for some situations, but it's very limited
extremely limited
(it's still not completely done, so give me a minute)
does anyone know why I might not be able to get both depth input and vertex color? is there a limit to the number of texcoords
hmm microsoft's documentation says there isn't the limit is 8 for SM3.0 pixel shaders, but it's also hard for me to read
no matter what I do I can't get vertex color to work with vertex normal and vertex transform
texcoord limit is 8. it woks for me
this is for a model btw
Maybe I’m mistaken, isn’t this relative to your GPU? Each GPU got limits so I think it depends on that. I could be wrong.
$ignorez 0
$writedepth 1
$writealpha 1
$depthtest 1
$cull 1
$vertexcolor 1
$vertextransform 1
$vertexnormal 1
$softwareskin 1
// $flags2 set to 39 through proxy means
through Microsoft's documentation I linked [here](#1324464901401477191 message) it looks like it's tied to the version of Shader Model that's in use, which is suppose is also limited by which GPU is in use
Ahh, in Vulkan, we got hardware limits that’s probably why I’d assume as such. Dx9 limits it by shader version. Gotcha
my condolences
Moving from vulkan to Dx9 is not hard, just very different.
I'm starting to realize that vertex color isn't the color set on an entity
I knew it wasn't, vertex color is actually in the mesh itself, but for some reason I was thinking the entity's color would be accessible through vertex color
It should, if I’m not mistaken, color and normals may potentially use the same memory so, they aren’t usable for both at the same time unless you declare the mesh in lua.
I remember having issues attributing both, in EGSM, the pipeline the meshes are being drawn, I think they “decompile” the normals, and send them inside the shader.
But if you use two at the same time, one takes over
Right, so if you had an extra texture buff, you could just do I.uv and maybe setup a serial system to attribute pixel to color or normal.
hmm
Maybe not as robust but it would work
so with the color, it's not actually color
when I said [this](#1324464901401477191 message) last night
I needed to pipe CurTime() into the vertex shader, but you can't use $c0_x or any of those
so I got to thinking, color255 has four 8-bit components, which add up to 32 bits, and a float is 32 bits
local band, lshift, rshift = bit.band, bit.lshift, bit.rshift
-- Converts a Lua number (assumed to be representable in 32-bit IEEE 754 format)
-- into a 32-bit unsigned integer
local function floatToBits(f)
if f == 0 then return 0 end
-- Determine the sign bit (0 for positive, 1 for negative)
local sign = 0
if f < 0 then
sign = 1
f = -f
end
-- Decompose f into mantissa and exponent so that f = mantissa * 2^exponent,
-- with mantissa in [0.5, 1)
local mantissa, exponent = math.frexp(f)
-- Adjust so we have a normalized fraction:
-- In IEEE 754, f = (1 + fraction) * 2^(exponent-1)
exponent = exponent - 1
-- Remove the implicit leading 1 and scale mantissa to [0,1)
mantissa = mantissa * 2 - 1
-- Calculate exponent bits (with bias 127)
local exp_bits = exponent + 127
-- NOTE: This approach does not handle all edge cases like subnormals precisely
-- Compute 23-bit fraction from the mantissa
local mantissa_bits = math.floor(mantissa * 8388608 --[[(2^23)]] + .5)
-- Combine sign, exponent, and mantissa into a 32-bit value
-- Bit layout: [sign:1 | exp:8 | mantissa:23]
local bits = bit.bor(
lshift(sign, 31),
lshift(exp_bits, 23),
mantissa_bits
)
return bits
end
-- Extract the four 8-bit channels (R, G, B, A) from a 32-bit number
local function bitsToRGBA(bits)
local r = band(bits, 0xFF)
local g = band(rshift(bits, 8), 0xFF)
local b = band(rshift(bits, 16), 0xFF)
local a = band(rshift(bits, 24), 0xFF)
return r, g, b, a
end
-- Combines the two functions to pack a float into four 8-bit channels
local function packFloatToRGBA(f)
local bits = floatToBits(f)
return bitsToRGBA(bits)
end
and then I combined it into this monstrosity for lua_run:
local a,b,c=bit.band,bit.lshift,bit.rshift;local function d(e)if e==0 then return 0 end;local f=0;if e<0 then f=1;e=-e end;local g,h=math.frexp(e)h=h-1;g=g*2-1;local i=h+127;local j=math.floor(g*8388608+.5)local k=bit.bor(b(f,31),b(i,23),j)return k end;local function l(k)local m=a(k,0xFF)local n=a(c(k,8),0xFF)local o=a(c(k,16),0xFF)local p=a(c(k,24),0xFF)return m,n,o,p end;local function q(e)local k=d(e)return l(k)end;local r=[[water]]local s=.05;local t=ents.FindByName(r)local u=[[Tick]]local v=[[piqey.Water.Advance]]local w=Color(0,0,0)hook.Add(u,v,function()if#t<1 then hook.Remove(u,v)return end;w:SetUnpacked(q(s*CurTime()))for x,y in ipairs(t)do y:SetColor(w)end;print([[Set channels:]],w,w:ToVector():Dot(Vector(1/0x1000000,1/0x10000,1/0x100)))end)```
If it were me, and I wanted an optimized solution I’d go with generating the texture for color via a simple texture.
For vertex Curtime situation, you can maybe pass the data using the matrix data we got. That should be passed in the vertex shader (idk)
so I'll probably write it to a render target that is a single pixel
and do the same solution
This would work for color, but not CurTime. I think you can just use the inverse view matrix
Test and see, if it does, fantastic
the only problem I foresee is that Shader Model 3.0 doesn't support bit shifting and asfloat (those features were added in 4.0 I think), so I have to use a 4D dot for an approximation, and I don't actually know exactly how bad the offset is
Hmm, that could work, but yeah dot might have issues, if your input for the check isn’t standardized for all the verticies
wait I could also just use RGBA16161616f for the image format and write the float directly LOL
no wait
that's 16
Honestly, you should just stick with the format with R16 maybe so it’s 1:1
?
I've already written the code to split it up into four 8-bit parts, so I'm going to at least try it with BGRA8888 first
Copy
I just need to write a crappy mantle to mount it on client with lua_run first, but I already have one written for something else so I need to transpose it
Like the depth target, one channel verses 4 is more optimized but yeah
You guys are provoking me to go back to shaders lol. I am nearly done modeling my space ship, with rigging. Next is to texture it. Then maybe revisit it.
Sure, I’ll DM it because I want people to be surprised
I will show you my spaceship
I will say this, rigging is probably the hardest when you gotta go inside the mesh to do it. Crazy stuff, takes days to rig it up because of how many layers it has lol
One mesh for an entire ship is crazy, but source freaks out if it’s not stacked into one big mesh
idk why but i have black texture using env_cubemap is screen space general.
if i write cubemaps like that, it works $texture2 "maps\cubemaptest_d\c0_0_32"
and this: $texture2 "env_cubemap"
u also use this: $flags2 55 (proxy - 7 + 16 + 32) MATERIAL_VAR2_LIGHTING_MASK + MATERIAL_VAR2_NEEDS_TANGENT_SPACES + MATERIAL_VAR2_USES_ENV_CUBEMAP
mb env_cubemap use defaultcubemap? this is black by default
Maybe I’m wrong but, if it’s not showing up, I always thought that env_cubemap was actually the other env cubemaps but they were not selected during runtime, the closest env cube. It itself is not a texture or anything, rather it selects the closest cubemap.
@snow cradle I don't know exactly how it works for VertexLitGeneric, but I think when you use "env_cubemap" in a VMT it actually just inserts the closest one at runtime. with LightmappedGeneric, however, VBSP actually generates and packs into the BSP a new VMT file variant for each VMT in use that contains "env_cubemap" with the new cubemap texture string inserted in place of that old string. that's why renaming a BSP post-compile breaks cubemaps—all the brush materials reference the cubemap textures by name, which has the original BSP filename in plaintext
I don't know if that changes anything in this situation, I'm sort of dropping in late here.
@upbeat kernel @misty surge
we can use proxy and have fancy $tex and float names for our shaders:
my vmt:
screenspace_general
{
$pixshader "parallax_mapping003_ps30"
$vertexshader "parallax_mapping31_vs30"
$baseTexture "murmansk/tiles/CeramicTiles02_a"
$bumpmap "murmansk/tiles/CeramicTiles02_ns"
$envmap "maps\cubemaptest_d\c0_0_32"//"env_cubemap"
$parallaxmapscale "0.01"
$parallaxcenter "0"
$surfaceprop "tile"
$test_flags2 39
$DEPTHTEST 1
$translucent 1
$softwareskin 1
$VertexColor 1
$VERTEXNORMAL 1
Proxies
{
Equals {
srcVar1 $test_flags2
resultVar $flags2
}
ParallaxSetup {
resultVar $c0_y
}
}
}
proxy:
result: bumps and cubemap (manual) works
i think we can write technical params to proxy. This is how you can make life easier for the user.
Hide everything unnecessary for future users
is this also Parallax Corrected Cubemaps because that looks like an example map from a youtube video
now this is just cubemaps
default
okay
Would it be hard to get parallax cubemap fixed?
Omggg you need to publish it !! 
crazyyy
💎 good work will you publish it soon
@misty surge @upbeat kernel idk why: render.GetResolvedFullFrameDepth() cant get depth from brushes (2 screen - white floor) with screenspace_general. but custom depth buffer works fine (1 screen)
maybe if need some flags or params like //$multipass 1 or //$opaquetexture 1 etc?
I just wanna use DDOF shader on default depth buffer for saving FPS,
not sure if this makes a difference but have you tried adding 32768 to $flags2? might just be for the frame buffer and not the depth buffer but idk
ok i will try it
Yes, I will publish it along with materials, test maps and settings output. I need to make sure everything works and work on stability and preserving default settings.
I will also write a guide on how to use it and all the pitfalls: manual creation of duplicates of materials for work parallax cubemap - a guide for mappers.
you are very good 👍
so... same
i also use DOFModeHack.
This thing seems to solve some problems as intended. But it didn't help either.
hook.Add("NeedsDepthPass", shaderName, function()
DOFModeHack( true )
return true
end)
looks like its the same situation for $VIEWPROJMAT/$INVVIEWPROJMAT
as in, it seems like we can't use those to pass custom matrices to the vertex shader
i wanna also make _rt worldpos + depth in .a. but it have bugs with render order... hmmm......
I was wondering if this was the case
I'm pretty sure literally nothing works for vertex shaders. even textures
soooo yea\
fixed
worldpos finaly
@nocturne patio
code looks like that
vmt:
shader:
no grass when u use IMAGE_FORMAT_RGBA16161616F
RT_WPNDepth = GetRenderTargetEx(rt_name, ScrW(), ScrH(),
-1,
0,
bit.bor(16, 256, 512, 65536, 32768),
0,
IMAGE_FORMAT_RGBA16161616F
)
so a little
off topic but what is the playermodel/c_hands?
Hands and weapons are late. Probably need to change the render hook.
pm OK
how to disable grass
decals
sprites
idk
mb i need
other hook
idk
a ok
i just mul znear zfar
then worldpos render order > grass, decals render order
no effects
on rt
but tranclusent props disappear when they idle
skybox support
excuse my ignorance but what's the point of doing that colors ? I'm really curious of what it is
These are world coordinates. Something like a UV map for textures (it can be used like this even in its current form for some things). Roughly speaking, textures are laid out according to these colors. Or other effects are drawn. I laid the snow texture this way, making it in screen space.
Many post processing shaders need these rt. And also the depth buffer and world normals.
🤔🤔🤔pistol broken
i don't undestand why screenspace shader breaks when drawing it on screen from lua but not when using r_screenoverlay. i looked at evgeny's lua and source sdk, it is nearly identical but it still results in the broken quad, what am i doing wrong?
here's my render code btw
local screentexture = render.GetScreenEffectTexture()
material:SetTexture( "$basetexture", render.GetScreenEffectTexture() )
local function DrawAgX()
render.UpdateScreenEffectTexture()
render.CopyRenderTargetToTexture(screentexture)
render.SetMaterial( material )
render.DrawScreenQuad()
end
hook.Add( "RenderScreenspaceEffects", "RenderAgX", function()
if ( !pp_agx:GetBool() ) then return end
if ( !GAMEMODE:PostProcessPermitted( "agx" ) ) then return end
DrawAgX()
end )
what about params?
try $fix_fb 32768??
Proxies
{
Equals
{
srcVar1 $fix_fb
resultVar $flags2
}
}
this: $basetexture "_rt_FullFrameFB"
or
render.GetScreenEffectTexture(1)
render.UpdateScreenEffectTexture(1)
cam.Start2D()
surface.SetMaterial(shaderMaterial)
surface.SetDrawColor(255, 255, 255, 255)
surface.DrawTexturedRectUV( -1, -1, 2, 2, 0, 1, 1, 0 )
cam.End2D()
Do that in RenderScreenspaceEffects, no need to do material:SetTexture( "$basetexture", render.GetScreenEffectTexture() ) or anything either.
Just make sure your shader vmt has this as the basetex as stated above:
$basetexture "_rt_FullFrameFB"
💀💀💀💀💀💀💀
It seems correct but it didn't fix the render order issue on my end. Could you try drawing vertex normal as the color, instead of vertex coordinates?
How to disable optimization when transparent prop stops being calculated in render? It seems like there should be a console command.
omg that worked, tysm
but why does render.DrawScreenQuad() work for everyone but me?
I tried myself for a while but I still can't get it to work. Could you provide the vertex shader and parameters for the RenderTarget?
How are you using it?
screenbuffer is slightly blured if using this method sadly
Model matrices work
$staticprop .qc cause it
r_PhysPropStaticLighting 0 fix it
--Workaround:
RunConsoleCommand("r_PhysPropStaticLighting", "0")
32 bit render target ( @misty surge's tip):
local rt_name = "_rt_WPNDepth"
RT_WPNDepth = GetRenderTargetEx(rt_name, ScrW(), ScrH(),
RT_SIZE_NO_CHANGE,
MATERIAL_RT_DEPTH_SHARED,
bit.bor(2, 16, 256, 512, 65536, 32768), -- u can use your flags
0,
29 --32 bit rt IMAGE_FORMAT_RGBA32323232F
)
mb u can write like that
IMAGE_FORMAT_RGBA32323232F = 29
local rt_name = "_rt_WPNDepth"
RT_WPNDepth = GetRenderTargetEx(rt_name, ScrW(), ScrH(),
RT_SIZE_NO_CHANGE,
MATERIAL_RT_DEPTH_SHARED,
bit.bor(2, 16, 256, 512, 65536, 32768), -- u can use your flags
0,
IMAGE_FORMAT_RGBA32323232F
)
what is going on
What's balling my dudes
@exotic willow's info about IMAGE_FORMAT
Here's the modified array with sequential numbering starting from -1:
static ImageFormatInfo_t g_ImageFormatInfo[] =
{
/* -1 */ { "UNKNOWN", 0, 0, 0, 0, 0, 0, 0, false, false, false }, // IMAGE_FORMAT_UNKNOWN,
/* 0 */ { "RGBA8888", 4, 8, 8, 8, 8, 0, 0, false, false, false }, // IMAGE_FORMAT_RGBA8888,
/* 1 */ { "ABGR8888", 4, 8, 8, 8, 8, 0, 0, false, false, false }, // IMAGE_FORMAT_ABGR8888,
/* 2 */ { "RGB888", 3, 8, 8, 8, 0, 0, 0, false, false, false }, // IMAGE_FORMAT_RGB888,
/* 3 */ { "BGR888", 3, 8, 8, 8, 0, 0, 0, false, false, false }, // IMAGE_FORMAT_BGR888,
/* 4 */ { "RGB565", 2, 5, 6, 5, 0, 0, 0, false, false, false }, // IMAGE_FORMAT_RGB565,
/* 5 */ { "I8", 1, 0, 0, 0, 0, 0, 0, false, false, false }, // IMAGE_FORMAT_I8,
/* 6 */ { "IA88", 2, 0, 0, 0, 8, 0, 0, false, false, false }, // IMAGE_FORMAT_IA88
/* 7 */ { "P8", 1, 0, 0, 0, 0, 0, 0, false, false, false }, // IMAGE_FORMAT_P8
/* 8 */ { "A8", 1, 0, 0, 0, 8, 0, 0, false, false, false }, // IMAGE_FORMAT_A8
/* 9 */ { "RGB888_BLUESCREEN", 3, 8, 8, 8, 0, 0, 0, false, false, false }, // IMAGE_FORMAT_RGB888_BLUESCREEN
/* 10 */ { "BGR888_BLUESCREEN", 3, 8, 8, 8, 0, 0, 0, false, false, false }, // IMAGE_FORMAT_BGR888_BLUESCREEN
/* 11 */ { "ARGB8888", 4, 8, 8, 8, 8, 0, 0, false, false, false }, // IMAGE_FORMAT_ARGB8888
/* 12 */ { "BGRA8888", 4, 8, 8, 8, 8, 0, 0, false, false, false }, // IMAGE_FORMAT_BGRA8888
/* 13 */ { "DXT1", 0, 0, 0, 0, 0, 0, 0, true, false, false }, // IMAGE_FORMAT_DXT1
/* 14 */ { "DXT3", 0, 0, 0, 0, 8, 0, 0, true, false, false }, // IMAGE_FORMAT_DXT3
/* 15 */ { "DXT5", 0, 0, 0, 0, 8, 0, 0, true, false, false }, // IMAGE_FORMAT_DXT5
/* 16 */ { "BGRX8888", 4, 8, 8, 8, 0, 0, 0, false, false, false }, // IMAGE_FORMAT_BGRX8888
/* 17 */ { "BGR565", 2, 5, 6, 5, 0, 0, 0, false, false, false }, // IMAGE_FORMAT_BGR565
/* 18 */ { "BGRX5551", 2, 5, 5, 5, 0, 0, 0, false, false, false }, // IMAGE_FORMAT_BGRX5551
/* 19 */ { "BGRA4444", 2, 4, 4, 4, 4, 0, 0, false, false, false }, // IMAGE_FORMAT_BGRA4444
/* 20 */ { "DXT1_ONEBITALPHA", 0, 0, 0, 0, 0, 0, 0, true, false, false }, // IMAGE_FORMAT_DXT1_ONEBITALPHA
/* 21 */ { "BGRA5551", 2, 5, 5, 5, 1, 0, 0, false, false, false }, // IMAGE_FORMAT_BGRA5551
/* 22 */ { "UV88", 2, 8, 8, 0, 0, 0, 0, false, false, false }, // IMAGE_FORMAT_UV88
/* 23 */ { "UVWQ8888", 4, 8, 8, 8, 8, 0, 0, false, false, false }, // IMAGE_FORMAT_UVWQ8888
/* 24 */ { "RGBA16161616F", 8, 16, 16, 16, 16, 0, 0, false, true, false }, // IMAGE_FORMAT_RGBA16161616F
/* 25 */ { "RGBA16161616", 8, 16, 16, 16, 16, 0, 0, false, false, false }, // IMAGE_FORMAT_RGBA16161616
/* 26 */ { "UVLX8888", 4, 8, 8, 8, 8, 0, 0, false, false, false }, // IMAGE_FORMAT_UVLX8888
/* 27 */ { "R32F", 4, 32, 0, 0, 0, 0, 0, false, true, false }, // IMAGE_FORMAT_R32F
/* 28 */ { "RGB323232F", 12, 32, 32, 32, 0, 0, 0, false, true, false }, // IMAGE_FORMAT_RGB323232F
/* 29 */ { "RGBA32323232F", 16, 32, 32, 32, 32, 0, 0, false, true, false }, // IMAGE_FORMAT_RGBA32323232F
/* 30 */ { "RG1616F", 4, 16, 16, 0, 0, 0, 0, false, true, false }, // IMAGE_FORMAT_RG1616F
/* 31 */ { "RG3232F", 8, 32, 32, 0, 0, 0, 0, false, true, false }, // IMAGE_FORMAT_RG3232F
/* 32 */ { "RGBX8888", 4, 8, 8, 8, 0, 0, 0, false, false, false }, // IMAGE_FORMAT_RGBX8888
/* 33 */ { "NV_NULL", 4, 8, 8, 8, 8, 0, 0, false, false, false }, // IMAGE_FORMAT_NV_NULL
// Vendor-dependent compressed formats typically used for normal map compression
/* 34 */ { "ATI1N", 0, 0, 0, 0, 0, 0, 0, true, false, false }, // IMAGE_FORMAT_ATI1N
/* 35 */ { "ATI2N", 0, 0, 0, 0, 0, 0, 0, true, false, false }, // IMAGE_FORMAT_ATI2N
/* 36 */ { "RGBA1010102", 4, 10, 10, 10, 2, 0, 0, false, false, false }, // IMAGE_FORMAT_RGBA1010102
/* 37 */ { "BGRA1010102", 4, 10, 10, 10, 2, 0, 0, false, false, false }, // IMAGE_FORMAT_BGRA1010102
/* 38 */ { "R16F", 2, 16, 0, 0, 0, 0, 0, false, false, false }, // IMAGE_FORMAT_R16F
// Vendor-dependent depth formats used for shadow depth mapping
/* 39 */ { "D16", 2, 0, 0, 0, 0, 16, 0, false, false, true }, // IMAGE_FORMAT_D16
/* 40 */ { "D15S1", 2, 0, 0, 0, 0, 15, 1, false, false, true }, // IMAGE_FORMAT_D15S1
/* 41 */ { "D32", 4, 0, 0, 0, 0, 32, 0, false, false, true }, // IMAGE_FORMAT_D32
/* 42 */ { "D24S8", 4, 0, 0, 0, 0, 24, 8, false, false, true }, // IMAGE_FORMAT_D24S8
/* 43 */ { "LINEAR_D24S8", 4, 0, 0, 0, 0, 24, 8, false, false, true }, // IMAGE_FORMAT_LINEAR_D24S8
/* 44 */ { "D24X8", 4, 0, 0, 0, 0, 24, 0, false, false, true }, // IMAGE_FORMAT_D24X8
/* 45 */ { "D24X4S4", 4, 0, 0, 0, 0, 24, 4, false, false, true }, // IMAGE_FORMAT_D24X4S4
/* 46 */ { "D24FS8", 4, 0, 0, 0, 0, 24, 8, false, false, true }, // IMAGE_FORMAT_D24FS8
/* 47 */ { "D16_SHADOW", 2, 0, 0, 0, 0, 16, 0, false, false, true }, // IMAGE_FORMAT_D16_SHADOW
/* 48 */ { "D24X8_SHADOW", 4, 0, 0, 0, 0, 24, 0, false, false, true }, // IMAGE_FORMAT_D24X8_SHADOW
/* 49 */ { "LINEAR_BGRX8888", 4, 8, 8, 8, 8, 0, 0, false, false, false }, // IMAGE_FORMAT_LINEAR_BGRX8888
/* 50 */ { "LINEAR_RGBA8888", 4, 8, 8, 8, 8, 0, 0, false, false, false }, // IMAGE_FORMAT_LINEAR_RGBA8888
/* 51 */ { "LINEAR_ABGR8888", 4, 8, 8, 8, 8, 0, 0, false, false, false }, // IMAGE_FORMAT_LINEAR_ABGR8888
/* 52 */ { "LINEAR_ARGB8888", 4, 8, 8, 8, 8, 0, 0, false, false, false }, // IMAGE_FORMAT_LINEAR_ARGB8888
/* 53 */ { "LINEAR_BGRA8888", 4, 8, 8, 8, 8, 0, 0, false, false, false }, // IMAGE_FORMAT_LINEAR_BGRA8888
/* 54 */ { "LINEAR_RGB888", 3, 8, 8, 8, 0, 0, 0, false, false, false }, // IMAGE_FORMAT_LINEAR_RGB888
/* 55 */ { "LINEAR_BGR888", 3, 8, 8, 8, 0, 0, 0, false, false, false }, // IMAGE_FORMAT_LINEAR_BGR888
/* 56 */ { "LINEAR_BGRX5551", 2, 5, 5, 5, 0, 0, 0, false, false, false }, // IMAGE_FORMAT_LINEAR_BGRX5551
/* 57 */ { "LINEAR_I8", 1, 0, 0, 0, 0, 0, 0, false, false, false }, // IMAGE_FORMAT_LINEAR_I8
/* 58 */ { "LINEAR_RGBA16161616", 8, 16, 16, 16, 16, 0, 0, false, false, false }, // IMAGE_FORMAT_LINEAR_RGBA16161616
/* 59 */ { "LINEAR_A8", 1, 0, 0, 0, 8, 0, 0, false, false, false }, // IMAGE_FORMAT_LINEAR_A8
/* 60 */ { "LINEAR_DXT1", 0, 0, 0, 0, 0, 0, 0, true, false, false }, // IMAGE_FORMAT_LINEAR_DXT1
/* 61 */ { "LINEAR_DXT3", 0, 0, 0, 0, 8, 0, 0, true, false, false }, // IMAGE_FORMAT_LINEAR_DXT3
/* 62 */ { "LINEAR_DXT5", 0, 0, 0, 0, 8, 0, 0, true, false, false }, // IMAGE_FORMAT_LINEAR_DXT5
/* 63 */ { "LE_BGRX8888", 4, 8, 8, 8, 8, 0, 0, false, false, false }, // IMAGE_FORMAT_LE_BGRX8888
/* 64 */ { "LE_BGRA8888", 4, 8, 8, 8, 8, 0, 0, false, false, false }, // IMAGE_FORMAT_LE_BGRA8888
/* 65 */ { "DXT1_RUNTIME", 0, 0, 0, 0, 0, 0, 0, true, false, false }, // IMAGE_FORMAT_DXT1_RUNTIME
/* 66 */ { "DXT5_RUNTIME", 0, 0, 0, 0, 8, 0, 0, true, false, false }, // IMAGE_FORMAT_DXT5_RUNTIME
// Vendor-dependent depth formats used for resolving
/* 67 */ { "INTZ", 4, 0, 0, 0, 0, 24, 8, false, false, true}, // IMAGE_FORMAT_INTZ
};
@misty surge
That’s awesomeee
I gotta update the example when I have more time. I’d also like to get a working example of the env cubes too
why not use R32F
That breaks the depth afaik. I tried that first
RGBA32323232F is veeery wasteful
32f make pic blue (rt with normals)
For some reason, some models are not supported by the shader
but other models works
Are you guys solving the z depth being so stepped/short? I have seen you guys playing with alpha blending and image formats
It brings me z depth nightmares randomly occurring until I found out it was related to msaa, then the rabbit hole of rendering techniques kicked in
Show me what bug you have going on.
Oh noes it was a year ago, i was trying to draw bloom over an entity with z clipping, and NOTHING fucking worked if msaa was on, it was playing with depth and image formats for the RT which I see you guys managed to get 32F
I didn't even know that was available on source 💀
(giving glow to entities, and it had to bleed over edges, basically bloom)
I always wondered if you could achieve a playermodel or something to have this cartoonish look, its like mixed media 2d into 3d model, I don't really know how fortnite or other games achieve this look, its probably some type of shader
keeping those outlines on different views is very cool
oh nvm i guess u can do this i just dont know how
oh i understand now kind of, they use a vmt called outline that uses the $lightwarptexture parameter
yeah most of those are literally just
a. baking lines onto the texture/polys
b. duplicating the mesh inside itself, inflating it a tiny bit, and inverting the normals
$lightwarp doesn't do anything there
that's just to modify the way it's colored in, not the outline
nice profile pic 
Unrelated to shaders, I got my car back after a whole month. I ended up fixing it myself. Yay for me!!
How many print statements did it take to debug the car?
put a pixel shader on ur car
Everytime I do mechanic it costs me more later 
Yup, it’s clogged fuel lines, bleh. A bit at a time it’s getting better, but every 10 minutes of driving it’ll shut off lol. It’s the HPFP
Stick some redex or a fuel additive in it and it'll be fine in 1hr if it's dragged shit through your tank
this looks really cool
have u released any of these to workshop yet?
would probably go viral if u did
I have already published the restored volumetric clouds shader from Mee. And i have only just started making the physical sky.
hook.Add(PHYSICAL_SKY and "PostDrawPhysicalSky" or "PostDraw2DSkyBox", shaderName, RenderVolumetricClouds)
damn nice
does this work with 2d drawings? https://steamcommunity.com/sharedfiles/filedetails/?id=3455761038
+++ just run it manual on HUDPaint, ui, etc
would be cool if it auto runs, as gmod's AA stopped working for some unknown reason with 2d
not all 2d
My friend already made SMAA settings save
very beautiful
Are there already some shaders on the workshop?
Have you tried searching
🤔🤔🤔🤔
Does anyone have a function for rendering cubemap textures in rendertarget?
real time cubemap
local shaderName = "RealtimeCubemap"
local cubemap_size = 64
local rt_name = "_rt_RealtimeCubemap"
local rt_w,rt_h = cubemap_size*3, cubemap_size*4
local rt_RealtimeCubemap = GetRenderTargetEx(rt_name, rt_w,rt_h,
RT_SIZE_NO_CHANGE,
MATERIAL_RT_DEPTH_SEPARATE,
bit.bor(32768,2,4,8,1024,512,1024), --2048 16384
CREATERENDERTARGETFLAGS_HDR,
IMAGE_FORMAT_RGB888
)
local angs = {
angle_zero, --front
Angle(0, 90, 0), --left
Angle(0, 180, 180), --back
Angle(0, 270, 0), --right
Angle(-90, 0, 0), --up
Angle(90, 0, 0) --down
}
local poses = {
{x = 1*cubemap_size, y = 1*cubemap_size}, --front
{x = 0*cubemap_size, y = 1*cubemap_size}, --left
{x = 1*cubemap_size, y = 3*cubemap_size}, --back
{x = 2*cubemap_size, y = 1*cubemap_size}, --right
{x = 1*cubemap_size, y = 0*cubemap_size}, --up
{x = 1*cubemap_size, y = 2*cubemap_size}, --down
}
local w,h = cubemap_size*3, cubemap_size*4
local m = 2
local view_data = {
origin = vector_origin,
x = 0, y = 0,
w = cubemap_size, h = cubemap_size,
aspectratio = 1,
drawhud = false,
drawviewmodel = false,
dopostprocess = false,
angles = 0,
fov = 90,
}
local RenderView = render.RenderView
local PushRenderTarget = render.PushRenderTarget
local PopRenderTarget = render.PopRenderTarget
hook.Add("RenderScreenspaceEffects", shaderName, function()
view_data.origin = EyePos()
for i = 1,6 do
view_data.x, view_data.y = poses[i].x, poses[i].y
view_data.angles = angs[i]
PushRenderTarget(rt_RealtimeCubemap, 0, 0, cubemap_size, cubemap_size)
RenderView(view_data)
PopRenderTarget()
end
end)
hook.Add("HUDPaint", shaderName, function()
render.DrawTextureToScreenRect(rt_RealtimeCubemap, 0, 0, rt_w*m, rt_h*m)
end)
what, am i dreaming? is this real?
Can you show us the real time reflection ???
I'm currently working on optimization so that the cubemap is updated on all sides, and only the visible ones.
i would imagine all 6 cubemaps will be visible at all times no matter where you look
either behind if you're facing a wall, above when reflecting off the floor or in front (like in the screenshot) if it's reflecting off the gun
only case that wouldn't be true is if there are no materials in the scene using env_cubemap, and that's... fairly rare
can probably reduce the resolution of the captures if the scene's normal maps are rough/invisible enough, accounting for inverted facing direction & dot product from viewpoint
that's about it
probably not very performant to calculate minimum roughness of individual textures, but that can be cached. (or even more/less performant than just not having the resolution switch for the scene, idk)
if you want to be fancy, you might even smoothly transition between resolutions over time, such as based on player camera movement (or use movement to temporarily disable creating new cubemaps, but this will lag behind the view slightly)
Can these cubemap textures be used as a replacement for pre-rendered cubemaps without requiring a custom shader?
I believe I recall someone saying that cubemaps cannot be replaced via lua
I always wondered why
bit.bor(32768,2,4,8,1024,512,1024)
But not
2 + 4 + 8 + 1024 + 512 + 1024

prob to make it obvious that its using bitflags or guy's so used to it
i want my | back