Jump to content


D3D10 - Where is my object??


  • You cannot reply to this topic
No replies to this topic

#1 XVincentX

    Valued Member

  • Members
  • PipPipPip
  • 115 posts

Posted 12 December 2008 - 07:46 PM

Hello.
I'm making a new demo and so made a new D3D10 application. But now i'm going in a situation i never see.

I just have a simple mesh that does not appears on the screen. So, thinking to the usual error, i run a Pix simulation that gave me this

http://img261.images...90793088uk7.jpg

So i thought: surely it's the culling. Disabling it, here is the result.

http://img517.images...39500994gs5.jpg

Even if i move camera in each kind of position the result does not change.

Here are the most important code parts

//Vertex and Pixel Shader creation

	ID3D10Blob *code, *error;


	HANDLE h = CreateFile("ShadowMap.fx",GENERIC_READ,0,0,OPEN_EXISTING,FILE_FLAG_SEQUENTIAL_SCAN,NULL);

		DWORD size = GetFileSize(h,0);

		DWORD read;

		char *data = new char[size + 1];

			ReadFile(h,data,size,&read,0);

			data[size] = 0;

	CloseHandle(h);


	HRESULT hr = D3D10CompileShader(data,size,"ShadowMap.fx",NULL,NULL,"ps_shadow","ps_4_0",D3D10_SHADER_OPTIMIZATION_LEVEL3|D3D10_SHADER_SKIP_VALIDATION,&code,&error);


	if (error)

	{

		MessageBox(NULL,(char*)error->GetBufferPointer(),"Error",MB_OK);

		error->Release();

	}


	Device->CreatePixelShader(code->GetBufferPointer(),code->GetBufferSize(),&PixelShader);

	code->Release();

	


	D3D10CompileShader(data,size,"ShadowMap.fx",NULL,NULL,"vs_shadow","vs_4_0",D3D10_SHADER_OPTIMIZATION_LEVEL3|D3D10_SHADER_SKIP_VALIDATION,&code,&error);

	

	if (error)

	{

		MessageBox(NULL,(char*)error->GetBufferPointer(),"Error",MB_OK);

		error->Release();

	}


	Device->CreateVertexShader(code->GetBufferPointer(),code->GetBufferSize(),&VertexShader);


	delete[] data;	

	

	Device->VSSetShader(VertexShader);

	Device->PSSetShader(PixelShader);	


	Room = LoadFromFile("room.x",Device);

	Room->Mesh->CommitToDevice();


	UINT declcount;

	const D3D10_INPUT_ELEMENT_DESC *desc;


	Room->Mesh->GetVertexDescription(&desc,&declcount);

	Device->CreateInputLayout(desc,declcount,code->GetBufferPointer(),code->GetBufferSize(),&Room->Layout);

	code->Release();








//This is the shader


cbuffer cEveryFrame

{

	float4x4	WorldMatrix;

}


cbuffer cSometime

{

	float4x4	ViewMatrix;

	float4		LightDirection;

}


cbuffer cNeverChange

{

	float4x4	ProjMatrix;

}


struct VS_INPUT

{

	float4 Pos	:	POSITION;

	float3 Nor	:	NORMAL;

	float2 Tex	:	TEXCOORD;

};


struct PS_INPUT

{

	float4	Pos	:	SV_POSITION;

	float3	Nor	:	NORMAL;

	float2	Tex	:	TEXCOORD;

};


PS_INPUT vs_shadow(VS_INPUT In)

{

	PS_INPUT Out = (PS_INPUT)0;


	Out.Pos = mul(mul(mul(In.Pos,WorldMatrix),ViewMatrix),ProjMatrix);

	Out.Nor = In.Nor;

	Out.Tex = In.Tex;


	return Out;	

}


float4	ps_shadow (PS_INPUT In)	:	SV_TARGET

{

	return 0;

}


technique10 ShadowMap

{

	Pass Simple

	{

		SetVertexShader( CompileShader( vs_4_0, vs_shadow() ) );

		SetGeometryShader(NULL);

		SetPixelShader( CompileShader( ps_4_0, ps_shadow() ) );

	}

}







//Viewport


	D3D10_VIEWPORT vp;


	vp.TopLeftX = 0;

	vp.TopLeftY = 0;

	vp.Width = desc.BufferDesc.Width;

	vp.Height = desc.BufferDesc.Height;

	vp.MinDepth = 0.0f;

	vp.MaxDepth = 1.0f;


	Device->RSSetViewports(1,&vp);


What kind of error could be here?
The only warning i get in Draw function is this one


D3D10: WARNING: ID3D10Device::DrawIndexed: The size of the Constant Buffer at slot 1 of the Vertex Shader unit is too small (64 bytes provided, 80 bytes, at least, expected). This is OK, as out-of-bounds reads are defined to return 0. It is also possible the developer knows the missing data will not be used anyway. This is only a problem if the developer actually intended to bind a sufficiently large Constant Buffer for what the shader expects. [ EXECUTION WARNING #351: DEVICE_DRAW_CONSTANT_BUFFER_TOO_SMALL ]

But i do not think that it means something...
Thank you!





1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users