Jump to content

  • Log In with Google      Sign In   
  • Create Account

We're offering banner ads on our site from just $5!

1. Details HERE. 2. GDNet+ Subscriptions HERE. 3. Ad upload HERE.


caballero

Member Since 12 Mar 2011
Offline Last Active Feb 16 2012 01:30 PM

Posts I've Made

In Topic: Using multiple constant buffer

30 January 2012 - 01:10 PM

Thanks for info!

Additionally some further gamedev redirections:
how to find the constant buffer slots via shader reflection
http://www.gamedev.net/topic/607104-d3d11shaderreflection-and-constant-buffer-slot/

some thoughts about UpdateSubResource vs Map/Unmap
http://www.gamedev.net/topic/616350-dx11-fastest-way-to-update-a-constant-buffer-per-draw-call/

In Topic: Using multiple constant buffer

30 January 2012 - 07:52 AM

Hi, I've updated all code parts in my previous posts.

Thx kauna for the hint since after changing the slots in the code no warnings or errors occur.

// I've set the following for slots for the buffers to be comprehensible
vs.setconstantbuffer(matrix_buffer, 1);
vs.setconstantbuffer(light_buffer, 0);
ps.setconstantbuffer(light_buffer, 2);

I thought that the cbuffers in the shader will be declared in sequential order since I'm defining first the Matrix cbuffer then the Light cbuffer. I tried to fixate that by setting : register(cb#).

Obviously i was wrong with this assumption.

Now it's all black (of course it is black, I think I am really learning dx the hard way) without any warnings thanks for your help!

Theoretically, if I define more cbuffers, how can I find out which slots they were assigned to?

In Topic: Using multiple constant buffer

30 January 2012 - 04:14 AM

The structure of the constant buffer is


cbuffer Matrixbuffer : register(cb0)
{
matrix World;           
matrix WorldViewProjection;
float3 CameraPosition;
float padding;
};
and

cbuffer LightBuffer : register(cb1)
{
float3 MaterialAmbient;   // Material's ambient color
float  MaterialAlpha;
float3 MaterialDiffuse;   // Material's diffuse color
float  MaterialShininess;
float3 MaterialSpecular;   // Material's specular color
float padding2;
float2 SpecularTextured;
float2 padding3;
};

It seems to me that updating the constant buffer in the foreach loop overwrites the first "global" constant buffer.
Could there be something that I am missing?

Would a pix run file help you to get more information out of it?

In Topic: Using multiple constant buffer

29 January 2012 - 03:53 PM

Thanks for the quick response!
I think you meant VSSetConstantBuffer and PSSetConstantBuffer in the last sentence.

I've replaced setting both cbuffer at the same time

ImmediateContext.VertexShader.SetConstantBuffers(new[] { _matrix_constant_buffer, _light_constant_buffer }, 0,2);

with

ImmediateContext.VertexShader.SetConstantBuffer(_matrix_constant_buffer, 0);
ImmediateContext.VertexShader.SetConstantBuffer(_light_constant_buffer, 1);

and also set the cbuffer to the pixel shader
ImmediateContext.PixelShader.SetConstantBuffer(_light_constant_buffer, 1);

I also tried to attach - : register(cbx) to the cbuffer declaration in the shader code.
but the result is the same error message Posted Image

Alright, I tried the same code with the sharpdx framework with the same ouput..

In Topic: View-space position reconstruction from DepthBuffer

07 July 2011 - 08:52 AM

Hi Folks,
we finally get the view-position reconstruction to work. The solution was obvious but doesn't look that nice in the shader code.

The shader code in the G-Buffer pass we removed the following lines,

output.DepthZW.xy = output.Position.zw; // in the vertex shader

output.Depth = input.DepthZW.x / input.DepthZW.y; // in the pixel shader
because the hardware depth buffer store this value for us, so we don't need to recalculate them.

In the post-process fullscreen pass we changed the following:
float3 getPosition(in float2 uv)
{
    // Get the depth value for this pixel
    float z = SampleDepthBuffer(uv);

    float x = uv.x * 2 - 1;
    float y = (1 - uv.y) * 2 - 1;
    float4 vProjectedPos = float4(x, y, z, 1.0f);

    // Transform by the inverse projection matrix
    float4 vPositionVS = mul(vProjectedPos, InverseProjection);

    // Divide by w to get the view-space position
    vPositionVS.z = -vPositionVS.z;

    // solution - discard texel values at depth = 1
    if(z == 1.0) 
    return float3(0, 0, 0);

    return vPositionVS.xyz / vPositionVS.w;
}

Before rendering the scene we clear the depth stencil buffer with 1. If the scene is not full of objects some depth values will be 1, painting the view-space position reconstruction at this position too.


Discarding these values, gives us the desired but static background. Another way would be to change the depth comparison function but imho both options doesn't look nice.


How do you guys (would) handle that problem, when using the hardware depth buffer for viewspace position reconstruction?

PARTNERS