• Advertisement

#### Archived

This topic is now archived and is closed to further replies.

# My Beginner demo - good fps?

This topic is 5706 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

## Recommended Posts

Hey. After learning the basics of 3D the past couple of weeks I finally have a small demo I''d like to share and get some criticism about (Bear in mind i literally learned how to plot a point in 3d space no more than 2 weeks ago if not less) Ok, so I have a torus .ASC file which gets loaded and is rotated at a constant rate (no interactivity) and uses diffuse lighting with gourad shading (finally got it down after ALL those posts!! Thanks to everyone who helped me out) So this exe uses DDRAW to get into 640x480x32 bit mode, but that''s all it does. Then I lock the backbuffer at the beginning of every frame and release it at the end, so the 3d is ALL pure software that I coded myself from reading massive amounts of articles and tutorials. So I wanted to know a few things. First and foremost, what are the FPS you are getting and your machines? Also, what is a good fps for something like this? Just having a spinning torus (I''m not sure how many vertices and faces there are but you can easily check in the asc file) with gourad shading. There is no clipping yet either. Sorry but I forgot to include the code in the zip and I dont have it with me here, I''m at work. But if anyone is interested in seeing the code just ask, you''re more than welcome to look through it. Ok, here''s the link, tell me what you think I''m a poet, and I didn''t even know it ;oP 3dTest Feel free to check out my web page if you want, http://pages.nyu.edu/~rba203 I await your repsponses - Rob ByteMe95::~ByteMe95()

#### Share this post

##### Share on other sites
Advertisement
cool. I got about 35 fps. it was pretty smooth though. p800, GeForce 16MG, 128MG ram. I was running about 3 or 4 other programs in the background, that might be why the frame rate was a little lower than it should be.

JoeMont001@aol.com www.polarisoft.n3.net

#### Share this post

##### Share on other sites
I recommend using 16-bit mode, not only will that be faster, but not all video cards support 32-bit mode(like mine).

*** Triality ***

#### Share this post

##### Share on other sites
I started off in 16b mode and it was working well, but I was having trouble drawing the right colors in that mode. I had the right code (I believe) that get sthe video mode "565" or "556" etc. and then a macro using that info RGB16() but it wasn''t working and i couldn''t be bothered to look into it. Besides I wanted to my jump into 3D look as nice as possible, and 16 million colors is a lot nicer than 65K from what I''ve seen.

I forgot one more thing in my original post, IF this frame rate is high enough (which im not so sure it is, it is only ONE object), what should i work on next on my quest to become a 3d guru? And when should I move on to D3D or opengl?

ByteMe95::~ByteMe95()

#### Share this post

##### Share on other sites
Wow, pretty cool.. seems like you''re working hard on this 3D thingy I haven''t had much time, just completed my VECTOR class and now I''m starting my Matrix class, and my 3D Object organization... I would like to organize it well so it would be easier for me when i start working on the engine, and use it as a framework for other engines that i do.. (or somethinb like that )... anyways, you said you were going to send me some ASC files... i never received any im waiting for those, so I can start coding my ASC loader...

What''s diffuse lighting?

Coule you give me some URLs of articles that you read on 3D programming? Thanks!

btw, Can I see the code that you have?,.. oh before i forget.. i got 20fps on my computer at work... it''s an NT, so it supports DirectDraw 3.x only... that''s why it''s so slow... ill try it out on my machine at home once i get there...

P.S. Apology for not coming back on time yesterday.. had to help out my father...

-------------------------------
That's just my 200 bucks' worth!

..-=gLaDiAtOr=-..

#### Share this post

##### Share on other sites
hey, it nice to see someone else taking the manual road to 3d.

yes it''s much faster using 16bpp mode. since you''re using ddraw try the function GetPixelFormat. it''ll give you everything you need. it gives you the bitmasks for each RGB component and it''s easy to calulate what you need.

if you want some code i''ll post it.

#### Share this post

##### Share on other sites
I had some code I found on the net that calculates the bitmasks using GetPixelFormat. I thought it was woring, but then i realized it didnt work for all values. Like if i put in RGB16(31, 31, 31) it would come up white, but if i did RGB16(15, 15, 15) it would be greenish instead of grey.

BTW, what color is the torus showing up for you guys? Is it yellow??? I have a feeling it wont be yellow on all machines.

I think I''ll stick with 32b for now cause it''s easier and the colors are much nicer. 255 shades per component sounds nicer to me than 32.

ByteMe95::~ByteMe95()

#### Share this post

##### Share on other sites
Hey Rob, could you answer my questions please? Thanks!

btw, about the color... Your RGB macro is not correct. I would guess that the pixel format is 565 on your machine when using 16-bit color. I had the same problem as you getting greenish, purplish type of color simply because my macro was wrong... but finally i found out what the problem was and here is what im using now (off the top of my head)

#define RGB16_565(r, g, b) (((r)>>3)<<11)|(((g)>>2)<<5)|((b)>>3)

Hope this helps!

-------------------------------
That's just my 200 bucks' worth!

..-=gLaDiAtOr=-..

#### Share this post

##### Share on other sites
Hey Gladiator.

Diffuse lighting is basic lighting, when you take the angle ofa light source with a face normal (for flat shading) or a vertex normal (gourad) to get the desired intensity of the light. It''s the most standard lighting from hwat I understand. After that comes specular lighting where you get the "shininess" effect, that takes the camera vector into account cause specular lighting is relative to the position of the viewer''s eye, or in this case the camera.

About the ASC files, sorry I completely forgot. You could actually use that torus asc file in the zip in my demo. But if you want more I told you where to find them, look for 3dica (REALLY easy to find!!) or zed3d (not so easy to find). But 3dica has the most asc files, like 7. Anyone else know where I can find more asc files? Or what 3d file format I should move on to that isn''t too complicated?

About the sites I''ve read, I can''t name any because I''ve pretty much read them all until I found myself reading the same articles. Take a look at flipcode tutorials, they''re pretty good. Also on the intro page of gamedev go to the side bar for "Hosted sites", there''s a link to a good 3d programming page.

And try to find zed3d. 115 pages on 3d coding in word format can''t ever be bad.

PS - no one answered me about the color of the torus, is it yellow for everyone?

ByteMe95::~ByteMe95()

#### Share this post

##### Share on other sites
Looks Nifty... i got 15 fps (sometimes 18) while running AOL and some other progs in the background. P2 350, 192MB Ram, ATI 3D Rage Pro.

Yes it was yellow for me too....

Nice work for pure software coding

40

www.databyss.com
www.omlettesoft.com

"Don''t meddle in the affairs of wizards, for they are subtle and quick to anger."

#### Share this post

##### Share on other sites
Thanks 40. As I was asking (in the subject of this post actually), is this fps good for software rendering? Meaning should i move on to bigger and beter things or should i work on optimizing this more? Just asking cause i have no idea what the acceptable frame rates for 3d stuff are.

And if it is acceptable, what do you 3d gurus suggest I move onto next?

Thanks for all the feedback guys

ByteMe95::~ByteMe95()

#### Share this post

##### Share on other sites
Thanks!

Yes, the color of the torus was yellow... okay.. for gourad shading you have to get the two vectors from the two vertices of a triangle, and then calculate the cross product of that... then you calculate the angle between that normal and the light vector and multiply the angle you get by the ambient color? okay if im correct so far (or almost correct) then how do you get the face normal? i heard something about finding the average of all the vertex normals.... well then, how do you find the AVERAGE of those normals? what does average mean? do you add all the X, Y and Z values and then divide them by 3? or what do you do? Thanks man! Gotta get serious about this stuff and get things moving on my side

-------------------------------
That's just my 200 bucks' worth!

..-=gLaDiAtOr=-..

#### Share this post

##### Share on other sites
Sounds like you got gourad shading and flat shading all mixed up.
For FLAT shading (each polygon is drawn in ONE color) you take 3 vertices (make sure their in clockwise order, they are in the asc file), make 2 vectors out of them::
simple, vec1 = vertex2-vertex1
vec2 = vertex3-vertex1
Normal = Cross(vec1, vec2)

Then you get the angle between that normal and your light vector, I personally multiply that by the color range (255 per component in 32b mode) and then I mutliply that by the color components, where each color comp is between 0 and 1

Then that''s your drawcolor for that polygon, just polyfill it with that color

That''s flat shading

Haven''t u dont flat shading yet?

Once you get that down I''ll be glad to explain gourad to you

ByteMe95::~ByteMe95()

#### Share this post

##### Share on other sites
I know what flat shading is and what gouraud shading is but I dont really know how to do it in 3D. I have never done flat shading on my 3D cube.. and ive done gouraud shading only on my landscape demo which doesnt use a light source, but uses the height map value as the color for that specific vertex...

okay, if what you just explained is flat shading, then how do you implement the gouraud shading.. how do you find the color for each vertex...

so for flat shading you do..

Normal = Cross(vec1, vec2)
Angle = Dot(Normal, Light) // angle now between -1..1

now how do you calculate the color intensity so it''s between 0 and 255?

and finally explain how gouraud shading works in 3D... Thanks man! You explain a lot better than those tutorials on the net

-------------------------------
That's just my 200 bucks' worth!

