Jump to content

  • Log In with Google      Sign In   
  • Create Account

menohack

Member Since 06 Mar 2013
Offline Last Active Aug 01 2013 03:22 PM

Topics I've Started

Debugging the stencil buffer

10 July 2013 - 10:19 PM

Is it possible to display the stencil buffer as a texture? The only formats available to a shader resource view are DXGI_FORMAT_R24_UNORM_X8_TYPELESS and DXGI_FORMAT_R32_FLOAT_X8X24_TYPELESS. When I try to draw this as a quad I only seem to have access to the x or r component, which is the depth.

 

Thanks!


Shadow volumes Z-fail

09 July 2013 - 12:24 PM

I have Z-pass working for my D3D11 application but no matter what I try I can't get z-fail to work. Here is my depth stencil state for building the stencil buffer with z-pass:

D3D11_DEPTH_STENCIL_DESC depthStencilDesc = {0};
	depthStencilDesc.DepthEnable = true;
	//Disable depth writes when rendering the volumes
	depthStencilDesc.DepthWriteMask = D3D11_DEPTH_WRITE_MASK_ZERO;
	depthStencilDesc.DepthFunc = D3D11_COMPARISON_LESS;
	depthStencilDesc.StencilEnable = true;
	depthStencilDesc.StencilReadMask = D3D11_DEFAULT_STENCIL_READ_MASK;
	depthStencilDesc.StencilWriteMask = D3D11_DEFAULT_STENCIL_WRITE_MASK;

	//Stencil operation for front-facing polygons should increment
	depthStencilDesc.FrontFace.StencilFunc = D3D11_COMPARISON_ALWAYS;
	depthStencilDesc.FrontFace.StencilDepthFailOp = D3D11_STENCIL_OP_KEEP;
	depthStencilDesc.FrontFace.StencilPassOp = D3D11_STENCIL_OP_INCR;
	depthStencilDesc.FrontFace.StencilFailOp = D3D11_STENCIL_OP_KEEP;
	

	//Stencil operation for back-facing polygons should decrement
	depthStencilDesc.BackFace.StencilFunc = D3D11_COMPARISON_ALWAYS;
	depthStencilDesc.BackFace.StencilDepthFailOp = D3D11_STENCIL_OP_KEEP;
	depthStencilDesc.BackFace.StencilPassOp = D3D11_STENCIL_OP_DECR;
	depthStencilDesc.BackFace.StencilFailOp = D3D11_STENCIL_OP_KEEP;
	

	hr = g_pd3dDevice->CreateDepthStencilState(&depthStencilDesc, &buildShadowVolumeDepthStencilState);

How would I modify this to do z-fail?


SDL TTF text cut off

20 June 2013 - 02:06 PM

As you can see from the picture when I render text from a certain font that I found it cuts off the top. Another similar font cut off the bottom. When I print using lazy.ttf from LazyFoo's tutorials it works fine. Is there something wrong with the fonts that I am using? I am using Pokemon GB from here. I am blitting using the entire surface (null for the srcRect).


Translation within geometry shader

23 April 2013 - 12:48 PM

Quick question: I am trying to translate vertices by a vector from a constant buffer in my geometry shader and something is not working out. My vertex shader multiplies the vertices by the world, view, and projection matrix. I pass in my vector (1,1,1) and set the w-component to 1 as well to allow translation. Then I multiply the vector by the view and the projection matrices and add it to the position of the vertex. I am expecting this to give me a new position further from the screen but it makes it closer instead. It also causes lines that I expect to be parallel to come closer together towards the new point. Please look at the attached image for an example. The purpose of this is to generate shadow volumes with an orthographic light source. I have even tried doing the projection matrix multiply in the geometry shader after calculating the position but I get the same result. Help would really be appreciated! Thanks.


Finding pixel offset for silhouette shadow mapping

06 March 2013 - 07:06 PM

I've looked around but I can't figure out if D3D will give me what I need. I want to create a silhouette map to implement this paper. What I need is an x-y offset of a line relative to the center of the pixel. That is, when a wireframe model is rendered D3D picks the closest pixel to the line and draws it. I want to know where exactly the line cuts through the pixel. This will be the value stored in my silhouette map. Is there any way to get this in D3D11? The x-y values of POSITION are just the pixel index plus 0.5. Do I have to do this on the cpu or use a compute shader or is there an easier way? From the attached image I want to find point O. The paper passes in the endpoints of the line segments but it would be a lot easier if D3D gave me access to some of the values that it computes at the rasterization state. Thanks.


PARTNERS