Jump to content

  • Log In with Google      Sign In   
  • Create Account


Member Since 05 Oct 2005
Offline Last Active Aug 25 2016 04:46 PM

#5288155 Looking for good fast geometry compression for streaming!

Posted by on 22 April 2016 - 10:44 AM

This video contains a rough overview of how Microsoft does it. There are no complete libraries for this as far as I'm aware. It's possible there are papers though on each individual technique, but the process is essentially a pipeline of different point cloud and mesh algorithms. (This problem seems extremely complex by the way when it comes to creating keyframes and delta frames. Microsoft might have broken new ground when performing this research).

#5288147 How do I keep track of nearby objects?

Posted by on 22 April 2016 - 09:31 AM

Right now I'm using a simple node system where I initially send objects in current/surrounding node and update them respectively if node boundaries are passed. But it looks extremely messy and perhaps inefficient. Opened for any suggestions.

Would this happen to be a normal uniform grid? I wrote a blog article years ago that covered the grid and spatial hashing methods. Might compare the data structures I use against yours.


A big picture idea of interest management is that you don't have to run it in real-time. As Frob mentioned loose variations will often be used that exploit this. If designed correctly you can update entities in cells, quadtrees, etc like once per second then query and build the list of nearby entities every 2 seconds or stagger updates across many ticks. This can get kind of complex, but in the end you can end up with a system that supports thousands of entities and scales. (Overkill usually).

#5276226 Vulkan is Next-Gen OpenGL

Posted by on 17 February 2016 - 05:08 PM

Are there any other spirv compilers out yet? I'm really excited about the prospect of not being tied to a single shader compiler.




Not aware of any others. I'm sure someone is writing an HLSL to Spir-V though, but I haven't seen one yet.

#5275461 Decompress quadtree image

Posted by on 12 February 2016 - 03:38 PM

From an image processing standpoint you should be able to use a gradient technique. https://en.wikipedia.org/wiki/Image_gradient I'd use a 3x3 kernel to start with and maybe combine a larger kernel to generate a gradient map. Post process the gradient to smooth it then apply the changes to the grayscale image. Using this you can even increase the resolution.

#5271611 Calculate time t along a 2D cubic bezier equal to a given tangent vector

Posted by on 17 January 2016 - 05:31 PM

I should have been more clear. I can probably write an iterative solution, but I'm more concerned with a closed form solution. (Since I've shown a partial solution can be calculated already for most cases).


edit: Someone solved it on stackoverflow. Interesting.

#5271042 Developing an Ocean Shader for Unreal Engine 4

Posted by on 14 January 2016 - 08:10 AM

The surface in yours looks like a large ocean of jello. The primary reason for this is you stretch and compress the whole mesh even the finest details. From watching videos of oceans waves the high noise and slow moving froth stay in place and move much less than the low frequency waves and crests. When watching videos it's like you start with a large taunt blanket then you have high frequency noise that moves very little in relation to the lower frequency waves. As you add lower frequencies of waves the movements go up and they affect each other more. Also low frequency waves crest. The lower the frequency (larger) the wave the more foam. You lose a lot of detail without this.


Also for more realistic rendering (which adds a lot to the overall effect) you might want to render your objects first to a texture and extract a depth map. Then use that when rendering the water and take the difference between the depth values. Using something like beer-lambert for the depth based transparency would add a lot. (I'm sure there's a paper with a more accurate volumetric transparency though for the water).

#5269426 Client/Server rendering

Posted by on 05 January 2016 - 09:31 AM

This should probably be in the Multiplayer and Networking section. There are a few ways to handle what you're describing.


Assuming you have a hash grid with uniform cell size then you just need to use the player's current camera on the server to collect all the entities in range. That just requires iterating through the cells and performing a look-up in the hash grid. Then for all the cells that exist in the hash grid union the entities into a list. This list represents all the entities the client can see. I have a tutorial on spatial partitioning and the queries here. That said the basic query function would look like this in C#:


