• Advertisement
  • Popular Tags

  • Popular Now

  • Advertisement
  • Similar Content

    • By fs1
      I have been trying to see how the ID3DInclude, and how its methods Open and Close work.
      I would like to add a custom path for the D3DCompile function to search for some of my includes.
      I have not found any working example. Could someone point me on how to implement these functions? I would like D3DCompile to look at a custom C:\Folder path for some of the include files.
      Thanks
    • By stale
      I'm continuing to learn more about terrain rendering, and so far I've managed to load in a heightmap and render it as a tessellated wireframe (following Frank Luna's DX11 book). However, I'm getting some really weird behavior where a large section of the wireframe is being rendered with a yellow color, even though my pixel shader is hard coded to output white. 

      The parts of the mesh that are discolored changes as well, as pictured below (mesh is being clipped by far plane).

      Here is my pixel shader. As mentioned, I simply hard code it to output white:
      float PS(DOUT pin) : SV_Target { return float4(1.0f, 1.0f, 1.0f, 1.0f); } I'm completely lost on what could be causing this, so any help in the right direction would be greatly appreciated. If I can help by providing more information please let me know.
    • By evelyn4you
      Hello,
      i try to implement voxel cone tracing in my game engine.
      I have read many publications about this, but some crucial portions are still not clear to me.
      At first step i try to emplement the easiest "poor mans" method
      a.  my test scene "Sponza Atrium" is voxelized completetly in a static voxel grid 128^3 ( structured buffer contains albedo)
      b. i dont care about "conservative rasterization" and dont use any sparse voxel access structure
      c. every voxel does have the same color for every side ( top, bottom, front .. )
      d.  one directional light injects light to the voxels ( another stuctured buffer )
      I will try to say what i think is correct ( please correct me )
      GI lighting a given vertecie  in a ideal method
      A.  we would shoot many ( e.g. 1000 ) rays in the half hemisphere which is oriented according to the normal of that vertecie
      B.  we would take into account every occluder ( which is very much work load) and sample the color from the hit point.
      C. according to the angle between ray and the vertecie normal we would weigth ( cosin ) the color and sum up all samples and devide by the count of rays
      Voxel GI lighting
      In priciple we want to do the same thing with our voxel structure.
      Even if we would know where the correct hit points of the vertecie are we would have the task to calculate the weighted sum of many voxels.
      Saving time for weighted summing up of colors of each voxel
      To save the time for weighted summing up of colors of each voxel we build bricks or clusters.
      Every 8 neigbour voxels make a "cluster voxel" of level 1, ( this is done recursively for many levels ).
      The color of a side of a "cluster voxel" is the average of the colors of the four containing voxels sides with the same orientation.

      After having done this we can sample the far away parts just by sampling the coresponding "cluster voxel with the coresponding level" and get the summed up color.
      Actually this process is done be mip mapping a texture that contains the colors of the voxels which places the color of the neighbouring voxels also near by in the texture.
      Cone tracing, howto ??
      Here my understanding is confus ?? How is the voxel structure efficiently traced.
      I simply cannot understand how the occlusion problem is fastly solved so that we know which single voxel or "cluster voxel" of which level we have to sample.
      Supposed,  i am in a dark room that is filled with many boxes of different kind of sizes an i have a pocket lamp e.g. with a pyramid formed light cone
      - i would see some single voxels near or far
      - i would also see many different kind of boxes "clustered voxels" of different sizes which are partly occluded
      How do i make a weighted sum of this ligting area ??
      e.g. if i want to sample a "clustered voxel level 4" i have to take into account how much per cent of the area of this "clustered voxel" is occluded.
      Please be patient with me, i really try to understand but maybe i need some more explanation than others
      best regards evelyn
       
       
    • By Endemoniada

      Hi guys, when I do picking followed by ray-plane intersection the results are all wrong. I am pretty sure my ray-plane intersection is correct so I'll just show the picking part. Please take a look:
       
      // get projection_matrix DirectX::XMFLOAT4X4 mat; DirectX::XMStoreFloat4x4(&mat, projection_matrix); float2 v; v.x = (((2.0f * (float)mouse_x) / (float)screen_width) - 1.0f) / mat._11; v.y = -(((2.0f * (float)mouse_y) / (float)screen_height) - 1.0f) / mat._22; // get inverse of view_matrix DirectX::XMMATRIX inv_view = DirectX::XMMatrixInverse(nullptr, view_matrix); DirectX::XMStoreFloat4x4(&mat, inv_view); // create ray origin (camera position) float3 ray_origin; ray_origin.x = mat._41; ray_origin.y = mat._42; ray_origin.z = mat._43; // create ray direction float3 ray_dir; ray_dir.x = v.x * mat._11 + v.y * mat._21 + mat._31; ray_dir.y = v.x * mat._12 + v.y * mat._22 + mat._32; ray_dir.z = v.x * mat._13 + v.y * mat._23 + mat._33;  
      That should give me a ray origin and direction in world space but when I do the ray-plane intersection the results are all wrong.
      If I click on the bottom half of the screen ray_dir.z becomes negative (more so as I click lower). I don't understand how that can be, shouldn't it always be pointing down the z-axis ?
      I had this working in the past but I can't find my old code
      Please help. Thank you.
    • By turanszkij
      Hi,
      I finally managed to get the DX11 emulating Vulkan device working but everything is flipped vertically now because Vulkan has a different clipping space. What are the best practices out there to keep these implementation consistent? I tried using a vertically flipped viewport, and while it works on Nvidia 1050, the Vulkan debug layer is throwing error messages that this is not supported in the spec so it might not work on others. There is also the possibility to flip the clip scpace position Y coordinate before writing out with vertex shader, but that requires changing and recompiling every shader. I could also bake it into the camera projection matrices, though I want to avoid that because then I need to track down for the whole engine where I upload matrices... Any chance of an easy extension or something? If not, I will probably go with changing the vertex shaders.
  • Advertisement
  • Advertisement
Sign in to follow this  

DX11 DirectX 11 Questions

This topic is 2441 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

So Dx11 comes with 2 new buffers, giving a total of 3 buffers

- Constant Buffer
- Read/Write Buffer
- Read/Write Structured Buffer

The last 2 are the new ones, that are similar to Constant buffers, only that they can be written to in the Compute and Pixel shaders. Whats the purpose of the structured buffer though? is the setting up of the structure size purely a convenience factor? Because it would be just as easy to fill a normal buffer with the data, and do your own indexing in the shader.

If you dont want the ability to write, do the last 2 hold any benefit over constant buffers?

Can someone suggest some examples of where you would write to a buffer using a pixel shader?

Ive noticed that the geometry shader is actually after the tessellation stage. I find this odd. When would you ever need to create geometry after the mesh has been tessellated? surely would have made more sense to put it before.

Share this post


Link to post
Share on other sites
Advertisement
Hi.

There are even more new buffer types, look better. None of them are anything like constant buffers!!! Recall that constant buffers are very limited in size. All the new types are SRV/UAV, which simply means they are accessed by texture sampling units (or what's the proper name) as all the other textures and buffers. The difference is that you can now scatter (not only gather) to some of them. In another thread here, we mention an example of writing to a buffer in a PS and that would be for Bokeh (using AppendBuffer). Structured buffers are just convenience buffers and I'd say pretty neat.

The fact that the geometry stage is after tessellation is pretty logical, too. Tessellation actually doesn't really duplicate or "spawn" geometry, it just "refines" it (there is some topology involved) and a Domain Shader is simply just a kind of Vertex Shader! You cannot duplicate geometry for a cube map rendering using tessellation any easily, for example. That's why GS comes after DS and it doesn't matter where the input to GS comes from.

Share this post


Link to post
Share on other sites
[color=#1C2837][size=2]There are even more new buffer types, look better.[/quote]

What are the others?


[color=#1C2837][size=2]The fact that the geometry stage is after tessellation is pretty logical, too. Tessellation actually doesn't really duplicate or "spawn" geometry, it just "refines" it (there is some topology involved) and a Domain Shader is simply just a kind of Vertex Shader! You cannot duplicate geometry for a cube map rendering using tessellation any easily, for example. That's why GS comes after DS and it doesn't matter where the input to GS comes from. [/quote]

The reason I find it odd, is that the general workflow for using a geometry shader was to add new geometry on the fly. It seems logical that you would want to add geometry in the geometry shader, and then further refine this with tessellation as necessary. Take for example the case where you wanted to transform points into random 3d shapes,[font="sans-serif"] something like Icosahedron's. If the tessellation was after the GShader, then these could be automatically further refined by the tessellation stage (which of course could still be done in the GShader). Im just trying to understand the benefit of having the tessellation before the GShader. [/font]

Share this post


Link to post
Share on other sites
What are the others?[/quote]
-> http://msdn.microsof...v=VS.85%29.aspx

The reason I find it odd, is that the general workflow for using a geometry shader was to add new geometry on the fly. It seems logical that you would want to add geometry in the geometry shader, and then further refine this with tessellation as necessary. Take for example the case where you wanted to transform points into random 3d shapes, something like Icosahedron's. If the tessellation was after the GShader, then these could be automatically further refined by the tessellation stage (which of course could still be done in the GShader). Im just trying to understand the benefit of having the tessellation before the GShader. [/quote]

There is huge difference between GS and tessellation purpose. Although GS can be used to do tessellation algorithms, it can do MUCH more and cannot do many things as effectively (and massively) as a tessellator, on the other hand. GS can spawn new geometry of different types. Tessellation just "refines" geometry, that means that it adds new vertices/edges into the existing primitives. But AFAIK, there isn't a way of turning one triangle into two triangles that would not share their vertices in the topology using SM5 tessellation.

Still, if you want to achieve your workflow, then just first expand your points into icosahedrons (without a tessellation stage!!!) and then feed back your newly generated geometry to the tessellation stage for refinement/displacement/whatever. And then perhaps continue with yet another GS that'd "duplicate" them for each side of cubemap at once (or not). There will not be a great performance hit, all data will stay on GPU and the host will just issue two draw calls (pixels will be rasterised just once, of course, at the very end).

Share this post


Link to post
Share on other sites
Constant buffers and the other buffer types are not really the same at all. Constant buffers are intended for small amounts heterogeneous data, regular buffers are intended for large amounts of homogeneous data.

Structured buffers are for when you have a buffer containing a user-defined structure of data that you'd like to look up by index. Without structured buffer implementing this would require lots of tedious and error-prone format conversions, unpacking, and address calculations in the shader.

pcmaster already mentioned that you can use an AppendStructuredBuffer in a pixel shader to push out data from a subset of your pixels, which I used in a sample to implement a bokeh effect using point sprites. Another example is AMD's order independent transparency demo, where instead of writing out pixel colors to a render target they used atomic operations on buffers to implement per-pixel linked lists.

The geometry shader is directly tied to both the stream out and rasterization stages, both of which require fully-formed primitive and not un-tessellated patches. Also most common and well-suited use cases for geometry shaders are generating fins, generating point sprites, and rendering geometry to multiple cube map faces/shadow map cascades in a single draw call. You would never want to do any of those things before tessellation. You also wouldn't want to just expand points to arbitrary geometry...expansion in a geometry shader can be very expensive and you want to minimize the number of output vertices as much as possible.

Share this post


Link to post
Share on other sites
One further convenience with the StructuredBuffer is that it can be used with the Append/Consume functionality with a whole structure. So if you have a particular data structure that you are using (as a particle state for example) then you can append and consume directly with complete structures instead of trying to manage the individual pieces of data.

In addition to the other points made about the geometry shader, don't forget that it can also reduce data as well as introduce it. After the tessellation is performed, if you want to cull unnecessary primitives before they get rasterized then the geometry shader can make the decision not to pass that primitive along. The GS can also change the topology type, so even if you tessellate triangles, then you can still convert them to lines or points if you want... It is one of the more flexible pipeline stages, and usually can be used for some unconventional and/or creative algorithms.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement