UE4 Tutorial 101 - Occlusion Outlines
HTML-код
- Опубликовано: 1 авг 2024
- ► Outlines Tutorial: read here for the topics timings
In this tutorial you'll learn how to create an outline post process in Unreal Engine 4 to show objects behind walls.
Topics:
0:00 - Intro: what we're gonna do
1:04 - Project and objects requirements
2:44 - Post process material
4:47 - Seeing the material effect on the scene
6:17 - The CustomDepth texture
8:15 - Outlines detection theory
11:12 - Sampling the required pixels
20:05 - Separating background from object pixels with an inline
22:21 - Highlighting the outlines on the objects
24:29 - Mixing the outlines and the original scene
26:26 - Isolating only occluded outlines
29:50 - Making line thickness configurable
31:27 - Giving a different color to each stencil value
37:36 - Commenting nodes
37:57 - Using a StaticSwitch to toggle outlines occlusion
40:11 - Thanks! Please, like and share :D
rvillani.com Хобби
This tutorial is really awesome! The best thing is that you don't just add all the notes and show the result, but you explain the thought process behind it. That's incredibly helpful.
Thank you! I always wanna know the "why", not just the "how". So that's how I try to explain stuff. Because if you know the "why", you might use it to solve something else.
I like how you actually explain what each of the parts are doing as you make them. Great job!
Thanks, Rexx! I really appreciate that, as it's the thing I try to focus the most. ^^
I'm relatively new to the UE4 community, and have been looking everywhere for a reasonable tutorial just on post processing and making occluded objects visible in some way. You sir hit the nail on the head. I've subscribed to keep track of you--thank you very much!
Thanks!
Just a heads up, I don't post only tutorials, I also do some art stuff using Unreal and post the videos. But I'll soon be back on making tutorials. Gotta make time in between jobs.
As a newbie in the VFX community, I'm extremely grateful for you doing these. Just wanted to let you know that. You're a huge help. Thank you so much
I'm very happy to help ^_^
非常感谢,你的教程帮我了一个大忙!thank you very much, your tutorial helped me solve a big problem!
Thank you for explaining the concepts and reasons behind this technique. I have watched some videos about custom depth pass and your video is this only one that I fully understand and I achieve the result I have been looking for a long time. Thank you.
And now that you know the concept, you can even do new stuff with the acquired knowledge :D
this was the only outline tutorial that i got to work. it even worked the first time. thanks a lot!
That's great, man! Happy to help
Thanks a lot for the explanation! I've looked everywhere for an explanation for outlines, but everybody just shoves the material in your face without any comments. You explained it perfectly :)
Thanks! I'm also not very fond of "do this and that" tutorials. I wanna know WHY to do this and that. Why press this button instead of the other one?
Exactly :) by understanding how it works I managed to modify it to suit my needs, for example making it work with multiple outlines on top of each other (as you mentioned at the end of the video). By the way, I'm looking forward for your next tutorials! :D
Thanks! I'll tru to get back to them, but right know I need to be able to pay the bills, so I'm drowning myself in freelancing. But I still have a big list of tutorials to make.
Very clear explanations. One learns about the different components and why their combinations provide the different effects. Thank you.
Thanks, Sven!
I believe knowing the "why" besides the "how" helps us create other things from the same concepts.
Hey thanks for the help! The material I followed in the video didn't exactly work for my situation (because I'm working on a 2D game) but I'm able to replicate this method to an existing highlight material I have that works. Really great tutorial! Very thorough.
The best tutorial about outlines! Thank you!!!
Thank you so much for this tutorial. It has everything I needed for the project I'm working on. Thank you, thank you, thank you!
Man, this is the best tutorial I've watched in a long while.
It wasn't just some mindless button-pushing. You made me understand what I was doing.
Thanks a lot
Thank you for letting me know! 🫶
I really strive to teach the why, not just the how. That way you can get this new knowledge and apply it to a different problem.
@@RVillani you nailed it with this one. I shared it to a couple of colleagues. I really hope you can afford to do this more often
@@NJoint Thank you for the kind words! I hope so too. I was very frustrated with my latest videos. The audio was bad (don't know how I didn't notice that while editing) and I feel like I'm not explaining things in a clear manner. Because of that I've been holding off on making more content until I figure out why I became so terrible at explaining this stuff.
You're insane man, thanks for explaining everything step by step rather than just doing it.
Thank you, Matthew!
Yeah, man. Sometimes I appreciate quick videos that just show me how to do what I want ASAP, but on mine I like to show the why's too, so you can use the knowledge to create something else.
Man you're awesome , savior to us all .
Awesome tutorial bro. this way i can comprehend why this works.
Dude, you, you are something special. I have been looking for something like this for a very long time now!
Modified it slightly to only highlight on things when you are close to them, but wouldn't have been able to do it without you.
Great! Glad I could help! :D
It's greatly appreciated if you share it wherever you can! ^_^
If you could explain how you did that it would seriously help me out.
You can measure the distance between the object and the camera using the custom depth output. Then, take that value, subract your minimum required distance from it, ceil, clamp to 0~1 then use 1-x (OneMinus) on the result. Multiply that by the outlines alpha. So, if the distance is less than the required (ie., you're close to the object), the result will be 1 and it will show the outlines. If it's any greater (you're far), the result will be 0 and the outline will be removed.
I just used an overlap volume, and have overlap enable/disable custom render
Hahahaha that'll work too XD But for several objects at different locations, you'd need more overlaps.
Good work, very well spoken, even if in a language that isn't your first, because that didnt stop me from understanding. Really wanted a stylistic approach to letting Players with certain roles see all other Characters through walls with an outline, and have each Character a different unique color that matches them. This was perfect for that, thank you gent + scholar.
Thanks a lot!! I'm happy to help the Unreal community! :D
Thank you for this excellent tutorial! So well explained. Please do more tut's like this
Glad to help! :D
I will start making them again. Just gotta complete some stuff before (work and a Broly model in Unreal)
Man You make PP and outlines so easy to understand! thank you very much.
Subscribed :D hope to see more tutorials!
Hugo Gómez Cervantes Thanks a lot! I'm currently working a lot and there's not much free time, but I'll get back to them some day. I do miss doing it.
You Mister Villani, are my personal hero of the day!
Sabselol Wow! Thanks a bunch! =D
Great tutorial, thanks for the theory part, it's really well explained and i learned a lot about shader!
Thanks for the feedback, Zio! :D I'm glad it helps!
Great Work, thank you for the time put into making this
This was great. Thank you. Learned a lot
Awesome Video!! I learnt a lot!! Muchas gracias por tu explicacion Rodrigo!!
Gracias, Alberto!
Thank you Rodrigo! This helped me very much. Another great tutorial with all the explanations. Not sure which version of Unreal you are using, but in 4.13.2 there is a small difference on how the material is being assigned to the PostProcessVolume. It is under Details -> Post Process Volume -> Blendables in case someone is on the 4.13. The rest is the same. Keep up the good work mate :)
Thanks a lot, Bojan!
I'm using 4.15
This seems very useful, so I've subscribed to remember you when I might need this. :)
Also I've coincidentally found comments of a fellow student on this video who has watched this just one day ago. (Arlen der Dichter) :D
Cr4zy Dude cool!
It's a small world indeed! :D
This is how you do a tutorial. Many Thanks!
Hey, thanks for the nice tutorial! I noticed that the outlines flicker a little bit. Just in case someone else wants to get rid of that flicker:
In the material settings go to Post Process Material and set Blendable Location to Before Translucency.
Till Mohr Thanks! =D
GOD
THANK YOU SO MUCH!
Thank's man.
Its saved me!thank brother!!
Thanks man. It couldn't be more descriptive.
Nice job man!
Awesome Tutorial! Thanks!
Thanks bro, this helps me a lot!!
I had an issue with something I made and couldn't find any information so I decided to watch this video as a break and to learn something new
After 30 minutes I saw you did something which was exactly what I was looking for, thank you!
Thanks for letting me know!
What was it that you needed?
@@RVillani Rendering the side of an actors with custom stencil that is not behind walls or any mesh (28:07)
Finally I found that efficient one! Great!
Haha awesome!
Great tutorial!
really clear explanations - thank you!
I'm glad you think so! I've been teaching programming to my cousin and I always feel like I mumble too much. haha
But that might be due to me not planning our classes ahead. 🤔
Nice thanks for tutorial, you are awesome!
Thank you for making my life easier.
Glad to help!
Thank you for sharing ur knowlegde !
You save the day !!
Thank you bro!! Great video
Thanks! :D
I love this tutorial, it is amazing!
I'm trying to figure out how to make this effect a character ability, so I can turn it on and off in game.
You could have a Lerp in the material in which 1 uses the effect and 0 doesn't. The Lerp alpha would be controlled by a Material Parameter Collection parameter. Than you could set that parameter's value from Blueprints.
Thanks man ❤
When i change the UV cordinends of the Custom Depth and add them togeter It dosn't mask it out, but if I dont offset the Scene texture custom depth texture it dose mask it out, why dose it not work as soon as I offset the UV's and add them togeter?
Maybe the offset values are miscalculated somehow? Could be many things. I advice you preview each node in your sequence of nodes to see if they display expected results. If you need to see specific numbers, you can use the debug nodes and preview them (Debug Scalar, Debug Float2 and so on).
That way you debug where things are going wrong in the logic and find what needs fixing.
I have a problem instead of coloring the edges the whole mesh has the color but when I move the camera the edge are the one with the color any idea D:
Great tutorial. Thank you very much.
Thank you!! Glad to help!
This is so awesome! You saved me from pulling my hair out over this! :D
Arlen der Dichter I'm very happy to help! ^_^
I really appreciate it!
I have another question though. Everything works fine now, but I would also like to add a colored silhouette to the outlines, as to basically fill them with a different color tone. In the video you are at one point seperating the inner shape from the outline, so I tried to use that to create my desired effect, but I couldn't figure out how to do it. Maybe you could give me a hint on how to do it? :)
Arlen der Dichter you mean to tint the object itself?
There's a part where you detect what's inside and what's outside the object, so you'd use the inside as an alpha to lerp the final color with the tint you want.
I can't really see it in detail right now (traveling), but if it's not clear, tell me and I'll try to explain better when possible.
The Lerp already helps, but somehow I cant manage to get the desired effect. I have been able to get outlines and fill my character, but then the rest of the world had a tint as wenn. Also I could no longer use the two color system you set up in the video. A more detailed explanation would be greatly appreciated, but don't stress yourself. if you dont have the time :)
Well, approx. by 23:00 I showed how to get only the objects as white. So you can multiply this result by your Lerp tint alpha in order to tint only the objects.
very good tutorial!thanks friend!
thanks for the kind words :)
Esse tutorial me ajudou muito! Obrigado!
É nozes! XD
How to fill inner part of object with same colour with transparency?
Vou tentar, gostei muito, obrigado
Que bom! Fico feliz em ajudar! :D
Hey thanks for the in-depth explanation! I have a question, how do i add a 50% color fill inside the outline?
You mean like highlighting the object?
Well, it's been a while that I did this, but if I'm not mistaken there's a part that output's 1 or 0 if inside of the object. You can use that (multiplied by 0.5) as the alpha for a Lerp between the original SceneColor and your highlight color.
Thank you for the awesome tutorial and in-depth teaching!
I have a question on using a similar material:
In the editor viewport view the occlusion outlines are drawn as intended, which is only when an object is behind something, for example a wall.
But in the play mode and camera view the outlines are drawn on meshes even when there is nothing between the camera and for example the player mesh.
Any ideas on how to fix this or what settings to look at?
Thank you!
Hmm, the problem was fixed when I swapped from using the normal "Camera" component to using "CineCamera" component. The normal camera probably has some rendering/post process settings which caused my issues.
Great tut. Thank you very much! .
Is there a way to hide the outlines for certain objects?
Like for example, my character goes into shallow water and his legs are hightlighted by the outlines. How can I ignore that water on this shader? Thanks!
I'm not sure about that because water is a translucent shader, usually. I think you'd have to enable depth writes for it on the water material settings and then have the water mesh render to the same custom stencil channel as the character.
Or a different channel that you account for in the post process and use it to hide the outlines.
You are just a god
Smith will suffice.
I hope you got that reference haha
Nah, I'm just a long time UE4 user trying to give something back to this community that helped me get where I am ^^
perfect.
Easy to understand tut!
@29:14, the lilo outline.
Is there a way to exclude terrain/ground from the calculation?
Thanks!
Good question. The floor has to render into the depth buffer, otherwise it'd be a translucent material, wasting performance by rendering everything behind it. So it should be there in the Scene Depth.
That said, you might be able to mask out lines on top of it by rendering the floor mesh(es) with a custom depth stencil. Then you could test in the post process material if the scene pixel also has that stencil value, and if so, don't display an outline there.
Hi!
Is there a way to modify this calculation to render not just the outline but the entire object? I'm trying to find a way to render the silhouettes of different objects as different colors but I'm having some trouble getting it to work. This is a great tutorial but I need some extra help to get that final step to the result I want :D
If you only want to render the entire object in a different colour, you don't really need any calculations. You just use the subtraction between custom depth and scene depth, use OneMinus to invert it, and use that result as the alpha of a Lerp between the SceneTexture (the PostProcessing0 one) and any colour you choose. You can look at this tutorial from the UE people here: ruclips.net/video/JH07z9Ap1hk/видео.html
If you actually need both the outline and the entire object (like at different times you want one or the other), i would try playing with the line thickness parameter. Since the outline always grows inwards, there's got to be a value at which the whole object is 'painted' 🙂
If anybody wants to be able to selectively occlude (for example lets say you have a pickup coin and your character, you don't want the outline on your character when behind the coin) you can do the following: do everything in the video except ALSO add an IF node, and we will use a stencil value of 2 as an object we don't want to occlude, (our coin will be 2, our character will be 1), you can do an if and if the stencil value is = 2 then instead of rendering out whats in the video you want to render out just the post processing input with mask of RGB, hope this helps
If you were asking how to do that, that's pretty much what I'd have suggested. A stencil value for "ignore this". I don't think there's another way if you can't tell those objects apart.
Thanks for that comment!
hey, This tutorial was very helpful to me, but im noticing that the lines are drawing within the object rather than outside of the object. Its important for me that the lines go around the outside of the object instead of within it, do you know how i could do this?
did you find a solution to this?
Ok I spent some hours being frustrated trying to get outlines to not x-ray, but finally got it working thanks to your video. Then I learned a way to make outlines even appear above other objects that also have outlines. I think a lot of people want to know how to do this. It's very easy to implement. You can even have objects have outlines above other parts of themselves (like the near side rim of a bowl having an outline).
i.imgur.com/O1xwUO8.png
i.imgur.com/SGJ0WHE.png
i.imgur.com/t6jNAjh.png
Hopefully those screenshots explain what you do well enough. Basically at every point where you'd normally be adding the texel depths together as in this video, instead you subtract the pixel's depth by the texel depths. Then you add those subtraction results together. Divide by a new scalar parameter which will let you adjust how aggressively it outlines things, and then finally subtract by 1 instead of 10 million. Clamp and ceiling as normal and the rest of the steps are the same.
Hopefully someone else found this as useful as I did.
Oh also in the screenshot you'll see that further objects have thinner outlines than nearer ones. This was easy to accomplish. Not only that, but I have it adjust for your screen resolution as well.
i.imgur.com/loG4CLJ.png
This should explain it.
Very good, man! :D
Thanks for your input. I've managed to implement the overlapping outlines based on your screenshots.
np, glad I could help
Thank you this was really helpful, do you know how to avoid the x-ray on the outlines when other objects are occluding them?
Hey man, thanks for this tutorial. I finally managed to not render outlines for hidden objects.
I do have another question tho. In the end of your video, at about 39:25 you're talking about rendering the outlines for overlapping objects with custom depth on. Could you please explain to me how i should do this? I've been trying for a while now, but none of my efforts work. Working with materials is different from other programming logic to me, and i just can't fully wrap my head around it.
The logic you use to detect the outlines between custom depth and non-custom depth objects, you'll have to use it to detect outlines between different custom depth values
I've been trying to do this for a while but I think I'm still not undertanding how this works well enough to do it.
From what I understood, you get the outline between custom depth and non-custom depth because the addition of the 8 texels around the one we're on gets very high if even a single one is in a non-custom depth area.
I assume that if you're comparing two objects with custom depth enabled the difference between the numbers is going to be much smaller, but I'm not sure of how much. How do I figure out what is the number I should subtract to the final addition for this to work?
other than the fact mine is a fill not an outline this tutorial was great explained a lot of material stuff for me.. In the newer ue4 with 2 outpots for screen position uv seemed to do nothing pixel works but I have a fill is there something I can do with the uv or something to change it to an outline? I kinda dig the fill if I get an outline working I will prob make a toggle for the fill as well :)
You ever found a solution for this?
I loved the tutorial, but could you please elaborate how to toggle it,
so that it can be use as an ability.
is there any method to some specific actor "not block mask"?
im making RPG and when my character equip a Sword. the sword cause masking to player body mesh.
What if you add equipped items to the effect with the character? Then instead of blocking, it glows with them.
That`s very nice stuff man! Extremely useful for me. The only thing i`d like to ask is how to use it together with original material of outlined object.
Thanks!
It doesn't affect the mesh material. You just need to activate custom depth on the mesh, but its materials remain untouched. So the original material will still be there.
ok, thanks a lot, i have to try to reproduce all your actions first. Maybe later will have some more questions.
U just earned a sub.
Thank you! ^^
@@RVillani Actually there's one more thing I wanna ask. What's the differences between Scene depth and Scenetexture.Scenedepth nodes?
Also I feel like pixeldepth and scene depth are similar, they all do output the distance between camera and the rendered pixels right?
Great tutorial. I was looking at ue5 and ScreenPosition now has a ViewportUV / PixelPosition options. I'm curious how those work.
Not sure how they work, just want to point out that the one we're meant to use here is the ViewportUV one
although my english is not good. but your expression is very clear. thank you for your excellent tutorial. expect more.
Thanks! I'm kinda busy these last months (need money to make tutorials xD), but I'll try to get back to making tutorials as soon as I can.
of course, earning money is top priority. but your tutorial is also valueable. I learn much knowledge about why to do something, not just how to do.
Thanks!
Yeah. I don't like those tuts where they just say what buttons to press. You gotta know why you're doing stuff.
yes, we all want to know what happen behind the back of node. just like what you painted about background knowledge of outline in the tutorial.
Where can I learn more about outline detection theory? How the renderer caculates the pixel depth and such.
That's an excellent question. I've never thought about it that way. I just found a bunch of tutorials with different techniques that helped me decide what worked best for me with the tool I have (Unreal, in this case).
When you read about different ways to do the same thing, I think the theory comes as a consequence, because you start to realize what works better for certain situations, why it is so and with that knowledge you can even start creating your own way of doing it.
That all said, I guess you could read about image processing with kernels to understand a bit more about this kind of effect. Sharpening is a similar technique to edge detection.
So great job! i love it! :D - What if i want a Range in this? you know, when a camera need to been close to see it?
nvm. i found a way to make it :)
Love this tutorial! Running into a bit of a snag though, if anyone can help. Every step of it has worked for me until he tests out the occlusion part around 28:10. When he tests it un obstructed objects are black while others are white, but for me everything just turns white, no matter the custom depth. My blueprint looks exactly the same, but I'm wondering if its possible if I've missed any steps anywhere? My current engine is 4.23 if there was anything changed there that might be causing this
From the ScreenPosition node make sure you are using the Viewport UV pin to connect to the add nodes - there are two pins in more recent engine versions compared to just one as in this video.
Great tutorial!! but I have a question, what if I don't want the outlines for objects behind?
I mean for all the static mesh but not when are behind something.
I'm trying really hard but I can't find a way to do it!
Thanks!
Check if the custom depth value is higher than the scene depth. If it is, your custom depth mesh is behind some other scene object, because those values are the distance from the camera.
An easy way to mask it out is to do:
• SceneDepth - CustomDepth
• Clamp (0, 1)
• Plug the result into a Ceil node
Now you'll have 0 if it's behind something and 1 if it's not. You can use that with a multiply or a Lerp to mask other effects.
ok I finally manage do it! thank you!!!
(I didn't except you would have respond to my comment :D)
Matty37Casa nice! I was gonna send you an email, but when I had the time. Glad you managed to do it =)
i was having the same problem but doing SceneDepth - CustomDepth was just removing the outline completely. so i tried adding a 1-x node after the clamp/ceil and it inverted the result and now the outline is only when objects are visible and not when behind something else. while im at it, can i change the size of the outline? i wanted to make it just a little bit bigger.
Would you please spell this out for me? I'm having the same issue with the outline showing through objects in front of it. What exactly does this modification look like and where do you plug this in at? Thanks!
Great Tutorial
Thanks!!!!
Is there a way to achieve this if the highlighted objects are being occluded by other translucent/transparent objects?
I don't think so. You could enable Allow Custom Depth Writes in the translucent material settings to get it to render its depth, but then you won't have the custom depth from the occluded object.
It would only be possible if translucent materials rendered to the depth buffer, but if they did, they'd make things behind them not render at all.
When I add my last multiply to the Alpha in the Lerp in guves me an error. Does anybody know why?
It says coercion failed. But I can add my multiply to the emissive color and it works.
Thank you and great video :)
Check if your Alpha input is not a value with more than one channel. For instance, the white pin out of a color node has 3 channels. The pin out of a TexCoord node has two. You can only use single channel values (floats) on Lerp's Alpha input.
To check that, use a ComponentMask node on it, turn on Preview for that node and activate one channel at a time to see if they're outputting something.
Thanks!
Hi!
Thank you so much for the video! It helped me a lot.
Can I Ask you if you think it would be possible to apply in the material something that activates the outline only when the camera/player is close (at x distance)? Or because it's a post-process material it wouldn't be possible?
Thanks eitherway :)
Thank you!
You're in luck! Because this technique only generates inlines (so contours only on top of the outlined meshes) you can get those meshes distances from the camera (custom depth map) and subtract it from your desired max distance. The result will be negative for meshes further away and positive for the ones closer. Than you can use Saturate on that result to clamp between 0 and 1 and use it as a mask (lerp or multiply) for the outlines.
@@RVillani Thank you soo much 😃☺☺
Thank you for the detailed explanation. Worked as expected but the outlines are kind of shaking. Do you know why and how to stop it?
I believe it can be Project Settings > Engine > Rendering > Postprocessing > Custom Depth with TemporalAA Jitter
It's enabled by default. Try disabling it.
Unfortunately, still same jitter after disabling/enabling the option.
What about Rendering > Default Settings > Anti-Aliasing Method
If it's not that, then I really don't know. Does it shake even with the camera and objects completely still?
I experienced the same thing, To fix it, open the material and go look in the parameters for the "Post Process Material" section. Inside there is an option "Blendable location": select "Before tonemapping"
Good one! I didn't remember that. It'll make you post process be calculated before the anti-aliasing pass, if I'm not mistaken.
Hey I did this tutorial twice just to make sure. I can not change colors. I want to use everything in this vid but several different ways. I did not realize that my game would basically be all post processing
Hello !
In UE4 4.20.3 the outline does work but within a weird part !
I followed each step and your material is the same as mine !
If I can describe more, the outline appears to fill up the entire outlined object,but I wanted just an outline !
Oops my bad, the "Screen Position" node have now 2 outputs, and I did plug it in the second one rather than the first one ! The first one worked finally ! Sorry for the inconvenience !
Thanks for posting this, it really helped save me some time!
To anyone else who reads this, for clarification, you want to use "ViewportUV" NOT "PixelPosition".
Im on 4.21 and I’m getting the same thing, but all of my nodes are correct. When he shows the different previews of what should happen, my results are all the same except for the step at 24:43.
I figured out a way to fix it. I have a comment that’s not a reply to you, you can find how there
Hey, so I followed the tutorial and it works perfectly within the viewport but for whatever reason when I press play it stops working. Do you have any ideas what could be causing that? Thanks for the great tutorial!
thanks!
Could be many things. The objects in play mode could be having stencil or custom depth disabled, for some reason. Or your player camera is overriding post process settings and disabling the PP material. Or something attached to the camera is drawing custom depth covering all the custom depth in the scene. Or you were testing from inside a Post Process Volume that's not set to infinite bounds, but in play you're outside of it. Or in your material you set some parameter during play that disables the effect. Or even something else specific to your project that I'd never guess haha
You'll have to debug. While playing in the editor viewport, you can press F8 to eject from your player into level-editing mode. Then you can select things in the viewport or in the World Outliner and inspect their details to see if the expected depth/stencil settings are set on the meshes. You can also select your pawn/character and inspect its camera to see if it's overriding any post process settings.
While ejected, you can also change the viewport mode from Lit to other view modes and see if stencil and custom depth look as expected.
To go back into possessing the character, press F8 again.
Awesome tutorial, thanks a lot. But it is possible to do the outline with translucent objects?
In recent versions, I think so. There's an option in the material details to make a translucent material write to custom depth. I haven't tested it, but I suppose that's what it's for.
牛逼~very cool ~Thank you for shared!
Great Tutorial. I''ve got one question. Is it possible to change alpha of color to make outline some transparent?
Thank you!
Yes. You can lerp the final result with the original scene color. The lerp amount will be the alpha
Big Thanks, Rodrigo! It works!
I've gone over the tutorial 3 times to try to figure out what's wrong, but this isn't working properly on 4.22.3 - in the final result, actors that are not occluded are still getting outlined, but that outline is jittering and looks glitchy - any occluded actors outlines work as they should though
Edit: after reading a comment below, this issue is caused if Temporal AA is disabled, strangely enough - I originally disabled this because the occluded actors outlines were looking weird and this was a supposed fix for it, oh well, minor tradeoff for an awesome effect!
I managed to fix it by changing the following project option: Project Settings> Engine> Rendering> Postprocessing> Activate the option: "Custom Depth with TemporalAA Jitter"
In the material, you can also set Blendable Location to "Before Tonemapping"
This tutorial is great! You explain so well!!
I have a question regarding the time stamp 29:12 - how can I do so that I it will only render the lines on the objects that are not behind any other scene object?
I finally got my nodes right, so what i did was:
Custom depth - Scene Depth, then put that into ceil and then clamp bethween 0 to 1. Then I masked R and then did a "oneminus". This then got put into the multiply node that was put into the lerp alpha :)
Nice one!
Sorry I didn't answer before. I think I missed the comment notification :(
There were some people who asked something similar, I think. But RUclips's comment ordering is weird, so it's a bit hard to find it.
Thank you for the compliment on your first comment as well! 🫶🏻
Hello
What music track playing at the start?
Great tutorial by the way!
Thanks! It's Cold Killa (Sting) from the RUclips Music Library
Is there anyway to make adjust the alpha of each color in the material? I'd like it so that one of them has an opacity of 0.
The Lerp that mixes the effect with the scene: multiply the value that goes into the Lerp alpha by how much you want the colors to affect the scene.
@@RVillani can you post a pic of the graph? I'm trying to use your material as a highlight material in game and need it to be visible behind walls as well as not behind walls.
@@RVillani the reason I need one of the colors to have an opacity of zero is because I'm finding that the postprocess on the character helps occulude the highlight of objects behind them. If you have a better solution where I can have the highlight not show thru or over my character that would be best. Can you do a tutorial specifically on creating a highlight material that works in this way? It'd be a lifesaver for noobs.
For anyone on 4.21 getting not just an outline but a fill too, I have a fix for that.
After the step at 39:02 ish, replace the Lerp with an “If” node. Plug the old Alpha in the “A” slot, set “B” to 1 using the details menu, plug the color in the “A>B” slot, and plug the Post Process Mask in the “A
What a good guy ^
No. If is bad for performance. For anyone with that problem, use "Start Previewing Node" on each node of the process to find where the mistake is. A "fix" will only create more operations on top of something wrong.
@@RVillani I was wonder if you knew about an issue that I'm having. The issue is even my character is 30 meters away he has a very thin outline when not occluded. Do you happen to know a fix for that? I'm in 4.21. Thank you
@@Righteous_Destiny doesn't sound familiar. Is the character too thin or small? Can you share a screenshot?
@@RVillani Thank you so much for the reply! I figured out the ossue it was the temporal AA that was causing the issue
Hi Rodrigo, have you ever done the tutorial about how to fix when the outlines overlap?
Can I contact you any way? I'm using outline to add people in a scene as just figures but when they pass in front of each other they overlap and it is not ok but I can not fix it.
@@diegososa3912 You could contact me here: rvillani.com/bio-contact
There's more than just e-mail there, but I won't post here to avoid spam. But I've been very busy. :(
I have another tutorial (not in english though) that uses a technique on the stencils that displays only one color at a time. The problem with that technique is that it displays the color of the highest stencil value using Max.
@@RVillani Thank you Rodrigo, I sent you an email from the company where I work explaining better my problem.
The resulting outline flickers a bit, any simple fix for this?
yeah. Project Settings > Rendering > Postprocessing > disable Custom Depth with Temporal AA Jitter
20:23 , actually since calculations are based on 8 samples pixels, this distance should be the meters multiplied by 80 instead of 100, because in your case there is 25% more lenght before the mask disappear. Anyway very good tutorial and well explained
I was just adding values there, so if the 8 samples are from 1/8 of the background distance (the 100km), it adds up to background distance. So I guess we're both incorrect XD
The right thing to do would be to get max from all samples. Because the real intention was just to find if background is among the sampled pixels. That would really make sure it works up to 100km, not just 1/8 of it. I should've realized it back then.
Thanks for calling it out and making me think again about it :D
@@RVillani To be fair this kind of calculations blow my mind, All yesterday I was trying to understand how it worked even though you given clear explication. Trying to think per pixel is so un natural to me
@@nawakman IKR! the way we have to think when making shaders is pretty unique
Hi Rodrigo, is it possible to keep the texture of the object instead of coloring the outline?
I mean an oultline that keep the object texture
Hmmmm interesting. Like, if it was a weapon you'd see black outlines?
I don't think so, because the object is hidden so if you tried to sample its color, you'd get the color from what's in front of it. You'd have to fake it with a texture for each Actor, but that would look a bit weird as the texture would likely move with the screen, not the object.
Do you have an example of something doing that? Maybe there's a better way I'm not thinking of because I'm picturing it wrong
@@RVillani hey thank you for your answer. I'm trying to build a portal. I need :
- the gun to be able to go inside the wall without being covered by the wall texture
- and I was also thinking to use stencil for recursive portal (the dev of portal explained he did it with stencil).
I'm burning my brain 😅
@@christopheaurelie6943 I don't suppose he was talking abou the same type of stencil we see in UE.
I found interesting solutions to that clipping problem here: forums.unrealengine.com/t/visible-through-walls/44042/11
My favorite is the vertex offset one: ruclips.net/video/K1kQGyBqcsE/видео.html
The shadows problem at the end you could try to solve by not doing the vertex offset only in the shadow pass, like I show here: ruclips.net/video/MaDhhyrFbrM/видео.html (at 1:42:45)
@@RVillani thank you very much for your answer ! 👍👍👍
Guys i followed this tutorial but my outline is always mixed like if the custom stencil mask ( R) is returning a float value between 0 and 1 .....
can you upload a screenshot somewhere and link it here? I didn't really understand the problem.
Good Tutorial!!!
Is anyway to hide in some object?
I want it visible behind the wall, but it also visible to the character....
Thanks!
I didn't understand what you're trying to do. If it's visible behind the wall, it's visible to the character. Right?
@@RVillani
:(( Sorry for my poor English...
Easy to say, what I want just not effect on the character.
28:46 / The part of showing the visible lines only in the hidden parts of the object did not work, they are still visible in the visible and hidden part, but in the visible part the lines were blinking frequently. UE4.24.3
I managed to fix it by changing the following project option: Project Settings> Engine> Rendering> Postprocessing> Activate the option: "Custom Depth with TemporalAA Jitter"
@@__foo__ by activating it? Not deactivating? Usually that settings is what causes people problems XD
@@RVillani activating
I see tremors on the screen how to fix that ?
Two ways: in the material details, set Blendable Location to Before Tonemapping or in Project Settings, on the search bar, search for "Custom Depth with TemporalAA Jitter" and turn it off.
how to receive shadow on 100% transparent material? Something like a cutout material, where you dont see color, only shadows from other objects.
I did something similar once. It wasn't perfect, but enough to fool the viewer on some situations.
On a transparent material, set opacity to 100% and set it to Default Lit mode.
Then, for its Emissive channel use the SceneColor node.
Let me know if it's at least close to what you want.
@@RVillani ok, i have two nodes on translucency material, 1. scene color to emissive, and 2. opacity parameter 0, there is no shadow, its just clear translucence material. What happened now, is that shadow is pure transparent, like a hole. Opposite of what we are looking for.
@@Went2PlayLLC But I said "set opacity to 100%", so it should be 1.
Then, if the material uses default lit mode, it should get some shadows, display what's behind it (because of Scene Color) and be fully visible. The shadows might be weak though, because of the emissive. But using emissive is the closest you have to making it's brightness match what's behind it.
Also, it might cast shadows, but you can turn that off in the actor.
And, something I never managed to solve: it'll have motion blur. So if you move your matte object, you'll see what's behind it with motion blur.
No matter what I do it colors the entire object instead of just the outline. Any advice on how to fix that?
output every node, on each step of the chains, to see if their output is making sense. That's how you debug materials. For numeric values, you can search for nodes called "debug". They exist for both a single scalar and float2, 3 and 4
doing that you can figure out where the problem comes from by seeing its origin and reduce wasted guessing time
@@RVillani Thank you