Flat shading for models!!!

Posted By: Impaler

Flat shading for models!!! - 08/25/08 11:03

Hi all,
being a game artist and not a shader programmer, I just want to make my models look good in the game, and often that requires them to be flat(solid) shaded. By default gamestudio blends the normal values to create a smooth shaded model, but for a vehicle or building, obviously you want to make it look like it's made of metal or cement, not jelly. The only way around this I have found is to seperate the desired face (so there are no normals around it to blend), but for a cube, this triples the amount of vertices besides being very time consuming. Do any of you have a shader/material(whatever!) that I can apply that will give me these hard edges?
Posted By: Slin

Re: Flat shading for models!!! - 08/25/08 13:55

As far as I know, this isnīt possible but if anyone knows it better, please post how to do it smile.
Posted By: ventilator

Re: Flat shading for models!!! - 08/25/08 14:08

you can't control this for individual edges with a material. you can only enable or disable gouraud shading for the whole model.

if you need control over single edges then splitting vertices is the only way. the increased vertex count doesn't matter at all. for directx mesh buffers the splitting has to be done anyway internally. there is no other way of achieving hard edges with directx (and also opengl).

but of course this can be an annoying workflow in some software. ideally the mdl exporter should care for this and convert smoothing information to correctly split up geometry.

blender handles this very well. if you use the edge split modifier you can define the smoothing like you want and everything will end up in gamestudio correctly.
Posted By: Altimeter

Re: Flat shading for models!!! - 08/25/08 17:48

Ventilator is right. Once I had the same problem. I applied a flat shader, but it did not solve the problem. You really have to accept some double vertices to split the edges.
Posted By: mpdeveloper_B

Re: Flat shading for models!!! - 08/25/08 18:26

you can apply a shader to only certain parts of a model, just use a seperate skin and apply the fx file to the skin in med. That way only certain parts would have gourad shading, but i'm not sure it would make the hard edges you want, it might even look a bit odd when rendered...
Posted By: Impaler

Re: Flat shading for models!!! - 08/26/08 06:05

Quote:

you can only enable or disable gouraud shading for the whole model.

Ventilator, how do you switch gouraud shading on or off for the whole model then? That's really all I'm interested in for now - I do use blender for all my models and if I need only parts of it smooth shaded I can seperate those manually, but it is much more vertex count intensive to separate every face of a complete model. Just knowing how to turn off gouraud shading for the whole model would be great.
Posted By: ratchet

Re: Flat shading for models!!! - 08/26/08 17:07

Under Blendre it's pretty simple :
-Select your object
- Enter in edit mode
-Just select the faces you want to smooth
- then having the mouse anywhere in the 3D view :
press "Space"
It will onpen the menu , then choose the submenus :
- Edit -> Faces -> Set smooth
or if you want some faces (or all) to be not smooth but solid:
Choose
- Edit -> Faces -> Set Solid


If you want a model to mix smooth and Hard edges in game,
the way to go is like already said here:
Apply one texture on the faces to be smooth and another
on the face to keep solid, then apply two different shaders
to the two textures.


Posted By: ventilator

Re: Flat shading for models!!! - 08/26/08 18:58

you simply have to set the "ShadeMode" state to "Flat" instead of "Gouraud" in a fixed function material.



in blender it's much better to use "set smooth" on everything and then use the edge split modifier to define smoothing.

"set smooth" and "set solid" don't offer good enough control over smoothing and many exporters won't handle it correctly.
Posted By: mpdeveloper_B

Re: Flat shading for models!!! - 08/26/08 19:24

@ventilator: thanks, i couldn't remember it myself...

@Impaler: so basically, put this in a fx file:

Code:
technique flatshade
{
	pass p0
	{
		shademode = Flat;
	}
}


then as before mentioned apply that fx file to a skin that is applied to the normals that you want to be flat shaded, or to the main skin of the model itself.
Posted By: Impaler

Re: Flat shading for models!!! - 08/27/08 03:52

Thanks, mpdeveloper_B,
that's exactly what I was looking for smile
© 2024 lite-C Forums