• Advertisement
Sign in to follow this  

Voxel structure programming implementation

This topic is 1952 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hello, everybody!

The 3D scene consist of 20 objects based on polygonal model structure. I wanna convert polygonal objects to voxel data structure (i think it's array 3D map) . And voxel objects will be used for constructing distance field of all environment world.

Please, tell me, do you have any ideas about using c# structure class to store voxel data and be able for further using in code or any algorithms and methods?

Do you know any API or wrap that could realize this functionality?

Thanks. Edited by PlatinumOz

Share this post


Link to post
Share on other sites
Thinking about it brought me to one idea. You can use a zbuffer to voxelize your objects. With the size of this ZBuffer you can scale the density of your voxelgrid. Now render each object or the whole scene at origin from all six sides and stay at same distance from origin for each side with an orthogonal projectionmatrix. For every "side-rendering" you know x,y,z position for every pixel and can set visibility-flag for all voxels. If you also need color for a voxel use an additonal diffuse-buffer and save the color from same position.

Share this post


Link to post
Share on other sites
No, man.

I don't need rendering voxelized object. I need structure of voxelizard object in program code, for exapmle, type - array of byte.

Share this post


Link to post
Share on other sites
[quote name='Auskennfuchs' timestamp='1347308222' post='4978685']
Thinking about it brought me to one idea. You can use a zbuffer to voxelize your objects. With the size of this ZBuffer you can scale the density of your voxelgrid. Now render each object or the whole scene at origin from all six sides and stay at same distance from origin for each side with an orthogonal projectionmatrix. For every "side-rendering" you know x,y,z position for every pixel and can set visibility-flag for all voxels. If you also need color for a voxel use an additonal diffuse-buffer and save the color from same position.
[/quote]
interesting idea :) !

Share this post


Link to post
Share on other sites
Look up the Sparse Voxel Octree. It's probably the best way to squeeze voxel data down to a reasonable size.

What's your end goal of the project? What do you want to use the distance fields for?

Share this post


Link to post
Share on other sites
[quote name='DracoLacertae' timestamp='1347483978' post='4979454']
Look up the Sparse Voxel Octree. It's probably the best way to squeeze voxel data down to a reasonable size.

What's your end goal of the project? What do you want to use the distance fields for?
[/quote] DracoLacertae, thanks so. I'm planing to use distance field for definition distance between objects. It's very difficult to build distance field for Sparse Voxel Octree, 3D array is more better I think. If you have another mind about it, please, post me material reference. Edited by PlatinumOz

Share this post


Link to post
Share on other sites
Make sure your model has uv coordinates. Render your model to a texture. Set each vertex position to its vertex coordinates. Set each vertex color to its position. For each pixel, create a voxel at the position from pixel's color.

Share this post


Link to post
Share on other sites
[quote name='MrOMGWTF' timestamp='1347549272' post='4979746']
Make sure your model has uv coordinates. Render your model to a texture. Set each vertex position to its vertex coordinates. Set each vertex color to its position. For each pixel, create a voxel at the position from pixel's color.
[/quote] man, I don't catch what you have in mind! Could you show me class structure?

Share this post


Link to post
Share on other sites
First, render your model to a texture. Vertex shader:
[code]
// Authors : Sinje Thiedemann, Niklas Henrich,
// Thorsten Grosch, Stefan Mueller

varying vec3 P;

void main()
{
// Transform atlas texture coordinate into NDC
gl_Position = vec4((gl_MultiTexCoord0.xy * 2.0) - vec2(1.0), 0.0, 1.0);

// Pass world-space position to fragment shader
P = (gl_ModelViewMatrix * gl_Vertex).xyz;
}
[/code]

Frag shader:
[code]
varying vec3 P;

void main()
{
// Store world-position in atlas texture
gl_FragColor = vec4(P, 1.0);
}
[/code]

Then, for each pixel, to something like this:
[code]
foreach pixel:
addVoxelAtPosition(pixel.color);
[/code]

Got it?

Share this post


Link to post
Share on other sites
[quote name='MrOMGWTF' timestamp='1347556918' post='4979782']
First, render your model to a texture. Vertex shader:
[code]
// Authors : Sinje Thiedemann, Niklas Henrich,
// Thorsten Grosch, Stefan Mueller

varying vec3 P;

void main()
{
// Transform atlas texture coordinate into NDC
gl_Position = vec4((gl_MultiTexCoord0.xy * 2.0) - vec2(1.0), 0.0, 1.0);

// Pass world-space position to fragment shader
P = (gl_ModelViewMatrix * gl_Vertex).xyz;
}
[/code]

Frag shader:
[code]
varying vec3 P;

void main()
{
// Store world-position in atlas texture
gl_FragColor = vec4(P, 1.0);
}
[/code]

Then, for each pixel, to something like this:
[code]
foreach pixel:
addVoxelAtPosition(pixel.color);
[/code]

Got it?
[/quote] Man, I got it, thanks. But how can I use voxel data in program code? Do you read my question?
I asked about "c# structure class to store voxel data and be able for further using in code". Capish?

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement