Skip to main content

Timeline for Mesh objects and a draw function

Current License: CC BY-SA 3.0

19 events
when toggle format what by license comment
Jun 11, 2013 at 16:19 comment added Fredrik Boston Westman nvm, this is getting to long, i making a question out of it.
Jun 11, 2013 at 13:54 comment added Fredrik Boston Westman @SeanMiddleditch do you really have to use the painters algorithm for tranceparancy. Cant you just use a z buffer, draw the object in whatever order they come, then last draw all transparant objects ? Even if you used the painter algorithm, how could you possibly sort all objects in the correct order if they need diffrent shaders and stuff. Say the furthest object needs shader 1, the second furthest need shader 3, and the 3rd need shader 2. Would take alot of time change back and forth all the time.
Jun 8, 2013 at 16:17 answer added Nicol Bolas timeline score: 1
Jun 7, 2013 at 17:28 comment added Sean Middleditch Draw objects in order of distance from the camera. For standard transparency, you must use the painter's algorithm (draw the farther objects before closer objects). Even for opaque objects with Z-buffering you can obtain on some hardware performance improvements by using reverse-painter's algorithm (closest first) so that the Z-buffer stops the fragment shader from drawing occluded objects (depends on hardare, scene/shader complexity, etc.)
Jun 7, 2013 at 9:02 comment added Fredrik Boston Westman @SeanMiddleditch seems like a good idea, well have to think about this a bit, but what do you meen with depth sorted ?
Jun 6, 2013 at 23:51 comment added Sean Middleditch @FredrikBostonWestman: A hierarchy for shaders is a little backwards. Materials have shaders, not the other way around. A single material might need different shaders for different passes, e.g. for forward vs deferred lighting or the like. Keep a list of objects; for each object, add each mesh to a queue. Sort the queue so meshes with identical materials or shaders are adjacent and so transparent objects are drawn after opaque ones and depth sorted. Then iterate over the sorted queue and draw, only changing state if the current mesh's material is different than the previous.
Jun 6, 2013 at 21:35 comment added Fredrik Boston Westman makes sence, i only working with .obj file rigth now and they dont have animations, so i never tougth about it that way :) guess i have to rework the code abit to split i up to diffrent meshes
Jun 6, 2013 at 21:16 comment added Nathan Reed @FredrikBostonWestman It has to be split into several meshes, one for each material. I think of a "mesh" as being a chunk of triangles you can draw in one call, so it all has the same shader/material. An object may be made of multiple meshes if it has multiple materials, or independently moving parts (e.g. a car and its wheels), etc.
Jun 6, 2013 at 20:05 comment added Fredrik Boston Westman @NathanReed i saw you where the one that wrote that anwser on the other question, its a good system, but what if one mesh have several materials?
Jun 6, 2013 at 19:54 history tweeted twitter.com/#!/StackGameDev/status/342731327436632065
Jun 6, 2013 at 18:55 comment added Fredrik Boston Westman dynamic system = a system that is easy to change and implement new functions ( atleast that is how I learned it). But thanks:) that question you linked gave me the insperation i needed :) gonna make like a hierarchy of objects. First a shader object that contains the shader . Inside of that is also a array of material object which contains the settings for each matterials. And inside of the material object there is an array of mech obj, and inside the mech an array of instances of that mech. That way you can go true all of them very fast and makes the system very dynamic :)
Jun 6, 2013 at 18:40 comment added Nathan Reed @FredrikBostonWestman You can certainly make a shader/material system that's partially or completely data-driven (I think that's what you mean by "dynamic"). It's a lot of work, though. Keeping some things hard-coded can make development simpler and faster. You can add data-drivenness a little at a time as you need to.
Jun 6, 2013 at 18:25 comment added Fredrik Boston Westman It feels like code like that isnt very dynamic ( tho maby faster)
Jun 6, 2013 at 18:22 comment added Fredrik Boston Westman Sorry didnt have any better word for them. But if i get you rigth, your saying that rather then set each object with shaders ect. I should prepare diffrent sections of my code. Like one section where i draw transparant object, one for non transparant ect ?
Jun 6, 2013 at 17:50 comment added Nathan Reed To amplify a bit on what Sean said: you usually have multiple meshes using the same material, and perhaps multiple materials using the same shader code with different textures etc. The render states don't belong to the object but rather to the shader, and the object would have a pointer to the material it uses, which would in turn have a pointer to its shader. See this question for more details.
Jun 6, 2013 at 17:30 comment added Sean Middleditch Normally these states are part of the material or part of the render pass and are not called "tools." Using the common vernacular might help you find better documentation when searching.
Jun 6, 2013 at 16:44 comment added Fredrik Boston Westman ooh i didnt know that
Jun 6, 2013 at 15:06 comment added Kikaimaru You can also specify states in effects (.fx files). msdn.microsoft.com/en-us/library/windows/desktop/…
Jun 6, 2013 at 13:02 history asked Fredrik Boston Westman CC BY-SA 3.0