Jump to content

  • Log In with Google      Sign In   
  • Create Account

Zaoshi Kaba

Member Since 04 Nov 2012
Online Last Active Today, 12:49 AM

#5105138 different colors when using XMVECTOR or XMFLOATs

Posted by Zaoshi Kaba on 28 October 2013 - 02:24 PM

Just making sure... XMFLOAT3 and XMVECTOR are different size, did you change input layout & vertex strides to match that?

#5104784 DirectX rendering procedure

Posted by Zaoshi Kaba on 27 October 2013 - 09:42 AM

Is short, you setup rendering states: render targets, render states, textures, buffers, other things, and then draw. After that you need to change only what changed.

So lets say if you have 100 different models that use same textures/everything your loop would look like (pseudocode):

context->SetIndexBuffer() // assuming index buffer is identical
for(...) {

#5104010 Just released some small project that I have

Posted by Zaoshi Kaba on 24 October 2013 - 01:02 AM

This is just my personal opinion and nothing constructive.


I hate boost, therefore I think this is a terrible idea to use boost for a library you're going to distribute. One of reasons is, to compile your 10 KB program I need to download 50+ MB boost libraries; that's just silly.


I noticed some weird things with your includes:

// you are using
#include <boost/unordered_map.hpp>

// but probably all compilers have unordered_map in Standard C++ Library (SCL)
#include <unordered_map>
// another boost include
#include <boost/filesystem.hpp>

// won't complain about this one, but kind of a tip
// Visual Studio 2013 has this include in SCL, don't know about other compilers
#include <filesystem>
using namespace std::tr2::sys;

Your PIUArchiveImpl::write() method (and others) print to standard output, that's unacceptable, use callbacks if output is possible.

#5103744 Matrix Multiplication Order

Posted by Zaoshi Kaba on 23 October 2013 - 09:44 AM

Try this:

float4x4 matFinal = mul(matProj, mul(matView, matWorld));

But it's probably better to transform vertex thrice:

position = mul(matWorld, position);
position = mul(matView, position);
position = mul(matProj, position);

#5102785 Depth Buffer rendering nothing

Posted by Zaoshi Kaba on 20 October 2013 - 02:00 AM

1. world_z_min cannot be 0. Use 0.1f or something similar.



g_pImmediateContext->Draw(sizeof(vertices), 0); 

sizeof() returns size in bytes, but Draw() call requires number of vertices, use ARRAYSIZE() macro.

#5102782 Depth sorting issue

Posted by Zaoshi Kaba on 20 October 2013 - 01:55 AM

You create DXGI_FORMAT_D24_UNORM_S8_UINT texture (32 bit) why your DSV is DXGI_FORMAT_D32_FLOAT_S8X24_UINT (64 bits) that's why it doesn't work.

If need Stencil and still want to use that texture format then I think DXGI_FORMAT_D24_UNORM_S8_UINT is the right choice for DSV.

You can also pass nullptr for 2nd parameter in CreateDepthStencilView() call, it'll use default values which shouldn't fail.

#5101256 Writing to R16G16_UINT

Posted by Zaoshi Kaba on 14 October 2013 - 05:44 AM

I think it complains your vertex's size isn't multiple of 4. You can try changing LODID to DXGI_FORMAT_R32_UINT or just leave it unused.

Since it mentions other formats you could also try to use separate buffer for LODID with DXGI_FORMAT_R16_UINT.

#5099139 Tesselation quad

Posted by Zaoshi Kaba on 06 October 2013 - 11:31 AM

Recently I attempted to tessellate basic quad as well so I compared your code to mine and my Domain Shader is a bit different:

float3 bilerpUV(float3 v[4], float2 uv) {
	float3 bottom = lerp(v[0], v[1], uv.x);
	float3 top = lerp(v[3], v[2], uv.x); // this line differs
	float3 result = lerp(bottom, top, uv.y);

	return result;

DS_OUTPUT main(HS_CONSTANT_DATA_OUTPUT input, const OutputPatch<HS_CONTROL_POINT_OUTPUT, 4> patch, float2 domain : SV_DomainLocation) {
    Output.vPosition = float4(bilerpUV(patch, domain), 1);
    // other code

#5098540 How do I use multithreading?

Posted by Zaoshi Kaba on 03 October 2013 - 01:38 PM

With while() loop compiler probably put variable into register, so value in memory will never be updated until function is exited or significant part of other code is executed. You can fix this by making variable volatile:

volatile int tp3 = 0;

#5098342 super small distant renderables

Posted by Zaoshi Kaba on 02 October 2013 - 02:33 PM

There are 3 rules for triangle rasterization, you can find them at http://msdn.microsoft.com/en-us/library/windows/desktop/cc627092%28v=vs.85%29.aspx

#5098341 interpolating scalar instead of vector

Posted by Zaoshi Kaba on 02 October 2013 - 02:31 PM

Yes you can. No, value will be different.

#5096633 Migrating from D3DX to DirectXMath

Posted by Zaoshi Kaba on 25 September 2013 - 07:07 AM

Function is hidden inside namespace, therefore you'll have to use one of these:

using namespace DirectX;
// or
using DirectX::operator-;

#5090599 ID3D11ShaderResourceView save to file

Posted by Zaoshi Kaba on 31 August 2013 - 09:49 AM

  1. Create texture with D3D11_USAGE_STAGING flag
  2. Use CopyResourcemethod to copy texture from ID3D11SRV to newly created texture
  3. Use Map to read texture data on CPU
  4. Figure how to write DDS files or use IWICImagingFactory interface

#5088457 DXUT and Windows 8, application hanging on first run

Posted by Zaoshi Kaba on 23 August 2013 - 01:02 PM

No hangs here, app starts within 5 seconds after double click.


Windows 8 Pro x64

i7-4770K @ 3.50 GHz



#5081376 Is there a simpler way of doing this?

Posted by Zaoshi Kaba on 29 July 2013 - 01:44 AM

Since you're using C++ you should refrain from using char* for text. string class was made specifically for that.

// at the top
#include <string>
using std::string;

// in main
string c = "Hello world\n";
for(int i = 0; i < c.length(); i++) {
    cout << c[ i ];

// alternatively
cout << c; // print whole string at once