Tag Info

Hot answers tagged

18

Under D3D9 with XPDM you almost certainly want to instance wherever possible. Draw call overhead is just so high that it makes sense. In that scenario the crossover-point can be as low as 2 or 3 instances. If you've only got one instance of a given mesh, it may on the surface seem tempting to draw it non-instanced. However, look at what's involved: You ...


10

(On my system, didn't test it anywhere else) In GL, instancing a single mesh (drawing with count = 1) has some nasty overhead, but I don't know where it comes from. I strongly suggest not doing it. I tested this in a practical application a couple of months ago. I coded some global illumination algorithms in the Crytek Sponza scene, which consists of ...


5

I think you may be losing some of the performance of instancing if you're making each instance an entity. I think your idea of using a instance group is good. I would then create a system that looks for entities with a instance group component and renders the instances. Like other systems, this system doesn't care about other components the entity has, ...


4

You are over generalizing and trying too hard to use what your idea of an entity system is. Instancing is easily just as simple as having your renderer automatically batch together all renderable objects with the same mesh and materials. It's not the job of the data or the components to render themselves. It's the job of the rendering system, which should ...


2

From the easy to the scalable and complex to implement, kind of: A fast to write option is simply to let the HUD know where the player is and let it grab what variables it needs directly. It's not very flexible, but for games where the player is well defined and the scope of the game is tightly contained it can work well enough. This is a tightly coupled ...


2

In general terms, you're talking about the difference between the Factory pattern - a piece of code that creates objects based on being told which type to make - and the Prototype pattern - a piece of code that creates objects by copying an existing object. In cases like this, I think the prototype pattern is the wrong way to go. A rocket will have several ...


2

This is not really dynamically coloring but you can alter the lighting effects to achieve the same thing. The AmbientLightColor effect should work. effect.AmbientLightColor = new Color(r, b, g); Also there is an effect.alpha that you use for transparency iirc which takes a float between 0-1.


2

You shouldn't be attempting to instance individual cubes at all. I developed Techcraft together with two close dev friends. It has all the sample code you will need to learn from, if it helps. Feel free to download the source code and use as you wish: http://techcraft.codeplex.com Good luck! Hopefully we can add your game to the list on the project page. ...


2

The DirectX SDK has samples on how to do this, and there are resources online you can find on how to do this. Look in C:\Program Files (x86)\Microsoft DirectX SDK (June 2010)\Samples\C++\Direct3D\Instancing\Instancing.cpp. Here's a Nvidia GPU Gem article on Geometry Instancing. And here's an article on MSDN. This article shows you the two vertex ...


2

Instancing requires to change the InputLayout of vertex buffers and pass an instancing buffer along the mesh vertices. Unfortunately, there is nothing automatic to do this with Toolkit models, though possible but would require to dig into the internals to do this yourself. Before even trying to do some instancing with models, you should start with a basic ...


2

You can be for certain that drawing a single object instanced is more expensive than drawing a single object normally. For instancing the GPU is preparing for a large amount of objects and this preparation will be different than for a single object. However how large this performance gap is can only be found by experimenting and is very much depending on ...


2

There are two main ways to get instance data into a shader program: Setting the instance divisor for one or more vertex attributes (instead of advancing every vertex, it will advance every N instances) Using gl_InstanceID or an instanced attribute to select part of an array of instance data stored in a uniform buffer, shader storage buffer, etc. ...


1

The issue seem to be that you don't copy data over, you're overwriting the idata pointer with the address of mIV: idata = mIV; // this changes idata to point to mIV, not copy data Should be something like: for(size_t i=0; i < (sizeof(mIV) / sizeof(mIV[0])); ++i){ idata[i] = mIV[i]; } Or memcpy(idata, mIV, sizeof(mIV)); Or some other copy ...


1

A modern gpu can easily handle around 3k Drawcalls ( This is well optimized of course ) and most likely even 2k with out any superb optimization. So I´m assume your FPS is down due to some CPU Bottleneck that's happening. ( could be related to rendering ) And to answer your question. One smart way of storing your Mesh to a compact and well optimized ...


1

The typical way to do it would be to rebuild the instance buffer each frame, akin to a particle system or other dynamic vertex buffer.


1

What you'll wind up doing David is creating a vertex buffer to hold the different transformation matrices for each instance of grass. You will need a vertex declaration that has your standard 'grass' vertex components( pos, norm, uv...etc ), and in that same declaration 4 additional 4-component floats to hold the 4x4 transformation matrix...the declaration ...


1

I agree with petterson, but if you want to reduce amount of draw calls as well you need to use instancing. Does my approach look good? If you create it once and will not move a lot of stuff around each frame, there is nothing bad in it. It all depends on you usage. How do I manage positions per mesh? For this you need to identity what mesh is ...


1

If all else fails you can do multiple render passes, with voxels I suppose splitting the screen into squares and rendering each of those separately will work reasonably. Also, please consider what you are trying to achieve. Voxel engines are mostly unsuitable for games, they are hard to work with and hard to get good performance from. If you want to make a ...


1

Changing color to a texture with an effect file can be done in this way: HLSL CODE And then a simple test game: VertexBuffer bufferVertex; IndexBuffer bufferIndex; Effect effect; Matrix View, Projection; protected override void LoadContent() { effect = Content.Load<Effect>("Color"); Projection = ...


1

You can definitely put multiple objects in a vertex buffer, even with different numbers of vertices. A vertex buffer doesn't know or care where the "objects" are in it - it's nothing more than a list of vertices. If you have a fixed set of objects you want to draw, you can simply concatenate all your vertices together and put them in one big vertex buffer; ...


1

What about making clones or factories? For clones, you could just call object.clone(). This would make another instance of this object type. Though I'm not sure if they will share references, so may not be the best way. Thinking a little more, I think you could use Java Reflection library. Assuming you just have one constructor with no parameters, this ...


1

Looking at your other question, you're building a Minecraft clone. Now I admit that I'm not sure what Minecraft's renderer does, but I would guess that it's not instancing. Instancing helps you want to draw many identical complicated models in a single batch, with different transforms. While it is possible to use a custom shader to transform the texture ...


1

can I send the instance data straight to the pixel shader somehow? What would that mean, exactly? The values your fragment (or pixel if you insist) shader gets are per-vertex values interpolated across the face of the primitive, and constant uniform values that do not change within a draw call. There is no way to magic a vertex stage input into a ...



Only top voted, non community-wiki answers of a minimum length are eligible