Tag Info

Hot answers tagged

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 ...


4

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, ...


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. ...


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

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 ...


1

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 ...


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

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