#Gamedevtips graph based shader development tips:

A thread...
Its easy to make complex node graphs for shaders these days, and debugging can be a headache, especially if compile times are slow.

Make a "workbench" material and shader and just copy the bit that is killing your soul slowly in.
Once you get it right, copy/paste it back in.
"Static Switches" let you make variants to your shaders. But we warned... I have seen a few "tutorials" suggesting making a master shader with a bajilliom switches.

Let me explain binary to you.

1 switch = 2 shaders compiled ans stored.
2 switches = 4 shaders.
3 = 8
4 = 16
5 =32
6 =64
7 =128

Okay, so a few switches and you get much slower compile times and you have to store all the variants.

This can be bad in very tight memory or disk spaces.

However it is ok if you only load a few variants.
Rather than use the default unity shader, I always make my own. It gives me much faster workflow and more control.

For example, for PBR I pack my textures like unreal... metal, roughness and AO in one RGB map.
Your normal map green channel can be used to fake lighting from the top of flat wall by passing it into emission. You can use a power to control the falloff.

Saturate is a clamp from 0 to 1 that is done on the gpu... it has no performance it.
*hit.
UV inputs give you perfect gradients. You can use these to do a bajillion different effects, such as wipes, dissolves, text write-on, creating circles and so on.
Vertex colors is just four channels of float data from 0-1.

You can use this to drive anything from wetness, switching materials, exaggerating normal maps, blending on damage or straight up tinting something.
The formula for cool particle effects is...

(((Texture A x Texture B) x 2) x Texture C) x2.

Pan texture A uvs x2
Pan texture B uvs x1
Pan texture C uvs x 0.5 or use a still mask to limit the effect

A voronoi noise is a good start
Comment your shadersin detail as if you are talking to an idiot.

You will need to fix them months from now at stupid o'clock and you will be a grateful idiot.
I organise my node graphs horizontally in comment boxes that break up the workflow into texture coordinates, texture inputs, and then effects, finally assembling to the final material.
I place comment boxes containing disabled effects or prototyping parts beneath.
This way, I can zoom out and always know where things are relatively speaking.

Fpr Unity I use Amplify, which let's me plug values into a "register" variable" node, which I can then access using "get" nodes along the graph without having long wires messing up the place.
*for.

Register and get allows me to keep all the nodes in a comment box self contained. It gets values and masks and usually outputs a mask into a register node at the other end. So the box has no wires in or out.

This lets me keep stuff organised.
I use prefixes for variables so they are easy to find. For example, OUT_ is the final output that goes into the material.

Out_metallic
Out_albedo
Out_emissive
Etc

Others I use are...

Color_
VC_ (vertex color)
Mask_
Fader_
This sounds trivial, but if you use drop down boxes having them grouped by prefix stops you going insane.
Standard tricks you should learn:

Fresnel:
gives you how much the polygon is pointing towards you or at a glancing angle, with falloff controls.

Use
-Force shields, force bubbles.
-Fade a particle or poly before you get side on to it.
-reduce window reflections when face on
Offset map

Slides the UVs based on camera view angle. Basis of parralax occlusion mapping... just without the occlusion bit.

Use
-adding fake depth.
-fake interiors
-holographic guis
STEP

If A is less than B, gives you black. If B is equal or greater than A, gives you white.

Use
Wipes
Dissolves
Turning a single vertex paint channel into several material masks, saving you the other channels for effects.
SIN

Think sine wave going from 1 to -1 over the time you feed in. Or, basically smoothly oscillate, wibble, flash, blink.

Sin, Add 1, divide by 2 to get pulsing from 0 to 1.

Uses:
Wind on leaves
Computer lights
Warning colours on low health bars
Waves lapping on your toesies
ONE MINUS

Inverts a value, because a one minus any number is the inverse.

Use:
-Inverting the Y in a normal map because your artists have you direct x format when you use open gl.

-flipping your texture coordinates

-flip an alpha so you can multiply the effect on.
UV plus UV equals UV

Texture coordinates are just vector 2s... aka two floating numbers. Therefore you can maths them to do funky shit like distortions, making parts of a texture scroll, sampling a different part of a texture depending on another value or making walls melt
Just stick them back into a vector 2 before you plug that into a texture sample and you are gucci.
MULTIPLY

The workhorse of all shaders. Multiply anything by zero gives you zero, and by 1 gives you the original value. That's a dimmer switch, beotch.

Uses
-fuck tonnes.
-Multiply a white image with blood stains on it to get a decent blood effect.
MAKE PRETTY

A node that makes games look better. Plug art into this. Art is easy. Gamers who say we are lazy are right... we are just to stupid to use this node to make everything AAA.
HEIGHT LERP

This is a must for environment artists. Blend texture A with texture B, but use a height map version of B to reveal parts of A faster.

Use
Painting puddles into cobblestones
Painting mortar into bricks.
World position

Gives you the vertices position in the world as a float3 (x,y and z value.) Plug two of these into a UV slot (usually scaled down a bit) to get world position textures.

Use:
-Making floor textures seamless regardless of scale or rotation of mesh.
- room grunge
Vertex offset

Use to make stuff move, swell, shrink, wobble, undulate, throb and rustle.
Each vertex can be moved using maaaaaaaaaaaaths.

USE:
-Throbbing, swollen, wobbly, disgusting things.
-also things that are not republicans.
-wind in grass.
PLUMBUS:

