Hey all, so I got this vertex shader that I use to generate a density field texture. I then use that texture and run a marching cubes algo. on it to create a mesh.
I believe I could achieve this by rendering to a texture using a material. Anyone know how to do that? This has to run on OpenGLES 3.0. That’s why I’m not doing it all in a compute or geometry shader.
Here’s the code, it’s really simple. In my engine that I’m porting from, I used a vertex shader and computed 16777216 values that get returned in an array.
out float density;
void main() {
vec3 p = to3D(gl_VertexID, 256, 256); //Gets a 3d position on a 256x256x256 grid, based off our 1d index(vertex id).
… compute density here…
density = someVal;
}
Here is a pic of my material attempt, it should work, It’d be nice if was able to sample a 3d texture.
I guess I didn’t word my questions properly. I’m trying to find out how to sample a 3d texture and how to get access to the texture output from the material at runtime. In OpenGL, normally this is called a transform feedback. No idea how to modify posts either, Epic, is there a reason I can’t edit my posts?