Great demo! I've used vertex lighting on some projects to help optimize rendering before, so I'm glad to see it's still something that would be seriously considered. At some point will you cover how to get more lighting data from the lights? In shader graph I'm not seeing how to get the light color or attenuation, which is pretty important.
Hey, I can add a detail if I may, You calculated the ambient lighting using the Lerp formula while implementing the shader in Unity. I think you could also use the BakedGI node. it calculates the ambient lighting automatically and also can give you access to the lightmap information if you need to also bake the light on vertices.
Yes, absolutely - you're right. Currently, we're building a version of the shader that is as cheap as it can possibly be. For that reason, I'm going with flat colors for ambient. In later videos, I'll get to more advanced techniques.
I think it's a good idea to multiply an AO map with an inverted dot product node, because ambient shadows usually disappear when lit by any light source.
I get what you're saying and it's true, but that's a little bit more advanced than what I'm showing here. If I had done it better, I would have combined the AO and diffuse textures in Photoshop so I was only sampling one texture instead of two - because that's how it was done way back then. And then as an improvement - if I had the texture memory to spare and the pixel shader performance, I could do what you're describing and make it so the AO mask only effects the ambient and not the diffuse.
I am curious if you will cover scenarios like occluded sunlight. for example if we put a sphere in room where sunlight is coming in through window which has bars and hit the sphere. in this case there will be a sunlight and window's bar shadow casting on sphere. this is just one example but is there any way to get dynamic light occlusion data or scene lighting similar to Editor-View modes (Simple Lighting and detailed lighting.)
I will show how to access light occlusion (shadow) data in a future video, yes. However, this is one of the items that I only know how to do in Unity and not in Unreal.
@BenCloward unfortunately I left unity in 2019, and now I work with unreal engine only. Based on what I found, it's not possible in unreal without touching the source code.
Hypothetically speaking, given the relatively high vertex count in our assets, the artifacts might not be as noticeable, right? Meaning, implementing specular lighting could result in quite appealing shading for the LODs overall. I’ve seen something similar being done in Batman: Arkham Knight.
It totally depends on how much artifacting you're willing to put up with. I'll show what specular looks like in the vertex shader next week when we cover specular.
Awesome! Question: Isn't Minecraft using vertex lighting as well but passing the closest light sources ? Is there a way to pass this king of data to this shader to achieve the same voxel lighting result? Thanks!
I noticed that SkyAtmosphereLightDirection node doesnt work with instanced stereo rendering for VR(actually works only for one eye). Do you know some other way to get this vector e.g. for Directional light ?
While I know this specific technique is long obsolete it may be useful to cover embossing/the old way of faking bump mapping (I already know how it works and how to implement it but having this technique get more exposure could potentially be useful for someone)
The Y component (in Unity) of the vertex Normal has a range from -1 (pointing down) to 1 (pointing up). If I were to saturate that, as you suggest, I would get 0 at the bottom, 0 in the middle, and 1 at the top. So my blend would only go from 0 to 1 from the middle to the top. From the middle to the bottom, it would all be 0. But I want it to blend from 0 to 1 from the bottom to the top, so I have to adjust the original range to go from 0 to 1 instead of -1 to 1. And I do that with the * 0.5 + 0.5. I hope that helps.
It should, yes. There's nothing here that's engine specific. I don't know if the light direction node exists in that version. If not, you can just substitute a Float3 node and hard-code it.
The lighting can be done in the vertex shader, but shadows need to be done in the pixel shader. You could do them in the vertex shader I suppose, but the result would look awful because there wouldn't be enough vertices to get the detail you need. It's similar to specular. I'll show how to do shadows in a future episode.
Anyone else get an error from the Light Direction node once its passed through the Vertex Interpolator node using UE4.26? Not using UE5 due to developing for Meta Quest.
These two operations affect the range of the original value slightly differently. When you add 1, the -1 to 1 range becomes 0 to 2, you then saturate it and throw away all values above 1. While when you just saturate, you are changing the -1 to 1 range to 0 to 1 right away by throwing away all values between -1 and 0. So the resulting masks that you use as the T input of the lerp are different.
Oh this is awesome, I was just about to experiment with Gouraud shading, thank you so much for starting this series! I have two questions: -Do you know a good way to replicate the "toonify" effect used in the wind waker, showcased in this video? ua-cam.com/video/mnxs6CR6Zrk/v-deo.html My approach would be to have the palette as a 255x1 texture parameter that would be set depending of the day/weather and sample it using the with the dot product result (the saturate(ndotl)). -In older games vertex colors seem to be used instead of baking the lighting in the diffuse map, where would the multiplication of the vcolor happen in the shader your showcased? Just after the saturate(ndotl)? Thanks again for this series, this is extremely helpful for people like me trying to replicate the older games' lighting! :)
@bencloward you are a gift from heaven
Thank you sir, for sharing your amazing knowledge
Its so nice to get such an awesome video on the topic that I'm researching right when I start. Thank you so much!
You're welcome!
thank you ben. can't wait for the next video.
Can't wait to start all of your shader tutorials after I'm through with all my general unreal courses, you're awesome!
I love your channel Ben! Thank you for sharing your knowledge.
Thank you Ben
I love these videos
Very good video Ben!
It would be really cool to see in the future an implementation of an anisotropic shader.
Great demo! I've used vertex lighting on some projects to help optimize rendering before, so I'm glad to see it's still something that would be seriously considered. At some point will you cover how to get more lighting data from the lights? In shader graph I'm not seeing how to get the light color or attenuation, which is pretty important.
Yes, I’ll show how to get the extra light information in a future video.
Hey, I can add a detail if I may, You calculated the ambient lighting using the Lerp formula while implementing the shader in Unity. I think you could also use the BakedGI node. it calculates the ambient lighting automatically and also can give you access to the lightmap information if you need to also bake the light on vertices.
oops, the lightmap data breaks if you bake the lights and use the vertex shader calculations.
Yes, absolutely - you're right. Currently, we're building a version of the shader that is as cheap as it can possibly be. For that reason, I'm going with flat colors for ambient. In later videos, I'll get to more advanced techniques.
I think it's a good idea to multiply an AO map with an inverted dot product node, because ambient shadows usually disappear when lit by any light source.
I get what you're saying and it's true, but that's a little bit more advanced than what I'm showing here. If I had done it better, I would have combined the AO and diffuse textures in Photoshop so I was only sampling one texture instead of two - because that's how it was done way back then. And then as an improvement - if I had the texture memory to spare and the pixel shader performance, I could do what you're describing and make it so the AO mask only effects the ambient and not the diffuse.
I am curious if you will cover scenarios like occluded sunlight. for example if we put a sphere in room where sunlight is coming in through window which has bars and hit the sphere. in this case there will be a sunlight and window's bar shadow casting on sphere. this is just one example but is there any way to get dynamic light occlusion data or scene lighting similar to Editor-View modes (Simple Lighting and detailed lighting.)
I will show how to access light occlusion (shadow) data in a future video, yes. However, this is one of the items that I only know how to do in Unity and not in Unreal.
@BenCloward unfortunately I left unity in 2019, and now I work with unreal engine only. Based on what I found, it's not possible in unreal without touching the source code.
@@IbtesamSadiq Yep, I believe that. Unreal seems to be a bit more closed off when it comes to customization.
Hypothetically speaking, given the relatively high vertex count in our assets, the artifacts might not be as noticeable, right? Meaning, implementing specular lighting could result in quite appealing shading for the LODs overall. I’ve seen something similar being done in Batman: Arkham Knight.
It totally depends on how much artifacting you're willing to put up with. I'll show what specular looks like in the vertex shader next week when we cover specular.
33:58 - You can also press *C* to create a comment. Thanks for the video
Awesome! Question: Isn't Minecraft using vertex lighting as well but passing the closest light sources ? Is there a way to pass this king of data to this shader to achieve the same voxel lighting result? Thanks!
I noticed that SkyAtmosphereLightDirection node doesnt work with instanced stereo rendering for VR(actually works only for one eye).
Do you know some other way to get this vector e.g. for Directional light ?
While I know this specific technique is long obsolete it may be useful to cover embossing/the old way of faking bump mapping (I already know how it works and how to implement it but having this technique get more exposure could potentially be useful for someone)
Love your videos. Are your Videos made in a way that one can skip the unity Part without losing anything? Or do I have to go through them as well?
You can usually skip the part you don't need. Occasionally I put something in one part or the other that's unique, but it's not intentional.
question- instead of multiplying by 0.5 and adding 0.5. why not saturate the masked vertex normals?
The Y component (in Unity) of the vertex Normal has a range from -1 (pointing down) to 1 (pointing up). If I were to saturate that, as you suggest, I would get 0 at the bottom, 0 in the middle, and 1 at the top. So my blend would only go from 0 to 1 from the middle to the top. From the middle to the bottom, it would all be 0. But I want it to blend from 0 to 1 from the bottom to the top, so I have to adjust the original range to go from 0 to 1 instead of -1 to 1. And I do that with the * 0.5 + 0.5. I hope that helps.
@@BenCloward Yep! thanks for the reply!
OMG you really did it 🥳, thank you. Is it working with Unreal 4.27? I'll check the video tomorrow 😁
It should, yes. There's nothing here that's engine specific. I don't know if the light direction node exists in that version. If not, you can just substitute a Float3 node and hard-code it.
Yeah, node exist in 4.27
How would I add support for more than 1 light?
We’ll get to that in a future video. I’ll warn you now, though, it’s pretty complicated.
Is it possible to make vertex lighting with shadows somehow?
The lighting can be done in the vertex shader, but shadows need to be done in the pixel shader. You could do them in the vertex shader I suppose, but the result would look awful because there wouldn't be enough vertices to get the detail you need. It's similar to specular. I'll show how to do shadows in a future episode.
@@BenCloward thank you very much!
Anyone else get an error from the Light Direction node once its passed through the Vertex Interpolator node using UE4.26? Not using UE5 due to developing for Meta Quest.
in 4.27 it works, dont know about 4.26
Why did we use add node then saturate to vertex ws node and just use saturate again to vertex ws
These two operations affect the range of the original value slightly differently.
When you add 1, the -1 to 1 range becomes 0 to 2, you then saturate it and throw away all values above 1.
While when you just saturate, you are changing the -1 to 1 range to 0 to 1 right away by throwing away all values between -1 and 0. So the resulting masks that you use as the T input of the lerp are different.
Oh this is awesome, I was just about to experiment with Gouraud shading, thank you so much for starting this series! I have two questions:
-Do you know a good way to replicate the "toonify" effect used in the wind waker, showcased in this video? ua-cam.com/video/mnxs6CR6Zrk/v-deo.html
My approach would be to have the palette as a 255x1 texture parameter that would be set depending of the day/weather and sample it using the with the dot product result (the saturate(ndotl)).
-In older games vertex colors seem to be used instead of baking the lighting in the diffuse map, where would the multiplication of the vcolor happen in the shader your showcased? Just after the saturate(ndotl)?
Thanks again for this series, this is extremely helpful for people like me trying to replicate the older games' lighting! :)