Jump to content

  • Log In with Google      Sign In   
  • Create Account


Member Since 29 Mar 2007
Offline Last Active Today, 12:02 AM

#5165642 DX11 Multithreaded Resource Creation Question

Posted by MJP on 08 July 2014 - 02:50 PM

In theory everything should work fine, since the runtime itself will synchronize to prevent the driver from having concurrent resource creates if it doesn't support it. But I've never tested on a driver that didn't support concurrent resource creation, so I can't verify anything.

#5165432 How can i have a softer Skin using BRDF

Posted by MJP on 07 July 2014 - 08:16 PM

Yeah we always use the same map, we don't animate it.

#5165119 How can i have a softer Skin using BRDF

Posted by MJP on 06 July 2014 - 03:41 PM

In my experience you really need to use curvature maps for the pre-integrated shading. The trick with using derivatives and clever and might work for certain simple scenarios, but the fact it has discontinuities across triangle edges is pretty much a deal-breaker for faces.


#5165117 Getting started with D3D in C#: InvalidCallException

Posted by MJP on 06 July 2014 - 03:36 PM

In D3D9 you can have a "Lost Device" scenario, and you have to recover from it by calling Reset on your device. It's a real pain to deal with in a robust way, and is the source of a lot of errors. Fortunately they fixed it for D3D10/D3D11.

I should definitely warn you that the "Managed DirectX" library you're using is very old, and hasn't been updated in many years. Microsoft essentially abandoned it, and left the task of a managed DirectX wrapper up to the community. Earlier on SlimDX was the most popular Managed DX wrapper, but these days SharpDX is much more active and up-to-date with the latest DirectX versions. I would recommend using SharpDX instead if you're looking to actually do any DX app development, and I would also recommend using D3D11 unless you really need to target Windows XP.


Posted by MJP on 29 June 2014 - 04:06 PM

You can always create your vertex buffer as a structured buffer or byte address buffer, and then us SV_VertexID to manually unpack your data in the shader. However it's almost certainly not going to save you any performance.

#5163128 DXT5 artifacts

Posted by MJP on 26 June 2014 - 06:37 PM

With BC5 the X and Y components will be in the red and green channels of the texture, so you would need to change your shader code to use .xy instead of .wy.

There are lots of ways you can verify the format of the texture that's created: you could step into the loader code and see what it does, you could call GetDesc on the ID3D11Texture2D to see what format it's using, or you could use a tool like VS Graphics Debugger or Renderdoc to inspect the texture.

DirectXTex has functions for compressing textures, which you could incorporate into a custom tool. It also comes with the texconv sample, which is a command-line tool that you can use for compressing files and generating mips.

#5163127 Getting around non-connected vertex gaps in hardware tessellation displacemen...

Posted by MJP on 26 June 2014 - 06:33 PM

It's a common problem, and it's pretty hard to work around. You should read through this presentation for some ideas.

#5163115 DX11 on a DX10-class GPU -- How far can you go?

Posted by MJP on 26 June 2014 - 05:26 PM

Other things you won't be able to use with feature level 10:


  1. 'Real' compute shaders (D3D11 supports a very limited version compute shaders for 10-level devices, but it's mostly useless)
  2. Read-only depth buffers
  3. Expanded MSAA support (reading from MSAA depth buffers, per-sample pixel shaders, SV_Coverage as input, interpolate to sample position)
  4. Cubemap arrays
  5. Append/Consume buffers
  6. UAV's from the pixel shader

#5163110 DXT5 artifacts

Posted by MJP on 26 June 2014 - 04:51 PM

Since you appear to be using D3D10 or D3D11, you should consider switching to BC5. It will give better quality than using the green and alpha channels of DXT5. That Nvidia plugin is from before D3D10 so it doesn't have BC5, but it's functionally equivalent to the 3Dc format so your DDS loader might bload it as BC5 if you save it as 3Dc format.

#5162845 How can i have a softer Skin using BRDF

Posted by MJP on 25 June 2014 - 03:14 PM

So this method only affect diffuse calculations right ?



Yes. Current sub-surface scattering techniques only address diffuse reflectance, so you can leave specular alone.




Will sub-surface scattering necessarily help the falloff though?

Absolutely. Take a look at this image from Eric Penner's slides:




Notice how the falloff becomes much softer as curvature increases.

#5162677 How can i have a softer Skin using BRDF

Posted by MJP on 24 June 2014 - 06:50 PM

You probably want to look into subsurface scattering for the skin. Jimenez's screen space shader is the popular one. However, I'm concerned about how sharp your light-shadow transition is independent of the material being rendered. That does not look correct to me. You should check out what's going on there before doing anything else. FWIW, a cheap starting point with skin is to simply shut off specular entirely. This is a good sanity check.


I think it looks right for a gamma-correct Lambertian diffuse falloff. Linear-space Lambertian is actually pretty harsh, especially compared to doing it in gamma-space. Obviously it looks totally wrong for skin, since the SSS will "soften" the falloff and avoid that "rocky" look that you would get otherwise.

So yeah, there's the screen-space stuff which has its pros and cons. At work we use Pre-Integrated Skin Shading (also has an article in GPU Pro 2), which has a different set of pros and cons. For some background reading, I would also suggest reading the skin rendering chapter from GPU Gems 3. The actual techniques it describes aren't really attractive for real-time rendering (texture-space diffusion is too expensive and doesn't scale well, and GGX is a cheaper approximation than multiple Beckmann specular lobes), but it's still a great article.

#5162413 question about linking

Posted by MJP on 23 June 2014 - 03:44 PM

If you're talking about static libs, then the behavior depends on the compiler toolchain you're using as well as the settings provided for the linker. In Visual C++ for instance, dead-code stripping is controlled by the /OPT:REF command-line option.

#5162406 Question about depth bias.

Posted by MJP on 23 June 2014 - 02:57 PM

Depth bias basically "nudges" every pixel forward or backwards in view-space, based on the bias value provided. So it doesn't just affect comparison with the depth buffer, it also affects the resulting depth value written to the depth buffer.

If you always want whatever you draw to end up on top, why not just disable depth testing? Or am I misunderstanding what you're attempting to accomplish?

#5162238 Filtering Cubemaps

Posted by MJP on 22 June 2014 - 09:26 PM

On all modern hardware a cubemap is just a texture array with NumSlices = 6, so there's not really much difference (from a hardware POV) between a cubemap and an 'atlased' texture where 6 faces are packed into one long horizontal strip. The main difference is that if you want to you have access to an easy direction->UV conversion in shader, or alternatively if you just want to treat it as an array you can easily address each face using an array index. In D3D11 which behavior you get is dependent on how you set up your shader resource view, and what type is declared in your shader. Personally I would probably go with a cubemap to get the nice cubemap behavior when sampling the filtered shadow map, especially since in D3D11 hardware filtering works correctly across cubemap seams.

#5162236 Per-instance data in (non-vertex) shaders

Posted by MJP on 22 June 2014 - 09:20 PM

Like Jason mentioned if you have your instance data in a buffer or texture (StructuredBuffer is probably the easiest to work with) then you can fetch the data in any stage as long as you pass the InstanceID downward from the vertex shader.