Take the 2-minute tour ×
Game Development Stack Exchange is a question and answer site for professional and independent game developers. It's 100% free, no registration required.

I would like to render clouds using C#, directX9.0

using Microsoft.DirectX.Direct3D;
using Microsoft.DirectX;

Now I have roughly add and render the vertex as per below:

enter image description here

As you can see, the vertex is added in a cubic structure. And what I need to do now is to change the cubic structure to curve structure so that the whole cubic structure should looks like a cloud.

I am not using any graphic library but to build this structure solely using Microsoft.DirectX and DirectX.Direct3D

I did some Google search, and it seems the cube marching algorithm is a useful method to be implemented on these kind of 3D rendering.

From what I researched, there are no ready source for C#, but only for C++ for cube marching algorithm.

So, I would like to ask, if I only want to do the cloud rendering, is the marching cube algorithm a must? Or are there other options to align the structure to let it look like a cloud?

I totally have no idea at all, hope could look for some snipshot of source code or any good reference in C# using DirectX.dll

share|improve this question
 
Marching cubes is the same algorithm, even when implemented in other languages. You appear to be asking, how to implement it and if you should implement it. If you should or not is up to you. It's not required, but it seems as though you'd get good results from it. How to implement it is left as an exercise for you, since you know the algorithm, all that's left is writing the code, and writing code for other people isn't something we do here. –  Byte56 Jul 18 '13 at 14:16
 
If you are making a terrain -> Yes, Marching cubes is very great for the job. But for clouds I think most of the detail will be lost, as you'll have just the shell. A very lightweight way of drawing this is by just rendering a billboard blend additive on each point where there's cloud. This should give a simple but nice smoke effect. Try it! –  Gustavo Maciel Jul 19 '13 at 16:01
add comment

3 Answers

There is a reference implementation by Paul Bourke. It has been adapted to C# by johannes, and also copied on a russian blog.

You can use the C# code linked if understanding the algorithm is not important to you.

Basically marching cubes places a series of cubes (it "marches" them) into the voxel grid. If a cube straddles the isosurface, the cube is "cut" in one of 15 different ways:

enter image description here

Actually the 15th cut is a symmetrical image of the one directly above it (the 10th cut), but that's how the original paper described the possible cuts.

There are a total of 256 possible ways for the isosurface to cut the cube, but they all end up being symmetrical images of the above listed ones. For example, configuration 1 shown above (with 1 triangle generated at the corner) can happen in 8 different ways.

Anyway, if you're not interested in implementing this yourself (it takes a long time to sort out all the different configurations!), just copy the C# code at Johannes's blog.

share|improve this answer
 
For those interested: there was a discussion on gamedev.net about face ambiguity. To generate "perfect" isosurfaces with no ambiguity, this marching cubes 33 paper emerged. –  bobobobo Jul 18 '13 at 14:57
 
Can I understand that, actually cube marching algorithm is to wrap the surface of a structure? Since my intention is to create a 3D cloud. So, I should first create the vertex points by myself to construct a cloud structure. Then only wrap the cloud structure with cube marching algorithm? Kindly correct me if I am wrong. –  jhyap Jul 19 '13 at 1:21
add comment

To answer more specifically your question "is the marching cube algorithm a must?"

One of the problem of the marching cubes algorithm is that it can't reproduce sharp corners. I recommend the following reading: From Voxels to Polygons. It introduces another method called Dual Contouring which is more deeply described in this paper.

Dual Contouring

The idea is take account of the direction of the surface intersecting a voxel edge to create a more accurate shape. You might want to read this article too about this technique.

share|improve this answer
 
while you are correct, and it is good for people to know about Dual Contouring, it is certainly not a good fit for this specific project. Sharp edges are not needed and DC produces a lot more vertices and faces than MC, and is also harder to implement. –  DaleyPaley Jul 19 '13 at 9:09
 
Oh my bad, you're right. This is unadapted for clouds :) –  Benlitz Jul 19 '13 at 9:51
add comment

I am a bit curious, how will you render the geometry once you have it?

I ask because clouds are fuzzy and if you just render a bunch of polygons, the clouds will look opaque.

I suggest rendering with a volumetric raycasting shader. You can use your marching cubes geometry for the basic shape.

Basically, you can render the backface depths/positions to an offscreen buffer and frontface depths/positions to another, and then cast a ray from front to back, summing a noise function (like perlin). Adding lighting is important but can be very slow unless you find a good hack. It is a bit complicated, but it would produce better results than simply rendering the faces of a blobbly cloud shape.

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.