Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

WIP cube GL demo #1

Draft
wants to merge 20 commits into
base: main
Choose a base branch
from
Draft

WIP cube GL demo #1

wants to merge 20 commits into from

Conversation

jcorbin
Copy link
Contributor

@jcorbin jcorbin commented Jun 28, 2022

Current attempt at minimally demonstrating an alternate rendering approach using webgl(2):

  • uses a 2d canvas to create a texture sheet/atlas
  • then uses an ortho-projected GL context to draw points textured by that atlas

Here's some other reference tutorials / code:

Next steps from minor to stellar:

  • fix alpha blending arftifacts
  • add per-tile rotation or at least mirroring
  • switch to a 2d array texture
  • switch to an offscreen canvas
  • animation at some level
  • implement something for drawing (back)ground fill, this can start out as a boring solid color of course, but we now have the full power of fragment shading to do procedural texturing for things like grass, water, etc
    • Marching Sqaures tileset demo
    • other factor out an autotiling system from the code inlined in the html demo
    • experiment with procedural patterning or shading for background tile style beyond solid colors
  • experiment with twisting the perspective matrix and introduce a model/view transform matrix
  • see how well 2.5d / pseudo-3d things work on this textured point approach
  • scale up and out to planetary cube/dia scale ; whether we're able to just keep drawing transformed points in 3-space as in prior point, or whether we instead add an intermediate step where we render points onto faces of one or more cubes

@jcorbin jcorbin requested a review from kriskowal June 28, 2022 21:00
@vercel
Copy link

vercel bot commented Jun 28, 2022

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
cube ❌ Failed (Inspect) Sep 29, 2023 10:46pm
forest ❌ Failed (Inspect) Sep 29, 2023 10:46pm
jspit ❌ Failed (Inspect) Sep 29, 2023 10:46pm

@jcorbin
Copy link
Contributor Author

jcorbin commented Jun 29, 2022

Right, so the alpha deal all comes down to handling pre-multiplied alpha (or not); which is probably why the default is "Nope, you need to set how that works, and don't get any default blending". I.E: "Not all rgba is the same"

For us part of the context is that 2d canvas contexts all work in pre-multiplied alpha, so when we scrape a texture in from a canvas, we have to deal with that, and then may have a texture that contains pre-multiplied alpha.

References:

Make it more self contained, and directly gl integrated, rather than a
bare data structure for layer/drawing code.
- contains layered drawing, decoupled form architecture like facets
- abstracts gl program interface
- pushes more particulars down into layer.draw()
Optionize and change world dimensions for example
- generation corner sourcing was always wrong
- needs to be +1 cell to cover the half cell overlap all around
- therefore needs to be clipped to the nominal layer bounds
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant