It is currently Sat Aug 22, 2020 4:17 am


All times are UTC




Post new topic Reply to topic  [ 95 posts ]  Go to page Previous  1, 2, 3, 4, 5, 6, 7, 8 ... 10  Next
Author Message
 Post subject: Re: Introduce yourself!
PostPosted: Sat Feb 19, 2011 2:39 pm 
Developer
User avatar

Joined: Sun May 04, 2008 6:35 pm
Posts: 1827
Hello and welcome! Sounds like another interesting project is on the way and it's always nice to have new users :-) Seems like you have a good idea what you are looking for so I'll do my best to clear up your questions...

Shanee wrote:
MLE is using DirectX 9, I saw the example uses OpenGL. As far as I know the OpenGL and DirectX triangles/indices are pretty much flipped, aren't they? Can I just copy the vertices and indices given by the SurfaceExtractor to my DirectX vertex buffers and index buffers as is?


It's no problem. The demo does use OpenGL but other people have used Direct3D. Personally I use Ogre, which has an abstraction layer allowing either Direct3D or OpenGL to be used behind the scenes. But PolyVox is independant of the graphics API you use. You are correct that the default winding direction for polygons is the otherway around in Direct3D, but it is possible to change this. Or, you can tweak the index buffers by swapping the second and third index of each triangle so that e.g. 1,2,3,4,5,6 becomes 1,3,2,4,6,5

Shanee wrote:
Second question, I tried to look but didn't find much (btw parts of the manual seem to be broken?) - How does LOD work here? and I heard there were some issues with holes?


There is not much in the way of LOD because I personally haven't had much need for it. There is a MeshDecimator class which will take a patch of terrain and reduce it's triangle count so that it is just an approximation of the surface. It does not introduce any holes but there is a limit to how far you can go with this.

Alternatively you can use several volumes at different resolutions. However, in this case there tends to be a slight mismatch between the generated meshes because the different resolution volumes cannot line up perfectly (these are the holes you have heard about). In the last few months a technique has been developed to address this (TransVoxels) but PolyVox does not implement this yet. It probably won't get implemented for a few months (at least by me, you could always implement it yourself).

Shanee wrote:
Question number three, texturing. How do you get the UV on the surface?


There are no UVs generated because there is no good way to do this (at least that I know of). Instead, for smooth terrain an approach called triplanar texturing is usually used. You can read about it here and I can answer questions about it. A similar appraoch can be used for Minecraft style terrain. On that topic, what style of terrain are you looking for?

Shanee wrote:
Last but not least, question number four! I saw the videos show real time editing of the voxels, how will this apply for terrain? Does it mean you should use relatively small "volumes" so when updated the vertex buffers are easy to update? What sizes of voluem should I consider?


You can use a single volume, but conceptually divide it into regions with a mesh generated for each region. Then, when a voxels changes you only have regenerate the mesh for that region (as you describe). Some people are using multiple volumes so that they can page them to disk to simulate infinite terrain etc, but this introduces some complication you should avoid to start with. Any idea how big your terrains need to be?


Top
Offline Profile  
Reply with quote  
 Post subject: Re: Introduce yourself!
PostPosted: Sat Feb 19, 2011 3:36 pm 

Joined: Fri Feb 18, 2011 8:41 pm
Posts: 173
Thank you for your reply :)

As for the terrain style I was hoping for something that could have a smooth terrain and an editor such as shown here:
http://www.youtube.com/watch?v=1RXlRHUzVyE

About the indices, so PolyVox generates them for right handed use always? Well, I could just cull front faces when using a PolyVox entity instead of wasting CPU time flipping them.

My terrain shouldn't be like minecraft, I am hoping for smooth and more realistic terrain such as in the above video, is it possible to accomplish what presented there with your system? will it be fast enough as well?

As you say, using different volumes could indeed cause problems as mis-match between areas. I could try to see which technique to use then, perhaps using multiple volumes but adding a buffer layer that has the same data as the next region to overlap? Maybe some other way of streaming the terrain data.

On a note - right now I am having problems with PolyVox, I have downloaded the latest SVN, built it, included some headers and linked the lib. The extractor only extracts triangles, no indices at all. The Cubic type doesn't extradct triangles or indices. What could be wrong? I have made a post about it:
viewtopic.php?f=2&t=143

Which I see you jsut replied to as I am writing this message! Whoops :)


Top
Offline Profile  
Reply with quote  
 Post subject: Re: Introduce yourself!
PostPosted: Sat Feb 19, 2011 4:08 pm 
Developer
User avatar

Joined: Sun May 04, 2008 6:35 pm
Posts: 1827
Shanee wrote:
About the indices, so PolyVox generates them for right handed use always? Well, I could just cull front faces when using a PolyVox entity instead of wasting CPU time flipping them.


Yes, you can change the winding in DirectX, it's only different by default. As you say, this would be faster than tweaking the index buffers.

Shanee wrote:
As for the terrain style I was hoping for something that could have a smooth terrain and an editor such as shown here:
http://www.youtube.com/watch?v=1RXlRHUzVyE


Shanee wrote:
My terrain shouldn't be like minecraft, I am hoping for smooth and more realistic terrain such as in the above video, is it possible to accomplish what presented there with your system? will it be fast enough as well?


No problem, it's perfect for this. Have you tried the demos?

Terrain editing: http://www.thermite3d.org/releases/Ther ... er2009.zip
Physics demo: http://www.thermite3d.org/releases/Ther ... csDemo.zip (also see http://www.youtube.com/watch?v=qmZrdBBQThk)

The terrain editing demo also shows differnt materials (rock, earth, grass) which I didn't see in the video you linked.

Shanee wrote:
As you say, using different volumes could indeed cause problems as mis-match between areas. I could try to see which technique to use then, perhaps using multiple volumes but adding a buffer layer that has the same data as the next region to overlap? Maybe some other way of streaming the terrain data.

Using multiple volumes will get complex and you'll have difficulty aligning the meshes between different volumes. The ideal solution would be if PolyVox supported infinate volumes and handled the paging itself, and this will probably happen one day but not yet. How big do you need your volumes to be?


Top
Offline Profile  
Reply with quote  
 Post subject: Re: Introduce yourself!
PostPosted: Sat Feb 19, 2011 4:32 pm 

Joined: Fri Feb 18, 2011 8:41 pm
Posts: 173
Hey David.

I am really not sue how big they should be as of yet, prior to Polyvox I used GPU ClipMaps which allowed me to displays kilometers into the horizon, I am hoping for large terrains as in Morrowind and other open world RPGs. Perhaps the solution would be a combination of the techniques and not just one of the two (use GPU clipmaps for surface and add the caves and underground caverns with PolyVox). Then again, it may be possible to have some duplicate data and change the vertex buffers as moving in zones.

I just tried the terrain editing demo, I wanted to ask about the smoothing, how is it handled? my sphere is kinda bulky. Also I am not sure how Ogre updates the vertex and index buffers, I noticed geometry was added to the world on the fly, how do you feed the GPU buffers with the updates information like this?


Top
Offline Profile  
Reply with quote  
 Post subject: Re: Introduce yourself!
PostPosted: Sat Feb 19, 2011 5:38 pm 

Joined: Fri Feb 18, 2011 8:41 pm
Posts: 173
David Williams wrote:
There are no UVs generated because there is no good way to do this (at least that I know of). Instead, for smooth terrain an approach called triplanar texturing is usually used. You can read about it here and I can answer questions about it. A similar appraoch can be used for Minecraft style terrain. On that topic, what style of terrain are you looking for?



I found a better solution! A working shader on your forums :) Maybe you should put the shader as sticky somewhere? It is HLSL:

viewtopic.php?f=2&t=121&p=847&hilit=triplanar+texturing#p847

Thank you ape!


Top
Offline Profile  
Reply with quote  
 Post subject: Re: Introduce yourself!
PostPosted: Sat Feb 19, 2011 6:10 pm 
Developer
User avatar

