How to do gouraud shading?

I have been trying to figure out how to make a gouraud shading material node setup to mimic an older look in my game. I am not talking about regular vertex shading, I specifically mean gouraud. I read in an old post back from 2015 where a guy by the username “CaptainScience” had mentioned this:

I am not quite sure how to do this in 4.24, or really any version of unreal for that matter. I am still pretty new to this, so excuse me if I don’t quite understand some of the terminology, or node names. You may have to give a screenshot of the node graph as you explain it.

1 Like

Anyone? Please, help.

I really need help with this.

Hi, those are the shading models you have in unreal engine: Shading Models | Unreal Engine Documentation

So you don’t have a gouraud shading model. Therefore it seems to me that you’ve got two options:

(1) Start from one of the existing shading models and use the material editor to “fake” the look of gouraud shading.

(2) Write your own shading model and add it to the existing list.
[HR][/HR]
I’ve got no idea how to do (2), except that it will involve C++ and hlsl, but you can search for something like “ue4 own shading model”, but since you said “I am still pretty new to this”, seems to me that (2) is not an option for you.
As for how to do (1), you might wanna watch some learning videos on epics learning tab about materials Unreal Online Learning - Unreal Engine to get a better feeling for those.

If you’re interested, the most up-to-date tutorial I’ve found is here: Unreal Engine 4 Rendering Part 6: Adding a new Shading Model | by Matt Hoffman | Medium

Unfortunately it requires modifying the engine source and a decent understanding of shader programming, and I’d imagine you’d have to force the engine to use forward rendering to get the per-vertex lighting you’re looking for (deferred rendering can only do per-pixel lighting).

I have no idea why you would want to ever do this, the default shading absolutely wrecks all the examples i can find online, but faking it via unlit has and will always be an option.

But wouldn’t unlit disable all lighting and shadows? I need gouraud shading for a project aiming to recreate an older style game. I have been told you can do it in a material node graph but can’t find any solid information on how to do it. Every tutorial about this is only for “PS1” style flat shading, that doesn’t work well for my purpose as each polygon is clearly visible as if no smooth shading was used at all. The visual style I am targeting is that of 6th-gen consoles like the PS2 and Gamecube. Those consoles only really used gouraud shading and not a more advanced phong shader like we have now. But they also aren’t “flat” looking like a PS1 or N64.

I quoted a post from back in 2015 that gave a vague explanation, but no real implementation of the node graph. I am looking for a good explanation of the nodes I will need to do what was said in that post.

Oh, then use lit with specular turned off, fake it there, thats what im doing for stylisation.

You might get more help if you would post a link to that forum discussion.

But basically you would need to switch to the forward renderer instead of the default deferred one. In forward shading you can access the lightning information per vertex.
As far as I understand gouraud shading, it linear interpolates between the lightning of the vertices. Therefore in the pixel shader you would take this lightning information of the vertex shader (by plugging it into a custom UV then you can use that in the pixel shader using the “texcoord” node with the correct index) and then do the gouraud shading lighting with that.

But you would have to do the implementation yourself, since nobody who has not actually implemented it can give you a finished graph and even then it would be not useful for learning. If you got a problem in your work in progress you can post an image of what you have so far and the people here can try helping you from there. [HR][/HR]

For understanding of how the material editor and shader works, what nodes there are, how to use them, workflows,… you might wanna watch the learning videos from epic games (top bar of this site -> Learning & Support -> Online Learning, but it will take some time to work through all the material learning videos but in the long run you will save time).

So you might wanna work trough the “Master Materials Learning” course and then after you’ve finished it, try implementing the gouraud shading again.

Do you use a “light material”? I heard that it is better to do it that way instead of in the materials for all the objects in the scene. Makes sense, and it seems light materials are the only way to really get the light direction and intensity mentioned in that quote I was talking about. Only problem, I can’t find any “light intensity” node or similar. Unless there is a way to pull that from the light vector?

No, i dont even know what that is.

I think it is called a “light function”. Essentially a material nodegraph linked to a light source. Like, you could make a light source project a pattern with one I think. I read that a light function is you would do a shader like this. But I am still foggy on the exact implementation. I figured out how to get per-vertex shading, but can’t figure out the “smoothing” of it across the vertex. Like, my current shader looks like flat shading but I am trying to now “blend” the light so it looks like gouraud.

Finally got it working. Still got a few problems, but I will be sorting them out shortly. If anyone is looking for similar shading, I can link you the shaders I am working on.

Hi, i need help with gouraud shading, could you link me or share me the shading you worked on? Please.

Here is a link to my test project that contains the shader and a test model to see it in action.

Hi, @! Currently, I’m learning how to do different shading in UE. I’ve some questions about your implementation.

  1. Why the object is getting bright on all surfaces when I approach them? Is it because you used your own lightning instead of using directional light?
  2. Why did you use a new lightning source instead of using the directional or point light source? (I thought the reflection should depend on the angle of the light source in the environment instead of using the artificial light).

Thank you

Well, this current implementation is done entirely in nodes and has no custom code either in C++ or HLSL. So in order to replicate the vertex lighting of a gouraud shader, I had to utilize the emissive input and a custom UV. It sort of fakes the vertex lighting and currently can’t take actual light input. Instead, it uses the position of the player (but can be changed to any actor in the map) as the position of the fake “light source”. It also can only use one actor for input. I am still working on improving it. But currently, my implementation is more or less a prototype, or “proof-of-concept”. I might just have to add my own shading mode if this technique doesn’t work out.

I’m very interested in what you’re trying to do here. I’ve been wanting to make a retro [Zelda Inspired] RPG for Oculus Quest for a while now.

I just started toying around with vertex lighting from the ps1 style, the market asset is here
(Retro Graphics in Visual Effects - UE Marketplace)
I tore out all the low res effects since I really just want the lighting.

Just stumbled across this concept of Gourad Shading and now I’m wondering if that would be useful as well.