Jump to content

  • Log In with Google      Sign In   
  • Create Account

Sturmh

Member Since 21 Nov 2010
Offline Last Active Feb 04 2014 11:43 AM

Topics I've Started

[Solved] Terrain tessellation and depth buffer

15 December 2013 - 10:16 PM

I am doing some terrain rendering and I've run in the some troubles. At this point in time I am just tessellating vertex patches then displacing them with a height map. My current problem is that the rendering looks pretty funky. I've been debugging this for a while and it looks like it is a problem with the depth buffer. Past that, I don't really have any ideas on what is happening. 
 
 
 
lQWcDk7l.pngbJkFPVGl.png
 
 
Here's what visual studio says is going on with the depth buffer (different scene). Wasnt really sure the best way to show this using the debugger so I grabbed an image of the red channel and the green channel
YrbbW9ul.pnggiVx552l.png
Note: The top left of this image is actually a similar depth to the bottom area of the image
 
 
Here's backbuffer:
XCyNgo5l.png
 
As I understanding it, closer pixels should be colored darker than further pixels. As you can see when comparing the second and third images, it seems like the opposite is happening. Am i misunderstanding something or is something weird happening.
 
Any thoughts or pointing in a direction would be very appreciated since I'm out of ideas.
 
 
I'll also post how I am setting up my depth buffer for possible questions:
 D3D11_DEPTH_STENCIL_DESC dsdesc;
    ZeroMemory(&dsdesc, sizeof(dsdesc));


    dsdesc.DepthEnable = true;
    dsdesc.DepthWriteMask = D3D11_DEPTH_WRITE_MASK_ALL;
    dsdesc.DepthFunc = D3D11_COMPARISON_LESS;
    dsdesc.StencilEnable = true;
    dsdesc.StencilReadMask = 0xFF;
    dsdesc.StencilWriteMask = 0xFF;
    dsdesc.FrontFace.StencilFailOp = D3D11_STENCIL_OP_KEEP;
    dsdesc.FrontFace.StencilDepthFailOp = D3D11_STENCIL_OP_INCR;
    dsdesc.FrontFace.StencilPassOp = D3D11_STENCIL_OP_KEEP;
    dsdesc.FrontFace.StencilFunc = D3D11_COMPARISON_ALWAYS;
    dsdesc.BackFace.StencilFailOp = D3D11_STENCIL_OP_KEEP;
    dsdesc.BackFace.StencilDepthFailOp = D3D11_STENCIL_OP_DECR;
    dsdesc.BackFace.StencilPassOp = D3D11_STENCIL_OP_KEEP;
    dsdesc.BackFace.StencilFunc = D3D11_COMPARISON_ALWAYS;


    HR(_device->CreateDepthStencilState(&dsdesc, &_depthStencilState));
    
    D3D11_RASTERIZER_DESC rd;
    rd.AntialiasedLineEnable = false;
    rd.CullMode = D3D11_CULL_BACK;
    rd.DepthClipEnable = true;
    rd.DepthBias = 0;
    rd.DepthBiasClamp = 0.0f;
    rd.FillMode = D3D11_FILL_SOLID; 
    rd.FrontCounterClockwise = false;
    rd.MultisampleEnable = false;
    rd.ScissorEnable = false;
    rd.SlopeScaledDepthBias = 0.0f;
 
 

 


Increment texture values using render to texture

15 December 2013 - 05:08 PM

As I understand it you cant bind the a texture as a render target and a shaderresource at the same time. How does one typically handle the situation where you want to render to a texture but sample that same texture in the render to texture operation. The reasoning would be if you need to use the previous value in the texture in the new value being written.The only way I could think of was to duplicate your texture and use one as the render target every frame and the other as the resource. Once the render is complete, copy the render target to the resource view.

 

Thought?

 


[Solved] DX11 Updating texture data

11 July 2011 - 09:46 PM

After looking through all the threads I could find relating to this topic and failing, it would seem it is now time to ask for some help.


I have a 32bit BGRA buffer that I am binding to a texture:
D3D11_TEXTURE2D_DESC td;
td.ArraySize = 1;
td.BindFlags = D3D11_BIND_SHADER_RESOURCE;
td.Usage = D3D11_USAGE_DYNAMIC; 
td.CPUAccessFlags = D3D11_CPU_ACCESS_WRITE;
td.Format = DXGI_FORMAT_B8G8R8A8_UNORM;
td.Height = m_renderBuffer.height;
td.Width = m_renderBuffer.width;
td.MipLevels = 1;
td.MiscFlags = 0;
td.SampleDesc.Count = 1;
td.SampleDesc.Quality = 0;
  
D3D11_SUBRESOURCE_DATA srd;
srd.pSysMem = m_renderBuffer.buffer;
srd.SysMemPitch = m_renderBuffer.rowspan;
srd.SysMemSlicePitch = 0;

HR(device->CreateTexture2D(&td, &srd, &m_texture));

which I then bind to a ShaderResourceView and set as a shader resource
HR(device->CreateShaderResourceView(m_texture, 0, &m_textureRV));
.
.
deviceContext->PSSetShaderResources(0, 1, &m_textureRV);

I render this once and it works just as expected.
Then I try to update the texture..
HR(deviceContext->Map(m_texture, 0, D3D11_MAP_WRITE_DISCARD, 0, &mappedResource)

mappedResource.pData = (void*)m_renderBuffer.buffer;
mappedResource.RowPitch = m_renderBuffer.rowspan;
mappedResource.DepthPitch = 0;

deviceContext->Unmap(m_texture, 0);

Right now Im just updating with the same buffer but that wont be the case in reality. After I try to update the texture, the texture is no longer shows up, and nothing shows up anymore. I am not getting any errors related to this from the Debug Device. I feel like I am doing everything correctly. Creating the texture with D3D11_USAGE_DYNAMIC, and D3D11_CPU_ACCESS_WRITE then using Map to update the texture. Everything I read says this is the proper method. Either I missed something, or I am doing it incorrectly.

Any ideas?

PARTNERS