Jump to content

  • Log In with Google      Sign In   
  • Create Account


Member Since 04 Jan 2010
Offline Last Active Private

#5198957 C++ | DirectX | Class system ?!

Posted by unbird on 18 December 2014 - 10:23 AM

You need to use brackets whenever the operator precedence dictates a different order ( * (dereference) has a lower precedence than ->).

But I wonder why you have a pointer to pointer for the device context at all. Usually you declare your DX objects as pointers, not as double pointers. Or are you confused by e.g. D3D11CreateDeviceAndSwapChain ? Note that the double pointer on the device context is a out parameter. Hmmm, a quick google search shows Java doesn't have such a thing (like the out keyword in C#). In this case you declare a pointer, but use & (address of operator)

ID3D11DeviceContext*    immediateContext = NULL;
D3D11CreateDeviceAndSwapChain( ..., &immediateContext);

Also: Be more precise when having troubles: Copy the exact error message from your compiler/linker and also copy relevant code (function definition and function call in this case). Please use code tags when you do.

PS:...and beaten.

#5197954 Writing my own pathtracer on mobile device

Posted by unbird on 13 December 2014 - 05:47 AM

General debugging hints ahead:


Write some test(s) or step through both implementations simultaneously, compare the intermediate results to see where they diverge. Or generate logs which you then can compare with diff.


Be aware that floating point calculation can produce different results depending on used language/compiler settings etc. (Edit: and hardware!)

#5197947 Global Illumination and Shader Engine

Posted by unbird on 13 December 2014 - 05:04 AM

I don't think putting theory and code in a video is the best way to start a discussion. Why not provide a PDF and/or use pastebin. You can also put code here with BBCode.


Also: Put your theory to the test with a implementation (and produce some nice screenshots wink.png). By the way: Although it will involve some work, research in approximating physically based rendering/global illumination usually compare to so-called ground truth, i.e. to a rendering with a raytracer/pathtracer and do diff image (or provide PSNR).

#5197582 C++ | DirectX | Class system ?!

Posted by unbird on 11 December 2014 - 08:48 AM

I agree. You switched API and language in the hope it will solve your performance issues. Nonetheless you're not sure it actually will. Then why switch at all.


I ask again: Have you profiled your code, with a profiling tool or manually ? And no, looking at FPS alone is not profiling. Do you use graphics profiling tools ?


How many draw calls do you have ? How many state changes ? And in the context of Java: Do you produce massive amounts of garbage each frame ? Also your graphics driver can make troubles: I hear that sometimes OpenGL drivers fall back to software rendering, if you use a feature unavailable in hardware.


If you just transliterate from Java/OpenGL to C++/DirectX you very likely have the same performance.

#5197455 C++ | DirectX | Class system ?!

Posted by unbird on 10 December 2014 - 02:51 PM

I mean it can't be so good for the performence to create instances of classes, or ?


Why do you actually have this impression ? Have you profiled any bottleneck in this regard ?


The only thing I can think of you can do wrong is creating (and destroying) buffers/textures and whatnot every frame. You usually create everything you need at app startup (or,  in the context of  game, at level beginning). If you need to change something you have Map/Unmap or UpdateSubresource.

#5197264 Merging two vertex buffers

Posted by unbird on 09 December 2014 - 03:31 PM

You can't do that, since you can only bind one index buffer at once.
What you can do though is concatenate the vertex buffers (also into one), and also concatenate the index buffers. For the latter you need to offset of the indices from the second buffer by the size of the first vertex buffer (or use a different BaseVertexLocation, like you did in your second draw call).

#5197115 Writing my own pathtracer on mobile device

Posted by unbird on 09 December 2014 - 03:05 AM

Salt'n Pepper ? Probably hitting the same object you bounced the ray off again. This can happen due to precision issues. Grant your Trace function a ignoreObject parameter, skip collision check for this and feed hitObject when you recurse.

#5196990 Shadow mapping matrix transform issue

Posted by unbird on 08 December 2014 - 11:05 AM

The issue was that my worldPos variable was a float3 while it should be a float4 for the matrix multiplication to work properly



As a general hint: Always watch the compilers output, such things get flagged as a warning:


warning X3206: 'mul': implicit truncation of vector type


You can even treat them as errors with D3DCOMPILE_WARNINGS_ARE_ERRORS (or /WX with the command line compiler).

#5196857 Post-processing effect questions

Posted by unbird on 07 December 2014 - 03:33 PM

ID3DXSprite only issues a draw call when calling End() or Flush(). So the whole Begin(), Draw(), End() triple should be within that pass. I'm also not quite sure you actually can use it with custom shaders, at least call it with D3DXSPRITE_DONOTMODIFY_RENDERSTATE also.

If that fails, setup your own vertices and draw call. Make sure you don't forget the half-pixel offset needed for correct sampling.

#5196855 Annoying shadow map artifacts

Posted by unbird on 07 December 2014 - 03:22 PM

Precisely. (Well, unless your shadow projection is badly chosen, e.g. too near a far plane. But that shouldn't happen :wink:)

#5196839 Annoying shadow map artifacts

Posted by unbird on 07 December 2014 - 02:39 PM

... and set border color to 1 (assuming you also clear your shadow map to 1).

#5196820 C# Write to memory stream instead of local file

Posted by unbird on 07 December 2014 - 01:25 PM

Reset the memory stream to the beginning before reading again:

stream.Position = 0;

Edit: Also don't forget to Dispose() the memory stream afterwards, or conveniently use using(var stream = new MemoryStream()){...}. Same applies to StreamReader.

#5196767 Writing my own pathtracer on mobile device

Posted by unbird on 07 December 2014 - 05:01 AM

Reading the docs helps, or what Vilem has written. Argument is in radians, not degrees. Even for degrees the value would be silly (> 180°).

#5196763 Determine Shader Model for Compiled Shader Object

Posted by unbird on 07 December 2014 - 03:16 AM

Looking at hex values it's more obvious:

vs_5_0 : 0x10050
hs_5_0 : 0x30050
ds_5_0 : 0x40050
gs_5_0 : 0x20050
ps_5_0 : 0x00050
cs_5_0 : 0x50050

vs_4_0 : 0x10040
gs_4_0 : 0x20040
ps_4_0 : 0x00040
cs_4_0 : 0x50040

Seems high-word is stage, low-word is shader model.


#5196671 RenderDoc - Weird output signatures

Posted by unbird on 06 December 2014 - 01:14 PM

Judging from the source code, looks like a 1:1 a dump from D3D shader reflection. "Used" in that view seems to be ReadWriteMask from D3D11_SIGNATURE_PARAMETER_DESC. It's actually confusing (quoting the docs):

Mask which indicates whether a given component is never written (if the signature is an output signature) or always read (if the signature is an input signature).

Emphasis mine. Flags or bools with negative meaning are bad wacko.png