..-=gLaDiAtOr=-..

#### Share this post

##### Share on other sites
Hey Gladiator, thanks. I had to read like 30 articles before I could understand it myself, which is probably I''m better at explaining it cause I understand how the articles DONT.

Hey, why dont you throw a little help over here on how to render a landscape ;o)

Anyway, after you have the intensity value from -1 to 1, you multiply that by your color range (I multiply by 255 for each color). If it is less than 0 then make it =0.(I think if it''s <0 then the light isn''t hitting it).
so then that''s your color, the brighter it should be the closer it''ll get to 255.

Now for gourad, oh yes what a bitch of a coloring method indeed.
I hope for your sake you''re using an edge filler to draw your polygons, cause I wasn''t but so i had to change it over just for convenience (it wasn''t too hard actually).

Well, for gourad you gotta get a color for each vertex of the triangle and then interpolate between them, I''m sure you knew that.
to GET the vertex normals (which dont actually exist in true mathematics), you do SOMETHING like this:

  Vector vNorm; //vertex normalint sum;for(i=0; i = vNorm; //VNormals should be an array of vectors to hold your Vertex normals }}

Now dont take me word for word on that code, it''s something like that. I''m especially not sure if i did the end right, when you divide by sum.
Anyway, the overall point is you go to every vertex. Then for every vertex loop through every face. If the face has a reference to that vertex, add the face''s normal to your vNorm.
Then when you''re done going through all the faces, divide by the number of face normals you added on and normalize.

Then to gourad shade look up the vertex normals and interpolate them (That was by far the hardest part for me, but it wasnt that bad)

Ok, if u need more info just ask
- Rob

ByteMe95::~ByteMe95()

#### Share this post

##### Share on other sites
Okay, FLAT shading is alright now... but.. there's something i dont understand about gouraud shading... why do you have to go through all the vertices in an object in order to find out which one exist and which doesnt... you have the indecies of your vertices in your face structure.. right? well can you just do..

Vertices[Face ].Normal... blah blah...

??

And do you have to calculate the vector normal for each vertex only once in the beginning and save it for later use when doing the shading? or? do you have to calculate it everytime you do the shading (if the object is being transformed[translated, rotated, etc...])? If your VECTOR normals are structures, how do you divide by an int? do you have an operator overloader for /, +, etc? when you do vNorm = vNorm+fIndex[j].Normal; what does that do? does it add the x, y, and z values of both vectors to each other and return a new vector?

same thing for when you do vNorm = vNorm/sum;, does that divide the x,y and z values accordingly?

quote:

Then to gourad shade look up the vertex normals and interpolate them (That was by far the hardest part for me, but it wasnt that bad)

That's easier for me than finding the vertex normals

