Speaker 1: Okay, let's unpack this. Today we're taking a deep dive
Speaker 1: into the fascinating world of game visuals. We're going to
Speaker 1: pull back the curtain on how developers craft those stunning,
Speaker 1: immersive graphics you see in modern Unity three D games.
Speaker 2: Right.
Speaker 1: Our mission isn't to bury you in technical jargon, but
Speaker 1: to cut through the complexity and extract the most important
Speaker 1: nuggets of knowledge and insight. Yeah, make it accessible, and
Speaker 1: we're drawing heavily from a truly fantastic resource, the Unity
Speaker 1: Shaders and Affects Cookbook by Kenny Lammers. A book that's well,
Speaker 1: it's a masterclass in practical recipe based learning, and it's
Speaker 1: full of surprising facts.
Speaker 2: That's right. This deep dive is your shortcut to being
Speaker 2: well informed about the magic behind how games look. Think
Speaker 2: of it as unveiling the clever illusions and powerful tools
Speaker 2: that turn polygons into vibrant living worlds.
Speaker 1: Yeah.
Speaker 2: We'll explore everything from the kind of foundational building blocks
Speaker 2: of visual effects to advance techniques that make a game
Speaker 2: truly shine. Our goal is to help you understand not
Speaker 2: just what shaders and effects are, but why they matter
Speaker 2: to the final esthetic and performance of a game. And
Speaker 2: how they contribute to that wow factor.
Speaker 1: So we're talking about making things look good in Unity.
Speaker 1: When you're building a game, where do you even begin
Speaker 1: to well paint that visual masterpiece?
Speaker 2: We begin with shaders. Imagine them as tiny, highly specialized
Speaker 2: painters that live inside your graphics card. Well painters, Yeah, exactly.
Speaker 2: Every surface in your game, a tree, a wall, a
Speaker 2: character skin gets painted by a shader. Historically it was
Speaker 2: like using a preset brush, maybe a bit rigid, But today,
Speaker 2: with modern rendering languages like Craig and Unity's user friendly
Speaker 2: surface shaders, developers have vastly more.
Speaker 1: Control, more flexibility, way more.
Speaker 2: Unity surface shadors are particularly efficient because they handle a
Speaker 2: lot of the heavy lifting for the graphics processing unit,
Speaker 2: the GPU, making it much smoother to customize how things look.
Speaker 1: That sounds incredibly powerful. So we're building these custom painters,
Speaker 1: these shaders, But how do artists who might not write
Speaker 1: code actually use them? Is there a simple way to
Speaker 1: tweak things?
Speaker 2: Absolutely? That's where properties come in. Think of them as
Speaker 2: the adjustable knobs and sliders on your shader's control panel
Speaker 2: right in the Unity editor.
Speaker 1: Ah okay, so the artist sees those directly.
Speaker 2: Yep, they let artists or designers fine tune colors, textures,
Speaker 2: or how shiny something is directly within Unity's inspector tab.
Speaker 2: No coding required for them at that point.
Speaker 1: That makes so much sense. So these properties literally let
Speaker 1: you declare different kinds of inputs. You could have a
Speaker 1: color property for a color picker.
Speaker 2: Maybe exactly, or a range for a slider. You can
Speaker 2: have a two D property for a texture image, a
Speaker 2: cube for something called a cube map. We'll definitely get
Speaker 2: to those later, okay. Or simple float values for numbers.
Speaker 2: Eat property like a missive color or my slider value
Speaker 2: links directly to the shader's inner workings. And the real
Speaker 2: beauty here is you can set up a slider in
Speaker 2: the Unity editor that, when dragged, might dynamically change how
Speaker 2: sack traded a color is in your game, all in
Speaker 2: real time. Wow.
Speaker 1: Yeah, that must be a huge time saver. Empowers the
Speaker 1: artists directly. What's fascinating here is how textures then become
Speaker 1: more than just image files you said, They become powerful
Speaker 1: data containers.
Speaker 2: Indeed, think of a texture not just as a pretty picture,
Speaker 2: but as a candice where each pixel can hold different
Speaker 2: kinds of information.
Speaker 1: It's quite clever like scrolling textures for effects like waterfalls, rivers,
Speaker 1: or maybe lava flows.
Speaker 2: Exactly, it's an illusion of movement, but incredibly effective. You're
Speaker 2: simply shifting the textures, coordinates, the uvs over time in
Speaker 2: the shader, often using unities built in time variable.
Speaker 1: Just sliding the picture along basically pretty much.
Speaker 2: And similarly animating sprite sheets. People often call them sprite atlases.
Speaker 2: That's like creating a digital flip book.
Speaker 1: Ah.
Speaker 2: You're taking a large texture with many smaller images frames
Speaker 2: of an animation, and the shader cleverly cycles through them,
Speaker 2: using precise mathematical calculations like wad and seal to create
Speaker 2: that smooth illusion to movement.
Speaker 1: And here's an AHA moment, I think, especially for performance
Speaker 1: packing textures. You mentioned storing multiple grayscale images inside a
Speaker 1: single texture.
Speaker 2: Yes, like a secret compartment. You use the red, green, blue,
Speaker 2: and alpha channels, the RGBA channels to store four different
Speaker 2: grayscale maps.
Speaker 1: Why is that so important?
Speaker 2: Memory textures eat up memory, especially on mobile. Packing them
Speaker 2: like this drastically shrinks your app size. It's a huge optimization.
Speaker 1: Okay, so you pack them save memory, then.
Speaker 2: What then the shader can intelligently blend these hidden images
Speaker 2: together on a surface. You use the LURP function linear
Speaker 2: interpolation to smoothly transition between say, grass, dirt, and rock
Speaker 2: on a terrain model, all from one tiny file.
Speaker 1: That sounds incredibly useful for detailed environments it is.
Speaker 2: And then there's normal mapping. This was well a truly
Speaker 2: genius technique that let games leak forward visually without tanking performance.
Speaker 1: Right, making things look bumpy without adding actual polygons.
Speaker 2: Instead of requiring complex high polling models. A normal map
Speaker 2: uses a special texture where pixel colors represent surface direction.
Speaker 2: It tells the light how to bounce off, faking intricate
Speaker 2: detail on a.
Speaker 1: Low poly mesh like optical illusion geometry kind of.
Speaker 2: Unity even has helpers like unpack normal to make it easier,
Speaker 2: and you can control the intensity with a shader property
Speaker 2: like a normal map intensity slider.
Speaker 1: It doesn't stop there, though. What if you need patterns
Speaker 1: that aren't in a file, or need to adjust textures
Speaker 1: on the fly.
Speaker 2: Well, you can create procedural textures dynamically within the Unity
Speaker 2: editor using c sharp.
Speaker 1: Scripts, generating them with code.
Speaker 2: Yeah, you can generate patterns, shapes, maybe gradulate distances to
Speaker 2: create rings or gradients. You can even replicate Photoshop levels
Speaker 2: effects directly in your.
Speaker 1: Shader, like adjusting brightness and contrast in real.
Speaker 2: Time exactly adjust brightness contrast gamma using functions like max
Speaker 2: to clamp values. Precise artistic control, but generated dynamically.
Speaker 1: Okay, so we've painted surfaces use textures as smart data.
Speaker 1: But what about making things really shine and reflect the
Speaker 1: world around them that metallic glint or waterychine.
Speaker 2: Right, That's where specularity comes in. It describes how shiny
Speaker 2: an object is, and crucially, it's a view dependent.
Speaker 1: Defect, meaning it changes based on where I'm standing.
Speaker 2: Precisely the highlight moves as you move around the object.
Speaker 2: A core concept here is the half vector, which is
Speaker 2: sort of an efficient way to calculate where that highlight
Speaker 2: should be between the light source and your viewpoint. Unity
Speaker 2: provides a built in blind fong lighting model that's very
Speaker 2: common and pretty efficient for this.
Speaker 1: But you're not limited to just the built in options, right?
Speaker 1: Can artists get more granular control?
Speaker 2: Oh? Absolutely not limited. You can write your own custom
Speaker 2: shine models and masking specula with textures gives artists incredible
Speaker 2: pixel level control.
Speaker 1: So using a texture as a stencil for shininess.
Speaker 2: Exactly a grayscale texture, where black means matt and white
Speaker 2: means full shine. This leads to tech niques for simulating
Speaker 2: different material properties, think metallic versus soft speculat.
Speaker 1: Like brushed metal versus say, plastic.
Speaker 2: Precisely, you can mimic different roughness levels or even at
Speaker 2: a fresnel term. That's the effect where reflections get stronger
Speaker 2: at glancing angles, like on water or car paint. And
Speaker 2: for really specialized surfaces like brush metal or even hair,
Speaker 2: there's anisotropic speculator that uses a normal map not just
Speaker 2: for bumps, but to define the direction of the highlight,
Speaker 2: making it stretch along the grain usually needs a slightly
Speaker 2: more powerful shader model like three.
Speaker 1: Point zero reflections. Then, equally important for realism, how do
Speaker 1: we get objects to actually mirror their surroundings.
Speaker 2: The key there is cube maps. Remember the cube property type.
Speaker 1: Yeah, you mentioned we'd get back to those right.
Speaker 2: So imagine taking six photos up, down, left, right, forward, backward,
Speaker 2: all from one point, stitch them together into a cube.
Speaker 2: That's your cube map. It captures the entire environment around an.
Speaker 1: Object, like wrapping the object in a photo box.
Speaker 2: Pretty much, you can create cube maps directly in Unity,
Speaker 2: using a function called rendered a cube map, often with
Speaker 2: a little menator helper tool for static scenes, or use
Speaker 2: external tools like Ati cube map gen for more control.
Speaker 1: Okay, so you've got your environment, box, your cube map.
Speaker 1: How does the shader use it?
Speaker 2: Unity makes simple cube map reflection surprisingly easy. The shader's
Speaker 2: input data usually have a built in vector, often called
Speaker 2: world refle that automatically calculates the correct reflection direction based
Speaker 2: on the surface normal and view angle.
Speaker 1: So it knows where to look into the cube exactly.
Speaker 2: Then you just use the text key function to sample
Speaker 2: that cube map at that direction and boom you get
Speaker 2: the reflection color.
Speaker 1: And just like with speculator, I assume you can control
Speaker 1: where it reflects.
Speaker 2: Yep, you can mask reflections using another grayscale texture black
Speaker 2: for no reflection, white for full reflection, same principle.
Speaker 1: And combining normal maps with reflections for bumpy reflective surfaces.
Speaker 2: Absolutely, That's where it gets really convincing. You need to
Speaker 2: access the surface normal after it's been modified by the
Speaker 2: normal map. Unity provides ways to do this, often using
Speaker 2: something called internal data. Then you use a function like
Speaker 2: world reflection vector to calculate the reflection direction based on
Speaker 2: that bumpy normal the reflection gets realistically perturbed.
Speaker 1: Makes sense, So the bumps distort the reflection, right, And.
Speaker 2: You mentioned fresnel reflections earlier with specularity, same applies here,
Speaker 2: very common for making reflections pomp at glancing angles looks
Speaker 2: great on water glass car paint.
Speaker 1: And can these reflections be dynamic update in real time?
Speaker 2: They can, but it's computationally expensive. You can build dynamic
Speaker 2: cube map systems that maybe swap between precaptured cube maps
Speaker 2: based on where the object is, or even re render
Speaker 2: the cube map periodically in real time.
Speaker 1: So needs careful scripting. Maybe checking distances.
Speaker 2: Exactly use c sharp scripts, maybe with execute an edit
Speaker 2: mode for editor previews, check distances using vector three, do
Speaker 2: distance and trigger cube map updates or swamps. It's powerful,
Speaker 2: but needs optimization. So if we connect this to the
Speaker 2: bigger picture, beyond the fundamental shine and color from diffuse
Speaker 2: in speculator lighting, custom lighting models let you achieve incredible
Speaker 2: visual fidelity, especially for really complex or unique surfaces, things
Speaker 2: that standard lighting just doesn't capture.
Speaker 1: Well, what's one of the more maybe unconventional approaches to lighting.
Speaker 1: You see something that doesn't rely on standard lights in
Speaker 1: the scene.
Speaker 2: One really interesting one is the lits sphere lighting model.
Speaker 2: You might hear it called Matt caps, especially if you've.
Speaker 1: Used z brush Matt caps. Okay, how does that work.
Speaker 2: It's a form of image based lighting. Basically, the entire
Speaker 2: lighting and shading of an object, highlights, shadows, everything is
Speaker 2: baked into a single two D texture, which looks like
Speaker 2: a picture of a sphere lit in a certain way.
Speaker 1: So you map that sphere image onto your object sort of.
Speaker 2: Yeah. The shader uses the object surface normal relative to
Speaker 2: the camera to look up the color on this sphere map.
Speaker 2: The big catches. This lighting is completely fake in a way.
Speaker 2: It doesn't react to scene lights at all.
Speaker 1: Ah, so it's always lit the same way relative to.
Speaker 2: The camera, exactly locked to the camera's view. But you
Speaker 2: can swap out the Matt cab texture to instantly change
Speaker 2: the perceived lighting and material. It's very fast, great for
Speaker 2: stylized looks or sculpting previews.
Speaker 1: Interesting shortcut. What else in image based lighting?
Speaker 2: Another technique is the diffuse convolution lighting model. This uses
Speaker 2: a preprocess sort of blurred cube map to simulate soft
Speaker 2: diffuse ambient lighting from the environment.
Speaker 1: So capturing the general color of the surroundings precisely.
Speaker 2: It gives you that nice effect where an object picks
Speaker 2: up ambient color from say a blue sky above and
Speaker 2: green grass below. I think ambient cube shading a convolution
Speaker 2: or blurring process is too slow for real time, but
Speaker 2: you pre calculate it great for static scenes or cinematics.
Speaker 2: For that realistic environmental downslid. It often uses the world
Speaker 2: normal vector function to sample this blurred cube map.
Speaker 1: Okay, so you have these specialized models, but then you
Speaker 1: start combining things. Right, what's a good example of a
Speaker 1: material that pulls multiple techniques together.
Speaker 2: The vehicle paint lighting model is a perfect example. It's
Speaker 2: not just one simple effect. It's often a sophisticated blend.
Speaker 2: You might use special BRDF textures B or bidirectional reflectance
Speaker 2: distribution function basically textures that define how light reflects differently
Speaker 2: based on viewing and light angles. So you use those
Speaker 2: for the diffuse color, maybe get that subtle color shift
Speaker 2: you see on cars, and you combine it with cue
Speaker 2: AAPS for the sharp clearcoat reflections. It really brings many techniques.
Speaker 1: Together, right, that complex layered Look what about something really
Speaker 1: organic like skin that seems incredibly hard to get right.
Speaker 2: Oh. Skin shading is notoriously tricky because light doesn't just
Speaker 2: bounce off skin, It penetrates and scatters underneath, called subsurface scattering.
Speaker 1: How do shaders even fake that?
Speaker 2: Well? The diffuse part often uses a BRDF lookup texture
Speaker 2: specifically designed to simulate that light scattering, and the speculator
Speaker 2: or shine is complex too. It usually incorporates fresmal effects
Speaker 2: and maybe some rim lighting techniques to give that soft,
Speaker 2: waxy highlight you see on skin. It often relies on
Speaker 2: calculating things like blurred normals and surface curvature.
Speaker 1: Curvature like how quickly the surface is bending.
Speaker 2: Yeah, Using functions like fwidth to find sharp changes in
Speaker 2: length to measure how sharp they are helps find details
Speaker 2: like pores or wrinkles to subtly affect the lighting.
Speaker 1: Wow. And for cloth shading, getting that fabric look a.
Speaker 2: Common technique there involves detail normal maps and detailed textures.
Speaker 1: Using two normal maps.
Speaker 2: Yeah, you overlay a fine tiling normal map representing the
Speaker 2: weave pattern on top of the main normal map for
Speaker 2: the folds. This achieves a higher level of micro detail,
Speaker 2: helping to break up and realistically disperse the speculator highlights
Speaker 2: across the tiny fibers makes it look much more like
Speaker 2: actual fabric.
Speaker 1: We've covered a lot on making things look solid, shiny, reflective,
Speaker 1: but what about the opposite, making things see through? Transparency
Speaker 1: seems simple, maybe just an alpha channel, but you mention
Speaker 1: it causes issues.
Speaker 2: It does, especially with draw order. Creating transparency with alpha
Speaker 2: is the fundamental part. Yes, you add an alpha parameters
Speaker 2: your shadeer's set up the hashtag pragma statement telling unity
Speaker 2: it can be transparent. Then you feed a value, usually
Speaker 2: from a texture's alpha channel to the O alpha parameter
Speaker 2: in your output. Zero is fully transparent, one is opaque.
Speaker 1: Okay, standard stuff. But then there's the transparent cutoff shader.
Speaker 1: How's that different?
Speaker 2: Right? Cutoff uses an alpha test variable name parameter. Instead
Speaker 2: of blending smoothly, it acts like a switch. If the
Speaker 2: alpha value is below a certain threshold the variable name
Speaker 2: the pixel is completely discarded, fully transparent. If it's above,
Speaker 2: it's fully opaque, no in between grays.
Speaker 1: Why use that performance often?
Speaker 2: Yes, especially historically, it avoids some blending complexities. But counterintuitively,
Speaker 2: the source points out that on some mobile GPUs, doing
Speaker 2: that per pixel test for the cutoff can actually be
Speaker 2: more expensive than regular alpha blending depends on the hardware architecture.
Speaker 1: Huh. Interesting, So this draw order problem, how does Unity
Speaker 1: handle stacks of transparent things.
Speaker 2: That's where depth sorting with rendered cues comes in. Normally,
Speaker 2: a Unity draw solid objects from front to back using
Speaker 2: the depth buffer or Z buffer to make sure closer
Speaker 2: things cover farther things. Transparent objects are usually drawn after
Speaker 2: solid ones sorted back to front, back to front. Why
Speaker 2: so that you can see farther transparent objects through closer
Speaker 2: ones correctly. But you can override this default sorting using
Speaker 2: tags in your shader. You can set tags q transparent ten,
Speaker 2: for example, to force an object into a specific drawing
Speaker 2: order within the transparent group.
Speaker 1: So you can layer them manually if needed.
Speaker 2: Exactly. Unity has built in queues like background geometry, alpha test,
Speaker 2: or cutoff shaders transparent and overlay, and a crucial tag
Speaker 2: for transparent objects is z write off. This tells Unity
Speaker 2: not to write the object's depth information into the depth buffer,
Speaker 2: which is essential for letting things behind it render correctly.
Speaker 1: Okay, that makes sense. So a practical example maybe GUI
Speaker 1: and transparency like three D interfaces floating in the world.
Speaker 2: Perfect example, you might create a cool three dui using
Speaker 2: texture sheets with alpha channels for buttons or readouts. When
Speaker 2: those UI elements get very close together, maybe overlapping slightly,
Speaker 2: Unity's automatic sorting might flicker or get confused.
Speaker 1: Right, you see that Z fighting sometimes exactly.
Speaker 2: So this is where a small C sharp script, maybe
Speaker 2: using execute and edit mode so it runs in the editor,
Speaker 2: becomes invaluable. It can let you dynamically adjust the Q
Speaker 2: values for individual UI materials right there in the inspector.
Speaker 2: It gives you that fine grained Photoshop like layer control
Speaker 2: over your three DUI.
Speaker 1: Elements, super useful for complex interfaces. Now, moving beyond just
Speaker 1: surface appearance. Vertex magic, you mean, shaders can actually change
Speaker 1: the shape of the model precisely.
Speaker 2: There's a special function within a shader, the vertex function,
Speaker 2: that runs once for every single point or vertex that
Speaker 2: makes up the three D model. Inside this function, you
Speaker 2: can manipulate that vertex's position, it's color, even it's textra
Speaker 2: coordinates uves before it even gets rendered.
Speaker 1: WHOA, so you can access a vertex color in a
Speaker 1: surface shader. Models can store colored data per point.
Speaker 2: They can often export of and three D modeling software.
Speaker 2: You can retrieve this using a specific infesststructure like ap
Speaker 2: data full and passed along. This float for color variable
Speaker 2: can hold RGB and even an alpha value for extra
Speaker 2: data right there on the vertex.
Speaker 1: What can you do with that vertex data?
Speaker 2: All sorts of cool stuff. You can animate vertices in
Speaker 2: a surface shader. Imagine making a flag ripple realistically. Instead
Speaker 2: of complex bones and skinning, you just apply a sine
Speaker 2: wave using the sin function to the vertex positions based
Speaker 2: on time.
Speaker 1: So the shader itself makes the flagwave.
Speaker 2: Yeah, or create ocean waves pulsating effects, all without traditional
Speaker 2: animation systems. You could also use Vertex color for terrains
Speaker 2: to blend textures. For instance, paint Vertex colors onto your
Speaker 2: terrain mash, maybe red for rock, green for grass, and
Speaker 2: use those colors in the shader to control the blend.
Speaker 2: Combined with a height map, this lets you get really
Speaker 2: detailed blending in crevasses and on hillsides. Games like Uncharted
Speaker 2: in Gears of War made this popular for their stunning environments.
Speaker 2: This all sounds incredibly powerful, but it does raise important question.
Speaker 2: With all these techniques layering effects, maybe animating vertices, how
Speaker 2: do we keep things running smoothly? Especially on say, mobile devices,
Speaker 2: How do we manage performance?
Speaker 1: That's the critical question, isn't it? What makes a shader
Speaker 1: cheap or efficient? It's not always obvious.
Speaker 2: It's not, but generally it means optimizing a few things,
Speaker 2: minimizing memory usage for variables, keeping the number of texture
Speaker 2: lookups low, and writing efficient code logic within the shader itself,
Speaker 2: fewer calculations per pixel.
Speaker 1: Basically, how do you even measure that? How do you
Speaker 1: know if a shader is slow?
Speaker 2: Unity's built in profiler is your absolute best friend here.
Speaker 2: It's like an EKG for your game.
Speaker 1: Okay.
Speaker 2: Lets you track GPU usage, CPU usage and specifically rendering performance.
Speaker 2: Frame by frame. You can see details like draw calls,
Speaker 2: how many separate things are being drawn, and the actual milliseconds.
Speaker 1: Spent rendering, so you can pinpoint bottlenecks exactly.
Speaker 2: Profiling might clearly show that adding just one more texture
Speaker 2: lookup and ALERP function for blending significantly increases the render
Speaker 2: time for certain objects, guiding you directly to where optimization
Speaker 2: is needed.
Speaker 1: And what about specifically modifying shaders for mobile? Are there
Speaker 1: common tricks?
Speaker 2: Yeah? There are definitely mobile specific considerations. You might use
Speaker 2: simplified lighting functions like a proxview or half as view,
Speaker 2: which are faster but slightly less accurate. You might declare
Speaker 2: variables using fixed or half precision instead of full float
Speaker 2: to save memory.
Speaker 1: And bandwidth smaller numbers basically right.
Speaker 2: You might also use directives like no forward ad to
Speaker 2: limit complex per pixel lighting to only one directional light,
Speaker 2: significantly cutting down calculations, or explicitly state no light mapping
Speaker 2: support if you're not using baked lighting to prevent the
Speaker 2: shader from doing unnecessary checks. Yeah, it's always a trade off.
Speaker 2: Balancing visual fidelity with the performance constraints of your target
Speaker 2: hardware makes sense.
Speaker 1: It sounds like you could end up with lots of
Speaker 1: slightly different versions of shaders, though, how do you manage
Speaker 1: that complexity.
Speaker 2: That's where modularity comes in. Making your shader world modular
Speaker 2: with c includes is crucial. Think of them like shared
Speaker 2: code libraries or header files and C plus plus hand.
Speaker 2: Unity already provides several built in siege include files. Unity
Speaker 2: CG dot c jink is a big one, full of
Speaker 2: helper functions for common tasks like calculating luminance for desaturation
Speaker 2: effects lighting. Dot cjinc defines the standard built in lighting
Speaker 2: models like blindphone.
Speaker 1: But the real power is making your own.
Speaker 2: Absolutely you can create your own cg include files, dot
Speaker 2: caging files. You wrap your custom lighting models, helper functions,
Speaker 2: maybe common variable declarations inside preprocessor directives like hashtag, if
Speaker 2: def hashtag define and hashtag NF.
Speaker 1: So you define a block of code once and.
Speaker 2: Then you just hashtag include my customs stuff, dot cgenejink
Speaker 2: at the top of any shader that needs it. It
Speaker 2: keeps your shaders clean, avoids repetition, and makes updates much easier,
Speaker 2: super efficient workflow.
Speaker 1: That sounds way better than copying and pasting code everywhere.
Speaker 2: Oh it is. And you can even use hashtag defined
Speaker 2: directives within your main shaders to build shaders with multiple
Speaker 2: states or feet feat How does that work? You could
Speaker 2: write your lighting code inside and hashtag if stiff my
Speaker 2: cool feature hashtag end off block. Then maybe in your
Speaker 2: material inspector or via script, you can enable or disable
Speaker 2: that hashtag define. Unity shader compiler will then create different
Speaker 2: compiled versions, one with the feature, one without, all from
Speaker 2: the same source file. Immense flexibility without managing dozens of
Speaker 2: near identical shader files.
Speaker 1: Okay, that's really clever for managing variations So we've built
Speaker 1: our objects, lit them, maybe made them transparent or wavy,
Speaker 1: But what about that final polish, that cinematic look. How
Speaker 1: do artists tweak the entire screen image?
Speaker 2: Ah? Now you're talking about screen effects, often called post
Speaker 2: effects or post processing. This is where the real magic
Speaker 2: often happens for mood and.
Speaker 1: Style, So effects applied after everything else is drawn.
Speaker 2: Exactly, you grab the entire rendered image of your game
Speaker 2: just before it's shown, process all its pixels on the
Speaker 2: GPU using another shader, a post effect shader, and then
Speaker 2: slap that altered image back onto the screen. It's like
Speaker 2: having photoshop layers and filters running over your live game view.
Speaker 1: How do you set that up? In Unity?
Speaker 2: It typically involves the script system. You attach a c
Speaker 2: sharp script to your camera. That script uses unities on
Speaker 2: render image function, which gets called after the scene is rendered.
Speaker 2: Inside that function, you use graphics dot blit. This takes
Speaker 2: the source render texture the current screen image, passes it
Speaker 2: to your post effects shader. The shader does its magic
Speaker 2: in its frag function fragment function, and blit puts the
Speaker 2: result back onto the screen. Usually requires Unity pro or
Speaker 2: now it's often part of the Universal render pipeline or
Speaker 2: high definition render pipeline features.
Speaker 1: Okay, so you have this pipeline, what kind of things
Speaker 1: can you easily do? Basic color correction?
Speaker 2: Absolutely, you can easily control global brightness, saturation, and contrast
Speaker 2: a function in your shad maybe contrast saturation brightness can
Speaker 2: adjust these values. Brightness calculation often uses standard luminance COEFT
Speaker 2: values based on how humanized perceive color, and you use
Speaker 2: LERP functions to blend between the original and adjusted color smoothly.
Speaker 1: What about those basic Photoshop like blend mode like multiply.
Speaker 2: Or screen yep, totally doable. Multiply is simple. Just multiply
Speaker 2: the pixel color from the render texture with the color
Speaker 2: from another blend texture. Channel by channel darkens the image
Speaker 2: add sums them, brightening it. Screen blend is a bit
Speaker 2: more math. Invert both textures, multiply them, then invert the
Speaker 2: result again. Gives a nice brightening effect that preserves whites.
Speaker 2: Each one is just a precise mathematical formula applied per pixel.
Speaker 1: And what about a more complex one like overlay blend mode?
Speaker 2: That was cool? It uses conditional checks for each pixel
Speaker 2: and color channel. It checks if the blend texture's value
Speaker 2: is less than point five. If it is, it applies
Speaker 2: a formula similar to multiply. If it's greater than or
Speaker 2: equal to point five, it applies a formula similar to screen.
Speaker 2: It creates a nice contrasty blend that preserves mid tones.
Speaker 2: Again just math, but give sophisticated artistic.
Speaker 1: Control beyond just global adjustments. How are these screen effects
Speaker 1: used for gameplay and screen effects to really enhance immersion? Oh?
Speaker 2: All the time. These effects can be triggered by in
Speaker 2: game events to dramatically change the mood, signal, danger, simulate conditions.
Speaker 2: It's huge for immersion.
Speaker 1: Like what give me an example.
Speaker 2: Okay, take the old movie screen effect. That's not just
Speaker 2: turning a grayscale. That's a combination of effects.
Speaker 1: Right, needs more than just desaturation.
Speaker 2: Yeah, you'd add a cpio tone for that brownish vintage look.
Speaker 2: You'd add a vignette effect, darkening the corners and edges
Speaker 2: like lightfall off from an old projector bulb. And crucially,
Speaker 2: you'd overlay animated dust and scratches textures animated. Ah, you
Speaker 2: scroll the uvs for the dust scratch texture over time,
Speaker 2: maybe using unity sind time or just time, and maybe
Speaker 2: add a random value multiplied in to make it flicker
Speaker 2: or jump slightly, simulating film imperfections. The cpiotone often uses
Speaker 2: specific YIQ color space values for accurate luminance calculation before tinting.
Speaker 1: That sounds really convincing. What about another classic like night vision?
Speaker 2: Ah, yeah, the staple of many first person shooters. That's
Speaker 2: another combo of effect. You need that distinct tinted green
Speaker 2: overlay obviously, but then you add scan lines, faint horizontal lines.
Speaker 2: You add some noise or grain to simulate the sensor noise.
Speaker 2: You definitely add vignette, often quite strong, simulating looking through
Speaker 2: a circular scope. And for extra polish, maybe some lens distortion.
Speaker 1: Lens distortion like Fishie.
Speaker 2: A little bit. Yeah, using functions like barrel distortion to
Speaker 2: slightly curve the edges of the screen outwards. It all
Speaker 2: comes together to sell the effect of looking through a device,
Speaker 2: not just seeing a green screen changes your whole perception.
Speaker 1: Wow. Okay, So from the absolute basics of surface shaders
Speaker 1: and the power of making things adjustable with properties.
Speaker 2: Yeah, all the way to transforming textures into data, faking detail,
Speaker 2: making things shine.
Speaker 1: Creating dynamic reflections that really mirror the world, even bending
Speaker 1: and animating the models themselves with Vertex Magic.
Speaker 2: Right through optimizing for different platforms, making your code reusable
Speaker 2: with includes.
Speaker 1: And finally layering on those screen effects for that cinematic
Speaker 1: polish or gameplay feedback. We've really journeyed through the whole
Speaker 1: pipeline of Unity's visual effects.
Speaker 2: Indeed, this deep dive should hopefully arm you with a
Speaker 2: much better understanding of how to make your Unity projects
Speaker 2: not just look good, but look stunning, run efficiently, and
Speaker 2: feel deeply immersive. You've got a solid foundation now to analyze,
Speaker 2: maybe debug, and certainly create more sophisticated visual experiences. You
Speaker 2: know the tricks behind the curtain.
Speaker 1: Now, So what does this all mean for you the listener?
Speaker 1: Given this incredible power of shaders not just to paint pixels,
Speaker 1: but to store data, change shapes, simulate physics, alter perception,
Speaker 1: what unthought of visual experience could you create by combining
Speaker 1: just two of these techniques that maybe aren't normally paired together.
Speaker 2: Yeah, Like, what if procedural textures didn't just create patterns,
Speaker 2: but actively drove the parameters of a complex cloth shader
Speaker 2: in real time?
Speaker 1: Or what if Vertex animation wasn't just cosmetic but somehow
Speaker 1: reacted dynamically to screen space, blend modes being applied. What unexpected,
Speaker 1: artistic or gameplay frontiers could you explore by smashing these
Speaker 1: powerful tools together in new ways