vm6502q / OpenRelativity

An open source framework to add the effects of traveling at relativistic speeds to visualizations or games
17 stars 2 forks source link

Refactor (and debug metric as "two-form") #6

Closed WrathfulSpatula closed 5 years ago

WrathfulSpatula commented 5 years ago

The primary purpose of this PR is to refactor:

As I go, looking over the code makes me rethink things. It's important to note what the metric commonly does.

The "metric" is called such because it defines the intrinsic measure of distance on the manifold. In practice, we get the distance in the form of the squared norm of a vector, because the metric defines the "inner product," as of a vector with itself. (To get the distance, left multiply the displacement vector by the metric matrix, producing a "covector," which is acted on from the left by another copy of the vector to produce a scalar, which is the squared norm. Or, we can think of the whole process happening in reverse, left-to-right.) Since the metric is a "two-form," i.e. it takes two vector inputs to a scalar this way, we have to transform it with the Jacobian (AKA "coordinate transformation matrix") from both left and right sides, such that the Jacobian and its inverse would act from the right starting coordinate system to the right target, to take both input vectors to the coordinate system of the numerical metric.

WrathfulSpatula commented 5 years ago

(Actually, it's the Jacobian and its transpose, rather than its inverse. All the rest follows.)

WrathfulSpatula commented 5 years ago

I don't know exactly what possessed me not to reuse all that code, originally. (Probably inexperience, misplaced performance concerns, and confusion as to the concept behind the shader and how to generalize it.)

I have a feeling the shader variants can also just be one standard shader that compiles to every variant, ultimately. If and when, that will be a subsequent PR.