I am trying to fetch a given geometry and, through (potentially multiple) render passes, create a 3D texture that stores the color value of said geometry into an associated texel.
In other words there is a 3D box that i am trying to color based on the geometry inside of that box.
Currently I am attempting to do so with the following vertex shader:
#version 450
#define PI 3.1415926535897932384626433832795
layout(location = 0) in vec3 position; //(x,y,z) coordinates of a vertex
layout(location = 1) in vec3 norm; //a 3D vertex representing the normal to the vertex
layout(location = 2) in vec2 texture_coordinate; // texture coordinates
layout(std430, binding = 3) buffer instance_buffer
{
vec4 cubes_info[];//first 3 values are position of object
};
out vec3 normalized_pos;
out vec3 normal;
out vec2 texture_coord;
uniform float width = 128;
uniform float depth = 128;
uniform float height = 128;
uniform float voxel_size = 1;
uniform vec3 origin = vec3(0,0,0);
uniform float level=0;
void main()
{
texture_coord = texture_coordinate;
vec4 pos = (vec4(position, 1.0) + vec4(vec3(cubes_info[gl_InstanceID]),0));
pos-=vec4(origin, 0);
pos.x = (2.f*pos.x-width)/(width);
pos.y = (2.f*pos.y-depth)/(depth);
pos.z = (2.f*pos.z-depth)/(height);
gl_Position = pos;
normalized_pos = vec3(pos);
normal = normalize(norm);
}
And the following fragment shader:
#version 450
in vec3 normalized_pos;
in vec3 normal;//Normal to the vertex
in vec2 texture_coord;
out vec4 outColor;//Final color of the pixel
uniform sampler2D text;
void main()
{
outColor = vec4(0,1,0,1);
}
Currently the color is ahrd set to green, just to test whether I am doing things in the correct fashion.
But I seem to have failed.
How exactly would you design a shading program that voxelizes a 3D grid of a space?