-
Notifications
You must be signed in to change notification settings - Fork 41
Geometry representation #46
Comments
Thanks for this @SimonDanisch. This is heavily related to what I try to do in Plots, which is creating compressed, equivalent definitions of generic visualization parameters. As an example, consider the following plot: (note: I had to make a couple fixes to get this to work... fixes on dev branch... always good to find bugs :)
The gist is that each element is stored in a compressed, generalized representation of the final visualization attributes, and only expanded if/when necessary for a specific backend (as some backends can handle inputs in compressed form as well). The @SimonDanisch I hope that as you are developing these concepts, that you can keep me in the loop as to your intentions, and we can have a solution that allows interop between whatever you need and the Plots representations. (also selfishly because I really want to be able to generate GLVisualize stuff using Plots!) |
@SimonDanisch This sounds great! And I'll be happy to help out regarding implementing WebGL support to GLVisualize. Do let me know what you need by raising issues. 😄 |
Great, thanks a lot @rohitvarkey. Here are some more thoughts: The old struggle how to layout your vertexarray will become a lot simpler. We can just use the format the user supplies, and if we know that some layout is faster with some backend, we can transform the data and/or document this for the user. E.g. there is no clear standard on how to represent meshes: immutable Vertex
position::Vec3f0
normal::Vec3f0
color::RGBA{Float32}
end
vertices = Array{Vertex}
is often seen, but this is also an often seen layout:
immutable Vertex
position::Vector{Vec3f0}
position::Vector{Vec3f0}
color::Vector{RGBA{Float32}}
end We can combine this nicely with our Also, we could make views and index lists a standard tool in the geometry representation. cc: @yeesian |
Personally I like the structure of arrays style more since it seems to often perform better. |
That's exactly the idea here... SOA(Vertex, rand(Vec3f0, 10), rand(Vec3f0, 10), rand(RGBA{Float32}, 10)) Vs SAO(Vertex, [Vertex(...) for i=1:10]) Because of the SAO they look the same to the algorithms, but users or Personally I like the structure of arrays style more since it seems to |
StructOfArrays could be great for performance! The animation problem troubles me too, but what you describe is already a problem, right? this should be a strict improvement. We still have to address the problem of whether e.g. |
Ah yeah, that's what I wanted to address as well. |
Yes, but now it's harder for me to cheat around this... Which is sort of a good thing, because it wasn't really a clean solution before... But since I don't have new clean solution, this might as well be the main blocking issue... |
No, I would not like to be required do this. Yes, I would very much like to be able to do this in some situations: Point{ TownshipGeocode, Income/household }, just because my data plots the township-relative wealth per household and comes from a relational database holding disaggregated data. |
@SimonDanisch For your consideration, an additional capability that would be helpful to design into low level animation support: When animating data to visualize how things change with/through time, the ability to run the animation using differently 'warped' time progressions can be informative. (The time axis is differentially dilated, as given through, e.g. a splined curve or nonuniform frame timestamps sampled from it). It is akin to zooming in on an area of interest in an image. |
That should map down to the ability to animate the parameters of time, which should be easily feasible.
My biggest concern with this is that it breaks a lot of assumptions (e.g. what is immutable TIPoint{N, T} <: FixedVector{N,T}
data::Tuple{TownshipGeocode{T}, Income{T}}
end Or another approach could be this: convert{T}(::Type{cm}, x::TownshipGeocode) = cm(x*2.1)
convert{T}(::Type{cm}, x::Income) = cm(x*3.712) With this, plotting libraries should be able to automatically convert I think this will keep things sane. The type diversity is already immense as it is! |
I've been thinking about some kind of low level/ intermediate representation for geometry lately to have a good way to switch out frontends and backends without much hassle. This is pretty much what I've come up with after working with Compose, GLVisualize and FireRender. They all differ hugely, but it seemed to me that they could all support the same intermediate representation.
This representation needs a great deal of flexibility, since we don't want to force any frontend/backend to miss out on compression/batching or force them to use one specific memory layout.
To not go crazy over the resulting diversity, I'd like to propose the following:
I want to use something like an extended version of @simonster's
StructsOfArrays
library (with added support for iterators, scalars and different memory layouts) to allow for the kind of compression and memory layout independence that GLVisualize and Compose already offer in some restricted form.A few examples:
With clever conversion and defaults for unsupported attributes, this can represent everything we might want to visualize.
There will be annoying corner cases like pointed lines, where it's not really clear if the points are a geometry attribute or part of the shader. But I'm pretty sure that we'll be able to solve this in a coherent way.
Benefits
All the algorithms can work on this representation, making it way easier to reuse them in all the different packages. E.g. the implementation of a boundingbox algorithm could look as simple as this:
In theory, this should also work on the GPU. So whenever we get better GPU support e.g. being able to compile Julia to SPIR-V, the data structures and algorithms should map nicely to the GPU.
It will be easier to display graphics created with e.g.
Gadfly
,Compose
,GLVisualize
in any backend likeOpenGL
,Cairo
,Skia
,SVG
,FireRender
,WebGL
,PDF
, as long as they support this intermediate representation.I've already implemented quite a bit for
OpenGL
andFireRender
and it shouldn't take too much time to addWebGL
viaThreejs.jl
(if the package is in a good state).Challenges
I'm not sure how to incorporate Animations. With Reactive there are two ways to do so, which I find both unsatisfactory.
Option1
is way cleaner, as you can easily apply algorithms to it viamap
.Option2
doesn't really allow to operate on the resultingSAO
without some hackage.But I'm not really sure how to make
option1
fast on the backend side in all cases. If you let the signal get bigger and bigger, it's not entirely clear how to detect what has changed anymore, which means it's more difficult to only update part of the scene (which is an important optimization).@shashi gets around this by diffing, but for big data-sets this still introduce a non trivial performance penalty. Since this is supposed to be a low level representation, it would be nice to not have such penalties early on.
Also, this must be implemented ;) I've working prototypes for most of this, so I'd be willing to start this off! Maybe, by adding WebGL support to GLVisualize.
Please criticize freely :)
Best,
Simon
CC: @sjkelly, @KristofferC, @rohitvarkey, @tbreloff, @ViralBShah, @timholy, @dcjones, @vchuravy
The text was updated successfully, but these errors were encountered: