Jump to content
  • Advertisement

komilll

Member
  • Content Count

    21
  • Joined

  • Last visited

Everything posted by komilll

  1. komilll

    Wrong HLSL buffer width

    You are seeing broken code on that changeset. Newest code uses registers - here is .h and .cpp - https://github.com/komilll/LEngine/tree/master/LEngine/src And here is blur shader - https://github.com/komilll/LEngine/blob/master/LEngine/blurHorizontal.vs
  2. It's more of a discussion question than actual problem with code, because I managed to fix it. I had VS shader with 2 constant buffers: cbuffer MatrixBuffer : register(cb0) { matrix worldMatrix; matrix viewMatrix; matrix projectionMatrix; }; cbuffer ScreenSizeBuffer : register(cb1) { float screenSize; float g_padding1; float g_padding2; float g_padding3; }; Nsight says that MatrixBuffer is 192 width (correct) and ScreenSizeBuffer is 192 width (wrong, should be 16). screenSize variable is always equal to 1. Removing MatrixBuffer fixes a problem, ScreenSizeBuffer is back 16 width and screenSize value is passed correctly. Why is that? Why previous buffer width is passed to next buffer?
  3. komilll

    Wrong HLSL buffer width

    I started with RasterTek tutorials but yea, I started noticing that there are many flaws regarding C++ and I was rewritting it to use C++11. But as I begin creating system with that convention, I continue to naming shader classes in that way. What's the difference between .fx and .vs/.ps? Can I modify .fx on runtime and continue to use it? I had no idea, I wasn't thinking about it back then. However, do you still recommend using std::array<float> or C-style array instead of storing XMFLOAT4 in buffer struct? Or is it ok for feature level 10.0?
  4. @MJP Well, my previous assumption was only partially right. In post above I managed to get version without skybox working, but I was investigating it for the last two days and I find why it actually doesn't work with skybox. Render scene to texture (msaa x2) Render skybox Resolve texture Present After resolve step, render target is black and just black screen is presented at the end. However, when I am not using msaa it works without problem. When I am not using skybox, it also works ok. Problem is that I don't know how to use MSAA with skybox. I am using CreateDDSTextureFromFile for importing .DDS skybox file.
  5. Hey, To begin with - I was successful with creating MSAA using MSAA swap chain, but I am not satisfied with it, especially because it doesn't support changing MSAA settings on the fly. I've already read many thread on this forum regarding MSAA and I learnt here about ResolveSubresource and how we deal with converting MSAA texture to non-MSAA to present it on screen with non-MSAA buffer. A little background: I have forward rendering engine, I have also already used render targets. I am creating render target for scene, render models to it. Then I am creating G-buffers for SSAO which I render to another texture and then I apply another post-processes. For sake of testing MSAA, I am using no post-processes. m_renderTextureMainScene is my MSAA buffer. Then I am trying to resolve it to non-MSAA render target but only black screen appears. When m_renderTextureMainScene is non-MSAA, rendering works fine: XMMATRIX worldMatrix, viewMatrix, projectionMatrix, lightViewMatrix, lightProjectionMatrix; m_renderTextureMainScene->SetRenderTarget(m_D3D->GetDeviceContext(), m_D3D->GetDepthStencilView()); m_renderTextureMainScene->ClearRenderTarget(m_D3D->GetDeviceContext(), m_D3D->GetDepthStencilView(), 0.0f, 0.0f, 0.0f, 1.0f); for (ModelClass* const& model : m_sceneModels) { // ... model->Render(m_D3D->GetDeviceContext()); // ... } if (DRAW_SKYBOX) { if (RenderSkybox() == false) return false; } m_D3D->SetBackBufferRenderTarget(); static RenderTextureClass *renderTexture; if (renderTexture == nullptr) { renderTexture = new RenderTextureClass; renderTexture->Initialize(m_D3D->GetDevice(), m_screenWidth, m_screenHeight, 1); } m_D3D->GetDeviceContext()->ResolveSubresource(renderTexture->GetShaderResource(), 0, m_renderTextureMainScene->GetShaderResource(), 0, DXGI_FORMAT_R16G16B16A16_FLOAT); m_renderTexturePreview->BindTexture(renderTexture->GetShaderResourceView()); if (!m_renderTexturePreview->Render(m_D3D->GetDeviceContext(), 0, worldMatrix, viewMatrix, projectionMatrix)) return false;
  6. komilll

    Wrong HLSL buffer width

    https://github.com/komilll/LEngine/blob/1a415024affbcb838e3fecf9f5e99eb66477352b/LEngine/src/BlurShaderClass.cpp https://github.com/komilll/LEngine/blob/1a415024affbcb838e3fecf9f5e99eb66477352b/LEngine/src/BaseShaderClass.cpp https://github.com/komilll/LEngine/blob/1a415024affbcb838e3fecf9f5e99eb66477352b/LEngine/blurHorizontal.vs BlurShaderClass inherits from BaseShaderClass. In BlurShaderClass::SetShaderParameters I am setting matrix buffer (through BaseShaderClass::SetShaderParameters) and ScreenSizeBuffer.
  7. komilll

    Wrong HLSL buffer width

    I stated in the first post:
  8. komilll

    Wrong HLSL buffer width

    @Adam Miles Maybe problem was somewhere else then, maybe buffer was still 16 bytes. However it doesn't change a fact that value in that cbuffer was always set to 1 (Nsight was saying that but also the output made me 100% it has value equal to 1).
  9. Thank you, sir. I had no idea that such debug options exist in DirectX, that's a great tool for debuging, thanks once again. But back to what a problem was - I was using only one DepthStencilView for everything. When there was an intention to render data that doesn't use MSAA, there was a count mismatch, because the only stencil view was the one with MSAA. That means that I created new StencilView: m_depthStencilViewBackBuffer = CreateDepthBufferReturn(1, 1); //Size multiplier = 1 (higher values for SSAA), depth buffer count = 1 //... void D3DClass::SetBackBufferRenderTarget() const //Use for non-MSAA rendering; Render MSAA directly to texture and resolve { m_deviceContext->OMSetRenderTargets(1, &m_renderTargetView, m_depthStencilViewBackBuffer); } However MSAA was working even without resolving texture, which is weird, I guess? Here is a result of MSAAx2 without resolving texture. Aftering uncommenting resolving, results are the same.
  10. Here is the code I'm using to create depth buffer. sizeMultiplier is set to 1 (I use higher values for SSAA). I checked it through Nsight and rendering seems to be ok. There are less jaggies but when presenting buffer, black screen appears. bool D3DClass::CreateDepthBuffer(int sizeMultiplier) { HRESULT result; DXGI_ADAPTER_DESC adapterDesc; D3D11_TEXTURE2D_DESC depthBufferDesc; D3D11_DEPTH_STENCIL_DESC depthStencilDesc; D3D11_DEPTH_STENCIL_VIEW_DESC depthStencilViewDesc; // Initialize the description of the depth buffer. ZeroMemory(&depthBufferDesc, sizeof(depthBufferDesc)); // Set up the description of the depth buffer. depthBufferDesc.Width = m_windowSizeX * sizeMultiplier; depthBufferDesc.Height = m_windowSizeY * sizeMultiplier; depthBufferDesc.MipLevels = 1; depthBufferDesc.ArraySize = 1; depthBufferDesc.Format = DXGI_FORMAT_D24_UNORM_S8_UINT; depthBufferDesc.SampleDesc.Count = 2; 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 = m_device->CreateTexture2D(&depthBufferDesc, NULL, &m_depthStencilBuffer); if (FAILED(result)) { return false; } // 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 = m_device->CreateDepthStencilState(&depthStencilDesc, &m_depthStencilState); if (FAILED(result)) { return false; } depthStencilDesc.DepthFunc = D3D11_COMPARISON_LESS_EQUAL; result = m_device->CreateDepthStencilState(&depthStencilDesc, &m_depthStencilStateSkybox); if (FAILED(result)) { return false; } ZeroMemory(&depthStencilDesc, sizeof(depthStencilDesc)); depthStencilDesc.DepthFunc = D3D11_COMPARISON_NEVER; depthStencilDesc.DepthWriteMask = D3D11_DEPTH_WRITE_MASK_ZERO; depthStencilDesc.DepthEnable = false; depthStencilDesc.StencilEnable = false; result = m_device->CreateDepthStencilState(&depthStencilDesc, &m_depthStencilStateZBufferOff); if (FAILED(result)) { return false; } // Set the depth stencil state. m_deviceContext->OMSetDepthStencilState(m_depthStencilState, 1); // 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_TEXTURE2DMS; depthStencilViewDesc.Texture2D.MipSlice = 0; // Create the depth stencil view. result = m_device->CreateDepthStencilView(m_depthStencilBuffer, &depthStencilViewDesc, &m_depthStencilView); if (FAILED(result)) { return false; } return true; }
  11. When I am rendering model by model and not using rendered texture with MSAAx2 it works fine. However trying to resolve subresource or presenting that texture shows first error. I don't really understand how did I mixed MSAA between render target and depth stencil. Could you explain more what that means?
  12. For rendering MSAA x2 I have those messages. Last message appear also for x1, others do not: D3D11 ERROR: ID3D11DeviceContext::OMSetRenderTargets: The RenderTargetView at slot 0 is not compatable with the DepthStencilView. DepthStencilViews may only be used with RenderTargetViews if the effective dimensions of the Views are equal, as well as the Resource types, multisample count, and multisample quality. The RenderTargetView at slot 0 has (w:1280,h:720,as:1), while the Resource is a Texture2D with (mc:2,mq:0). The DepthStencilView has (w:1280,h:720,as:1), while the Resource is a Texture2D with (mc:1,mq:0). D3D11_RESOURCE_MISC_TEXTURECUBE factors into the Resource type, unless GetFeatureLevel() returns D3D_FEATURE_LEVEL_10_1 or greater. [ STATE_SETTING ERROR #388: OMSETRENDERTARGETS_INVALIDVIEW] D3D11 WARNING: ID3D11DeviceContext::DrawIndexed: The Pixel Shader unit expects a Sampler to be set at Slot 1, but none is bound. This is perfectly valid, as a NULL Sampler maps to default Sampler state. However, the developer may not want to rely on the defaults. [ EXECUTION WARNING #352: DEVICE_DRAW_SAMPLER_NOT_SET] ERROR: ID3D11DeviceContext::DrawIndexed: The Shader Resource View dimension declared in the shader code (TEXTURE2D) does not match the view type bound to slot 0 of the Pixel Shader unit (TEXTURE2DMS). This mismatch is invalid if the shader actually uses the view (e.g. it is not skipped due to shader code branching). [ EXECUTION ERROR #354: DEVICE_DRAW_VIEW_DIMENSION_MISMATCH] I found solution for last point I guess. Or is it different problem?
  13. komilll

    SSAO black dots

    Changing multiplying order of "mul(matrix, vector)" doesn't change anything. Also I've tried reversing TBN matrix and other combinations and I can't find any visual difference after doing it. Do you think my kernel generation or usage might be wrong?
  14. Hello, I am trying to implement SSAO using DirectX11 but instead I got white screen with few black dots on model: I am using normal-oriented hemispheres based on this tutorial: https://learnopengl.com/Advanced-Lighting/SSAO My G-Buffer (albedo skipped), Tangent and Bitangent buffer: Position: Normal: Tangent: Bitangent: myPixelShader.ps: I suppose that either my projection matrix is wrong (I am passing my global projection matrix that I use in every shader). Another option is that my kernel generation is wrong: myKernelGeneration.cpp:
  15. komilll

    SSAO black dots

    For some reason, there are few. But it shouldn't change the result SSAO map, right?
  16. komilll

    SSAO black dots

    I changed code and remove multiplying tex coords by 100: float3 randomVector = normalize(float3(textures[2].Sample(SampleType, input.tex).xy, 0.0f)); And it resulted in changed tangent/bitangent buffers: Additionally I have found that "black dots" are actually the scaled models shown across the actual model. I found it on my sphere model which SSAO looks like this:
  17. Cool, now I understand. So baking reflection probe is basically just rendering it in 6 directions and just save it back on your HDD for further use, right? By the way I've sticked with Texassemble as you adviced and it works great. That's sufficient for my needs and as I'm using it through system("...") in my C++ code it works great. However I have problem with creating diffuse irradiance map. As reference I am using https://learnopengl.com/PBR/IBL/Diffuse-irradiance and https://github.com/TheEvilBanana/PhysicallyBasedRendering/blob/master/Game.cpp#L490. My map convolution looks not as it is supposed. I have black dot on every face. I use 2048x2048 which I render to 256x256 Texture2D and save each face which I then assemble. Below debug image. Up is +Y, Down is -Y, Middle is from the left -X, -Z, +X, +Z. What can I do to fix it? Also it looks like I am rendering same face twice somehow because +(plus) faces looks same like their -(minus) faces. Render to texture method: Vertex shader: Pixel shader:
  18. Hello, I am trying to create TextureCube with array of 6 ID3D11Resources. My motivation is to import textures, create convolution diffuse map for each of the faces and import it to the Texture with 6 elements that I will use further for IBL diffuse. However code below is resulting in empty cubemap with 6 black faces: ID3D11Resource* srcTex[6]; CreateDDSTextureFromFile(device, L"seafloor.dds", &srcTex[0], NULL); CreateDDSTextureFromFile(device, L"seafloor.dds", &srcTex[1], NULL); CreateDDSTextureFromFile(device, L"seafloor.dds", &srcTex[2], NULL); CreateDDSTextureFromFile(device, L"seafloor.dds", &srcTex[3], NULL); CreateDDSTextureFromFile(device, L"seafloor.dds", &srcTex[4], NULL); CreateDDSTextureFromFile(device, L"seafloor.dds", &srcTex[5], NULL); D3D11_TEXTURE2D_DESC texArrayDesc; texArrayDesc.Width = width; texArrayDesc.Height = height; texArrayDesc.MipLevels = 1; texArrayDesc.ArraySize = 6; texArrayDesc.Format = DXGI_FORMAT_R16G16B16A16_FLOAT; texArrayDesc.SampleDesc.Count = 1; texArrayDesc.SampleDesc.Quality = 0; texArrayDesc.Usage = D3D11_USAGE_DEFAULT; texArrayDesc.BindFlags = D3D11_BIND_SHADER_RESOURCE; texArrayDesc.CPUAccessFlags = 0; texArrayDesc.MiscFlags = D3D11_RESOURCE_MISC_TEXTURECUBE; ID3D11Texture2D* texArray = 0; HRESULT result = device->CreateTexture2D(&texArrayDesc, NULL, &texArray); if (FAILED(result)) return false; // Copy individual texture elements into texture array. ID3D11DeviceContext* deviceContext; device->GetImmediateContext(&deviceContext); D3D11_BOX sourceRegion; //Here i copy the mip map levels of the textures for (UINT x = 0; x < 6; x++) { for (UINT mipLevel = 0; mipLevel < texArrayDesc.MipLevels; mipLevel++) { sourceRegion.left = 0; sourceRegion.right = (texArrayDesc.Width >> mipLevel); sourceRegion.top = 0; sourceRegion.bottom = (texArrayDesc.Height >> mipLevel); sourceRegion.front = 0; sourceRegion.back = 1; //test for overflow if (sourceRegion.bottom == 0 || sourceRegion.right == 0) break; deviceContext->CopySubresourceRegion(texArray, D3D11CalcSubresource(mipLevel, x, texArrayDesc.MipLevels), 0, 0, 0, srcTex[x], mipLevel, &sourceRegion); } } // Create a resource view to the texture array. D3D11_SHADER_RESOURCE_VIEW_DESC viewDesc; viewDesc.Format = texArrayDesc.Format; viewDesc.ViewDimension = D3D11_SRV_DIMENSION_TEXTURECUBE; viewDesc.TextureCube.MostDetailedMip = 0; viewDesc.TextureCube.MipLevels = texArrayDesc.MipLevels; result = device->CreateShaderResourceView(texArray, &viewDesc, &m_skyboxTextureView); if (FAILED(result)) return false; ID3D11Resource* resource; m_skyboxTextureView->GetResource(&resource);
  19. I will test debug in layer when I get back to my computer (in 12h). I was thinking about using Texassemle at some point and I might end using it. However my main motivation was to break imported skybox, prepare each face to be used as diffuse IBL map and then reassemble it to cubemap. Doing it at runtime is doesn't require creating new IBL by hand if I want to change skybox. I was also interested how to deal with reflection probes without assembling skybox at the runtime. Is it possible or do you have to render each face capture and create cubemap which will be used further?
  • 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!