How to make DP render flat-shaded?
Moderator: InsideQC Admins
29 posts
• Page 2 of 2 • 1, 2
gl_smoothmodels looks bad though. It applies one vertex's colour over the whole triangle. But you don't want the colour of a certain arbitrary vertex, you want lighting according to the triangle normal. glShadeModel is probably just another one of those holdovers from the 1991 days of OpenGL that nobody should ever use (like the old "lighting" functions).
By the way, I checked and the QWalk argument is "-facet", not "-facetize". And I'm not sure if it's available in the build of it, you might have to compile it from SVN. And for some reason when I processed and resaved armor.mdl it lost the rotate flag... so maybe I should take a look into QWalk for the first time in months.
I'll also get on that MDL utility today.
By the way, I checked and the QWalk argument is "-facet", not "-facetize". And I'm not sure if it's available in the build of it, you might have to compile it from SVN. And for some reason when I processed and resaved armor.mdl it lost the rotate flag... so maybe I should take a look into QWalk for the first time in months.
I'll also get on that MDL utility today.
F. A. Špork, an enlightened nobleman and a great patron of art, had a stately Baroque spa complex built on the banks of the River Labe.
- Sajt
- Posts: 1215
- Joined: Sat Oct 16, 2004 3:39 am
how to not mark triangles to not smooth lighting over edges: create a separate copy of the vertex just for that triangle.
Do NOT merge duplicate triangles.
And then hope that the engine doesn't merge identical verticies...
Yes. This means triangles will no longer have any neighbours which will make stencil shadows slightly slower.
I don't know what tools there are that allow splitting them up.
-facet sounds appropriate.
glShadeModel(GL_FLAT) is useful for software implementations, or where you're too lazy to specify different colours for each vertex.
like so much in the world today, it sucks.
Like sajt says, in this case, it'll pull out the colour of a vertex facing in one direction and assume the entire triangle should get the same lighting. But that vertex direction is the average direction of all the triangles that are connected to that vertex, not just the current triangle, so will give random colours on an otherwise regular cube.
Do NOT merge duplicate triangles.
And then hope that the engine doesn't merge identical verticies...
Yes. This means triangles will no longer have any neighbours which will make stencil shadows slightly slower.
I don't know what tools there are that allow splitting them up.
-facet sounds appropriate.
glShadeModel(GL_FLAT) is useful for software implementations, or where you're too lazy to specify different colours for each vertex.
like so much in the world today, it sucks.
Like sajt says, in this case, it'll pull out the colour of a vertex facing in one direction and assume the entire triangle should get the same lighting. But that vertex direction is the average direction of all the triangles that are connected to that vertex, not just the current triangle, so will give random colours on an otherwise regular cube.
- Spike
- Posts: 2892
- Joined: Fri Nov 05, 2004 3:12 am
- Location: UK
Seems odd to me that this spawns such complicated discussion. I've always viewed it as faceted illumination is simpler, and smoothed is a step further, requires additional code and computing or whatever. I remember modeling in Milkshape3D on my old Pentium 200mhz and having to use flatshaded because the smoothed rendering was too slow.
Yes, I'd prefer if LH or someone else on the team simply reinstated or added this, it can't possibly be a hard thing to do :S
I didn't manage to find another cvar which did the same thing in DP.
Here's an example, the image is even called flatshaded.jpg
I'd obviously want it to still be textured just like normally. Flatshaded doesn't have to mean vertex-colored or whatever.
Yes, I'd prefer if LH or someone else on the team simply reinstated or added this, it can't possibly be a hard thing to do :S
I didn't manage to find another cvar which did the same thing in DP.
Here's an example, the image is even called flatshaded.jpg
I'd obviously want it to still be textured just like normally. Flatshaded doesn't have to mean vertex-colored or whatever.
I was once a Quake modder
-

