Jump to content

  • Log In with Google      Sign In   
  • Create Account


Member Since 04 Aug 2011
Offline Last Active Feb 22 2016 08:10 PM

#4941990 What's the best C#(XNA) book/site

Posted by on 21 May 2012 - 01:16 PM


One of the best places to find XNA articles, examples, tutorials and source code.

#4937677 Artifacts in image that dont appear when using reference device

Posted by on 05 May 2012 - 04:21 PM

Like I said before I calculated halfpixel using the following code: output.position.xy += halfPixel; But halfpixel is equal to Vector2(-1f / destination.Width, 1f / destination.Height)); Be aware that the first value is negative. I forgot to mention before.

That said: position.y = -(input.TexCoord.x * 2.0f - 1.0f); The x should be y.

The rest seems fine. I you want to improve performance you can avoid the matrix multiplication in the world position calculation. Ask me if you want.

#4933670 Is an engine necessary for 3D games?

Posted by on 21 April 2012 - 07:53 PM

You can create your prototype in Unity or Unreal Engine SDK. Both have good video tutorials (for instance, digitaltutors.com (http://www.digitaltutors.com/training/unity-tutorials) and are incredible solid. With this you can focus in the game design without worrying in aspects that are not related with gameplay.

Then, if you want to make a real game of your prototype you can use noncommercial software like an XNA engine. The good part is XNA and C# allow making games easier than C++ plus OpenGL or DirectX and Unity works with C# so that you can port directly part of your code.

Here are a list of XNA engines: http://nelxon.com/resources/xdsk2.php (My engine is trying to be Unity friendly, but still are much work to do).

#4932593 VertexBuffer performance issue. Idea for a strategy?

Posted by on 18 April 2012 - 03:28 PM

I've found a bottelneck in my code.
I call SetTexture for every chunk Posted Image
Now I'm calling it once and the performance is better.

If I fill the Buffers once and draw draw the primitives the program runs with 60 fps.
I think your right, that the bottleneck is copying the std::vectors into the buffers.

Have you got any idea to fix the problem with the performance issue?

Both problems seems related with CPU-GPU communication.

Just copy the buffers when you do modifications. And only copy the chunk being altered.
Load Method: Create a set of chunks.
Update Method: If the player add or remove a block then redo the chunk affected
Render Method: just render the buffers.

If you need even more performance you can improve the update method with dynamic buffers.
Vertex buffers are arrays of information stored in the GPU memory. The problem is that access this memory is costly (for several reason). In consequence you should do the less communication possible. Dynamic buffers are like regular vertex buffers that can be altered with user commands. You are still doing a communication between CPU and GPU, but dynamic buffers allows you to do per vertex, so that less communication is need it.
One more thing, Is the system destroying the memory used for the previous buffers? Like I said I don’t know much of DX9 commands, so don’t ask how to know that.

#4932236 Multiple point lights, shaders.

Posted by on 17 April 2012 - 01:04 PM

This is an old problem that has many solutions. Some are:
  • Let’s say that you know the engine needs in several scenarios three point lights and one point light in others. You could implement a technique for three point lights and one for one point light and you switch to whatever you need.
  • I think Unreal uses a multi pass shader. I suppose they use additive blending.
  • Deferred renderers. My favorite!!! You can render the points lights you need. 100? Ok, you have it and with a very good performance. The problem is that you have to re implement all your pipeline Posted Image
If you only ask how to add the second point light to your shader, just calculate a second LightDir in your vertex shader (with the second point light position) and add the diffuse result of the second light to the diffuse result of the first.

And try to work in linear space: http://http.develope...gems3_ch24.html


#4931192 Component based >? Inheritance based design

Posted by on 14 April 2012 - 08:07 AM

Then surely having a state class with event/update/render functions (which mine have always had) wouldn't be needed.

Yes and no. Yes, because the game objects are renderered and updated by thyself. However, you should need to update your logic somewhere. One possibility is to associate scripts components to game objects. The scripts have custom update functions (the only component with an update method that is called by the script manager) and know the entity (the entity could be an empty entity with just the script). Another alternative is to manage the logic partial or totally in a higher level.
It’s up to you. But yes, the components are managed only by their manager, you only modified their data.

#4931088 Component based >? Inheritance based design

Posted by on 13 April 2012 - 05:17 PM


In this kind of hierarchy, should the parent and child knows about each other's components in general, and work accordingly?

Depends how you interpreted “knowing each other”. The child only need to know the father world matrix and nothing more. It is possible that some custom script could also read some information from the father.

- Ideally all entities should be treated exactly the same (on the outside nothing knows or can know what components does the entity have)

Yes. The entity does not have an update, only the components.

- Each component is capable of working completely independently without the assumption or knowledge of any other component within the same entity

This is tricky. For example, a renderer component needs the world matrix from the transform component and the model from the model component. You just can’t avoid not knowing anything.
That said, yes, the component update has to be isolated. The only exception is the transform component; a physic component for instance could modify the entity’s transformation.

For the communication, the way I picture it huge switch-case blocks will need to be used for the "just in case there is a xyz component in this entity". Is that how it should be?

No, messages or events are the best. The component that needs information asks for the information, not the other way around. Read Jason book, read Unity3D reference, or look at my engine.

For the custom hierachy, when an entity is in Father-Child relationship, how does that affect the general operation? Does each component have to have a different set of switch-case statements in case the holding entity is a Child, or is a Father?

The components normally are very simple. Transformation components (a maybe physics components, I don’t know) are the only that needs to know the entity father. And actually, in the actual implementation the transform component is the only that holds the father (not even the entity). This is intended for data oriented optimizations and because is somehow logical.

#4931080 Component based >? Inheritance based design

Posted by on 13 April 2012 - 04:34 PM

In my inheritance based structure, I could have my ship entity that owns 2 wing entities that move and emit particles based on the ships velocity, and can own weapon entities, that are also animated, and can use auto targeting (turn toward and target the closest enemy).

With component based design how is this implemented? Should the ship, wings, weapons be separate entities (each with its own set of components) that are tied together somehow, or I should just have my ship entity and the wings, ship weapons, wing weapons be components?

They are different entities with different components. But the entities are in a hierarchy (not inherence).
You should have something like this:
Ship = new GameObject();
// Fill Components
Wings = new GameObject();
// Fill Components
Wings.Father = Ship;

Then, when you move the ship the wings will move equally.

#4931078 Component based >? Inheritance based design

Posted by on 13 April 2012 - 04:30 PM

Another one from DICE: http://publications.dice.se/attachments/AStepTowardsDataOrientation.ppt

And another good one:

#4931074 Component based >? Inheritance based design

Posted by on 13 April 2012 - 04:19 PM

You can read about components in the chapter 14 of the Jason Gregory's book Game Engine Architecture (third time in two weeks that I recommend this book, I am not Jason Posted Image)

Component based model could be complemented with data oriented design: http://research.scee.net/files/presentations/gcapaustralia09/Pitfalls_of_Object_Oriented_Programming_GCAP_09.pdf

#4930955 graphic card

Posted by on 13 April 2012 - 08:22 AM

XNA 4 requires a DX10 GPU

Are you sure on this? Pretty sure XNA is limited to DirectX 9 because of the XBox compatibility.

XNA 4 requires a DX10 GPU for HiDef profile, and DX9 for Reach. (http://blogs.msdn.co...h-vs-hidef.aspx)

DX10 standardized several hardware incompatibilities, like filtering in floating point textures. When XNA 4 was developed DX 9 GPUs were losing their presence, so it was a good call.

#4930660 Deferred rendering diffuse

Posted by on 12 April 2012 - 01:43 PM

And what surface formats do you use in this GBuffer? I predict a lack of precision. 8 bits per channel are not enough, and more important don’t store negative values.

Use a R32F to store the depth (only the depth), be aware that Z is managed different in OpenGL/XNA and DirectX. For now you should use a 1010102 format to store normals in a floating point format.

If you are serious about this you should do things correctly for the start. Deferred rendering is not an easy topic.

#4930313 Shadow Mapping

Posted by on 11 April 2012 - 11:22 AM


I don’t remember where I read about PCF. Sorry. I remember that I read a lot (the only way to learn properly) and adapted a MJP example to implement my shadow system.


You can find my shadow system in my signature (download the source code from the source tab). I have to do some optimizations but for the most part works well.

Good luck!!!

#4928503 3D engine core layout questions.

Posted by on 05 April 2012 - 09:22 AM

I find the Jason Gregory’s book (Game Engine Architecture) to be a great survey of graphic engine technologies.

I don’t know the time frame that you have, your skills, and the level of technology that you want to achieve. However, I can recommend that you research about data oriented design and component oriented design. For me the core of the engine start there, then you can plan the assets and stuff.

Good luck!!

#4927873 Ashikhmin-Shirley lightning model

Posted by on 03 April 2012 - 08:06 AM

Why not isolate the different parts of the equation?

Also, the pow function does not work with values below or equal 0 because the implementation is done with the equation exp(log(value) * value). Try to put something like this: max(dot(…), 0.0001f);

Good luck!!!