Hornsj3

Members
  • Content count

    52
  • Joined

  • Last visited

Community Reputation

195 Neutral

About Hornsj3

  • Rank
    Member
  1. If you want per-pixel lighting you have to do it in the pixel shader.     To do this you need at least the pixel normal and light direction vector for each light used.  You can calculate the light vector if you pass position and have the light positions as a uniform, and you must pass the normal vector as input as well.   Yes, what you describe is the standard way.
  2. There's at least one book with an example implementation. Practical Rendering and Computation with DirectX 11.
  3. The author is pretty responsive. I've contacted him in the past.
  4. Terrainperformance - round 2

    I'm going to remove this post because I don't think it adds any value.
  5. DirectX book

    [url="http://www.crcpress.com/product/isbn/9781568817200"]http://www.crcpress.com/product/isbn/9781568817200[/url]
  6. Terrain (advanced)

    Another optimization. I can't remember the syntax exactly but you should probably grab raw memory instead of new chunk[max_chunks]. The reason is calling new chunks[max_chunks] will invoke the chunks constructor max_chunks times. There's no reason to do this and it will slow you down. I think the solution is this chunk* variableName = static_cast<chunk>(operator new (sizeof(chunk) * max_chunks)); The difference is when you say "operator new" and specify an amount of memory it will just reserve raw memory and therefore not construct your objects. All other aforementioned rules apply. edit - When doing this please note you have to keep track of how many constructed objects you have and where they are in the buffer because as I mentioned those objects will not exist until placed. Using raw memory when you expect to have a constructed object would not have the effect you intend =D.
  7. Terrain (advanced)

    That looks about right, yes. Edit - I spoke a bit too soon. You don't want to call delete on a single item. The whole idea is to have that memory reserved for your program throughout its lifetime. Just call the destructor on the object you want to get rid of. You only have to call delete on the buffer when you are done with the entire thing. //To get rid of one item : pseudo code (chunkList + someInteger)->~chunk(); (e.g. chunkList + 3 will put you at effectively chunkList[3]) //to get rid of the pool : pseudo code 1. for each object in pool 2. call destructor 3. end of loop 4. call delete [] pool. Herb Sutter has a great example of this in Exceptional C++.
  8. Terrain (advanced)

    If you are using C++ you could use a memory pool. This would cut down on your allocation and deallocation on the heap. Basically during program initialization you could allocate an amount of memory off the heap and store it in a pointer. Then, you can use the placement new (look this up) syntax during runtime to store your data in this pre-allocated area of memory. Because heap allocations are expensive at runtime and can throw exceptions this solution would increase your performance and make it more exception safe. You must look up how to use placement new because there are tricks to it, such as the need to explicitly call the destructor. edit - You don't have to store all of the tiles in memory either, you can place and destroy at will.
  9. Remeber state of pixel in HLSL.

    Hmm if you said DX11 I would say use an unordered access view (UAV) and use it as a RWTexture2D in your pixel shader. It looks like those are only available in the compute shader for DX10.
  10. Screen space , World space issue ?

    This shader is going from screen space to world space. It is taking a point (where w == 1 i.e. screen space) and multiplying by the inverse of the view*projection matrix. After this multiplication w should not be 1. You then divide the point by w to get the world space coordinates. I'll have to do more digging in my graphics text book for a detailed explanation. What I've just given you is based off memory and a quick refresher.
  11. Screen space , World space issue ?

    Look up the terms perspective divide and homogeneous coordinates. Also, post code for the shaders please. It is hard to imagine the full context. Thank you.
  12. The more you know about the subject, the quicker it is to finish. Sometimes you just want to get a different person's perspective, but you are already an expert on the subject. Sometimes it's a new subject and you have to learn to think differently (the graphics pipeline comes to mind here).
  13. And, WIN32 is fully supported for Windows8 desktop apps. If you are targeting Metro Apps you have to target WinRT, as well as a subset of DirectX (due to the Metro sandbox). Go to MSDN and look at the target environment of some of the functions (desktop apps / metro apps). Like all mobile environments, MetroUI restricts access to system resources.
  14. Quaternion Camera rotation

    The orientation is determined by where the camera is looking, i.e. the target vector, and the up direction. If your camera is rolling you create the quaternion for rotation about the target vector. You can then multiply the current up vector by that quaternion, and then that result by the conjugate of the quaternion (same as the inverse of a quaternion if the quaternion's vector component is uniform). This will give you a new up vector which will be in a direction which corresponds to the rotation about the target axis. Follow the example above for roll. The view matrix can then be created using the [left][background=rgb(250, 251, 252)]XMMatrixLookToLH( m_camPosition, m_camTarget, m_camUp) function.[/background][/left]
  15. Quaternion Camera rotation

    A quaternion represents a rotation of some scalar amount around a specified axis. (e.g. {30.0, 0.0, 0.0, 1.0} could represent 30 degrees around the z axis) What you are doing above seems to be creating a view matrix and using that to generate a rotation quaternion. If you use the XMMatrixRotationQuaternion method I think you need to pass it a rotation matrix (not the view matrix). Either way, once you have the rotation quaternion you apply it to the up axis to rotate the up direction with respect to the amount of roll you specified. I think you should search around for a simplified explanation of quaternions. I am terrible at explaining this.