Sign in to follow this  
punmaster

OpenGL Separate index for position, normal, texture coordinate

Recommended Posts

I read that OpenGL 2.0 has added support for having multiple indices for each face, allowing me to separately index arrays containing position, normal, and texture coordinate data. Which extensions (I'm on Windows) would I need to use to take advantage of this functionality? Are there any samples / tutorials showing how to do this? Thank you. :)

Share this post


Link to post
Share on other sites
Hmm. I thought is was described in an article detailing new support for geometry sharers. Maybe they were implying that you could write a shader to do this, but it is not supported natively. Either way, thank you. Guess I'll stick with repeated vertices for now. :)

Share this post


Link to post
Share on other sites
Quote:
Original post by punmaster
Hmm. I thought is was described in an article detailing new support for geometry sharers. Maybe they were implying that you could write a shader to do this, but it is not supported natively. Either way, thank you. Guess I'll stick with repeated vertices for now. :)


Well what exactly are you trying to do? Maybe we can help you get what you want.

Share this post


Link to post
Share on other sites
I am writing a cross-platform game engine for the PC and the Wii. For the most part, the PC side of things has been much easier because, unlike the Wii's libraries, OpenGL is very well documented and relatively easy to debug. Still, the Wii does have some interesting features. One in particular, that I recently discovered, is the ability to use separate indices for each vertex component (position, normal, texture, etc.). Given the Wii's very limited memory and graphics resources, this seemed like a feature I wanted to take advantage of, especially given that most modeling programs store data in this format anyway. The catch is that if I am going to encode my models like this, the PC version will need to be able to handle them too. Likewise, I went in search for some way to do this in OpenGL, and stumbled upon a few short articles talking about some new types of shaders supported in OpenGL 2.0. The article briefly mentioned that one thing they could be used for is the multiple index system stated above. I came here with the hope that somebody could help point me in the right direction as far as implementing it. I apologize if this sounds crazy, and I can always stick with the old system if nothing can be done, but I was hoping someone would have some ideas. Either way, thanks for your help. :)

Share this post


Link to post
Share on other sites
Quote:
Original post by punmaster
I am writing a cross-platform game engine for the PC and the Wii. For the most part, the PC side of things has been much easier because, unlike the Wii's libraries, OpenGL is very well documented and relatively easy to debug. Still, the Wii does have some interesting features. One in particular, that I recently discovered, is the ability to use separate indices for each vertex component (position, normal, texture, etc.). Given the Wii's very limited memory and graphics resources, this seemed like a feature I wanted to take advantage of, especially given that most modeling programs store data in this format anyway. The catch is that if I am going to encode my models like this, the PC version will need to be able to handle them too. Likewise, I went in search for some way to do this in OpenGL, and stumbled upon a few short articles talking about some new types of shaders supported in OpenGL 2.0. The article briefly mentioned that one thing they could be used for is the multiple index system stated above. I came here with the hope that somebody could help point me in the right direction as far as implementing it. I apologize if this sounds crazy, and I can always stick with the old system if nothing can be done, but I was hoping someone would have some ideas. Either way, thanks for your help. :)


First off let me say, I am jelious :[ I want to program for the wii soooo bad, but dont have the money..

But, If the values are only being used in the given shader why wont varying work? If you need to pass the values to multiple shaders, only method I know is using frame buffer objects (fbo). This is used a lot in gaming, and shouldn't cause much memory issues on moderner hardware. Now, I don't know how much memory the wii has, and I have believed it to hold at least 512mb if not 1gig, but by your post im guessing not a lot, so you should already be making it in a low memory way, so adding fbo's should be much of a pain.

Hope this helps.

Share this post


Link to post
Share on other sites
Quote:
Original post by punmaster
I am writing a cross-platform game engine for the PC and the Wii. For the most part, the PC side of things has been much easier because, unlike the Wii's libraries, OpenGL is very well documented and relatively easy to debug. Still, the Wii does have some interesting features. One in particular, that I recently discovered, is the ability to use separate indices for each vertex component (position, normal, texture, etc.). Given the Wii's very limited memory and graphics resources, this seemed like a feature I wanted to take advantage of, especially given that most modeling programs store data in this format anyway. The catch is that if I am going to encode my models like this, the PC version will need to be able to handle them too. Likewise, I went in search for some way to do this in OpenGL, and stumbled upon a few short articles talking about some new types of shaders supported in OpenGL 2.0. The article briefly mentioned that one thing they could be used for is the multiple index system stated above. I came here with the hope that somebody could help point me in the right direction as far as implementing it. I apologize if this sounds crazy, and I can always stick with the old system if nothing can be done, but I was hoping someone would have some ideas. Either way, thanks for your help. :)


