Jump to content
  • Advertisement

Search the Community

Showing results for tags 'DX11'.

The search index is currently processing. Current results may not be complete.


More search options

  • Search By Tags

    Type tags separated by commas.
  • Search By Author

Content Type


Categories

  • Audio
    • Music and Sound FX
  • Business
    • Business and Law
    • Career Development
    • Production and Management
  • Game Design
    • Game Design and Theory
    • Writing for Games
    • UX for Games
  • Industry
    • Interviews
    • Event Coverage
  • Programming
    • Artificial Intelligence
    • General and Gameplay Programming
    • Graphics and GPU Programming
    • Engines and Middleware
    • Math and Physics
    • Networking and Multiplayer
  • Visual Arts
  • Archive

Categories

  • Audio
  • Visual Arts
  • Programming
  • Writing

Categories

  • Game Developers Conference
    • GDC 2017
    • GDC 2018
  • Power-Up Digital Games Conference
    • PDGC I: Words of Wisdom
    • PDGC II: The Devs Strike Back
    • PDGC III: Syntax Error

Forums

  • Audio
    • Music and Sound FX
  • Business
    • Games Career Development
    • Production and Management
    • Games Business and Law
  • Game Design
    • Game Design and Theory
    • Writing for Games
  • Programming
    • Artificial Intelligence
    • Engines and Middleware
    • General and Gameplay Programming
    • Graphics and GPU Programming
    • Math and Physics
    • Networking and Multiplayer
  • Visual Arts
    • 2D and 3D Art
    • Critique and Feedback
  • Community
    • GameDev Challenges
    • GDNet+ Member Forum
    • GDNet Lounge
    • GDNet Comments, Suggestions, and Ideas
    • Coding Horrors
    • Your Announcements
    • Hobby Project Classifieds
    • Indie Showcase
    • Article Writing
  • Affiliates
    • NeHe Productions
    • AngelCode
  • Topical
    • Virtual and Augmented Reality
    • News
  • Workshops
    • C# Workshop
    • CPP Workshop
    • Freehand Drawing Workshop
    • Hands-On Interactive Game Development
    • SICP Workshop
    • XNA 4.0 Workshop
  • Archive
    • Topical
    • Affiliates
    • Contests
    • Technical
  • GameDev Challenges's Topics
  • For Beginners's Forum

Calendars

  • Community Calendar
  • Games Industry Events
  • Game Jams
  • GameDev Challenges's Schedule

Blogs

There are no results to display.

There are no results to display.

Product Groups

  • GDNet+
  • Advertisements
  • GameDev Gear

Find results in...

Find results that contain...


Date Created

  • Start

    End


Last Updated

  • Start

    End


Filter by number of...

Joined

  • Start

    End


Group


About Me


Website


Role


Twitter


Github


Twitch


Steam