Plug Shleem into Dinglebop, and it is pushed into the grumbo.

Uses:
-every house has one.
RENDER TEXTURE

Super useful trick, taking a camera image of something in the scene. That image can then be used in a shader to do... STUFFFS

Use
- get out of may way, grass!
- snow trails and foot prints!
- it doesn't rain inside.
-minimaps
CLIP
Discards a fragment (a pixel before it becomes a pixel). Makes shit vanish into the void. Poof... gone. Therefore cheaper than transparent things.

Use
-randomly hide parts of an npc's decorations.
-dissolve corpses
-spawn in
-put holes in things.
DITHER
Turns a value into a dotty pattern usually using a bayer pattern. Yunno how things like walls go transparent by turning into fine dots? That's dither. See clip as to why it is cheap.

Use
-see through shit on a tight budget.
-making retro pixel effects.
MILKSHAKE

Plugs boys to yard. I would teach you about this but I would have to charge.
Soeaking of charge. If I helped you go "aha!" Then take on me... take me on... I'll be gone in a day or twwwwoooooooooooooooooodonateToMyKoFi

ko-fi.com/dellak

• • •

Missing some Tweet in this thread? You can try to force a refresh
 

Keep Current with Delaney King ✍🏻👸🏻

Delaney King ✍🏻👸🏻 Profile picture

Stay in touch and get notified when new unrolls are available from this author!

Read all threads

This Thread may be Removed Anytime!

PDF

Twitter may remove this content at anytime! Save it as PDF for later use!

Try unrolling a thread yourself!

how to unroll video
  1. Follow @ThreadReaderApp to mention us!

  2. From a Twitter thread mention us with a keyword "unroll"
@threadreaderapp unroll

Practice here first or read more on our help page!

More from @delaneykingrox

12 Aug
I absolutely want everyone writing manuals and documentation to punch themselves in the head if they define a feature by just reordering the words.

To quote the @unity@ documentation, for example:
It describes "Material.Renderqueue" as...

"The Render Queue of the Material".
Maya was the absolute worst for this. The manual basically did this for everything.

PUNCH. HEAD. OWN. NOW.
Amazingly, the documentation goes on to elaborate on the Render queue and say absolutely nothing. Ready for this?
Read 9 tweets
11 Aug
Ivy messes with Scarecrow's formulas and Scarecrow becomes ultra loved up, becoming THE CARECROW. His bomb goes off and Gotham becomes a really nice place full of caring people and crime drops to 0.
Batman and Selina retire and pour all their money into preserving wild big cats.
Ivy gets a loan from Batwoman to restore the amazon rainforest and halts global warming.

Bane runs a gym.

DR. Quinzel takes over Arkham Asylum and makes it a lovely safe, healing space. Her fun approach to therapy and her insights into her own experiences set a new standard.
The Riddler retires after discovering his books of puzzles and his brain training app sell more than crime.

Bane runs a gym called 'Splosions".

Mr. Freeze falls in love again and moves on from his wifes death. His new husband is super chill.
Read 8 tweets
31 Jul
Women who face abuse at work do so doubly. First the abuse and then when you call out the men who did it you are attacked for 'craving attention', 'seeking to profit', trying to cover your work failings.

Then you get a third whammy as men who witnessed it stay silent.
Either way you lose the job, the stability and the trust, and have to pay for therapy to heal the damage, and lawyers if you even dare to stand up for yourself legally.
Meanwhile the assholes keep their jobs, and get to enjoy a career.
Read 4 tweets
30 Jul
#Gamedevtips

One trick you can use in adding replayability to a game is to break up some parts of your level into discreet prefabs/blueprints that can be shuffled.
This can be as simple as switching a few corridors or rooms around, or just changing enemy or item placement but the effect is the same... players cannot rely on their memory of the layout, and can jolt them into being in the present, rather than playing by wrote.
Having parts of levels in prefab slabs help you test them separately.

You don't need many of these to create enough variety to cause this effect and it doesn't shake up the narrative.

You just... can't memorise a map.
Read 7 tweets
30 Jul
Following on from previous discussion vis a vis #weekenderGames I need to stress that a good game is worth more than a long game.

A good long game is a great thing and deserves a good price, but the length of the narrative does not equate to price tag alone.
A short game that is brilliant deserves a good financial reward.

A short game with huge amounts of replay value is well worth the price tag of a sprawling epic.

What I am saying is push down your expectations of duration of the core playthrough, and allow shorter games.
If we shift the format to shorter play throughs, we can focus more on making an industry that is more stable, games that are more polished, and faster releases.
Read 6 tweets
29 Jul
What sucks is all the devs who are currently being reminded over and over of the abuse we ourselves went through with the #blizzard situation coming to light on twitter.

Its important we share this stuff so everyone knows, and hopefully we can get real change. But triggering AF
The industry is full of this vile crap. And it has been devastating for many, many amazing people.
Been there. Done that. Got the scars. Got the PTSD. Got the NDAs. And not just from one company.
Read 4 tweets

Did Thread Reader help you today?

Support us! We are indie developers!


This site is made by just two indie developers on a laptop doing marketing, support and development! Read more about the story.

Become a Premium Member ($3/month or $30/year) and get exclusive features!

Become Premium

Too expensive? Make a small donation by buying us coffee ($5) or help with server cost ($10)

Donate via Paypal Become our Patreon

Thank you for your support!

Follow Us on Twitter!

:(