One alternative to run-time support on the PC is to have your toolchain automatically convert from the Wii approach to the PC limitation by automatically creating extra vertices that contain each required combination of attributes (pos, norm, UV, etc).

Most games I've worked on generate completely separate data files for each platform (mostly because of endianness but also for other reasons), so this is not out of the ordinary.

This is very similar to the problem of converting a DAG (directed acyclic graph) like those in Maya to a tree and then into a list.

Share this post


Link to post
Share on other sites
Quote:
Original post by cherryyosh
Now, I don't know how much memory the wii has, and I have believed it to hold at least 512mb if not 1gig, but by your post im guessing not a lot, so you should already be making it in a low memory way, so adding fbo's should be much of a pain.


From what I understand, the Wii has a TOTAL of 88MB of RAM (some of that is reserved for different things, like texture and audio memory, and I'm sure someone else can be more specific). It sounds like it'd be tough to develop for...

I second Nypren's approach. For a quick hack, you can have your PC and Wii builds optimize the data structure of the models when they get loaded up. However, in my experience, you get the best results by generating platform-specific content at compile-time. Most major cross-platform engines have this functionality (Cryengine 2, Unreal 3, Source [I think]). Since iterating on the PC is so much faster, I always just build all the content in the preferred PC format (Windows, I assume), and then build a utility to convert to the other platform-specific data types.

Share this post


Link to post
Share on other sites
Quote:
Original post by generaleskimo
Quote:
Original post by cherryyosh
Now, I don't know how much memory the wii has, and I have believed it to hold at least 512mb if not 1gig, but by your post im guessing not a lot, so you should already be making it in a low memory way, so adding fbo's should be much of a pain.


From what I understand, the Wii has a TOTAL of 88MB of RAM (some of that is reserved for different things, like texture and audio memory, and I'm sure someone else can be more specific). It sounds like it'd be tough to develop for...


Oh man, that's insane. I could see most of the fun little party games not needing much, but a game like zelda, or okami (only ones I can comment on).. How?? But that value really does seem small, s this just for the wii? or are the other consoles as low or near as low on the memory?

PS. I dont mean to hijack, but hardware specs are hard to find, and I really am intrested in programming for consoles once I can afford it.

Share this post


Link to post
Share on other sites
I concurr. As Nypyren stated, the only reasonable approach to this problem is to generate content for each platform as required. Every studio I've worked for took this approach, and it makes the most sense. You need to develop for the platform, rather than hoping the hardware/APIs will support (or bend to) your arbitrary formats.

Each additional platform you develop for compounds the requirement for a flexible toolchain.

Share this post


Link to post
Share on other sites
When I first began this project, I immediately assumed that the toolchain would compile resources in different formats for each platform. I started with the PC version and designed all data formats to make the most sense on the PC. Then, when I began coding for the Wii, I surprised myself by being able to load the unmodified PC files on the Wii with little more than an on-the-fly endian swap. Still, later in the project, as the formats have gotten more advanced, keeping up this 100% compatibility has become increasingly difficult, and the next rewrite for the format specifications will probably mean specialized specs for each platform. One of the candidates for this new spec is the index system I have been describing. Obviously, there is no problem with making the PC files use the single-index system, but I thought as long as I was considering it for the Wii, I'd look into it's applications on the PC as well, because it seemed like a generally nice idea. Further reading though suggests that this might not be as good of an idea on the PC (amusing the extra memory isn't an issue) because the single index system improves the usefulness of the cache by keeping things close together and contiguous. I already know that, on the Wii, vertices are read by the GPU uncached from main RAM, which would explain why this loss of cache performance isn't a topic for concern here (and thus the three index system is supported.) If anyone here thinks this system, despite possible cache issues, is still worth pursuing on the PC side of things, feel free to let me know. Otherwise, I'll leave it as a Wii-only feature.

If you have any comments or suggestions, feel free to share. :)

Slightly off topic, but here's some background on the Wii for those interested. The Wii has a whopping 88 MB of main memory (which is much less than the Xbox 360 and PS3). The GPU will read data from anywhere in addressable memory space, as long as that area has been flushed from the cache before the GPU goes to read it, as all GPU reads are by-nature uncached. Because this puts the memory as a 100% bottleneck for graphics performance, 24 MB of this total is included as high-performance SRAM inside the GPU package (so that frequently used objects can be allocated here and thus rendered more quickly.) The GPU also contains a 3 MB dedicated "Embedded Frame Buffer" (not included in the 88 MB main RAM total) which is clocked directly by the GPU and automatically serves as the destination for all rendered graphics. Frames are then copied from this buffer to main RAM before being drawn to the screen (as the Wii's video encoder can only scan frames from main memory), or can optionally be fed back to the GPU as a texture. The CPU and the GPU communicate by means of a shared FIFO buffer allocated in main RAM. The CPU can fill this buffer with graphics commands, do something else, and then come back in a few milliseconds and grab the rendered frame from the EFB. Other non-graphics tasks are issued via IOCTLs to an ARM296 coprocessor, which is also built into the GPU package. This processor also handles various tasks related to system management and security. An audio decoder is also provided in the GPU package, which can also take advantage of the previously mentioned 24 MB of on-die SRAM.

There's today's supplement of Wii developer knowledge. If you want to know more, just ask. :) Otherwise, happy coding, and thanks for all the help.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this  

  • Announcements

  • Forum Statistics

    • Total Topics
      628402
    • Total Posts
      2982471
  • Similar Content

    • By test opty
      Hi all,
       
      I'm starting OpenGL using a tut on the Web. But at this point I would like to know the primitives needed for creating a window using OpenGL. So on Windows and using MS VS 2017, what is the simplest code required to render a window with the title of "First Rectangle", please?
       
       
    • By DejayHextrix
      Hi, New here. 
      I need some help. My fiance and I like to play this mobile game online that goes by real time. Her and I are always working but when we have free time we like to play this game. We don't always got time throughout the day to Queue Buildings, troops, Upgrades....etc.... 
      I was told to look into DLL Injection and OpenGL/DirectX Hooking. Is this true? Is this what I need to learn? 
      How do I read the Android files, or modify the files, or get the in-game tags/variables for the game I want? 
      Any assistance on this would be most appreciated. I been everywhere and seems no one knows or is to lazy to help me out. It would be nice to have assistance for once. I don't know what I need to learn. 
      So links of topics I need to learn within the comment section would be SOOOOO.....Helpful. Anything to just get me started. 
      Thanks, 
      Dejay Hextrix 
    • By mellinoe
      Hi all,
      First time poster here, although I've been reading posts here for quite a while. This place has been invaluable for learning graphics programming -- thanks for a great resource!
      Right now, I'm working on a graphics abstraction layer for .NET which supports D3D11, Vulkan, and OpenGL at the moment. I have implemented most of my planned features already, and things are working well. Some remaining features that I am planning are Compute Shaders, and some flavor of read-write shader resources. At the moment, my shaders can just get simple read-only access to a uniform (or constant) buffer, a texture, or a sampler. Unfortunately, I'm having a tough time grasping the distinctions between all of the different kinds of read-write resources that are available. In D3D alone, there seem to be 5 or 6 different kinds of resources with similar but different characteristics. On top of that, I get the impression that some of them are more or less "obsoleted" by the newer kinds, and don't have much of a place in modern code. There seem to be a few pivots:
      The data source/destination (buffer or texture) Read-write or read-only Structured or unstructured (?) Ordered vs unordered (?) These are just my observations based on a lot of MSDN and OpenGL doc reading. For my library, I'm not interested in exposing every possibility to the user -- just trying to find a good "middle-ground" that can be represented cleanly across API's which is good enough for common scenarios.
      Can anyone give a sort of "overview" of the different options, and perhaps compare/contrast the concepts between Direct3D, OpenGL, and Vulkan? I'd also be very interested in hearing how other folks have abstracted these concepts in their libraries.
    • By aejt
      I recently started getting into graphics programming (2nd try, first try was many years ago) and I'm working on a 3d rendering engine which I hope to be able to make a 3D game with sooner or later. I have plenty of C++ experience, but not a lot when it comes to graphics, and while it's definitely going much better this time, I'm having trouble figuring out how assets are usually handled by engines.
      I'm not having trouble with handling the GPU resources, but more so with how the resources should be defined and used in the system (materials, models, etc).
      This is my plan now, I've implemented most of it except for the XML parts and factories and those are the ones I'm not sure of at all:
      I have these classes:
      For GPU resources:
      Geometry: holds and manages everything needed to render a geometry: VAO, VBO, EBO. Texture: holds and manages a texture which is loaded into the GPU. Shader: holds and manages a shader which is loaded into the GPU. For assets relying on GPU resources:
      Material: holds a shader resource, multiple texture resources, as well as uniform settings. Mesh: holds a geometry and a material. Model: holds multiple meshes, possibly in a tree structure to more easily support skinning later on? For handling GPU resources:
      ResourceCache<T>: T can be any resource loaded into the GPU. It owns these resources and only hands out handles to them on request (currently string identifiers are used when requesting handles, but all resources are stored in a vector and each handle only contains resource's index in that vector) Resource<T>: The handles given out from ResourceCache. The handles are reference counted and to get the underlying resource you simply deference like with pointers (*handle).  
      And my plan is to define everything into these XML documents to abstract away files:
      Resources.xml for ref-counted GPU resources (geometry, shaders, textures) Resources are assigned names/ids and resource files, and possibly some attributes (what vertex attributes does this geometry have? what vertex attributes does this shader expect? what uniforms does this shader use? and so on) Are reference counted using ResourceCache<T> Assets.xml for assets using the GPU resources (materials, meshes, models) Assets are not reference counted, but they hold handles to ref-counted resources. References the resources defined in Resources.xml by names/ids. The XMLs are loaded into some structure in memory which is then used for loading the resources/assets using factory classes:
      Factory classes for resources:
      For example, a texture factory could contain the texture definitions from the XML containing data about textures in the game, as well as a cache containing all loaded textures. This means it has mappings from each name/id to a file and when asked to load a texture with a name/id, it can look up its path and use a "BinaryLoader" to either load the file and create the resource directly, or asynchronously load the file's data into a queue which then can be read from later to create the resources synchronously in the GL context. These factories only return handles.
      Factory classes for assets:
      Much like for resources, these classes contain the definitions for the assets they can load. For example, with the definition the MaterialFactory will know which shader, textures and possibly uniform a certain material has, and with the help of TextureFactory and ShaderFactory, it can retrieve handles to the resources it needs (Shader + Textures), setup itself from XML data (uniform values), and return a created instance of requested material. These factories return actual instances, not handles (but the instances contain handles).
       
       
      Is this a good or commonly used approach? Is this going to bite me in the ass later on? Are there other more preferable approaches? Is this outside of the scope of a 3d renderer and should be on the engine side? I'd love to receive and kind of advice or suggestions!
      Thanks!
    • By nedondev
      I 'm learning how to create game by using opengl with c/c++ coding, so here is my fist game. In video description also have game contain in Dropbox. May be I will make it better in future.
      Thanks.
  • Popular Now