Jump to content

View more

Image of the Day

The beast has a mighty searchlight of evil! #screenshotsaturday https://t.co/bzKepOojDL
IOTD | Top Screenshots

The latest, straight to your Inbox.

Subscribe to GameDev.net Direct to receive the latest updates and exclusive content.

Sign up now

Debug pixel shader

4: Adsense

Old topic!

Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.

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

#1 blackfe2010   Members   


Posted 16 December 2012 - 01:41 AM


I want draw a model, but nothing displayed on the screen, just background color.
I use the PIX to find the problem. but it's hard for me to detect what's wrong with it.

I look at the mesh in PIX, the Pre-Vertex shader and Post-Vertex Shader are drew well. but nothing in viewport.(I'm not use the Geomethry shader)

I guess there is someting wrong in the Pixel shader.

Here is the code in HLSL:

Texture2D DefaultTexture : register( t0 );
SamplerState DefaultSampler : register( s0 );
cbuffer cbChangesEveryFrame : register( b0 )
matrix WorldMatrix;
cbuffer cbNeverChanges : register( b1 )
matrix ViewMatrix;
cbuffer cbChangeOnResize : register( b2 )
matrix PerspMatrix;

struct VSInputTexture
float4 pos : POSITION;
float2 tex0 : TEXCOORD0;
struct PSInputTexture
float4 pos : SV_POSITION;
float2 tex0 : TEXCOORD0;

PSInputTexture VSWithCameraWithTexture(VSInputTexture vertex)
PSInputTexture vsOut = ( PSInputTexture )0;
vsOut.pos = mul( vertex.pos, WorldMatrix );
vsOut.pos = mul( vsOut.pos, ViewMatrix );
vsOut.pos = mul( vsOut.pos, PerspMatrix );
vsOut.tex0 = vertex.tex0;
return vsOut;

float4 PSWithTexture(PSInputTexture frag) : SV_TARGET
float4 col = DefaultTexture.Sample( DefaultSampler, frag.tex0 );
return col;

technique11 DefaultTechniqueWithCameraWithTexture
pass P0
SetVertexShader( CompileShader( vs_5_0, VSWithCameraWithTexture()));
SetGeometryShader( NULL);
SetPixelShader( CompileShader( ps_5_0, PSWithTexture()));

No compile error about this HLSL.

In Rasterizer:

Slot TopLeftX TopLeftY Width Height MinDepth MaxDepth
0 0.000f 0.000f 800.000f 600.000f 0.000f 1.000f
(1-15) N/A N/A N/A N/A N/A N/A

Rasterizer 0x066294A0
Fill Mode D3D11_FILL_SOLID
Cull Mode D3D11_CULL_BACK
Front Counter-clockwise FALSE
Depth Bias 0
Depth Bias Clamp 0.000f
Slope Scaled Depth Bias 0.000f
Depth Clip Enable FALSE
Scissor Enable FALSE
Multisample Enable FALSE
Antialiased Line Enable FALSE

In Pixel Shader:

Slot Sampler Filter AddressU AddressV AddressW MipMapLODBias MaxAnisotropy ComparisonFunc BorderColorRGBA MinLOD MaxLOD
0 0x06627010 D3D11_FILTER_MIN_MAG_MIP_LINEAR D3D11_TEXTURE_ADDRESS_WRAP D3D11_TEXTURE_ADDRESS_WRAP D3D11_TEXTURE_ADDRESS_WRAP 0.000f 0 D3D11_COMPARISON_NEVER (0.000f, 0.000f, 0.000f, 0.000f) 0.000f 340282346638528860000000000000000000000.000f

I have checked every thing but still don't know why nothing displayed.

Could you help me?

#2 DgekGD   Members   


Posted 16 December 2012 - 06:14 AM

Actually, there are a lot of things that can go wrong in your code and i don't see any explicit error here. In pixel shader try
     return float4(1.0f, 1.0f, 1.0f, 1.0f);

If you see your object white, probably problem lies in binding texture resource (DefaultTexture in your shader code). If still nothing appears, check that you update constant buffers with matrices correctly for the vertex shader and bind right render target for your pixel shader. Or maybe you placed vertices in the wrong order and rasterizer culls your geometry, try D3D11_CULL_NONE.

#3 blackfe2010   Members   


Posted 16 December 2012 - 08:27 AM

	 return float4(1.0f, 1.0f, 1.0f, 1.0f);

I don't see the white object.

And i try to use "D3D11_CULL_NONE", it's still not work.

so I think the problem seem in the render target because I can see the object in Post-Vertex Shader in the PIX,
It can prove the matrix work, isn't it?

Here is the code about the render target:

[source lang="cpp"] hr = m_swapChain->GetBuffer(0, __uuidof(ID3D11Texture2D), (LPVOID*)&backBufferPtr); CHECK_FAILED(hr) hr = m_device->CreateRenderTargetView(backBufferPtr, NULL, &defaultRenderTargetView); CHECK_FAILED(hr) backBufferPtr->Release(); backBufferPtr = 0; deviceContext->OMSetRenderTargets(1, &defaultRenderTargetView, NULL);[/source]

The code is simple. but I only use OMSetRenderTargets at the beginning of the porgram. Shall I use It pre-frame?

And I still dont know what's wrong in my code.

Old topic!

Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.