Jump to content

  • Log In with Google      Sign In   
  • Create Account


Member Since 28 Feb 2013
Offline Last Active Today, 11:52 AM

#5308384 Marching cubes on GPU (DirectX)

Posted by on 28 August 2016 - 02:14 PM

Sorry for the late responce.

I found also this implementation on GitHub 



Thanks everyone for help.

#5306322 Marching cubes on GPU (DirectX)

Posted by on 17 August 2016 - 04:40 AM

Hi all.


Recently I started to study marching cubes technique to generate infinite terrains on GPU in runtime.

I found these articles: 




But partial demo source code is very hard to understand and also it is almost 10 years old.


I understand how this should work in theory, but don`t understand yet how it should be implemented in code.


So, I want to ask if someone has already faced with this technique and has more recent working open source implementation on DirectX11 (C++ or C#), could you share your source code, please?

#5297105 Logarithmic depth buffer/Infinite far clip plane?

Posted by on 18 June 2016 - 01:00 AM


Is there any changes how I should make my intersection tests with Ray/Bounbox/etc using inverse Depth buffer?

#5294428 False negative result in bounding frustum test

Posted by on 01 June 2016 - 03:17 AM

Ok, after spending the whole day of debugging I finally fixed this issue:

The root cause of the issue was that OrientedBoundingBox.GetCorners() method returns incorrect points. I don`t know why this is happening, especially that I update my OBB matrix and scale each frame and it should be correct.

But If I get corners from basic OBB (without any transformations applied) and transform all these points with my World matrix with Vector3.TransformCoord(), then issue will gone and all frustum checks goes correctly.

That is very strange issue.


Here is SharpdX OBB code for GetCorners()

Is there anything wrong with it:

/// <summary>
      /// Retrieves the eight corners of the bounding box.
      /// </summary>
      /// <returns>An array of points representing the eight corners of the bounding box.</returns>
      public Vector3[] GetCorners()
         var xv = new Vector3(Extents.X, 0, 0);
         var yv = new Vector3(0, Extents.Y, 0);
         var zv = new Vector3(0, 0, Extents.Z);
         Vector3.TransformNormal(ref xv, ref Transformation, out xv);
         Vector3.TransformNormal(ref yv, ref Transformation, out yv);
         Vector3.TransformNormal(ref zv, ref Transformation, out zv);

         var center = Transformation.TranslationVector;

         var corners = new Vector3[8];
         corners[0] = center + xv + yv + zv;
         corners[1] = center + xv + yv - zv;
         corners[2] = center - xv + yv - zv;
         corners[3] = center - xv + yv + zv;
         corners[4] = center + xv - yv + zv;
         corners[5] = center + xv - yv - zv;
         corners[6] = center - xv - yv - zv;
         corners[7] = center - xv - yv + zv;

         return corners;

#5287949 Update only portion of data inside constant buffer D3D12

Posted by on 21 April 2016 - 06:20 AM


I started to learn DX12 and I have a question regarding constant buffer update.


I need to write only to the certain parts of my constant buffer by offset.

In D3D11 I could do like that:


BackingBuffer is type of DataBuffer and I could write there my data separately by offsets like this:

BackingBuffer.Set(offset, ref value);

And then update my constant buffer:

// Setup the dest region inside the buffer
            if ((this.Description.BindFlags & BindFlags.ConstantBuffer) != 0)
               device.UpdateSubresource(new DataBox(BackingBuffer.Pointer, 0, 0), constantBuffer);
               var destRegion = new ResourceRegion(offsetInBytes, 0, 0, offsetInBytes + BackingBuffer.Size, 1, 1);
               device.UpdateSubresource(new DataBox(BackingBuffer.Pointer, 0, 0), constantBuffer, 0, destRegion);

How can I do the same in D3D12?

#5267934 Place message loop inside each window

Posted by on 25 December 2015 - 04:35 PM

I dont want to be dependent from WInForms or WPF as they has their own bugs and I want to make my own UI Control system from scratch.




Pick one thread to run the UI (likely your main thread which is already running a message pump) and issue messages to it when you want it to do something either through your own message passing system, or the PostMessage Win32 function.


You mean that I must not create windows in other threads than main? Or just post messages to the threads, where windows was created?

#5264580 Draw 2D empty and filled circle

Posted by on 02 December 2015 - 07:51 AM

Maybe because I am a little bit stupid)


1. I iterate to 363 because I thought that less will made circle unfinished, but obviously I was wrong.

2. I added three vertices per iteration because I didnt fully understand triangle strip yet and work with it like with triangle list

3. This is also because of point 2.


Now, I apply your algorithm (which was obviously very simple) and not it works as expected.


Thanks a lot for that!

Attached Thumbnails

  • circle.png

#5263520 Render GUI elements with projection matrix

Posted by on 25 November 2015 - 02:15 AM

OK, I understand. I wanted to merge 2D and 3D UI, but seem this is not possible.

I need to separate 2D and 3D UI.

#5263385 Render GUI elements with projection matrix

Posted by on 24 November 2015 - 04:45 AM

Thanks to all for your answers. 


What do you think about using PerspectiveOffCenterLH matrix for this?

Seems it project DirectX units directly to pixels and position correspondingly. Using this matrix 0.0 will be at the top left corner of the window without any additional manipulations.

#5263298 Render GUI elements with projection matrix

Posted by on 23 November 2015 - 12:53 PM

I mean that I want to draw controls using true depth feeling, which could be made only with projection matrix. With ortho I need to scale objects manually if I want make them smaller when they are far from the camera.

#5263247 Render GUI elements with projection matrix

Posted by on 23 November 2015 - 06:23 AM

By visible depth I mean z-ordering with z-buffer. I want a real 3D UI behaviour.


How I need to render it in that case taking into account that I want to convert 3D Zero(0,0,0) in the middle of coordinates to the 2D Zero (0,0) at the left top corner?

#5224347 [SharpDX] Correctly handle mouse delta in Raw input

Posted by on 19 April 2015 - 01:51 PM

Ok, seems I get it myself. 

I found out that mouse can send more than one event before my input update mehod with called and I used earlier only last deltas. SO, movement was jerky.

Now I create a buffer for deltas and update camera rotation in loop.

Now camera rotations become much smoother.

#5212160 Bone animation implementation problem

Posted by on 21 February 2015 - 03:33 PM

OK, digging around I found an issue:

1. I import collada to DirectX, so all matrices should be transposed.

2. I use Yup axis and Blender has Zup axis, so I have to change axis with special matrix 


M11 - 1

M23 - 1

M32 - 1

M44 - 1


multiply each joint matrix once like this - newjointMatrix = axisChangeMatrix * jointMatrix * axisChangeMatrix


You need to do this once during load.


Then I should just multiply offset * keyframeMatrix. Or If I have hierarchy - keyframe*keyFrame.Parent *..... Parent and so on.


Then - send final matrices array to shader.

Thats all.


Now animation works correct.

#5210276 Set/Get array of value using effects framework C#

Posted by on 12 February 2015 - 08:51 AM

Thanks for help!

In sharpdx there is a little difference, but in general almost the same:

var matrixArray = renderSystem.customEffect.GetVariableByName("jointsArray").AsMatrix();

#5206149 Why RawInput does not work from dll C#

Posted by on 23 January 2015 - 01:25 AM

I am using C# + Sharpdx, so I have managed raw input lib without any Win 32. 

But seems I understood the problem - on main thread I need to register device and then I can subscribe to events on any part of the code.