voidstarHQ / voidstar

anything can be numbers, numbers can be anything... What does data look like, in color and in 3D.
https://voidstarhq.github.io/
MIT License
14 stars 4 forks source link

Load file to texture & apply transformations with stacked shaders #35

Open fenollp opened 7 years ago

fenollp commented 7 years ago

The time it takes to transmit data to GPU is non negligible.

Right now what we do is

  1. mmap the file to RAM
  2. create RAM buffers for vertices & colors & the indices of the elements that are worth rendering
  3. transfer these buffers to GPU memory
  4. draw
  5. repeat

Instead we could

  1. load the file into a texture (mmap on GPU?)
  2. create vertices & their colors with shaders (tricky part*)
  3. draw
  4. repeat

This would make the host code much simpler. Thus porting to Web or Android would be much simpler.

*The tricky part is that to do something like Algo3DCubeFrebet with shaders, one needs to somehow:

  1. read multiple bytes from the file-texture
  2. write a color to the output texture but at different coordinates I believe that (x1,y1) --> (x2,y2,z) transformation is hard for a GPU. Maybe compute shaders can help here?

@icehess Ideas?

fenollp commented 4 years ago

If shaders can be used to fill a texture then things such as https://github.com/rikusalminen/triangles/blob/613a27d047f0caba934173448260b932e33b0924/shaders/icosphere/icosphere.glslv could be used as well.

Also: https://github.com/voidstarHQ/voidstar/blob/b5182cc3758bae1ef1b718e5df37f68a40c24b12/pi.glsl

fenollp commented 4 years ago

https://www.khronos.org/opengl/wiki/Vertex_Texture_Fetch

fenollp commented 4 years ago

Some experiments at https://github.com/voidstarHQ/voidstar/blob/b5182cc3758bae1ef1b718e5df37f68a40c24b12/hacking/argh.cc#L401