| 7 | mat4 model; |
| 8 | mat4 projection; |
| 9 | mat4 inverseModel; |
| 10 | vec4 parameters; // time, refraction, brightness, sparkles |
| 11 | vec4 viewport; // width, height, optical plane count, unused |
| 12 | vec4 sparkleShape; // main layer scale, contour morph, core scale, star glow scale |
| 13 | vec4 sparkleHalo; // circular glow scale, main face rotation, horizontal correction, visibility |
| 14 | vec4 crownGradient; |
| 15 | vec4 pavilionGradient; |
| 16 | vec4 lightSweep; // diagonal position, environment phase, transmission, reserved |
| 17 | vec4 facetProjection; // reference pitch cosine/sine, source units, projected top |
| 18 | vec4 crownSweep; |
| 19 | vec4 rightCrownSweep; |
| 20 | vec4 leftCrownSweep; |
| 21 | vec4 pavilionSweep; |
| 22 | vec4 rightPavilionSweep; |
| 23 | vec4 leftPavilionSweep; |
| 24 | vec4 appearance; // palette identifier, reserved |
| 25 | vec4 referenceCrownFlash; |
| 26 | vec4 referencePavilionFlash; |
| 27 | }; |
| 28 | struct Raster { |
| 29 | vec4 position ; |
| 30 | vec3 localPosition; |
| 31 | vec3 normal; |
| 32 | vec3 worldPosition; |
| 33 | vec3 facetWeights; // table, crown, pavilion; interpolated across rounded edges |
| 34 | }; |
| 35 | struct SparkleVertex { vec4 contours; vec4 material; }; |
| 36 | struct SparkleRaster { |
| 37 | vec4 position ; |
| 38 | vec2 sourcePoint; |
| 39 | float strength ; |
| 40 | uint layer ; |
| 41 | }; |
| 42 | struct SparkleAnchor { vec4 position; vec4 normal; }; |
| 43 | uniform Uniforms u; |
| 44 | uniform vec4 planes[17]; |
| 45 | uniform SparkleAnchor anchors[8]; |
| 46 | out vec3 v_localPosition; |
| 47 | out vec3 v_normal; |
| 48 | out vec3 v_worldPosition; |
| 49 | out vec3 v_facetWeights; |
| 50 | layout(location=0) in vec4 a_position; layout(location=1) in vec4 a_normal; layout(location=2) in vec4 a_surface; |
| 51 |
| 52 | void main(){ |
| 53 |
| 54 | Vertex v = Vertex(a_position,a_normal,a_surface); |
| 55 | vec4 world = u.model * v.position; |
| 56 | Raster result; |
| 57 | result.position = u.projection * world; |
| 58 | result.localPosition = v.position.xyz; |
| 59 | result.normal = normalize((u.model * v.normal).xyz); |
| 60 | result.worldPosition = world.xyz; |
| 61 | result.facetWeights = v.surface.z == 3.0 ? vec3(v.surface.xy, 1.0-v.surface.x-v.surface.y) |
| 62 | : vec3(v.surface.z == 0.0, v.surface.z == 1.0, v.surface.z == 2.0); |
| 63 | gl_Position=result.position; gl_Position.z=gl_Position.z*2.0-gl_Position.w; |
| 64 | v_localPosition=result.localPosition; |
| 65 | v_normal=result.normal; |
| 66 | v_worldPosition=result.worldPosition; |
| 67 | v_facetWeights=result.facetWeights; |
| 68 |
| 69 | } |
| 70 |