Okay let's see if i understand... you get a Normal vector for each vertex in the face, right? (or simply go through all the vertices in an object, calculate the normal and save it for later use)... then for each face, you get the vertices' normals, add their X, Y and Z values, and divide by the number of vertices (usually 3 if you're using triangles) right? is that correct? am i on the right track here? waiting for your responese

-------------------------------
That's just my 200 bucks' worth!

..-=gLaDiAtOr=-..

Edited by - Gladiator on July 24, 2000 3:35:26 PM

#### Share this post

##### Share on other sites
Nice one.
I got 21-25 fps.
I have a p-3 500, Matrox G400 Max 32mb, 128 mb ram.
And yes, it was yellow.

#### Share this post

##### Share on other sites
Just to clarify something, the reason I ask if it''s yellow is because when i use windows RGB() function, it switches the red and blue (at least on mycomp). So i made a definition
#define _RGB(r, g, b) RGB(b, g, r)
to fix that problem, but i thought it might just be on my machine

anywho, gladiator, you''re still a bit off on this concept.
The way i have it set up is I have a vertex list
3DV *Vertices; (where 3DV is my vector struct)
then when i add vertices it goes into that (*dont forget to allocate mem)

so I can''t simply do vertices[face], cause it doesnt go by that, there could be 70 vertices and 25 faces, so by doing vertices[face], you''ll never get all the vertices and it''s just plain wrong.

Then i have Face *fIndex; which is an index of faces I have. Every time i add a face it goes into that list, where Face is basically defined as
struct
{
int V[3]; //LOOKUP VALUES!! into int *Vertices;
3DV Normal;
etc...
}

so let''s say i have 70 vertices, and one triangle is made up of vertices 3, 24, and 65, then to get the vertices i would do Vertices[fIndex[Poly#].V[0]].x for the x value of the first vertex of Polygon # whatever.

To get gourad you have to find what faces are SHARING a vertex.
So let''s say for vertex 43, there are 6 polygons that use vertex 43, so you have to take the normal of those 6 faces, add them up and divide by 6 (I THINK Divide by 6, pretty sure) and then normalize. That gives you the average color at that vertex based on the normals of all the faces that are using it.

then to draw a gourad polygon, to get the color of a vertex you do

ColorV0 = 255*Dot(VNormals[fIndex[Poly].V[0]], LightSource);
ColorV1 = 255*Dot(VNormals[fIndex[Poly].V[1]], LightSource);
ColorV2 = 255*Dot(VNormals[fIndex[Poly].V[2]], LightSource);

It''s all a little complicated the way i have it set up, but once you get it you get it.

Now that i explained how i have things set up, look at my last post with the code to find the vertex normals, maybe it''ll make more sense.
If not, just post again!
:o)
- rob

ByteMe95::~ByteMe95()

#### Share this post

##### Share on other sites
I was confused by the names you used for vectors and stuff...

yeah, now that you said you gotta find the average of the normals sharing a vertex, that makes a lot more sense i thought you had to take the average of the vertices in the same face, but all vertices have the same normal (the face normal) so that didnt make any sense to me.. and i was pretty confused as you saw

anyways... you didnt tell me about the operator overloading... you divide the x, y and z values, and then divide them by the number of faces sharing the same vertex.. right?

about the vertices[face] thing, i meant to say vertices[faces.v[j]] but now that you said you gotta find the faces being shared by the same vertex, it makes clears things up quite a bit... isnt there an easier way to find which faces are shared by a vertex instead of going through each vertex? that loop takes A LOT of time, so i think that''s what''s slowing things down so much.. the shading and stuff...

if something i said sounds crazy just correct me.. okay

-------------------------------
That's just my 200 bucks' worth!

..-=gLaDiAtOr=-..

#### Share this post

##### Share on other sites
Hey Gladiator, This is my 100 post to gamedev, so I''m assuming my tag is gonna change after I post this, I wonder what it''s gonna be.

About operator overloading, yes, operator overloading, do it, it makes things easier

so VNorm = VNorm/sum would call the operator overloader and would actually be doing

VNorm.x = VNorm.x/sum;
VNorm.y = VNorm.y/sum;
...

I dont know why you asked if you divide the x, y and z values, i didnt understand that but i dont think it''s right.

I think this post is some kind of record for number of replies in one day, look when I started this post, some time this morning :o)

I''m gonna go look for a good texture mapping tutorial
- Rob

ByteMe95::~ByteMe95()

#### Share this post

##### Share on other sites
sweet, just became a zealot :o)

ByteMe95::~ByteMe95()

#### Share this post

##### Share on other sites
I get about 25 frames per second (while online) with a max of 27 fps on my P3-450 with 64Mb RAM and Diamond Viper V550. And yes, it''s yellow

#### Share this post

##### Share on other sites
Just wanted to thank everyone for their quick replies and framerates

But back to my ORIGINAL question, are these frame rates good enough to render only ONE object?? If not, what fps should i aim for to render this bad ass torus?

ByteMe95::~ByteMe95()

#### Share this post

##### Share on other sites
Quote 1:
quote:

VNorm.x = VNorm.x/sum;
VNorm.y = VNorm.y/sum;
...

Quote 2:
quote:

divide the x, y and z values, i didnt understand that but i dont think it''s right.

Quote 1 and Quote 2 are exactly the same and you didn''t know what I meant? You divide the X, Y and Z values by sum... that''s what i meant Anyways, I think I know what''s going on now.. wow.. wanna be my teacher? This 3D stuff is pretty confusing...

-------------------------------
That's just my 200 bucks' worth!

..-=gLaDiAtOr=-..

#### Share this post

##### Share on other sites
Well these framerates are *good* considering that it is running in 32bpp. I would suggest trying again with 16bpp, it may be tricky to get your colours right, but many machine don''t support 32bpp and you''d probably double your framerates! Umm... I''d say that it''s actually quite nice being software rendered but w/ HAL I''ve had demo''s / 1000''s of polygons and running @ like 695fps, so it''s always best to use Hardware when you can (Using a Graphics API, see forum faq for why and why not to choose DirectX or OpenGL)

See ya,
Ben

P.S. I got 30fps on a PIII 533Mhz w/ 128 mb ram and a Voodoo3 3000 16mb AGP card... w/ acceleration off (I don''t think your using acceleration though so it doesn''t matter)

#### Share this post

##### Share on other sites

This topic is 5706 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

This topic is now closed to further replies.

• Advertisement
• Advertisement
• ### Popular Tags

• Advertisement
• ### Popular Now

• 11
• 10
• 10
• 11
• 12
• Advertisement