Found 628 results

  1. I've been out of the loop for a while and just noticed that term. I tried looking it up on google, but the closest answer was a gamedev topic with a similar title as mine. I read it, but didn't get a full explanation. Is it a method of swapping/replacing data in GPU memory with texture data in CPU memory?
  2. Kilickaya

    a skeleton application

    Hi I'm looking for a Direct3D SKELETON application (an application as small as possible) written in C++ which makes a simple small drawing which does NOT move or rotate, so that I can get a quick start into Direct3D programming. Is there a web site that contains that kind of a skeleton application? Thanks in advance
  3. So have been struggeling with this issue now for 20 hours or so. I'm using DirectInput, I know it's not the best but I have tried other approaches aswell which yields me the same results. What is happening is that I'm orbiting around a sphere with my up and down cursor buttons. Nothing to complicated really. What my issue is however is that when I press the key and hold it for a while(atleast this seems to be when the issue occurs, I have seen it at other times aswell but not as common) the keystate I get from DirectInput doesn't recognize that I have released the key. I can see from my debugging that I get a new keyboardState, and I can also see that from that keyboardState the key is still down, even tho I don't press it. This lag, delay or freeze or whatever one wants to call it can be up to several seconds. Here is a hastebin that includes the code in question: https://hastebin.com/ayucajobaw.cpp Any kind of ideas what my issue could be, or pointers for me what to google, cause I'm really running out of ideas here Best Regards Toastmastern
  4. Kilickaya

    about DirectX SDK

    Hi My OS is Windows 10. Where is the latest DirectX SDK for me to download? Thanks in advance
  5. I am the lead developer on a D3D11 game (using pixel and vertex shaders) that has water done as a flat mesh with textures on it (we use something similar to bump mapping to produce the water effect as well as scrolling the texture) but we want something better. Are there any tutorials on how to get cool looking water in a game? Particularly I am interested in refraction (whatever it is that lets you see what's under the water but the water obscures/distorts it a bit) and that kind of thing rather than reflection or wave motion.
  6. Hi I want to render a hologram inside a real object. But the Mixed Reality Capture result shows the hologram looks like out of the real object. Please see the attached image in which the real object is a lampshade. Thanks. YL
  7. Hello, I'm doing tessellation and while I got the positions setup correctly using quads I am at a loss how to generate smooth normals from them. I suppose this should be done in the Domain shader but how would this process look like? I am using a heightmap for tessellation but I would rather generate the normals from the geometry than use a normal map, if possible. Cheers
  8. Has anyone ever tried to draw with one of the D3D11_PRIMITIVE_TOPOLOGY_XX_CONTROL_POINT_PATCHLIST primitive topologies, when only a vertex, geometry and pixel shader are active? Practical Rendering and Computation with Direct3D 11, microsoft's documentation for the InputPatch hlsl type and this (old) blog post seem to suggest it should be possible. But when I try, an error occurs when drawing: D3D11 ERROR: ID3D11DeviceContext::Draw: Rasterization Unit is enabled (PixelShader is not NULL or Depth/Stencil test is enabled and RasterizedStream is not D3D11_SO_NO_RASTERIZED_STREAM) but the input topology is Patch Control Points. You need either a Hull Shader and Domain Shader, or a Geometry Shader. [ EXECUTION ERROR #349: DEVICE_DRAW_INPUTLAYOUT_NOT_SET] D3D11: **BREAK** enabled for the previous message, which was: [ ERROR EXECUTION #349: DEVICE_DRAW_INPUTLAYOUT_NOT_SET ] I'm sure I did bind a geometry shader (and renderdoc agrees with me 😉). The OpenGL and Vulkan documentation seem to explicitly *not* allow this, though, so maybe it's simply not possible 🙂 If you've ever managed to do this, were there some special details to take into account to get it working? Thanks! PS: for completeness, here's my test shader code, although I don't think it does anything special: // // vertex shader // struct VertexShaderInputData { float4 pos : position; }; struct VertexShaderOutputData { float4 pos : position; }; VertexShaderOutputData vs_main(VertexShaderInputData inputData) { VertexShaderOutputData outputData; outputData.pos = inputData.pos; return outputData; } // // geometry shader // struct GeometryShaderInputData { float4 pos : position; }; struct GeometryShaderOutputData { float4 pos : SV_Position; }; [maxvertexcount(8)] void gs_main(in InputPatch<GeometryShaderInputData, 8> inputData, uint input_patch_id : SV_PrimitiveID, uint gs_instance_id : SV_GSInstanceID, inout TriangleStream<GeometryShaderOutputData> output_stream) { GeometryShaderOutputData output_vertex; output_vertex.pos = inputData[0].pos; output_stream.Append(output_vertex); ...and so on... } // // pixel shader // struct PixelShaderOutputData { float4 color : SV_Target0; }; PixelShaderOutputData main() { PixelShaderOutputData outputData; outputData.color = float4(1.0,1.0,1.0,1.0); return outputData; }
  9. CONUNDRUM I'm very new to DirectX C++ programming, I come from a unity background but I'm trying to optimize my procedural mesh generation system to run on the graphics card with the new Unity ECS and Jobs system. For that I need native access to the render API and I've settled on DirectX11, I spent the last week or so learning DirectX11 and implementing a Compute Shader marching cubes implementation to run in native code in a multi threaded environment. Everything seems to be working but because I don't have much experience implementing a Multi-threaded rendering system I thought I'd ask here if I was doing it right. I plan on running my own tests but nothing beats someone with years of experience, if anyone one has any advice to offer that would be amazing :). IMPLEMENTATION So for my rendering system I knew I had to minimize the amount of blocking going on between the processing job threads and the rendering thread if I wanted to get any performance out of this at all. I decided to follow a similar double buffer design as modern rendering APIs; I have one front queue of draw calls being rendered by the rendering thread, and then a back queue that is being allocated to from the processing threads. At the end of the frame on the main thread I "present" the back queue to the front queue and swap there pointer memories, I of course do this in a windows CRITICAL_SECTION lock. Then again in the render thread I use the same CRITICAL_SECTION and lock it while I access the front queue. I copy the contents from the front queue into a dynamic buffer and then release the lock, I then proceed to render using this copied version of the front queue buffer. I copy the buffer instead of rendering directly from it because I want to minimize the lock time for the main thread present task. On top of this I also have to guarantee that the resources in the front queue that are being rendered are not destroyed or corrupted while they are being accessed. To do this I implemented my own thread safe pinning system. It's like a reference counting system except it deletes the data whenever I tell it to delete it in the processing thread, but it does not delete the object holding the data so I can tell whatever other thread that is attempting to acquire the lock that that the data is gone. When all pins are released and the objects gpu data has been killed, the holding object is destroyed. I use another CRITICAL SECTION per renderable object to pin, unpin, and generally access and modify this holder data. PRESENT QUEUE EXECUTE DRAW QUESTIONS 1.) Is it reasonable to copy the whole front buffer, element by element, into a dynamic array and delete it after rendering? Will this be too much allocation? Would it be better to just lock the whole front queue while I am rendering and render directly from it. 2.) Is it reasonable to use a CRITICAL SECTION for every renderable object and for pinning and unpinning? Is that too many critical sections? Is there a possible workaround with atomic functions and would there be a way to do automated pinning and unpinning so I can use std::copy instead of manually going element by element and pinning the data. I feel more secure knowing exactly when the data is pinned and unpinned aswell as when it is alive or dead. (BTW the pin and unpin methods also unlock the CS, that's why you see a lock with no unlock) 3.) Is there a better method for threading that does not require 3 buffers at once or maybe just a better way of preserving the integrity of GPU data while it's in the render thread being rendered. 4.) Am I making any noob D3D11 mistakes . This is my first time using it. Everything seems to be working in the Unity Editor but I want to be sure before I continue and build off of this. THANKS
  10. Hi, The attached rendering result about the human heart looks so realistic. I would like to get some suggestion about how to reach this effect. What I have is a surface triangle mesh of the heart (has vertex normals, but no color and no texture). I think I need the following processes: 1. Use 3D Max to associate the surface model with a texture 2. Rendering with lighting (Is Phong shading sufficient?) I am not sure if my consideration is correct or not. Any suggestion are really appreciated. YL
  11. Hi, I've been trying to implement a skybox for some time now and there's probably only a tiny problem left to solve. When I load a texture using DirectXTK's CreateDDSTextureFromFileEx with a TEXTURECUBE flag, the resulting shader resource has its view dimension set to Texture2D and not TextureCube, which means I can't treat it as a TextureCube in HLSL. Also the file I'm loading contains all six faces. Here's snippets of my code where I load the texture, set the shader resource view to the pixel shader and then sample it in HLSL: // Loading the texture HRESULT hr = DirectX::CreateDDSTextureFromFileEx(device, filename, 0, D3D11_USAGE_IMMUTABLE, D3D11_BIND_SHADER_RESOURCE, 0, D3D11_RESOURCE_MISC_TEXTURECUBE, false, &texture, &mSkyboxSRV); // Setting the texture DeviceContext->PSSetShaderResources(0, 1, mSkybox->GetSkyboxSRV()); // HLSL: Sampling the texture TextureCube skyboxTexture : register(t0); SamplerState sampWrap : register(s0); struct PS_IN { float4 Pos : SV_POSITION; float3 lookVector : TEXCOORD0; }; float4 PS_main(PS_IN input) : SV_TARGET { return skyboxTexture.Sample(sampWrap, input.lookVector); } This is the error message being output by DirectX: D3D11 ERROR: ID3D11DeviceContext::Draw: The Shader Resource View dimension declared in the shader code (TEXTURECUBE) does not match the view type bound to slot 0 of the Pixel Shader unit (TEXTURE2D). 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] Does anyone have any ideas on what to do? Any help is much appreciated!
  12. Hi all. I'm looking for a font to test my 2D text rendering using DirectX 11. I would need a truetype font that has correct kerning and valid other properties such as baseline, advance, scale, etc. I tried Arial on Windows, but I'm not sure if it's the version I have but I cannot get the kerning working. It would be great if there was a font that is guaranteed to have most properties and that they be valid. Any ideas on the best font to use for testing? Thanks!
  13. Hi Guys, I have a problem where a textured quad is being severely interpolated. I am trying to achieve the clean pixelated look on the right hand of the example. There is no MSAA enabled on the back buffer DXGI_SWAP_CHAIN_DESC swapChainDesc; ZeroMemory(&swapChainDesc, sizeof(swapChainDesc)); swapChainDesc.BufferCount = 2; swapChainDesc.BufferDesc.Width = width; swapChainDesc.BufferDesc.Height = height; swapChainDesc.BufferDesc.Format = DXGI_FORMAT_R8G8B8A8_UNORM; swapChainDesc.BufferDesc.RefreshRate.Numerator = numerator; swapChainDesc.BufferDesc.RefreshRate.Denominator = denominator; swapChainDesc.BufferUsage = DXGI_USAGE_RENDER_TARGET_OUTPUT; swapChainDesc.OutputWindow = hWnd; swapChainDesc.Windowed = true; swapChainDesc.SampleDesc.Count = 1; swapChainDesc.SampleDesc.Quality = 0; swapChainDesc.Flags = DXGI_SWAP_CHAIN_FLAG_ALLOW_MODE_SWITCH; swapChainDesc.SwapEffect = DXGI_SWAP_EFFECT_DISCARD; I have verified in the debugger that my sampler is being applied, without asking for any anti-aliasing. D3D11_SAMPLER_DESC samplerDesc; samplerDesc.Filter = D3D11_FILTER_MIN_MAG_MIP_LINEAR; samplerDesc.AddressU = D3D11_TEXTURE_ADDRESS_CLAMP; samplerDesc.AddressV = D3D11_TEXTURE_ADDRESS_CLAMP; samplerDesc.AddressW = D3D11_TEXTURE_ADDRESS_CLAMP; samplerDesc.MipLODBias = 0.0f; samplerDesc.MaxAnisotropy = 1; samplerDesc.ComparisonFunc = D3D11_COMPARISON_NEVER; samplerDesc.MinLOD = -FLT_MAX; samplerDesc.MaxLOD = FLT_MAX; if (FAILED(d3dDevice->CreateSamplerState(&samplerDesc, &d3dSamplerDefault))) return E_WINDOW_SAMPLER_DESC; d3dContext->PSSetSamplers(0, 1, &d3dSamplerDefault); And the default blend state, which as far as I can tell should be ok. // Create default blend state ID3D11BlendState* d3dBlendState = NULL; D3D11_BLEND_DESC omDesc; ZeroMemory(&omDesc, sizeof(D3D11_BLEND_DESC)); omDesc.RenderTarget[0].BlendEnable = true; omDesc.RenderTarget[0].SrcBlend = D3D11_BLEND_SRC_ALPHA; omDesc.RenderTarget[0].DestBlend = D3D11_BLEND_INV_SRC_ALPHA; omDesc.RenderTarget[0].BlendOp = D3D11_BLEND_OP_ADD; omDesc.RenderTarget[0].SrcBlendAlpha = D3D11_BLEND_ONE; omDesc.RenderTarget[0].DestBlendAlpha = D3D11_BLEND_ZERO; omDesc.RenderTarget[0].BlendOpAlpha = D3D11_BLEND_OP_ADD; omDesc.RenderTarget[0].RenderTargetWriteMask = D3D11_COLOR_WRITE_ENABLE_ALL; if (FAILED(d3dDevice->CreateBlendState(&omDesc, &d3dBlendState))) return E_WINDOW_DEVICE_BLEND_STATE; d3dContext->OMSetBlendState(d3dBlendState, 0, 0xffffffff); if (d3dBlendState) d3dBlendState->Release(); And the pixel shader, which is as basic as can be. SamplerState samLinear : register(s0); Texture2D squareMap : register(t0); struct VS_OUTPUT { float4 position : SV_POSITION; float2 textureCoord : TEXCOORD0; }; float4 ps_main(VS_OUTPUT input) : SV_TARGET { return squareMap.Sample(samLinear, input.textureCoord); } I have a ton of error checking and there are no failed calls and the debugger shows that everything is running great. Any ideas as to why I am still getting interpolation would be hugely appreciated
  14. Hello, I'm implementing SSAO for my engine but I noticed the kernel wasn't rotating properly. What happens is when I sample my random-vector texture I always get the same result, regardless of input texture coordinates. Here's my shader: Texture2D randomTexture : register(t2); SamplerState smplr { Filter = D3D11_FILTER_ANISOTROPIC; AddressU = Wrap; AddressV = Wrap; }; float4 PS_main( in float4 screenPos : SV_Position) : SV_TARGET0 { //screensize 1280x720, randomTexture size 64x64 float2 rvecCoord = float2(screenPos.x * 1280.f / 64.f, screenPos.y * 720.f / 64.f); float3 rvec = randomTexture.Sample(smplr, rvecCoord).xyz; return float4(rvec, 1.0f); } Off-topic code omitted. I cant for the love of my life figure out why this sample would always give me the same result. Changing the line : float2 rvecCoord = float2(screenPos.x * 1280.f / 64.f, screenPos.y * 720.f / 64.f); to float2 rvecCoord = float2(screenPos.xy); seems to make no difference. Here's a print of the shader state. Any help appreciated! ❤️
  15. I'm not sure what the correct terminology is to describe what is happening. In the following video, you will see that the grass quad has one of the tris glitching out towards the end in the far distance. YOUTUBE VIDEO DEMO Anyone know what might be causing this? Here is a link to the github if it helps. The actual drawing is done in the Graphics.cpp RenderFrame function GITHUB LINK (set project to x86 to run or go into the libs folder and extract the x64 archives to run as x64) Edited to Add: To move camera use WASD / Space / Z
  16. Some people reported they can't play my game, while a video recording tool is running at the same time. So, I bought a popular one to test it and as it turns out they are right. 😕 I get a System.AccessViolationException with HResult=0x80004003 when calling SwapChain.Present. I am developing with DirectX 11 using C# and SharpDX. This problem only happens when a video recording tool is running. After I close it, the runs perfectly fine! I searched online for this problem, but I did not find a solution. I also read the MSDN page of SwapChain.Present to search for possible error sources. However, according to this page the SwapChain.Present does not throw System.AccessViolationException error messages. So, I assume the problem comes from somewhere else. I tested this problem also with my second game that I am currently developing which is a 2D game that only uses basis DirectX 11 3D stuff and I get the same problem. I tried to search all the parameters of all the render targets, viewport, swap chain, depth stencil views, etc. to search for something that might conflict with other applications (e.g. forcing my game to use some resource exclusively that might be also used by the video recording tool). To locate the exact problem, I removed all code from the render loop, except for the SwapChain.Present call. So it was just this single line of code and it still crashed... Does anyone of you have had a similar problem?
  17. Hey folks, I am developing two video game projects at the moment and I am developing my own game engine at the same time. The engine grows with my game projects and more and more features are ready to use. For a very long time, I only had a single render pass of my 3D scenes: I rendered all visible models using a PBR or Blinn-Phong-Shader - depending on the model's material - and it looked nice. In order to improve Galactic Crew, I wanted to add shadows and improved laser effects. After doing some research, I implemented a Shadow Mapping algorithm to add shadows. This resulted in two additional render passes. Now, I have this sequence, if the shadows are activated in the settings: Render scene from the point of view of the main light source to create a Depth Map. Render scene from the point of view to create a Light Map (using the Depth Map from 1.). Render scene and apply shadows using Light Map from step 2. I did some optimizations with your help and it worked like a charm in all scenarios (space, planets and dungeons). Then, I wanted to improve my laser beam effects. I added moving laser clutter to make it look more dynamic in combat situations and I added a Glow effect to make it look smoother. However, I had to add three render passes for the Glow effect: Create a Glow Map, blur Glow Map and add Glow Map to final scene resulting in this sequence: Render scene from the point of view of the main light source to create a Depth Map. Render scene from the point of view to create a Light Map (using the Depth Map from 1.). Render all laser beams from the camera's point of view into a Glow Map. Blur Glow Map using a bi-directional filter and increase brightness of the laser beam's inner areas. Render scene and apply shadows using Light Map from step 2. Use an orthogonal plane to add Glow Map to rendered scene from step 5. So, if the shadows are activated and the player is in combat, I have six render passes instead of just one. I want to add planetary missions with water worlds and island this winter that will add even more render passes for water reflection, etc. How many render passes do you guys use in your game project?
  18. Anybody know is it necessary to clear AppendStructuredBuffer if I don't have a consume buffer ? What's the max size of AppendStructuredBuffer ? Now, my code doesn't clear the AppendStructuredBuffer, and the structured buffer i've created is very big, I append instances in compute shader every frame, then render, the instances flick everywhere.
  19. Hello! I would like to introduce Diligent Engine, a project that I've been recently working on. Diligent Engine is a light-weight cross-platform abstraction layer between the application and the platform-specific graphics API. Its main goal is to take advantages of the next-generation APIs such as Direct3D12 and Vulkan, but at the same time provide support for older platforms via Direct3D11, OpenGL and OpenGLES. Diligent Engine exposes common front-end for all supported platforms and provides interoperability with underlying native API. Shader source code converter allows shaders authored in HLSL to be translated to GLSL and used on all platforms. Diligent Engine supports integration with Unity and is designed to be used as a graphics subsystem in a standalone game engine, Unity native plugin or any other 3D application. It is distributed under Apache 2.0 license and is free to use. Full source code is available for download on GitHub. Features: True cross-platform Exact same client code for all supported platforms and rendering backends No #if defined(_WIN32) ... #elif defined(LINUX) ... #elif defined(ANDROID) ... No #if defined(D3D11) ... #elif defined(D3D12) ... #elif defined(OPENGL) ... Exact same HLSL shaders run on all platforms and all backends Modular design Components are clearly separated logically and physically and can be used as needed Only take what you need for your project (do not want to keep samples and tutorials in your codebase? Simply remove Samples submodule. Only need core functionality? Use only Core submodule) No 15000 lines-of-code files Clear object-based interface No global states Key graphics features: Automatic shader resource binding designed to leverage the next-generation rendering APIs Multithreaded command buffer generation 50,000 draw calls at 300 fps with D3D12 backend Descriptor, memory and resource state management Modern c++ features to make code fast and reliable The following platforms and low-level APIs are currently supported: Windows Desktop: Direct3D11, Direct3D12, OpenGL Universal Windows: Direct3D11, Direct3D12 Linux: OpenGL Android: OpenGLES MacOS: OpenGL iOS: OpenGLES API Basics Initialization The engine can perform initialization of the API or attach to already existing D3D11/D3D12 device or OpenGL/GLES context. For instance, the following code shows how the engine can be initialized in D3D12 mode: #include "RenderDeviceFactoryD3D12.h" using namespace Diligent; // ... GetEngineFactoryD3D12Type GetEngineFactoryD3D12 = nullptr; // Load the dll and import GetEngineFactoryD3D12() function LoadGraphicsEngineD3D12(GetEngineFactoryD3D12); auto *pFactoryD3D11 = GetEngineFactoryD3D12(); EngineD3D12Attribs EngD3D12Attribs; EngD3D12Attribs.CPUDescriptorHeapAllocationSize[0] = 1024; EngD3D12Attribs.CPUDescriptorHeapAllocationSize[1] = 32; EngD3D12Attribs.CPUDescriptorHeapAllocationSize[2] = 16; EngD3D12Attribs.CPUDescriptorHeapAllocationSize[3] = 16; EngD3D12Attribs.NumCommandsToFlushCmdList = 64; RefCntAutoPtr<IRenderDevice> pRenderDevice; RefCntAutoPtr<IDeviceContext> pImmediateContext; SwapChainDesc SwapChainDesc; RefCntAutoPtr<ISwapChain> pSwapChain; pFactoryD3D11->CreateDeviceAndContextsD3D12( EngD3D12Attribs, &pRenderDevice, &pImmediateContext, 0 ); pFactoryD3D11->CreateSwapChainD3D12( pRenderDevice, pImmediateContext, SwapChainDesc, hWnd, &pSwapChain ); Creating Resources Device resources are created by the render device. The two main resource types are buffers, which represent linear memory, and textures, which use memory layouts optimized for fast filtering. To create a buffer, you need to populate BufferDesc structure and call IRenderDevice::CreateBuffer(). The following code creates a uniform (constant) buffer: BufferDesc BuffDesc; BufferDesc.Name = "Uniform buffer"; BuffDesc.BindFlags = BIND_UNIFORM_BUFFER; BuffDesc.Usage = USAGE_DYNAMIC; BuffDesc.uiSizeInBytes = sizeof(ShaderConstants); BuffDesc.CPUAccessFlags = CPU_ACCESS_WRITE; m_pDevice->CreateBuffer( BuffDesc, BufferData(), &m_pConstantBuffer ); Similar, to create a texture, populate TextureDesc structure and call IRenderDevice::CreateTexture() as in the following example: TextureDesc TexDesc; TexDesc.Name = "My texture 2D"; TexDesc.Type = TEXTURE_TYPE_2D; TexDesc.Width = 1024; TexDesc.Height = 1024; TexDesc.Format = TEX_FORMAT_RGBA8_UNORM; TexDesc.Usage = USAGE_DEFAULT; TexDesc.BindFlags = BIND_SHADER_RESOURCE | BIND_RENDER_TARGET | BIND_UNORDERED_ACCESS; TexDesc.Name = "Sample 2D Texture"; m_pRenderDevice->CreateTexture( TexDesc, TextureData(), &m_pTestTex ); Initializing Pipeline State Diligent Engine follows Direct3D12 style to configure the graphics/compute pipeline. One big Pipelines State Object (PSO) encompasses all required states (all shader stages, input layout description, depth stencil, rasterizer and blend state descriptions etc.) Creating Shaders To create a shader, populate ShaderCreationAttribs structure. An important member is ShaderCreationAttribs::SourceLanguage. The following are valid values for this member: SHADER_SOURCE_LANGUAGE_DEFAULT - The shader source format matches the underlying graphics API: HLSL for D3D11 or D3D12 mode, and GLSL for OpenGL and OpenGLES modes. SHADER_SOURCE_LANGUAGE_HLSL - The shader source is in HLSL. For OpenGL and OpenGLES modes, the source code will be converted to GLSL. See shader converter for details. SHADER_SOURCE_LANGUAGE_GLSL - The shader source is in GLSL. There is currently no GLSL to HLSL converter. To allow grouping of resources based on the frequency of expected change, Diligent Engine introduces classification of shader variables: Static variables (SHADER_VARIABLE_TYPE_STATIC) are variables that are expected to be set only once. They may not be changed once a resource is bound to the variable. Such variables are intended to hold global constants such as camera attributes or global light attributes constant buffers. Mutable variables (SHADER_VARIABLE_TYPE_MUTABLE) define resources that are expected to change on a per-material frequency. Examples may include diffuse textures, normal maps etc. Dynamic variables (SHADER_VARIABLE_TYPE_DYNAMIC) are expected to change frequently and randomly. This post describes the resource binding model in Diligent Engine. The following is an example of shader initialization: ShaderCreationAttribs Attrs; Attrs.Desc.Name = "MyPixelShader"; Attrs.FilePath = "MyShaderFile.fx"; Attrs.SearchDirectories = "shaders;shaders\\inc;"; Attrs.EntryPoint = "MyPixelShader"; Attrs.Desc.ShaderType = SHADER_TYPE_PIXEL; Attrs.SourceLanguage = SHADER_SOURCE_LANGUAGE_HLSL; BasicShaderSourceStreamFactory BasicSSSFactory(Attrs.SearchDirectories); Attrs.pShaderSourceStreamFactory = &BasicSSSFactory; ShaderVariableDesc ShaderVars[] = { {"g_StaticTexture", SHADER_VARIABLE_TYPE_STATIC}, {"g_MutableTexture", SHADER_VARIABLE_TYPE_MUTABLE}, {"g_DynamicTexture", SHADER_VARIABLE_TYPE_DYNAMIC} }; Attrs.Desc.VariableDesc = ShaderVars; Attrs.Desc.NumVariables = _countof(ShaderVars); Attrs.Desc.DefaultVariableType = SHADER_VARIABLE_TYPE_STATIC; StaticSamplerDesc StaticSampler; StaticSampler.Desc.MinFilter = FILTER_TYPE_LINEAR; StaticSampler.Desc.MagFilter = FILTER_TYPE_LINEAR; StaticSampler.Desc.MipFilter = FILTER_TYPE_LINEAR; StaticSampler.TextureName = "g_MutableTexture"; Attrs.Desc.NumStaticSamplers = 1; Attrs.Desc.StaticSamplers = &StaticSampler; ShaderMacroHelper Macros; Macros.AddShaderMacro("USE_SHADOWS", 1); Macros.AddShaderMacro("NUM_SHADOW_SAMPLES", 4); Macros.Finalize(); Attrs.Macros = Macros; RefCntAutoPtr<IShader> pShader; m_pDevice->CreateShader( Attrs, &pShader ); Creating the Pipeline State Object To create a pipeline state object, define instance of PipelineStateDesc structure. The structure defines the pipeline specifics such as if the pipeline is a compute pipeline, number and format of render targets as well as depth-stencil format: // This is a graphics pipeline PSODesc.IsComputePipeline = false; PSODesc.GraphicsPipeline.NumRenderTargets = 1; PSODesc.GraphicsPipeline.RTVFormats[0] = TEX_FORMAT_RGBA8_UNORM_SRGB; PSODesc.GraphicsPipeline.DSVFormat = TEX_FORMAT_D32_FLOAT; The structure also defines depth-stencil, rasterizer, blend state, input layout and other parameters. For instance, rasterizer state can be defined as in the code snippet below: // Init rasterizer state RasterizerStateDesc &RasterizerDesc = PSODesc.GraphicsPipeline.RasterizerDesc; RasterizerDesc.FillMode = FILL_MODE_SOLID; RasterizerDesc.CullMode = CULL_MODE_NONE; RasterizerDesc.FrontCounterClockwise = True; RasterizerDesc.ScissorEnable = True; //RSDesc.MultisampleEnable = false; // do not allow msaa (fonts would be degraded) RasterizerDesc.AntialiasedLineEnable = False; When all fields are populated, call IRenderDevice::CreatePipelineState() to create the PSO: m_pDev->CreatePipelineState(PSODesc, &m_pPSO); Binding Shader Resources Shader resource binding in Diligent Engine is based on grouping variables in 3 different groups (static, mutable and dynamic). Static variables are variables that are expected to be set only once. They may not be changed once a resource is bound to the variable. Such variables are intended to hold global constants such as camera attributes or global light attributes constant buffers. They are bound directly to the shader object: PixelShader->GetShaderVariable( "g_tex2DShadowMap" )->Set( pShadowMapSRV ); Mutable and dynamic variables are bound via a new object called Shader Resource Binding (SRB), which is created by the pipeline state: m_pPSO->CreateShaderResourceBinding(&m_pSRB); Dynamic and mutable resources are then bound through SRB object: m_pSRB->GetVariable(SHADER_TYPE_VERTEX, "tex2DDiffuse")->Set(pDiffuseTexSRV); m_pSRB->GetVariable(SHADER_TYPE_VERTEX, "cbRandomAttribs")->Set(pRandomAttrsCB); The difference between mutable and dynamic resources is that mutable ones can only be set once for every instance of a shader resource binding. Dynamic resources can be set multiple times. It is important to properly set the variable type as this may affect performance. Static variables are generally most efficient, followed by mutable. Dynamic variables are most expensive from performance point of view. This post explains shader resource binding in more details. Setting the Pipeline State and Invoking Draw Command Before any draw command can be invoked, all required vertex and index buffers as well as the pipeline state should be bound to the device context: // Clear render target const float zero[4] = {0, 0, 0, 0}; m_pContext->ClearRenderTarget(nullptr, zero); // Set vertex and index buffers IBuffer *buffer[] = {m_pVertexBuffer}; Uint32 offsets[] = {0}; Uint32 strides[] = {sizeof(MyVertex)}; m_pContext->SetVertexBuffers(0, 1, buffer, strides, offsets, SET_VERTEX_BUFFERS_FLAG_RESET); m_pContext->SetIndexBuffer(m_pIndexBuffer, 0); m_pContext->SetPipelineState(m_pPSO); Also, all shader resources must be committed to the device context: m_pContext->CommitShaderResources(m_pSRB, COMMIT_SHADER_RESOURCES_FLAG_TRANSITION_RESOURCES); When all required states and resources are bound, IDeviceContext::Draw() can be used to execute draw command or IDeviceContext::DispatchCompute() can be used to execute compute command. Note that for a draw command, graphics pipeline must be bound, and for dispatch command, compute pipeline must be bound. Draw() takes DrawAttribs structure as an argument. The structure members define all attributes required to perform the command (primitive topology, number of vertices or indices, if draw call is indexed or not, if draw call is instanced or not, if draw call is indirect or not, etc.). For example: DrawAttribs attrs; attrs.IsIndexed = true; attrs.IndexType = VT_UINT16; attrs.NumIndices = 36; attrs.Topology = PRIMITIVE_TOPOLOGY_TRIANGLE_LIST; pContext->Draw(attrs); Tutorials and Samples The GitHub repository contains a number of tutorials and sample applications that demonstrate the API usage. Tutorial 01 - Hello Triangle This tutorial shows how to render a simple triangle using Diligent Engine API. Tutorial 02 - Cube This tutorial demonstrates how to render an actual 3D object, a cube. It shows how to load shaders from files, create and use vertex, index and uniform buffers. Tutorial 03 - Texturing This tutorial demonstrates how to apply a texture to a 3D object. It shows how to load a texture from file, create shader resource binding object and how to sample a texture in the shader. Tutorial 04 - Instancing This tutorial demonstrates how to use instancing to render multiple copies of one object using unique transformation matrix for every copy. Tutorial 05 - Texture Array This tutorial demonstrates how to combine instancing with texture arrays to use unique texture for every instance. Tutorial 06 - Multithreading This tutorial shows how to generate command lists in parallel from multiple threads. Tutorial 07 - Geometry Shader This tutorial shows how to use geometry shader to render smooth wireframe. Tutorial 08 - Tessellation This tutorial shows how to use hardware tessellation to implement simple adaptive terrain rendering algorithm. Tutorial_09 - Quads This tutorial shows how to render multiple 2D quads, frequently swithcing textures and blend modes. AntTweakBar sample demonstrates how to use AntTweakBar library to create simple user interface. Atmospheric scattering sample is a more advanced example. It demonstrates how Diligent Engine can be used to implement various rendering tasks: loading textures from files, using complex shaders, rendering to textures, using compute shaders and unordered access views, etc. The repository includes Asteroids performance benchmark based on this demo developed by Intel. It renders 50,000 unique textured asteroids and lets compare performance of D3D11 and D3D12 implementations. Every asteroid is a combination of one of 1000 unique meshes and one of 10 unique textures. Integration with Unity Diligent Engine supports integration with Unity through Unity low-level native plugin interface. The engine relies on Native API Interoperability to attach to the graphics API initialized by Unity. After Diligent Engine device and context are created, they can be used us usual to create resources and issue rendering commands. GhostCubePlugin shows an example how Diligent Engine can be used to render a ghost cube only visible as a reflection in a mirror.
  20. I'm following the http://rastertek.com/dx11tut48.html(Directional Shadowmap Tutorial). You can see the problem in the image attached. Shadows are not opposite to the sun. How can I solve this problem? float4 PSMAIN(VS_OUTPUT Input) : SV_Target { float4 textureColor = txCUTex.Sample(SSCU, Input.TextureCoords); float bias, depthValue, lightDepthValue; float2 projectTexCoord; float3 FinalColor = 0; float LCL; float3 SunDir = normalize(vSunDir); bias = 0.00001f; // Calculate the projected texture coordinates. projectTexCoord.x = Input.LightVP.x / Input.LightVP.w / 2.0f + 0.5f; projectTexCoord.y = -Input.LightVP.y / Input.LightVP.w / 2.0f + 0.5f; // Determine if the projected coordinates are in the 0 to 1 range. If so then this pixel is in the view of the light. if((saturate(projectTexCoord.x) == projectTexCoord.x) && (saturate(projectTexCoord.y) == projectTexCoord.y)) { // Sample the shadow map depth value from the depth texture using the sampler at the projected texture coordinate location. depthValue = txCUSMTex.Sample(SSSM, projectTexCoord).r; // Calculate the depth of the light. lightDepthValue = Input.LightVP.z / Input.LightVP.w; // Subtract the bias from the lightDepthValue. lightDepthValue = lightDepthValue - bias; // Compare the depth of the shadow map value and the depth of the light to determine whether to shadow or to light this pixel. // If the light is in front of the object then light the pixel, if not then shadow this pixel since an object (occluder) is casting a shadow on it. if(lightDepthValue < depthValue) { LCL = saturate(dot(Input.LSNormal.xyz, SunDir)); if (LCL>0) { FinalColor = Input.Atte*LCL;//input.atte comes from sky shader (attenuation) FinalColor = saturate(FinalColor); FinalColor = textureColor.rgb*FinalColor; } } } return float4(FinalColor.rgb, 1); } ...... tDelta = 0; QueryPerformanceCounter((LARGE_INTEGER*)&PrevCount); float Theta =XM_PI*(float)tElapsed/50; float Phi = XM_PIDIV2; pImmediateContext->RSSetViewports(1, &SMVP); // Set null render target because we are only going to draw // to depth buffer. Setting a null render target will disable // color writes. pImmediateContext->OMSetRenderTargets(1, &NULLRTV, pSMDSV); pImmediateContext->ClearDepthStencilView(pSMDSV, D3D11_CLEAR_DEPTH, 1.0f, 0); XMMATRIX mgLightProjection = XMMatrixOrthographicLH(SM_SIZE, SM_SIZE, 0.01f, 200000); XMVECTOR Sun = XMVector4Normalize(XMVectorSet(cos(Theta)*cos(Phi), sin(Theta), cos(Theta)*sin(Phi), 0)); XMMATRIX mgLightView = XMMatrixLookAtLH(150000*Sun, XMVectorSet( -5000, /*550*/0, 0, 0.0f ), XMVectorSet(0,1,0,0)); // rendering sm cricket stuffs //rendering sm pitch pImmediateContext->IASetInputLayout(pVtxCULayout); uiStride = sizeof(TERVTX); pImmediateContext->IASetVertexBuffers(2, 1, &pVtxPitchBuffer, &uiStride, &uiOffset); pImmediateContext->IASetIndexBuffer(pIndxPitchBuffer, DXGI_FORMAT_R32_UINT, 0); pImmediateContext->IASetPrimitiveTopology(D3D11_PRIMITIVE_TOPOLOGY_TRIANGLELIST); pImmediateContext->VSSetShader(pVtxSMShader, NULL, 0); ..............
  21. Hello everyone, I've been during the past few days trying to fix sunlight on my sphere which have some bugs in it. For starters I'm using this code: https://github.com/Illation/ETEngine/blob/master/source/Engine/Shaders/PlanetPatch.glsl to calculate my normals instead of using a normal map. I'm then using this guide: http://www.thetenthplanet.de/archives/1180 To get my TBN Matrix. I have 2 main issues I'm working to solve when reworking this code. First I get seams in the normal map along the equator and from pole to pole. The normal also seems to move when I move my camera. Here is a video showing what I mean, the color is the normal calculated with the TBN matrix and as the camera moves it moves along with it. Nothing is multiplied by the view matrix or anything. Here is my code Vertex Shader: output.normal = mul(finalPos, worldMatrix); output.viewVector = (mul(cameraPos.xyz, worldMatrix) - mul(finalPos, worldMatrix)); mapCoords = normalize(finalPos); output.mapCoord = float2((0.5f + (atan2(mapCoords.z, mapCoords.x) / (2 * 3.14159265f))), (0.5f - (asin(mapCoords.y) / 3.14159265f))); output.position = mul(float4(finalPos, 1.0f), worldMatrix); output.position = mul(output.position, viewMatrix); output.position = mul(output.position, projectionMatrix); return output; and also what might be more important, the pixel shader: float3x3 GetTBNMatrix(float3 normalVector, float3 posVector, float2 uv) { float3 dp1, dp2, dp2perp, dp1perp, T, B; float2 duv1, duv2; float invMax; dp1 = ddx(posVector); dp2 = ddy(posVector); duv1 = ddx(uv); duv2 = ddx(uv); dp2perp = cross(dp2, normalVector); dp1perp = cross(normalVector, dp1); // * -1 due to being LH coordinate system T = (dp2perp * duv1.x + dp1perp * duv2.x) * -1; B = (dp2perp * duv1.y + dp1perp * duv2.y) * -1; invMax = rsqrt(max(dot(T, T), dot(B, B))); return float3x3(T * invMax, B * invMax, normalVector); } float GetHeight(float2 uv) { return shaderTexture.SampleLevel(sampleType, uv, 0).r * (21.229f + 8.2f); } float3 CalculateNormal(float3 normalVector, float3 viewVector, float2 uv) { float textureWidth, textureHeight, hL, hR, hD, hU; float3 texOffset, N; float3x3 TBN; shaderTexture.GetDimensions(textureWidth, textureHeight); texOffset = float3((1.0f / textureWidth), (1.0f / textureHeight), 0.0f); hL = GetHeight(uv - texOffset.xz); hR = GetHeight(uv + texOffset.xz); hD = GetHeight(uv + texOffset.zy); hU = GetHeight(uv - texOffset.zy); N = normalize(float3((hL - hR), (hU - hD), 2.0f)); TBN = GetTBNMatrix(normalVector, -viewVector, uv); return mul(TBN, N); } float4 MarsPixelShader(PixelInputType input) : SV_TARGET { float3 normal; float lightIntensity, color; float4 finalColor; normal = normalize(CalculateNormal(normalize(input.normal), normalize(input.viewVector), input.mapCoord)); lightIntensity = saturate(dot(normal, normalize(-lightDirection))); color = saturate(diffuseColor * lightIntensity); return float4(normal.rgb, 1.0f);//float4(color, color, color, 1.0f); } Hope anyone can help shine some light on this problem for me Best Regards and Thanks in advance Toastmastern
  22. Hi folks, I have a problem and I really could use some ideas from other professionals! I am developing my video game Galactic Crew including its own game engine. I am currently working on improved graphics which includes shadows (I use Shadow Mapping for that). I observed that the game lags, when I use shadows, so I started profiling my source code. I used DirectX 11's Queries to measure the time my GPU spends on different tasks to search for bottlenecks. I found several small issues and solved them. As a result, the GPU needs around 10 ms per frame, which is good enough for 60 FPS (1s / 60 frames ~ 16 ms/frame). See attachment Scene1 for the default view. However, when I zoom into my scene, it starts to lag. See attachment Scene2 for the zoomed view. I compared the times spent on the GPU for both cases: default view and zoomed view. I found out that the render passes in which I render the full scene take much longer (~11 ms instead of ~2ms). One of these render stages is the conversion of the depth information to the Shadow Map and the second one is the final draw of the scene. So, I added even more GPU profiling to find the exact problem. After several iteration steps, I found this call to be the bottleneck: if (model.UseInstancing) _deviceContext.DrawIndexedInstanced(modelPart.NumberOfIndices, model.NumberOfInstances, 0, 0, 0); else _deviceContext.DrawIndexed(modelPart.NumberOfIndices, 0, 0); Whenever I render a scene, I iterate through all visible models in the scene, set the proper vertex and pixel shaders for this model and update the constant buffer of the vertex shader (if required). After that, I iterate through all positions of the model (if it does not use instancing) and iterate through all parts of the model. For each model part, I set the used texture maps (diffuse, normal, ...), set the vertex and index buffers and finally draw the model part by calling the code above. In one frame for example, 11.37 ms were spent drawing all models and their parts, when I zoomed it. From these 11.37 ms 11.35ms were spent in the drawing calls I posted above. As a test, I simplified my rather complex pixel shader to a simple function that returns a fixed color to make sure, the pixel shader is not responsible for my performance problem. As it turned out, the GPU time wasn't reduced. Does anyone of you have any idea what causes my lag, i.e. my long GPU time in the drawing calls? I don't use LOD or anything comparable and I also don't use my BSP scene graph in this scene. It is exactly the same content, but with different zooms. Maybe I missed something very basic. I am grateful for any help!!
  23. The code to create d3d11 structured buffer : D3D11_BUFFER_DESC desc; desc.ByteWidth = _count * _structSize; if (_type == StructType::Struct) { desc.MiscFlags = D3D11_RESOURCE_MISC_BUFFER_STRUCTURED; } else { desc.MiscFlags = 0; } desc.StructureByteStride = _structSize; desc.BindFlags = D3D11_BIND_SHADER_RESOURCE; if (_dynamic) { desc.Usage = D3D11_USAGE_DEFAULT; desc.CPUAccessFlags = 0; } else { desc.Usage = D3D11_USAGE_IMMUTABLE; desc.CPUAccessFlags = 0; } if (FAILED(getDevice()->CreateBuffer(&desc, NULL, &_object))) { return false; } D3D11_SHADER_RESOURCE_VIEW_DESC resourceViewDesc; memset(&resourceViewDesc, 0, sizeof(resourceViewDesc)); if(_type == StructType::Float) resourceViewDesc.Format = DXGI_FORMAT_R32_FLOAT; else if (_type == StructType::Float2) resourceViewDesc.Format = DXGI_FORMAT_R32G32_FLOAT; else if (_type == StructType::Float3) resourceViewDesc.Format = DXGI_FORMAT_R32G32B32_FLOAT; else if (_type == StructType::Float4) resourceViewDesc.Format = DXGI_FORMAT_R32G32B32A32_FLOAT; else resourceViewDesc.Format = DXGI_FORMAT_UNKNOWN; resourceViewDesc.ViewDimension = D3D11_SRV_DIMENSION_BUFFER; resourceViewDesc.Buffer.ElementOffset = 0; resourceViewDesc.Buffer.NumElements = _count; ID3D11Resource* viewObject = _object; auto hr = getDevice()->CreateShaderResourceView(viewObject, &resourceViewDesc, &_shaderResourceView); if (FAILED(hr)) { return false; } I've created a float type structured buffer. The source data is a float array, I update the buffer from array[startIndex] to array[endIndex - 1]. The code to update buffer : bool setData(int startIndex, int endIndex, const void* data) { if (!data) return false; D3D11_BOX destBox; destBox.left = startIndex * _structSize; destBox.right = endIndex * _structSize; destBox.top = 0; destBox.bottom = 1; destBox.front = 0; destBox.back = 1; getContext()->UpdateSubresource(_object, 0, &destBox, data, _count * _structSize, 0); } The final result is that the data is not smooth, then I change the code of setData destBox.left = startIndex ; destBox.right = endIndex ; Then, the result looks smooth, but with some data missed !!!! Don't know why..
  24. Is it reasonable to use Direct2D for some small 2D games? I never did too much of Direct2D stuff, mostly I used it for displaying text/2D GUI for Direct3D engine etc. but I never tried doing game in it. Is it better to use Direct2D and sprites or would you prefer to go with D3D but with 2D shaders // is D2D not meant for games, no matter how big or small, at all?
  25. Hey, This is a very strange problem... I've got a computation shader that's supposed to fill 3d texture (voxels in metavoxel) with color, based on particles that cover given metavoxel. And this is the code: static const int VOXEL_WIDTH_IN_METAVOXEL = 32; static const int VOXEL_SIZE = 1; static const float VOXEL_HALF_DIAGONAL_LENGTH_SQUARED = (VOXEL_SIZE * VOXEL_SIZE + 2.0f * VOXEL_SIZE * VOXEL_SIZE) / 4.0f; static const int MAX_PARTICLES_IN_METAVOXEL = 32; struct Particle { float3 position; float radius; }; cbuffer OccupiedMetavData : register(b6) { float3 occupiedMetavWorldPos; int numberOfParticles; Particle particlesBin[MAX_PARTICLES_IN_METAVOXEL]; }; RWTexture3D<float4> metavoxelTexUav : register(u5); [numthreads(VOXEL_WIDTH_IN_METAVOXEL, VOXEL_WIDTH_IN_METAVOXEL, 1)] void main(uint2 groupThreadId : SV_GroupThreadID) { float4 voxelColumnData[VOXEL_WIDTH_IN_METAVOXEL]; float particleRadiusSquared; float3 distVec; for (int i = 0; i < VOXEL_WIDTH_IN_METAVOXEL; i++) voxelColumnData[i] = float4(0.0f, 0.0f, 1.0f, 0.0f); for (int k = 0; k < numberOfParticles; k++) { particleRadiusSquared = particlesBin[k].radius * particlesBin[k].radius + VOXEL_HALF_DIAGONAL_LENGTH_SQUARED; distVec.xy = (occupiedMetavWorldPos.xy + groupThreadId * VOXEL_SIZE) - particlesBin[k].position.xy; for (int i = 0; i < VOXEL_WIDTH_IN_METAVOXEL; i++) { distVec.z = (occupiedMetavWorldPos.z + i * VOXEL_SIZE) - particlesBin[k].position.z; if (dot(distVec, distVec) < particleRadiusSquared) { //given voxel is covered by particle voxelColumnData[i] += float4(0.0f, 1.0f, 0.0f, 1.0f); } } } for (int i = 0; i < VOXEL_WIDTH_IN_METAVOXEL; i++) metavoxelTexUav[uint3(groupThreadId.x, groupThreadId.y, i)] = clamp(voxelColumnData[i], 0.0, 1.0); } And it works well in debug mode. This is the correct looking result obtained after raymarching one metavoxel from camera: As you can see, the particle only covers the top right corner of the metavoxel. However, in release mode The result obtained looks like this: This looks like the upper half of the metavoxel was not filled at all even with the ambient blue-ish color in the first "for" loop... I nailed it down towards one line of code in the above shader. When I replace "numberOfParticles" in the "for" loop with constant value such as 1 (which is uploaded to GPU anyway) the result finally looks the same as in debug mode. This is the shader compile method from Hieroglyph Rendering Engine (awesome engine) and it looks fine for me but maybe something's wrong? My only modification was adding include functionality ID3DBlob* ShaderFactoryDX11::GenerateShader( ShaderType type, std::wstring& filename, std::wstring& function, std::wstring& model, const D3D_SHADER_MACRO* pDefines, bool enablelogging ) { HRESULT hr = S_OK; std::wstringstream message; ID3DBlob* pCompiledShader = nullptr; ID3DBlob* pErrorMessages = nullptr; char AsciiFunction[1024]; char AsciiModel[1024]; WideCharToMultiByte(CP_ACP, 0, function.c_str(), -1, AsciiFunction, 1024, NULL, NULL); WideCharToMultiByte(CP_ACP, 0, model.c_str(), -1, AsciiModel, 1024, NULL, NULL); // TODO: The compilation of shaders has to skip the warnings as errors // for the moment, since the new FXC.exe compiler in VS2012 is // apparently more strict than before. UINT flags = D3DCOMPILE_PACK_MATRIX_ROW_MAJOR; #ifdef _DEBUG flags |= D3DCOMPILE_DEBUG | D3DCOMPILE_SKIP_OPTIMIZATION; // | D3DCOMPILE_WARNINGS_ARE_ERRORS; #endif // Get the current path to the shader folders, and add the filename to it. FileSystem fs; std::wstring filepath = fs.GetShaderFolder() + filename; // Load the file into memory FileLoader SourceFile; if ( !SourceFile.Open( filepath ) ) { message << "Unable to load shader from file: " << filepath; EventManager::Get()->ProcessEvent( EvtErrorMessagePtr( new EvtErrorMessage( message.str() ) ) ); return( nullptr ); } LPCSTR s; if ( FAILED( hr = D3DCompile( SourceFile.GetDataPtr(), SourceFile.GetDataSize(), GlyphString::wstringToString(filepath).c_str(), //!!!! - this must be pointing to a concrete shader file!!! - only directory would work as well but in that case graphics debugger crashes when debugging shaders pDefines, D3D_COMPILE_STANDARD_FILE_INCLUDE, AsciiFunction, AsciiModel, flags, 0, &pCompiledShader, &pErrorMessages ) ) ) //if ( FAILED( hr = D3DX11CompileFromFile( // filename.c_str(), // pDefines, // 0, // AsciiFunction, // AsciiModel, // flags, // 0,//UINT Flags2, // 0, // &pCompiledShader, // &pErrorMessages, // &hr // ) ) ) { message << L"Error compiling shader program: " << filepath << std::endl << std::endl; message << L"The following error was reported:" << std::endl; if ( ( enablelogging ) && ( pErrorMessages != nullptr ) ) { LPVOID pCompileErrors = pErrorMessages->GetBufferPointer(); const char* pMessage = (const char*)pCompileErrors; message << GlyphString::ToUnicode( std::string( pMessage ) ); Log::Get().Write( message.str() ); } EventManager::Get()->ProcessEvent( EvtErrorMessagePtr( new EvtErrorMessage( message.str() ) ) ); SAFE_RELEASE( pCompiledShader ); SAFE_RELEASE( pErrorMessages ); return( nullptr ); } SAFE_RELEASE( pErrorMessages ); return( pCompiledShader ); } Could the shader crash for some reason in mid way through execution? The question also is what could compiler possibly do to the shader code in release mode that suddenly "numberOfParticles" becomes invalid and how to fix this issue? Or maybe it's even sth deeper which results in numberOfParticles being invalid? I checked my constant buffer values with Graphics debugger in debug and release modes and both had correct value for numberOfParticles set to 1...
  • Advertisement
×

Important Information

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

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!