Joined: Sun May 04, 2008 6:35 pm
Posts: 1827
Shanee wrote:
I am really not sue how big they should be as of yet, prior to Polyvox I used GPU ClipMaps which allowed me to displays kilometers into the horizon, I am hoping for large terrains as in Morrowind and other open world RPGs. Perhaps the solution would be a combination of the techniques and not just one of the two (use GPU clipmaps for surface and add the caves and underground caverns with PolyVox). Then again, it may be possible to have some duplicate data and change the vertex buffers as moving in zones.


Yeah, your not going to be able to come close to what GPU clipmaps can do in terms of terrain size, but of course they are far more limited (no overhangs, no modification, etc). The biggest terrain I have done was 1024x1024x256 voxels. That's a square kilometre if you say each voxel is 1 metre big. It was a single volume broken down into regions as described previously. I'm not sure how much bigger you will be able to go.

Shanee wrote:
I just tried the terrain editing demo, I wanted to ask about the smoothing, how is it handled? my sphere is kinda bulky. Also I am not sure how Ogre updates the vertex and index buffers, I noticed geometry was added to the world on the fly, how do you feed the GPU buffers with the updates information like this?


Actually the terrain in that demo if quite poor, PolyVox can make it much smoother now. The key is to use the density value, Currently you are setting the density of each voxel to 0 or the maximum value. If you set you density values so they change smoothly though the intermediate values then the resulting terrain will be smooth.

Shanee wrote:
I found a better solution! A working shader on your forums :) Maybe you should put the shader as sticky somewhere? It is HLSL:

viewtopic.php?f=2&t=121&p=847&hilit=triplanar+texturing#p847

Thank you ape!


True, I added it to the Wiki now.

Also, have a look at the images in that thread you posted. That's what happens if you try to use multiple volumes for paging the terrain. It's very difficult to fix, which is why you should use a single volume. Some people are fixing it by duplicating data across volumes when working with the Cubic SurfaceExtractor, but it's even harder to fix when working with the Marching Cubes one.


Top
Offline Profile  
Reply with quote  
 Post subject: Re: Introduce yourself!
PostPosted: Sat Feb 19, 2011 7:26 pm 

Joined: Fri Feb 18, 2011 8:41 pm
Posts: 173
Oh, I'd suggest to change the UV Clamp to Wrap ;) also comment the rgb values at the colors.

Also you removed the first lettet when copying the shader and left the float as loat ;)

Here is my sphere now :)
Image

Guess the next thing is (to finally go prepare for bio exam) write a terrain editor/system, fun! :)

Oh, to make your life easy:
Code:
float4x4 World;
float4x4 View;
float4x4 Projection;
float4 lightDirection = { 1, -0.7, 1, 0};
float textureScale;

texture gTex0;
sampler ColorMapSampler = sampler_state
{
   Texture = <gTex0>;
   MinFilter = ANISOTROPIC;
   MagFilter = ANISOTROPIC;
   MipFilter = Linear;   
   AddressU  = Wrap;
   AddressV  = Wrap;
};

// TODO: add effect parameters here.

struct VertexShaderInput
{
    float4 Position : POSITION0;
    float3 Normal : NORMAL0;

    // TODO: add input channels such as texture
    // coordinates and vertex colors here.
};

struct VertexShaderOutput
{
    float4 Position : POSITION0;
    float3 Normal : TEXCOORD0;
    float3 worldPosition : TEXCOORD1;

    // TODO: add vertex shader outputs such as colors and texture
    // coordinates here. These values will automatically be interpolated
    // over the triangle, and provided as input to your pixel shader.
};

VertexShaderOutput VertexShaderFunction(VertexShaderInput input)
{
    VertexShaderOutput output;

    float4 worldPosition = mul(input.Position, World);
    float4 viewPosition = mul(worldPosition, View);
    output.Position = mul(viewPosition, Projection);

   output.worldPosition = input.Position.xyz / input.Position.w;
   output.Normal = normalize(input.Normal);

    // TODO: add your vertex shader code here.

    return output;
}

