Jump to content
  • Advertisement


  • Content Count

  • Joined

  • Last visited

Community Reputation

137 Neutral

About Andimus

  • Rank

Personal Information

  • Interests


  • Twitter
  1. Thanks for getting back to me, yeah its definitely the correct buffer being assigned to the right shader, verified it in the graphics debugger, also everything is working as expected. I'll keep digging and report back if I find the source of the problem 
  2. Hey, so i added some padding to the structs to take them to the expected size, this unsurprisingly removed the warnings. I guess I just don't under stand the alignment . The first buffer is shown below, was 16 had to expand it too 48       struct SpecularLightBuffer     {            DirectX::XMFLOAT3 mSpecularColor;            float mSpecularPower;            DirectX::XMFLOAT4 PADDING1;              DirectX::XMFLOAT4 PADDING2;     };   this matches with this buffer:       cbuffer Specular: register(b0)     {             float3 specularColor;             float specularPower;      };   The second was 48 but was expecting 64:     struct DirectionalLightBuffer     {            DirectX::XMFLOAT4 mAmbientColor;            DirectX::XMFLOAT4 mDiffuseColor;            DirectX::XMFLOAT4 mLightDirection;            DirectX::XMFLOAT4 PADDING;      };   Matches with       cbuffer LightBuffer: register(b0)     {          float4 ambientColour;          float4 diffuseColour;          float4 lightDirection;     };   Both buffers are intialised with this:       //Setup the description of a dynamic constant buffer      bufferDesc.Usage = D3D11_USAGE_DYNAMIC;     bufferDesc.ByteWidth = mBufferSize;     bufferDesc.BindFlags = D3D11_BIND_CONSTANT_BUFFER;     bufferDesc.CPUAccessFlags = D3D11_CPU_ACCESS_WRITE;     bufferDesc.MiscFlags = 0;     bufferDesc.StructureByteStride = 0;       //Create the constant buffer pointer      result = _device->CreateBuffer(&bufferDesc, nullptr, &mBuffer);     if (FAILED(result)){            return false;     }   where mBufferSize is set in the constructor for the specific buffer. They are then set just before with the following code before draw is called:       _deviceContext->PSSetConstantBuffers(0, 1, &mBuffer);   Can anyone point out why the buffer aren't the size I expected?
  3. Hey quick question, so i keep getting this warning "The size of the Constant Buffer at slot 0 of the Pixel Shader unit is too small" for 2 of my pixel shaders. The first is 16 bytes but expects 48, the second is 48 but expects 64. I have checked the shader reflection and VS Graphics debugger to verify these sizes in the shader and they do match what I'd expect. Also double checked the size of the buffers being created.   Any ideas about what could cause this
  4. Hey so I'm currently using a compute shader to read in a texture, update each pixel positions with a motion vector then write to another texture,  like below       output[threadID.xy + direction] = tex.SampleLevel(TextureSampler, uv.xy, 0);   but I'm concerned about going out of bounds of the output texture, what would happen exactly?   If it is a problem is there a more elegant solution that an if statement?  
  5.   Exactly, near and far were wrong way round, knew it was something stupid, thanks for all your help
  6. yeah sure        mViewport.Width = (float)mWidth;      mViewport.Height = (float)mHeight;      mViewport.MinDepth = 0.0;      mViewport.MaxDepth = 1.0f;      mViewport.TopLeftX = 0.0f;      mViewport.TopLeftY = 0.0f;        deviceContext->RSSetViewports(1, &mViewport);
  7. Ok so much for a few days, the attached image is taken for RenderDoc. All the cube are the same size so the larger one should occlude the smaller cubes. Yet the the depth of the smaller ones are around 0.0017 as opposed to 0.003 for the larger one.    Not sure what would cause this though
  8. Ah I see unbird, stencils is disable now, to no avail though.   Buckeye, I was previously using uavs but wasn't getting depth so i changed to rtvs but same situation. I have now changed it to deviceContext->OMSetRenderTargets(_numberOfRTVs, _rtvs, mDepthStencilView);   Also it was "just to be sure" as depth is never disable. But thank you.    Not sure what else i can post but i'll think on it for a day or so and report back if i find anything. I know its gonna be something stupid
  9. Thanks for the reply, I need the stencil view otherwise i can't clear the depth buffer.  I'm using the debug flag already but unfortunately nothing is showing and have been using the graphics diagnostic. Nothing is been shown in the output merger pipeline view of though, which is concerning 
  10. Hey having some problems with the depth buffer ie its not working. So my current set up is I'm rendering to two half x resolution rtv's. These rtv's go through 2 passes of a compute shader and before being rendered to screen. Everything looks pretty standard yet no depth.   The dpeth stencil is looking like this:       // Initialize the description of the stencil state.     ZeroMemory(&depthStencilDesc, sizeof(depthStencilDesc));       // Set up the description of the stencil state.     depthStencilDesc.DepthEnable = true;     depthStencilDesc.DepthWriteMask = D3D11_DEPTH_WRITE_MASK_ALL;     depthStencilDesc.DepthFunc = D3D11_COMPARISON_LESS;      depthStencilDesc.StencilEnable = true;     depthStencilDesc.StencilReadMask = 0xFF;     depthStencilDesc.StencilWriteMask = 0xFF;       // Stencil operations if pixel is front-facing.     depthStencilDesc.FrontFace.StencilFailOp = D3D11_STENCIL_OP_KEEP;     depthStencilDesc.FrontFace.StencilDepthFailOp = D3D11_STENCIL_OP_INCR;     depthStencilDesc.FrontFace.StencilPassOp = D3D11_STENCIL_OP_KEEP;     depthStencilDesc.FrontFace.StencilFunc = D3D11_COMPARISON_ALWAYS;       // Stencil operations if pixel is back-facing.     depthStencilDesc.BackFace.StencilFailOp = D3D11_STENCIL_OP_KEEP;     depthStencilDesc.BackFace.StencilDepthFailOp = D3D11_STENCIL_OP_DECR;     depthStencilDesc.BackFace.StencilPassOp = D3D11_STENCIL_OP_KEEP;     depthStencilDesc.BackFace.StencilFunc = D3D11_COMPARISON_ALWAYS;           // Create the depth stencil state.     result = mDevice->CreateDepthStencilState(&depthStencilDesc, &mDepthStencilState);     if (FAILED(result)){          return false;     }   The depth view is set for the resolution i am using        // Initialize the description of the depth buffer.     ZeroMemory(&depthBufferDesc, sizeof(depthBufferDesc));       // Set up the description of the depth buffer.     depthBufferDesc.Width = mWidth;     depthBufferDesc.Height = mHeight;     depthBufferDesc.MipLevels = 1;     depthBufferDesc.ArraySize = 1;     depthBufferDesc.Format = DXGI_FORMAT_D24_UNORM_S8_UINT;     depthBufferDesc.SampleDesc.Count = 1;     depthBufferDesc.SampleDesc.Quality = 0;     depthBufferDesc.Usage = D3D11_USAGE_DEFAULT;     depthBufferDesc.BindFlags = D3D11_BIND_DEPTH_STENCIL ;     depthBufferDesc.CPUAccessFlags = 0;     depthBufferDesc.MiscFlags = 0;       // Create the texture for the depth buffer using the filled out description.    result = _device->CreateTexture2D(&depthBufferDesc, NULL, &mDepthStencilBuffer);    if (FAILED(result)){        return false;    }       // Initialize the depth stencil view.     ZeroMemory(&depthStencilViewDesc, sizeof(depthStencilViewDesc));       // Set up the depth stencil view description.     depthStencilViewDesc.Format = DXGI_FORMAT_D24_UNORM_S8_UINT;     depthStencilViewDesc.ViewDimension = D3D11_DSV_DIMENSION_TEXTURE2D;     depthStencilViewDesc.Texture2D.MipSlice = 0;         // Create the depth stencil view.     result = _device->CreateDepthStencilView(mDepthStencilBuffer, &depthStencilViewDesc, &mDepthStencilView);     if (FAILED(result)){         return false;     }   I'm also setting the rtvs with         // Bind the render target view and depth stencil buffer to the output render pipeline.      deviceContext->OMSetRenderTargetsAndUnorderedAccessViews(_numberOfRTVs, _rtvs, mDepthStencilView, _startSlot, _numberOfUavs, _uavs, _counts);        // Set the viewport.      deviceContext->RSSetViewports(1, &mViewport);   Also calling just to be sure     // Set the depth stencil state.     mDeviceContext->OMSetDepthStencilState(mDepthStencilState, 1);   I'm not using mulitsampling or the geometry shader, which I've read might affect it. Also tried the debugger but don't seem to get anything in the output merger, so not sure how to debug. Any suggestions? I'm stumped      
  11. Andimus

    Temporal Reprojection

    Sorry the post was a bit vague, I'll try and clear up my problem now.   So I am trying to find a pixels previous position in screen space in DirectX 11. The vertex shader is looking like this. PixelInputType Main(VertexInputType input) { PixelInputType output; // Calculate the position of the vertex against the world, view, and projection matrices. output.position = mul(float4(input.position.xyz, 1.0f), worldMatrix); output.position = mul(output.position, viewMatrix); output.position = mul(output.position, projectionMatrix); output.prevPosition = mul(float4(input.position.xyz, 1.0f), prevWorld); output.prevPosition = mul(output.prevPosition, prevView); output.prevPosition = mul(output.prevPosition, prevProj); // Store the texture coordinates for the pixel shader. output.tex = input.tex; return output; }   Here we are calculating the vertex's current and previous position. The current position is being passed to the pixel shader as a sv_position and the previous positon as a texture coordinate. The pixel shader is looking like this. float4 Main(PixelInputType input) : SV_TARGET { float4 prevPosition = input.prevPosition; prevPosition.xyz /= prevPosition.w; prevPosition.xy *= float2(0.5, -0.5); prevPosition.xy += 0.5f; prevPosition.xy *= resolution; float2 motion = input.position.xy - prevPosition.xy; ....//other stuff } I'm dividing the previous position by w to get the homogeneous coordinates, adjusting the coordinates then multiplying by the resolution. I thought this would get me the screen space coordinates of the pixel so I can calculate a motion vector. But I'm not getting any sensible values. Does anyone have any suggestions?
  12. Hi  So I'm trying recreate the method of temporal reprojection from Killzone: Shadowfall; see this article for details, in DirectX 11.   In the vertical shader I calculate the current vertex position as normal along with its previous position using the previous matrices. The previous position is passed to the pixel shader with texcoord semantic as suggested by Nehab here. In the pixel shader i calculate its colour and along with a motion vector in a rwbuffer. Using the information I reconstruct the frame in a compute shader.   however I'm a little lost about how to calculate the the motion vector in the pixel shader. The motion vector is in the direction the pixel is moving in screen space, which the the current position will be in, but what about the previous position? I seem to be just getting garbage. I am I missing something or just misunderstanding the problem?   Any help would be appreciated  Andrew    
  • Advertisement

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!