public HashSet<IGridEntity> Query(AxisAlignedBoundaryBox aabb)

    var entities = new HashSet<IGridEntity>();
    var startX = (int)(aabb.MinX / CellSize);
    var endX = (int)(aabb.MaxX / CellSize);
    var startY = (int)(aabb.MinY / CellSize);
    var endY = (int)(aabb.MaxY / CellSize);
    for (var x = startX; x <= endX; ++x)
        for (var y = startY; y <= endY; ++y)
            Cell cell;
            if (grid.TryGetValue(y * dimensions + x, out cell))
    return entities;


Now once you have all the entities you have to tell the player about them. In the past I've advocated using a full and delta state pattern. That is for every client you store an array of all the entities you've told the client about and then on every message after that you simply tell them what's changed. If you do that then you'll have an array that's empty when the client connects. We can refer to this array as the "known entities" array.


Depending on how you're building packets you'd want to add all the information about the new entities that aren't in the array (so that the client can recreate it). This would include things like the entity type. You're right that you'll want to give all the entities a unique id. You'll use this id to refer to the client entity later. If the entity is already known by the client (it's in the known entities array) then you just need to send a delta packet with things that have changed, like position. You can use bools to track changed items in the entity then after sending data to all the clients just set the bool to false.


That's all there is to it. Every tick of the server query for the entities in the camera then check the known entities and either add new entity data to the packet or write a delta entity data. The client has its own array of known entities so if it receives an entity id it's never seen it knows it needs to deserialize the full state and if it already knows about the entity then it'll deserialize a delta for the entity.


The two tutorials I linked go into things a lot more including how to forget entities. There are a lot of optimizations, but this is a fairly simple technique especially for a lock-step game. (It forms the basis though for a lot of technique for drastically reducing bandwidth though).

#5255663 Real-Time WebSockets and REST

Posted by on 05 October 2015 - 09:58 AM

In regards to WebSockets I personally wouldn't bother with socket.io. You can just use the ws module for games. Falling back isn't necessary anymore for any browser or device. (Nor for a game is it really worth it).

#5235225 Uses of curves in graphics?

Posted by on 16 June 2015 - 07:39 PM

I've always found the CSS documentation on MDN to be a nice overview of timing functions: https://developer.mozilla.org/en-US/docs/Web/CSS/timing-function


Also check this out: http://www.gdcvault.com/play/1020583/Animation-Bootcamp-An-Indie-Approach (It starts at movement continued with a full animation system defined by curves)

#5225744 Direct3D 12 documentation is now public

Posted by on 26 April 2015 - 08:17 PM


Okay almost have DirectWrite working and Direct2D. All the code is done from what I can tell. One big issue though and I fear this is a critical bug still. You can't get a IDXGIDevice from a ID3D12Device?

Microsoft::WRL::ComPtr<ID3D12Device> mDevice;
hr = D3D12CreateDevice(.., D3D_DRIVER_TYPE_UNKNOWN, D3D12_CREATE_DEVICE_NONE, D3D_FEATURE_LEVEL_11_1, D3D12_SDK_VERSION, __uuidof(ID3D12Device), (void**)&mDevice);
Microsoft::WRL::ComPtr<IDXGIDevice2> dxgiDevice;
hr = mDevice.As(&dxgiDevice); // E_NOINTERFACE No such interface supported.

As you may know the alternative code, shown in the documentaiton, when not using ComPtr is:

hr = mDevice->QueryInterface(__uuidof(IDXGIDevice2), (void**)&dxgiDevice); // E_NOINTERFACE No such interface supported.

This produces the same error with IDXGIDevice, IDXGIDevice1, IDXGIDevice2, or IDXGIDevice3.


Since getting a valid IDXGIDevice is required to create a ID2D1Device1 - using the ID2D1Factory2 - it's impossible to use DirectWrite easily with D3D12 as far as I can see. Is there something simple I'm missing? Did something change with how you go from D3D12Device to IDXGIDevice2?


Yes, IDXGIDevice interfaces are no longer supported with Direct3D 12 (that's not a big secret as you found out about it!).


If you look in the SDK you will find an header (and its .IDL) called "d3d11on12" and if you open it you will find what this new API is meant about: interoop between Direct3D 12 and Direct3D 11 (also not another big secret since it states in the API comments).


Darn. Yeah I commented about that the other day. Got the impression that d3d11on12 was the only way, but noticed the only missing piece was the IDXGIDevice. Seemed weird to have to use a whole separate API as a workaround. I have it partly coded though. Thanks for the clarification.


Actually not too bad. Just needed this I think:

const const D3D_FEATURE_LEVEL featureLevels[] = { D3D_FEATURE_LEVEL_11_1 };
IUnknown* commandQueues[] = { mCommandQueue.Get() };
Microsoft::WRL::ComPtr<ID3D11Device> mD3D11Device;
Microsoft::WRL::ComPtr<ID3D11DeviceContext> mD3D11DeviceContext;
hr = D3D11On12CreateDevice(mDevice.Get(), D3D11_CREATE_DEVICE_SINGLETHREADED | D3D11_CREATE_DEVICE_BGRA_SUPPORT, featureLevels, ARRAYSIZE(featureLevels), commandQueues, 1, 1, mD3D11Device.GetAddressOf(), mD3D11DeviceContext.GetAddressOf(), nullptr);

This returns S_OK.


It works! Then also you need to do:

Microsoft::WRL::ComPtr<IDXGIDevice> dxgiDevice;
hr = mD3D11Device.As(&dxgiDevice); // S_OK

Microsoft::WRL::ComPtr<ID2D1Device1> mD2DDevice;
hr = mD2DFactory->CreateDevice(dxgiDevice.Get(), mD2DDevice.GetAddressOf()); // S_OK

I'll have a full example when I'm done understanding and learning. I don't want to give out bad code examples since I've never really used D3D before this point.

#5219225 What are your opinions on DX12/Vulkan/Mantle?

Posted by on 25 March 2015 - 10:13 PM

Just saw this was posted: https://msdn.microsoft.com/en-us/library/windows/desktop/dn903821%28v=vs.85%29.aspx Seems to be the D3D12 Documentation.

#5178225 GOTO, why are you adverse to using it

Posted by on 04 September 2014 - 10:39 PM

I have no aversion. The way I write code means a goto is never necessary. I've never ran into a problem and thought to myself that a goto would be cleanest solution in C#, Javascript or C++. Maybe it's useful outside of those languages. I remember seeing it used in C and that's it. I use lambdas a lot and lambda callbacks rather than returns. It's very flexible especially with asynchronous stuff.

#5175408 GUI Scissor

Posted by on 21 August 2014 - 10:24 PM

Assuming you only need rectangles you can just passing in the x, y, width, height region as a uniform to your pixel shader and discarding pixels outside the region.

#5174340 Thesis idea: offline collision detection

Posted by on 17 August 2014 - 06:38 PM

Even if your memory requirements were enormous for 3D this might still be an interesting experiment to open the discussion to other methods. In 2D this might be feasible. You can precompute the minkowski sum for each object for every rotation to simplify things down to a point vs the world simulation. If you could interpolate the stored state between different rotations you might end up with a very fast solution. There is already research for dynamic minkowski summations. Sounds like this would take a lot of research though and a lot of memory.

#5170496 College or Solo?

Posted by on 30 July 2014 - 09:33 PM

For profit schools are generally a sham. You should be looking at and applying to an accredited university for a CS program. You should be programming by yourself already and when you're getting your degree be programming on the side to build experience. The idea is a well rounded education. Try to get scholarships also if you haven't already.