float4 PixelShaderFunction(VertexShaderOutput input) : COLOR0
{
   float3 absNormal = abs(input.Normal);
   float3 blend_weights = absNormal;
   blend_weights = blend_weights - 0.2679f;
   blend_weights = max(blend_weights, 0);
   // force sum to 1.0
   blend_weights /= (blend_weights.x + blend_weights.y + blend_weights.z).xxx;

   float4 blended_color;
   float tex_scale = 0.1f;

   float2 coord1 = input.worldPosition.yz * tex_scale;
   float2 coord2 = input.worldPosition.zx * tex_scale;
   float2 coord3 = input.worldPosition.xy * tex_scale;

   float4 col1 = tex2D(ColorMapSampler, coord1);// * 0.01 + float4(1.0,0.0,0.0,1.0); // uncomment to see the blending in red/green/blue only
   float4 col2 = tex2D(ColorMapSampler, coord2);// * 0.01 + float4(0.0,1.0,0.0,1.0);
   float4 col3 = tex2D(ColorMapSampler, coord3);// * 0.01 + float4(0.0,0.0,1.0,1.0);

   blended_color = col1.xyzw * blend_weights.xxxx + 
               col2.xyzw * blend_weights.yyyy + 
               col3.xyzw * blend_weights.zzzz;

   // directional lighting
   //float4 light = -normalize(lightDirection);
   //float ldn = max(0, dot(light, input.Normal));
   //float ambient = 0.2f;

   //return float4(blended_color.xyz * (ambient + ldn), 1);
   return float4(blended_color.xyz, 1);
}

technique Technique1
{
    pass Pass1
    {
        // TODO: set renderstates here.
      CULLMODE = CCW;
      ZENABLE = TRUE;
        ZWRITEENABLE = TRUE;
        VertexShader = compile vs_1_1 VertexShaderFunction();
        PixelShader = compile ps_2_0 PixelShaderFunction();
    }
}


I commented out lighting in addition to the fixing.


Top
Offline Profile  
Reply with quote  
 Post subject: Re: Introduce yourself!
PostPosted: Wed Feb 23, 2011 7:56 am 

Joined: Tue Feb 22, 2011 10:21 pm
Posts: 12
Hi fellow developers!

I'm Jonathan, a 24 years old trainee engineer & game developer in Paris, France.
I develop in C++ tools & games since 11 years.

My I-hate-web-coding-website : http://www.jmgr.info (I'm not proud of the design)

I recently discovered a well-known cube game and was very disapointed it was written in Java (no I will not start a troll about this ;p), full of bugs and worst of all, privative.

So I started coding another mega-cool-cube-based-game-project, mostly because it's really interresting to code. For the moment I have no plans to make a real game out of it, but who knows ?

A first tech demo video : http://www.dailymotion.com/video/xh3v2c ... videogames

Anyway, thanks for having made PolyVox what it is today!


Top
Offline Profile  
Reply with quote  
 Post subject: Re: Introduce yourself!
PostPosted: Wed Feb 23, 2011 8:48 pm 
Developer
User avatar

Joined: Sun May 04, 2008 6:35 pm
Posts: 1827
Looks good! I had a peek at your website too, you've written a lot of stuff :-)

I see you asked a question about physics, I'll probably have to reply to it tomorrow though as I'm a little short of time at the moment. But it can definitely be done - Bullet was used for the physics demo on the Thermite3D front page.


Top
Offline Profile  
Reply with quote  
 Post subject: Re: Introduce yourself!
PostPosted: Thu Feb 24, 2011 2:49 am 

Joined: Sun Jan 23, 2011 6:06 am
Posts: 92
It's nice to see lots of activity on these forums lately. I hope this means lots of voxel-based indie games in the next couple of years ;-)

Voxels are sweet.


Top
Offline Profile  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 95 posts ]  Go to page Previous  1, 2, 3, 4, 5, 6, 7, 8 ... 10  Next

All times are UTC


Who is online

Users browsing this forum: No registered users and 2 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
cron
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group
Theme created StylerBB.net