Download

Vertex Color and Face Color

Hi all,

maybe this is a very stupid question, but anyway…
I was wondering if there’s any way to define geometry data as color, that instead of being treated as per-vertex would be treated per-face.
Basically what I’m after is a material capable of rendering clear, uniform color per face; these colors being geometry data (not textures).
So I want an effect like this:
polybreno_800.jpg

Rather than the classic smoothly interpolated vertex color ones:
Manual-VertexPaint.png

Possible?

you could split all edges and then the triangles could be colored flat. but this will obviously increase your vertex count tremendously. i do not think that there is another way using just vertex colors. alternatively you could just split the triangles in the UVs and map them to individual pixels of solid color. but that should probably be automated in some way :smiley:

Yep, splitting geometry doesn’t seem like a feasible solution…

I thought about doing it with textures, but seems like an overkill to me.
Also, I doubt in the distance, if filtering kicks in, those texture-based uniform colors would not blur&bleed neighboring values, while I want a sharp result.

Something else I was thinking is to rely on some sort of surface parametrization similar to what UVs are, where you can split vertices in face-vertices, ad assign a color-coded value to them.
Quite a bit of over-engineering for something so simple, I guess…

Any other ideas?

I don’t see any way to get the effect in the first image easily without splitting the edges -if you examine it closely, the colors the artist chooses for each poly are meant to simulate the amount of light hitting the polygon. With split edges you should, in theory be able to get this effect in the shader natively without relying on any colors pre-baked in. This would have the advantage of being dynamic in terms of lighting.

The only tricky part about doing this in the shader, is your source art shows a really distinct color shift based on the amount of light hitting the object (you can see how fast it falls off to purple in the shadows on the right). If you check out the non-realistic rendering content example from Epic there’s a great example of how to do this in the shader though. Only slight complication is that since it’s ‘faked’ you need to get the position of your key light in the shader. It works great once you set it up though, and I think it should be able to give you the effect you are after.

I wouldn’t personally worry too much about the increased poly count unless you’re just going nuts with it since the effect depends on low poly models to start with you’ll prolly still end up well below the poly budget for your typical character model even with the edge splits. Highly dependant on your target platform though I guess.

But I want this a a pre-lighting effect, to be displayed as you’d display textures, not as a lighting technique.
On the lighting side you can achieve this just by changing the smoothing groups, right?
That’s not what I mean, I want for the colour of my surface to be uniform per-face.

Not sure what the most optimal workflow for this type of art would be, but it’s not a big issue to get some solid vertex colored mesh into UE4. I just made every edge a hard edge and colored the faces by hand.

If you are splitting UVs, it’s basically the same as splitting an edge or creating a hard edge performance wise, so both options will have similar impact.

You can achieve the flat shading by plugging the following in your material’s Normal slot. Also turn off tangent normals in the material properties for this to work:
lVGoaTY.jpg

Thanks everyone, I’ve got a few thing to test out.

Cheers!

ZacD is correct regarding the cost of splitting any aspect of those faces (smoothing groups, UVs, vertex colors, etc.). To the video card rendering it, each separation between two faces means duplicating the vertices. Contrary to what most modeling packages will display as their vertex counts, adding a smoothing group split or a UV split will double those vertices when it’s time to render them to your monitor.

So, splitting each face is going to be the same cost regardless of whichever method you use (split in UVs with flat color swatches or split in the model so each face can be manually colored).

With that in mind, though, I know 3DSMax (and likely other modeling packages) allow you to assign vertex colors by face, and I believe Unreal reads this and imports it correctly.

yet again requiring the vertices to be split. so there really is no way of getting around splitting the verts for what you want and you just have to figure out what workflow is the most comfortable for you.

Thank you very much for this one, awesome. Unfortunately there are issues with the light using the World Positions of the Pixels. I played with it a bit, and transforming the the locations into local space solve the issue with the light.

DXX_DDY.jpg

A must have shader for any low poly game. As the guys above mentioned already, importing and object with flat faces explodes the poly count. This way you can have smoothed objects that still render low poly.

Any way to achieve the same result in Unlit?