set texture coordinates to large vb
set texture coordinates to large vb
set texture coordinates to large vb
set texture coordinates to large vb
set texture coordinates to large vb
set texture coordinates to large vb set texture coordinates to large vb set texture coordinates to large vb set texture coordinates to large vb set texture coordinates to large vb set texture coordinates to large vb set texture coordinates to large vb set texture coordinates to large vb
set texture coordinates to large vb set texture coordinates to large vb
set texture coordinates to large vb
Go Back  Xtreme Visual Basic Talk > > > > set texture coordinates to large vb


Reply
 
Thread Tools Display Modes
  #1  
Old 09-25-2006, 05:23 PM
beefmonky's Avatar
beefmonky beefmonky is offline
Regular
 
Join Date: Jun 2004
Posts: 66
Default set texture coordinates to large vb


Ok, So I've been trying to make a tile RPG game in VB.NET using D3D9. At first I was attempting to create a subroutine that behaves like DirectDraw. It was a simple Draw sub, each time you needed to draw something you would call it. It would create a new vertex buffer, lock it, set up the vertices, unlock it, draw the primitives, then dispose of the vertex buffer. After drawing only my tiles to the screen, the performance was horrible.

I was advised to create a vertex buffer large enough to store all of my on-screen quads, lock it once, set up all of the vertices/texture coordinates, unlock it, then draw them all. That way I'd only be locking/unlocking the vertex buffer once per frame. The first time I draw the grid, it works great.. But when I need to update what texture coordinates go to what quads (when the player moves)... I'm lost... I'm having trouble finding out how to set texture coordinates to specific quads inside a large vertex buffer. If anyone can point me in the right direction it would be greatly appreciated.
Reply With Quote
  #2  
Old 09-25-2006, 07:07 PM
Iceplug's Avatar
Iceplugset texture coordinates to large vb Iceplug is offline
MetaCenturion

Retired Moderator
* Guru *
 
Join Date: Aug 2001
Location: Iowa, USA
Posts: 16,583
Default

So, your original formula didn't work?:

L = Src.Left / Target.Width
T = Src.Top / Target.Height
R = Src.Right / Target.Width
B = Src.Bottom / Target.Height

How are you creating the texture?
__________________

Iceplug, USN
Quadrill 1 Quadrill 2 (full) Quadrill 3 JumpCross .NET Website is ALIVE! - DL Platform Tour for VB.NET! Posting Guidelines Hint: Specify your location in your user cp profile if you want compassion!
Reply With Quote
  #3  
Old 09-25-2006, 07:18 PM
beefmonky's Avatar
beefmonky beefmonky is offline
Regular
 
Join Date: Jun 2004
Posts: 66
Default

Quote:
Originally Posted by Iceplug
So, your original formula didn't work?:

L = Src.Left / Target.Width
T = Src.Top / Target.Height
R = Src.Right / Target.Width
B = Src.Bottom / Target.Height

How are you creating the texture?
No the formula worked great. It rendered the tiles to the screen... It was the constant locking/unlocking of hundreds of vertex buffers every frame made the performance terrible. I posted a message on the msdn forum, one of the MS guys said to create a vb large enough for all of my quads (as opposed to creating a new vertex buffer for each tile) I'm just having trouble figuring out how to render a texture to specific quads inside a vertex buffer that contains hundreds of other quads.
Reply With Quote
  #4  
Old 09-25-2006, 07:21 PM
Iceplug's Avatar
Iceplugset texture coordinates to large vb Iceplug is offline
MetaCenturion

Retired Moderator
* Guru *
 
Join Date: Aug 2001
Location: Iowa, USA
Posts: 16,583
Default

Do you really need hundreds of vertex buffers for just a tile map? You should only need one vertex buffer to hold the tile location (which should not have to change) and you just run through the vertex buffer, updating their texture coordinates.
__________________

Iceplug, USN
Quadrill 1 Quadrill 2 (full) Quadrill 3 JumpCross .NET Website is ALIVE! - DL Platform Tour for VB.NET! Posting Guidelines Hint: Specify your location in your user cp profile if you want compassion!
Reply With Quote
  #5  
Old 09-25-2006, 07:31 PM
beefmonky's Avatar
beefmonky beefmonky is offline
Regular
 
Join Date: Jun 2004
Posts: 66
Default

Quote:
Originally Posted by Iceplug
Do you really need hundreds of vertex buffers for just a tile map? You should only need one vertex buffer to hold the tile location (which should not have to change) and you just run through the vertex buffer, updating their texture coordinates.
Well, this is how i'm doing it. (Please tell me if you know of a better way I know very little about D3D)

