Team Fortress Style 2 Shader Material

Been playing Tf2 for fps inspiration recently and I want to recreate the graphics style and have a shader for the materials in my game, I’ve looked up many different things but the only cartoon type shader tutorials I can seem to find are ones that make the game look 2D cartoony, and nothing similar to the sort of dull lighting of tf2. Would anyone know how to create this kind of effect in URP shader graph?
Something in between a toon and normal lit shader

Lighting Models In Unity - Jordan Stevens
Cheap Global Illumination – Half Lambert | Chetan Jags

half lambert lighting was used heavily by valve, and is the key to what you’re looking for.

GRID Broadband Content Delivery Platform

1 Like

Not experienced in shaders, I can’t seem to find and resources on creating a half-lambert shader in unity URP? Tried to use something I found but was purple because it was not made for URP

any tutorial for custom lighting will do, half lambert itself is an extremely simple principle.

// standard lambertian diffuse
float diffuse = max(0, dot(lightDir, normal)); 


// half lambert diffuse
float diffuse = dot(lightDir, normal) * .5 + .5;
diffuse *= diffuse;

as far as I can tell, this just creates a float with a value that is not used for anything. How would I input this value so that it affects the material?
And how would I get the light direction? This vector3 is null

the code i gave you won’t work with anything, that’s just what those variables actually are in diffuse calculations.
i’m saying that it would be easy to go modify an existing (working) shader. it shouldn’t be too hard to find all the diffuse calculations by searching something like ctrl f “dot” and scrolling through them.

once you’ve found the diffuse calculation, whatever it might look like, make it the same as the half lambert example i wrote above, only with the actual variables instead of just the names of them i wrote.

i use the built in rendering pipeline, so i don’t actually know the specifics of writing in urp, i just know the specifics of half lambert shading.

But this creates a float called diffuse, what does diffuse do? is it the main color? the normal? what is done with the diffuse float?

in standard cg lighting, there are 3 parts, ambient, diffuse, and specular.

ambient is the base color, kind of like a minimum brightness level.

diffuse is the shading created by the direction of the light and the direction the triangle is facing.

specular reflections are more complex, so i won’t explain them here.

//the rendering equation in pseudocode. col represents the texture
col *= (diffuse + ambient);
col += specular;

you don’t need to create a float diffuse, you need to find where diffuse is calculated and change the math accordingly.

Can’t seem to find any free resources at all for creating this effect in modern URP lit

Custom Lighting in URP with Shader Graph – Bronson Zgeb

here’s a tutorial for custom lighting, i have no clue how good it is.

implement this, and change the diffuse calculations to half lambertian

I find this source to be misleading, the shader is not created in URP shader graph, it is created in code and converted into a shader graph. The instructions to creating the shaders he supplies at the bottom don’t seem to make sense as not only do I not understand what he is doing, but he doesn’t explain how to do it as far as I can tell. He explains that a package needs to be imported but doesn’t say what code to write to import it. Nowhere does he really explain the entire creation of the three shaders he supplies. It doesn’t even explain how to make the shader a URP shader from a normal one, as there is no option for creating a URP shader, you can create a built-in shader and code it to be urp or create a urp shader graph. The shaders listed in the github do not work, it seems the conversion into a shader graph is broken or something, as the shaders do nothing at all or are broken, one has errors and is the broken pink color as well.
It’s possible that this is all just because I have absolutely no idea what I am doing when it comes to coded shaders, but I can’t seem to get this to work. No part of the imported shaders seem to have any diffuse calculations for me to edit, even though he calculates one with a shadow step float that I would set to 0.5, it does nothing

lol welcome to unity dude. Custom lighting in ShaderGraph is a nightmare; it’s easier to just write your own HLSL shaders. If you need that done and can’t do it yourself, you need to either learn how or hire someone to do it for you.

There won’t be many resources on learning how, because Unity keeps changing and breaking everything every single update. Built in, URP, HDRP, Unified. They’re all different, and within each one there are multiple pipelines (forward/deferred/forward+/deferred+).

The best place to learn is quite literally the source code itself. Myself and many others have gone through the pain of reading Unity’s shader source and keeping up to date with how it works under the hood. It’s really the only reliable way. It’s located in your PackageCache folder in your project’s Library folder.

Good luck :ok_hand:

1 Like

I don’t particularly want to learn the entire shader system, I intend to just create a shader for everything and use it for all of the game
In URP shader graph I could create this if I could edit the diffuse going into it, but I can’t find anything on how, I went into the shader graph cache but found nothing

Custom lighting in Shader Graph: Expanding your graphs in 2019
this could easily be outdated, but it is simpler.

i actually switched back to BIRP because i was getting so annoyed by URP’s constant restrictions in shadergraph, plus the lack of documentation or examples for written shaders in urp. they have like 3 pages that go super in depth about shaders for birp, but literally nothing for urp.

Stupid how there’s no URP resources but I do want to use URP, I would’ve really assumed it would be easy to create something between a toon and lit shader
Maybe I don’t need to create half lambert or anything, just a slightly cartoony shader so that I don’t have to create as realistic assets for my game