I’m not sure if this is a shader question or not, but either way:
Is there a way in Unity to get flat shaded fog?
That is, I’ve performed the first part of this trick in my project to get flat shaded untextured polygons:
But as with point light, any application of fog gets me smooth shading (only thing not producing smooth shading that I’ve found so far is directional light).
All I want is polygons further from the camera to be more colorized by the fog.
Alternatively, a fall off light source that I can attach to the player which also flat shades would be acceptable.
I don’t think I understand what you mean with flat shaded fog, because I automatically associate the word ‘fog’ with a volumetric/ depth-based effect, like standard fog.
Or are you saying that your model suddenly switches back to shared vertices when you enable fog?
If you have a certain visual effect in mind, perhaps you could create a mock-up of the effect in a program like Photoshop, so it’s easier to see what you mean.
What I had in mind when I created this topic, was the look of the top screenshot, but the effect of “fog” in that polygons get darker the further away they are from the camera.
Do you mean the polygons being darkened as a whole (every fragment by the same amount), in stead of every fragment being darkened independently based on distance from the camera? I’m afraid any per-polygon or per-triangle effect like that would have to be created on the CPU.
Vertex shaders only know about individual vertices, not their neighbours. And fragment shaders only know about the data of their position, which is interpolated data from 3 vertices combined, they don’t know about those vertices individually.
By the way, if you’re wondering why it looks more faceted in the editor than in the game view: I’m pretty sure that’s because of the artificial headlight of the scene view camera.
That artificial headlight seems to the exactly the same as directional light, which so far is the only thing I’ve discovered so far that can flat shade.
Yeah, it’s a directional light, as far as I’m aware.
Ahhh, I think you’re talking about the specular reflections you get. All the pictures you posted use flat shading, they just don’t really look that way because the lighting on each of the surfaces is too similar. You could try to create a custom lighting model that shows more extreme changes in lighting, for smaller changes in light angle. Something less realistic.