i did have it set where each tile had 1 vertex buffer assigned to it. i only had vertex buffers assigned to the tiles being displayed on the screen. if my on-screen tile grid is 19 x 15. that's 285 tiles being displayed each frame, which means i had 285 vertex buffers.

they guy from MS said i should create one large vertex buffer, large enough to hold all 285 quads. i can't figure out how to run through and change the texture coordinates for a specific quad inside that large vertex buffer though...
Reply With Quote
  #6  
Old 09-25-2006, 08:38 PM
Rockoon's Avatar
Rockoon Rockoon is offline
Joseph Koss

* Guru *
 
Join Date: Aug 2003
Location: Unfashionable End
Posts: 3,615
Default

Mind if we take a step back for a moment?

Firstly.. I am presuming that you are familiar with rendering indexed primitives.



Forget about the fact that you have however many tiles on screen.. lets consider a single screen-space tile. "The upper left tile."

The upper-left tile has unchanging position infromation for the tiles corners. They are always the same. Thus we never have to change (as in lock, edit, unlock) the position information. You appear to already be leveraging this fact by having all 285 locations cached in a vertex buffer.



Why can't this also be done for texture coordinates?

Lets consider a single set of valid texture coordinates. "Texture coordinate permutation #1"

Now you are dealing with unchanging texture coordinates.


Now the current problem is that you cache the tile position information and have to fill in the tile texture information.

This problem can be transformed into that you cache the tile texture information and fill in the tile position information. But this reduces to the same sort of problem.. locking and unlocking the vertex buffer and all that..



Now I ask you, how many texture coordinate sets are you really dealing with? 16? 48? 100?

Is it not possible to cache all PAIRS of "position + texture coordinate" in a single vertex buffer?

Presuming:
32 bytes per vertex
4 vertices per tile
285 tile position permutations
100 texture coordinate permutation

32 * 4 * 285 * 100 = ~4 megabyte vertex buffer


Its just a thought.. I realize that what you really want is to stick with a "directdraw-like" rendering abstraction .. but perhaps you can let go of that and work with an abstraction more suited to the hardware?
Reply With Quote
  #7  
Old 09-25-2006, 09:19 PM
beefmonky's Avatar
beefmonky beefmonky is offline
Regular
 
Join Date: Jun 2004
Posts: 66
Default

Quote:
Firstly.. I am presuming that you are familiar with rendering indexed primitives.
I explained that I know very little about D3D in my last post. I'm not familiar with indexed primitives, could you point me to a tutorial or documentation on the subject?

I also never said I'm trying to stick to a "directdraw-like rendering abstraction". At first I thought it would be easy to just create a sub that draws a quad/texture to the screen. Well I abandoned that idea. Now, I'm trying to find what will be best suited performance-wise, for what I'm trying to do.

I'm dealing with 500 or more different sets of texture coordinates. If by caching pairs you mean just loading all of the tiles from my entire map into a vertex buffer, I assumed that would be too much so I didn't even try. My map array as of right now is (5000, 5000)...

I'm sorry If I don't understand exactly what you're asking me. I may have a misconception of how the whole process works alltogether. It seems posting in in this forum is the only way to get answers due to the limited resources avaliable for d3d in vb.net. Thanks again for all of your help.
Reply With Quote
  #8  
Old 09-25-2006, 11:50 PM
Rockoon's Avatar
Rockoon Rockoon is offline
Joseph Koss

* Guru *
 
Join Date: Aug 2003
Location: Unfashionable End
Posts: 3,615
Default

Can I ask why you are dealing with so many sets of texture coordinates?
Reply With Quote
Reply


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Forum Jump

Advertisement:





Free Publications
The ASP.NET 2.0 Anthology
101 Essential Tips, Tricks & Hacks - Free 156 Page Preview. Learn the most practical features and best approaches for ASP.NET.
subscribe
Programmers Heaven C# School Book -Free 338 Page eBook
The Programmers Heaven C# School book covers the .NET framework and the C# language.
subscribe
Build Your Own ASP.NET 3.5 Web Site Using C# & VB, 3rd Edition - Free 219 Page Preview!
This comprehensive step-by-step guide will help get your database-driven ASP.NET web site up and running in no time..
subscribe
set texture coordinates to large vb
set texture coordinates to large vb
set texture coordinates to large vb set texture coordinates to large vb
set texture coordinates to large vb
set texture coordinates to large vb
set texture coordinates to large vb set texture coordinates to large vb set texture coordinates to large vb set texture coordinates to large vb set texture coordinates to large vb set texture coordinates to large vb set texture coordinates to large vb
set texture coordinates to large vb
set texture coordinates to large vb
 
set texture coordinates to large vb
set texture coordinates to large vb
 
-->