Results 1 to 31 of 31

Thread: Rendering

  1. #1

    Thread Starter
    Not NoteMe SLH's Avatar
    Join Date
    Mar 2002
    Location
    192.168.0.1 Preferred Animal: Penguin Reason for errors: Line#38
    Posts
    3,051

    Rendering

    In my game i'm rendering many different objects. To render my particles i load some into the vertex buffer, then render them and so on.

    But to render my triangles, because they're all orientated differently (different rotation and size) i can't render more than one at once.
    Is there a way i can streamline my rendering without manually doing the sizing and rotation so i can put them in the buffer together as a triangle list?

    Cheers for any help.
    Quotes:
    "I am getting better then you guys.." NoteMe, on his leet english skills.
    "And I am going to meat her again later on tonight." NoteMe
    "I think you should change your name to QuoteMe" Shaggy Hiker, regarding NoteMe
    "my sweet lord jesus. I've decided never to have breast implants" Tom Gibbons
    Have I helped you? Please Rate my posts.


  2. #2
    So Unbanned DiGiTaIErRoR's Avatar
    Join Date
    Apr 1999
    Location
    /dev/null
    Posts
    4,111
    That's what the Z-Buffer is for?

    http://www.directx4vb.com/
    Last edited by DiGiTaIErRoR; May 18th, 2004 at 12:02 PM.

  3. #3

    Thread Starter
    Not NoteMe SLH's Avatar
    Join Date
    Mar 2002
    Location
    192.168.0.1 Preferred Animal: Penguin Reason for errors: Line#38
    Posts
    3,051
    Thanks for the reply, but I thought that the zbuffer was a buffer that held a pixel's distance from the camera, and was used to decide whether to render any subsequent pixels.
    Not sure how this helps me to put my objects in the vertexbuffer in such a way as to allow me to render several at once.

    BTW, i'm using DX9 in C++, and i don't know which part of dx4vb you were directing me to.
    Quotes:
    "I am getting better then you guys.." NoteMe, on his leet english skills.
    "And I am going to meat her again later on tonight." NoteMe
    "I think you should change your name to QuoteMe" Shaggy Hiker, regarding NoteMe
    "my sweet lord jesus. I've decided never to have breast implants" Tom Gibbons
    Have I helped you? Please Rate my posts.


  4. #4
    So Unbanned DiGiTaIErRoR's Avatar
    Join Date
    Apr 1999
    Location
    /dev/null
    Posts
    4,111
    Sorry, vertex buffer. I'm rather new to 3D programming.

    http://216.5.163.53/DirectX4VB/Tutor...R_Lesson05.asp

    Constructs a VBuffer with several vertices.

  5. #5
    Ex-Super Mod'rater Electroman's Avatar
    Join Date
    Sep 2000
    Location
    Newcastle, England
    Posts
    4,349
    But Vertex buffers are generally used to only hold one object. If the objects won't get rotated indipendantly then you can put them all in one buffer butif you plan to move (or rotate) one triangle and not the others then you must use seprate buffers.
    At least I've bnever seen it anyother way
    When your thread has been resolved please edit the original post in the thread ()
    and amend "-[RESOLVED]-" to the end of the title and change the icon to , Thank you.

    When posting Code use the [VBCode]Code Here[/VBCode] tags to be able to use the code highlighting.

  6. #6

    Thread Starter
    Not NoteMe SLH's Avatar
    Join Date
    Mar 2002
    Location
    192.168.0.1 Preferred Animal: Penguin Reason for errors: Line#38
    Posts
    3,051
    Ok, i thought this was the case. Thanks for the clarification.
    Quotes:
    "I am getting better then you guys.." NoteMe, on his leet english skills.
    "And I am going to meat her again later on tonight." NoteMe
    "I think you should change your name to QuoteMe" Shaggy Hiker, regarding NoteMe
    "my sweet lord jesus. I've decided never to have breast implants" Tom Gibbons
    Have I helped you? Please Rate my posts.


  7. #7
    Retired G&G Mod NoteMe's Avatar
    Join Date
    Oct 2002
    Location
    @ Opera Software
    Posts
    10,190
    Actually you can have more then one object in a vertex buffer. I have no idea why, but NVIDIA and ATI have stated that it is faster to have few big vertex buffers then many small ones. Not sure how they mean you should implement this, but I guess it is easier to optimize it in the drivers this way. Becuase if you are using vertex buffers and index buffers, then it is up to the driver to optimize the rendering.

    I guess it is has something to do with the offset as the parameter of the vertex buffer, and how yoy have aranged the index buffer to get this done. But as I said, I have no idea how...

  8. #8
    Ex-Super Mod'rater Electroman's Avatar
    Join Date
    Sep 2000
    Location
    Newcastle, England
    Posts
    4,349
    Yeah I've seen that too but the thing is you'll still be making a pass for each object. I suppose the V Buffer only gets loaded once. And using Index Buffers would make that even better.
    When your thread has been resolved please edit the original post in the thread ()
    and amend "-[RESOLVED]-" to the end of the title and change the icon to , Thank you.

    When posting Code use the [VBCode]Code Here[/VBCode] tags to be able to use the code highlighting.

  9. #9

    Thread Starter
    Not NoteMe SLH's Avatar
    Join Date
    Mar 2002
    Location
    192.168.0.1 Preferred Animal: Penguin Reason for errors: Line#38
    Posts
    3,051
    Yeah, it is a bit odd. I'd have thought that constantly swapping primitives in and out VBs would be slow, but i guess they know what they're doing.

    I've done it pretty easily using 1 VB for all my point sprites, because i just move them manually before puting them in the vertex buffer (and so not using any translation matrices).
    It's just that with other primitives (specifically triangles) i need to rotate them and there's no way i'm doing the maths for that myself (thus i'm using a rotation matrix), which meens that many triangles in one vertex buffer is a no-go.

    What i don't understand is why they bothered with things like trianglelists for example, when you're only realistically gonna have one triangle in there anyway.

    Ah well.
    Quotes:
    "I am getting better then you guys.." NoteMe, on his leet english skills.
    "And I am going to meat her again later on tonight." NoteMe
    "I think you should change your name to QuoteMe" Shaggy Hiker, regarding NoteMe
    "my sweet lord jesus. I've decided never to have breast implants" Tom Gibbons
    Have I helped you? Please Rate my posts.


  10. #10
    Ex-Super Mod'rater Electroman's Avatar
    Join Date
    Sep 2000
    Location
    Newcastle, England
    Posts
    4,349
    I don't understand what you mean. I put a whole object in a VBuffer (lots of triangles making a kinda mesh) then render the whole VBuffer in one go with triangleList. See my VB6 3D Thingy: http://www.electromanuk.com/Download.php?file_id=23
    When your thread has been resolved please edit the original post in the thread ()
    and amend "-[RESOLVED]-" to the end of the title and change the icon to , Thank you.

    When posting Code use the [VBCode]Code Here[/VBCode] tags to be able to use the code highlighting.

  11. #11
    Retired G&G Mod NoteMe's Avatar
    Join Date
    Oct 2002
    Location
    @ Opera Software
    Posts
    10,190
    If you have a triangle list with 6 diffrent vertices, then the triangles don't have to be attached to each other. If you use a Triangle fan or something with 6 vertices, then you suddenly have 4 traingles in a fan....

  12. #12
    Ex-Super Mod'rater Electroman's Avatar
    Join Date
    Sep 2000
    Location
    Newcastle, England
    Posts
    4,349
    I never use Fans only Lists or Strips
    When your thread has been resolved please edit the original post in the thread ()
    and amend "-[RESOLVED]-" to the end of the title and change the icon to , Thank you.

    When posting Code use the [VBCode]Code Here[/VBCode] tags to be able to use the code highlighting.

  13. #13

    Thread Starter
    Not NoteMe SLH's Avatar
    Join Date
    Mar 2002
    Location
    192.168.0.1 Preferred Animal: Penguin Reason for errors: Line#38
    Posts
    3,051
    To make a mesh it's fine.

    To have a list of triangles that are moving/rotating independently in a vertex buffer is impossible, because i can't use translation matricies to move them as it moves them all.

    It's not really a problem, just meens i'm gonna have to loop through all my triangles loading each into the vertex buffer, rotating them then displaying them.

    P.S. Here's a good site with examples i learnt from: http://www.codesampler.com/dx9src.htm
    Quotes:
    "I am getting better then you guys.." NoteMe, on his leet english skills.
    "And I am going to meat her again later on tonight." NoteMe
    "I think you should change your name to QuoteMe" Shaggy Hiker, regarding NoteMe
    "my sweet lord jesus. I've decided never to have breast implants" Tom Gibbons
    Have I helped you? Please Rate my posts.


  14. #14
    Retired G&G Mod NoteMe's Avatar
    Join Date
    Oct 2002
    Location
    @ Opera Software
    Posts
    10,190
    OK..here is a sumary from my book "Real time rendering tips and tricks in DirectX, from the chapter "Everything starts with the Vertex":

    Performance Considerations:

    • In genral, locking the vertex buffer is a costly operation and should be avoided when possible. Oten a lock is neccessary, but I've heard horro stories og people locking, setting three vertices, rendering, and repeating. Instead, add many more vertices in a single lock.
    • Be very aware of the flags used when creating and locking the vertx buffer. Diffrent flag or flag combinations could make measurable performance diffrences. Wehn in doubt, experiment until you find the best setup.
    • Usually, the more vertices you can send to the card in a single call, the better. The number differ for diffrent cards and diffrent applications, but a general rule f thumb is that the number should be in the thousands, not in the tens of vertices.
    • Calling SetVertexShader is a costly operation. It forces the device to stop and prepare for the new type of data. If you're dealing with diffrent FVFs, group your geometry by FVF to avoid switching back and forth. Some people even go as far as to render every other frame in diffrent orders to avoid unnecessary switches!
    • Because switches formats is costly, create formats based on attributes, not on objects. Therefor, don't create one format for cars and another format for airplanes if they share the same atributes. Instead, create one format for single textured vertices, another for multitextured vertices, and so on, and use the correct format for all appropriate objects.
    • Setting thre stream source is also a costly operation. Again, rendering calls should be batched togheter to take the most advantage of a single vertex buffer before switching.
    • As stated earlier, the more geometry you can process in a single call, the better. This applies to DrawPrimitive as well. In some cases, you might not be able to send thousends of vertices at the same time, but in general, do as much as you can.

  15. #15
    Ex-Super Mod'rater Electroman's Avatar
    Join Date
    Sep 2000
    Location
    Newcastle, England
    Posts
    4,349
    No if you put the all in one Vbuffer: Then Set the Rotation Matrix for the first one and draw just verts 0-2 from the VBuffer. Then Apply the Second Triangles Martix and Draw Verts 3-5. Then Same again for the third one.
    When your thread has been resolved please edit the original post in the thread ()
    and amend "-[RESOLVED]-" to the end of the title and change the icon to , Thank you.

    When posting Code use the [VBCode]Code Here[/VBCode] tags to be able to use the code highlighting.

  16. #16
    Ex-Super Mod'rater Electroman's Avatar
    Join Date
    Sep 2000
    Location
    Newcastle, England
    Posts
    4,349
    Originally posted by SLH
    http://www.codesampler.com/dx9src.htm
    Cool, I've been using that site too .
    When your thread has been resolved please edit the original post in the thread ()
    and amend "-[RESOLVED]-" to the end of the title and change the icon to , Thank you.

    When posting Code use the [VBCode]Code Here[/VBCode] tags to be able to use the code highlighting.

  17. #17

    Thread Starter
    Not NoteMe SLH's Avatar
    Join Date
    Mar 2002
    Location
    192.168.0.1 Preferred Animal: Penguin Reason for errors: Line#38
    Posts
    3,051
    Ah ha!!

    Thanks Electroman. Exactly what i was after.
    Quotes:
    "I am getting better then you guys.." NoteMe, on his leet english skills.
    "And I am going to meat her again later on tonight." NoteMe
    "I think you should change your name to QuoteMe" Shaggy Hiker, regarding NoteMe
    "my sweet lord jesus. I've decided never to have breast implants" Tom Gibbons
    Have I helped you? Please Rate my posts.


  18. #18
    Retired G&G Mod NoteMe's Avatar
    Join Date
    Oct 2002
    Location
    @ Opera Software
    Posts
    10,190
    Originally posted by Electroman
    No if you put the all in one Vbuffer: Then Set the Rotation Matrix for the first one and draw just verts 0-2 from the VBuffer. Then Apply the Second Triangles Martix and Draw Verts 3-5. Then Same again for the third one.


    Ohhh...you where faster then me, to say that...I was looking in my book to see if you could transform all of them first, and then draw them all in one....but I havn't found it yet...do you know if that is possible?

  19. #19

    Thread Starter
    Not NoteMe SLH's Avatar
    Join Date
    Mar 2002
    Location
    192.168.0.1 Preferred Animal: Penguin Reason for errors: Line#38
    Posts
    3,051
    Originally posted by NoteMe
    I was looking in my book to see if you could transform all of them first, and then draw them all in one....but I havn't found it yet...do you know if that is possible?
    Yep, just load 'em into the vertex buffer, then set up the transform matrix, then render them all.
    Quotes:
    "I am getting better then you guys.." NoteMe, on his leet english skills.
    "And I am going to meat her again later on tonight." NoteMe
    "I think you should change your name to QuoteMe" Shaggy Hiker, regarding NoteMe
    "my sweet lord jesus. I've decided never to have breast implants" Tom Gibbons
    Have I helped you? Please Rate my posts.


  20. #20
    Ex-Super Mod'rater Electroman's Avatar
    Join Date
    Sep 2000
    Location
    Newcastle, England
    Posts
    4,349
    I've seen those weird things were a transformation doesn't move or roate all of them it makes wierd twisting effects but thats down to the matrix stuff. And actually you posted first . I was lost cos loads of people responded to loads of thread I was subscribed to and I got lost on which ones I'd read already .
    When your thread has been resolved please edit the original post in the thread ()
    and amend "-[RESOLVED]-" to the end of the title and change the icon to , Thank you.

    When posting Code use the [VBCode]Code Here[/VBCode] tags to be able to use the code highlighting.

  21. #21
    Retired G&G Mod NoteMe's Avatar
    Join Date
    Oct 2002
    Location
    @ Opera Software
    Posts
    10,190
    And I think I found the answer...it is possible...you can just empty the vertex buffer then refill it...and I even found a statement from NVIDIA that said that you should make the vertexbuffer 10 times bigger then the amount of vertices that you are using. That way you don't need to empty it every time, next time you add transformed vertices to it, then add them after the vertices you added last time, and only render then new ones. That way you only have to empty the vertex buffer every 10th frame...

  22. #22
    Retired G&G Mod NoteMe's Avatar
    Join Date
    Oct 2002
    Location
    @ Opera Software
    Posts
    10,190
    Originally posted by SLH
    Yep, just load 'em into the vertex buffer, then set up the transform matrix, then render them all.

    But I was thinking about if you had diffent objects in the vertx buffer...then you don't want to use the same transformation all all of the objects (vertices)

  23. #23

    Thread Starter
    Not NoteMe SLH's Avatar
    Join Date
    Mar 2002
    Location
    192.168.0.1 Preferred Animal: Penguin Reason for errors: Line#38
    Posts
    3,051
    Ok, got it. As with many things in life, bigger is better.
    Quotes:
    "I am getting better then you guys.." NoteMe, on his leet english skills.
    "And I am going to meat her again later on tonight." NoteMe
    "I think you should change your name to QuoteMe" Shaggy Hiker, regarding NoteMe
    "my sweet lord jesus. I've decided never to have breast implants" Tom Gibbons
    Have I helped you? Please Rate my posts.


  24. #24
    Retired G&G Mod NoteMe's Avatar
    Join Date
    Oct 2002
    Location
    @ Opera Software
    Posts
    10,190
    Originally posted by Electroman
    I've seen those weird things were a transformation doesn't move or roate all of them it makes wierd twisting effects but thats down to the matrix stuff. And actually you posted first . I was lost cos loads of people responded to loads of thread I was subscribed to and I got lost on which ones I'd read already .

    I didn't post first you did....and are you sure it makes a weird twist. Can't you in some way apply the transformation to only some of the vertices?

  25. #25
    Retired G&G Mod NoteMe's Avatar
    Join Date
    Oct 2002
    Location
    @ Opera Software
    Posts
    10,190
    Originally posted by SLH
    Ok, got it. As with many things in life, bigger is better.

    I am not sure if I want to think in the same direction as you are right now...

    But yeah, bigger the better. If I can rewrite what I just wrote from my book, I might add that, and many other tips to the FAQ. Can get usefull now when people here are really getting into 3D in DX...

  26. #26
    Ex-Super Mod'rater Electroman's Avatar
    Join Date
    Sep 2000
    Location
    Newcastle, England
    Posts
    4,349
    I saw this thing where the vertex buffer had the data for a cylinder. A martic was applied then the whole Buffer rendered and the result was a trwisted up cylinder. You do it my setting the Matrix in different ways, so your not just doing a straight forward rotate or transposition. The demo was trying to give the twisting effect mind. Will see if I can find it again....
    When your thread has been resolved please edit the original post in the thread ()
    and amend "-[RESOLVED]-" to the end of the title and change the icon to , Thank you.

    When posting Code use the [VBCode]Code Here[/VBCode] tags to be able to use the code highlighting.

  27. #27
    Retired G&G Mod NoteMe's Avatar
    Join Date
    Oct 2002
    Location
    @ Opera Software
    Posts
    10,190
    Looks intresting...some kind of morphing or animation of object...when I am have finished that engine with you Electroman, then I want to look into object animation....remember my words...even if it can take 10 years..

  28. #28
    Ex-Super Mod'rater Electroman's Avatar
    Join Date
    Sep 2000
    Location
    Newcastle, England
    Posts
    4,349
    Posted by NoteMe
    Looks intresting...some kind of morphing or animation of object...when I am have finished that engine with you Electroman, then I want to look into object animation..
    Yeah It was like morphing it, not exactly animating it but that would be possible I suppose.
    When your thread has been resolved please edit the original post in the thread ()
    and amend "-[RESOLVED]-" to the end of the title and change the icon to , Thank you.

    When posting Code use the [VBCode]Code Here[/VBCode] tags to be able to use the code highlighting.

  29. #29

    Thread Starter
    Not NoteMe SLH's Avatar
    Join Date
    Mar 2002
    Location
    192.168.0.1 Preferred Animal: Penguin Reason for errors: Line#38
    Posts
    3,051
    Wouldn't be supprised if you could make it morph by multiplying the matrix by an ever increasing number (from 0 to 1).
    Quotes:
    "I am getting better then you guys.." NoteMe, on his leet english skills.
    "And I am going to meat her again later on tonight." NoteMe
    "I think you should change your name to QuoteMe" Shaggy Hiker, regarding NoteMe
    "my sweet lord jesus. I've decided never to have breast implants" Tom Gibbons
    Have I helped you? Please Rate my posts.


  30. #30
    Retired G&G Mod NoteMe's Avatar
    Join Date
    Oct 2002
    Location
    @ Opera Software
    Posts
    10,190
    I must admit that I don't know much about animating, but I know one of the ways is to add stuff (maybe like "frames") to the X file. So I guess it is not by doing matrix transformations. But it can still be a fun way to show collisions like a car running into a road light (you know those tall ones) and the road light bends over, when he hit it. At least an example to what it can be used for....

    Now E...go get that link..

  31. #31
    Ex-Super Mod'rater Electroman's Avatar
    Join Date
    Sep 2000
    Location
    Newcastle, England
    Posts
    4,349
    Originally posted by NoteMe
    Now E...go get that link..
    E, Whos E . I hope your not refferring to me . I'll have a look then N.. .
    When your thread has been resolved please edit the original post in the thread ()
    and amend "-[RESOLVED]-" to the end of the title and change the icon to , Thank you.

    When posting Code use the [VBCode]Code Here[/VBCode] tags to be able to use the code highlighting.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width