Voxel structure programming implementation

Started by
10 comments, last by Leo Oz 11 years, 7 months ago
First, render your model to a texture. Vertex shader:

// 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;
}


Frag shader:

varying vec3 P;

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


Then, for each pixel, to something like this:

foreach pixel:
addVoxelAtPosition(pixel.color);


Got it?
Advertisement

First, render your model to a texture. Vertex shader:

// 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;
}


Frag shader:

varying vec3 P;

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


Then, for each pixel, to something like this:

foreach pixel:
addVoxelAtPosition(pixel.color);


Got it?
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?

This topic is closed to new replies.

Advertisement