Urre - Posts: 1109
- Joined: Fri Nov 05, 2004 2:36 am
- Location: Moon
The way hardware rendering works (using vertex arrays) is, understandably, not built with fast flat-shading in mind.
A triangle is defined as three vertex indices. A vertex can have attributes such as position, colour, normal, etc. The triangle cannot contain separate "vertex position" and "vertex colour" indices. When you run a shader, first the vertices are set up, then the fragment shader is run interpolating vertex values across triangles. It's not set up for "triangle attributes".
The only way it could be implemented on the engine would be:
- To split the vertices up at load-time, the same thing that an offline model tool would do, resulting in 3x as many vertices as triangles.
- Draw models not using vertex arrays, which is much slower.
- Possibly some complicated shader trick which could hack in "triangle attributes", but at the cost of speed (both batching overhead and fillrate would suffer).
- Maybe there is some brand-new feature in DX10 or DX11 which allows triangles to have indices to different attributes? I don't know if it would be worth it, if they did...
The fastest solution is the brutest: to give each triangle its very own vertices. Even if those vertices are in the same position as other triangles' vertices, they can have different colour/normal attributes. Yes, you end up with more vertices than you think you should need, but flat-shaded games are usually low-poly anyway so it shouldn't matter.
A triangle is defined as three vertex indices. A vertex can have attributes such as position, colour, normal, etc. The triangle cannot contain separate "vertex position" and "vertex colour" indices. When you run a shader, first the vertices are set up, then the fragment shader is run interpolating vertex values across triangles. It's not set up for "triangle attributes".
The only way it could be implemented on the engine would be:
- To split the vertices up at load-time, the same thing that an offline model tool would do, resulting in 3x as many vertices as triangles.
- Draw models not using vertex arrays, which is much slower.
- Possibly some complicated shader trick which could hack in "triangle attributes", but at the cost of speed (both batching overhead and fillrate would suffer).
- Maybe there is some brand-new feature in DX10 or DX11 which allows triangles to have indices to different attributes? I don't know if it would be worth it, if they did...
The fastest solution is the brutest: to give each triangle its very own vertices. Even if those vertices are in the same position as other triangles' vertices, they can have different colour/normal attributes. Yes, you end up with more vertices than you think you should need, but flat-shaded games are usually low-poly anyway so it shouldn't matter.
F. A. Špork, an enlightened nobleman and a great patron of art, had a stately Baroque spa complex built on the banks of the River Labe.
- Sajt
- Posts: 1215
- Joined: Sat Oct 16, 2004 3:39 am
http://www.icculus.org/qshed/fixmdl/FixMDL-0.1-ALPHA.zip
Urre, try this pre-release version of FixMDL. It has a "facetize" feature which should work. Although I haven't tested it much (that is, more than once, right before uploading).
Urre, try this pre-release version of FixMDL. It has a "facetize" feature which should work. Although I haven't tested it much (that is, more than once, right before uploading).
F. A. Špork, an enlightened nobleman and a great patron of art, had a stately Baroque spa complex built on the banks of the River Labe.
- Sajt
- Posts: 1215
- Joined: Sat Oct 16, 2004 3:39 am
Hehe. The preferable thing would be to half-flat-shaded... like select in a modelling app which edges should be "hard" and which not (I think most programs call this smoothing groups). Then for example, for a wheel, the flat part around the tire (with the tread) could be smooth, but the seam between the sides and this could be hard...
F. A. Špork, an enlightened nobleman and a great patron of art, had a stately Baroque spa complex built on the banks of the River Labe.
- Sajt
- Posts: 1215
- Joined: Sat Oct 16, 2004 3:39 am
Sajt wrote:Hehe. The preferable thing would be to half-flat-shaded... like select in a modelling app which edges should be "hard" and which not (I think most programs call this smoothing groups). Then for example, for a wheel, the flat part around the tire (with the tread) could be smooth, but the seam between the sides and this could be hard...
True, that'd be cool. No can do with good ol' QME :/
I was once a Quake modder
-

Urre - Posts: 1109
- Joined: Fri Nov 05, 2004 2:36 am
- Location: Moon
To tell you the truth, I had planned for an edge-faceting feature in the QWalk model viewer. You would be able to just select and deselect edges with the mouse to make them sharp or smooth. It would not be difficult (still a day's work though), you don't need any UI or 2D views. But I'm kind of sick of this sort of thing by now...
F. A. Špork, an enlightened nobleman and a great patron of art, had a stately Baroque spa complex built on the banks of the River Labe.
- Sajt
- Posts: 1215
- Joined: Sat Oct 16, 2004 3:39 am
If you were looking to make sleek, almost vector-graphic-like games, as it looks like your car game is going to be, then MDL seems like the wrong choice... just because it will screw with nice, smooth shapes and round curves. 
F. A. Špork, an enlightened nobleman and a great patron of art, had a stately Baroque spa complex built on the banks of the River Labe.
- Sajt
- Posts: 1215
- Joined: Sat Oct 16, 2004 3:39 am
29 posts
• Page 2 of 2 • 1, 2
Who is online
Users browsing this forum: No registered users and 1 guest
