13 Commits

Author SHA1 Message Date
Christopher Willis-Ford
9f59b42901 Implement color-touching-color
The `isTouchingColor` function now takes an optional mask parameter. If
provided, only the parts of the Drawable which match the mask color will
be used for the test. For example:
```
  isTouchingColor(4, red, blue);
```
This means "are there any parts of Drawable #4 which are blue and are
touching a red pixel on some other Drawable?"
2016-06-06 16:21:24 -07:00
Christopher Willis-Ford
e03e9a0929 Drop lightness threshold for color effect
HSL's lightness is, in this case, basically the same as half of HSV's
value, so this change halves the threshold value used by the color
effect to make it similar in appearance to the HSV implementation.
2016-06-01 14:23:13 -07:00
Christopher Willis-Ford
94cbe8999d Implement pick(x,y) -> Drawable ID 2016-05-27 16:10:22 -07:00
Christopher Willis-Ford
36439bf665 Multiply projection and model matrices in shader
This will allow rendering the primary view, picking view, and "touching
color" view with different projection matrices without needing to
recalculate the model matrix for every Drawable every time.
2016-05-27 11:55:15 -07:00
Christopher Willis-Ford
c24cfaaf4c Fix pixelate "pixel" size
Pixelate still needs a bit more work: at certain scales the edges of the
"pixels" are ragged. This happens in Scratch 2.0 as well, but for me it
seems slightly worse in this implementation.
2016-05-26 09:53:22 -07:00
Christopher Willis-Ford
03107781ab Use HSL instead of HSV for brightness effect 2016-05-25 14:21:40 -07:00
Christopher Willis-Ford
dcedd0c3cf Fix brightness and ghost effects
The renderer now uses premultiplied alpha in the frame buffer, though
textures are still stored without premultiplied alpha. This makes it
easier to get the desired results from the browser's canvas compositing
step, and might be nicer for mobile hardware depending on which parts of
the Internet you believe.
2016-05-20 15:36:02 -07:00
Christopher Willis-Ford
920271d076 Fix pixelate effect
This implementation of the pixel effect is now very similar to the
PixelBender implementation in Scratch 2.0

I also added a slider to demo.html as a debugging aid: it manipulates a
value that is passed into the shader and used in whatever way helps.
2016-05-20 14:17:44 -07:00
Christopher Willis-Ford
41d3d6f6ba First pass at implementing all effects
Some of the math is wrong but I believe all the structure is now in place.
2016-05-19 15:46:37 -07:00
Christopher Willis-Ford
8b461e0651 Tweak whirl, color effects for #ifdef-based shader
Also fixed a typo in effect value conversion
2016-05-19 13:25:01 -07:00
Christopher Willis-Ford
4fc42ca00a Added a TODO regarding a texturing issue
The current fragment chader contains non-uniform control flow for
determining the texture coordinates to use with `texture2D()`. The spec
says that this can cause undefined behavior; in my case I see a
"sparkle" of wrong pixels near primitive edges.
See:
https://www.opengl.org/wiki/Sampler_%28GLSL%29#Non-uniform_flow_control
2016-05-17 14:10:51 -07:00
Christopher Willis-Ford
dbe3f1370b Draw a squirrel
This change introduces the Drawable class, which corresponds to a
Scratch sprite or clone. It supports setting its "skin" (corresponding
to a Scratch costume) by md5+extension, but currently only supports
bitmap skins. Drawables can be created, destroyed, and otherwise
manipulated by ID through the renderer.
2016-05-17 13:52:37 -07:00
Christopher Willis-Ford
51e17c57a9 Establish initial structure, create demo.html
So far this does nothing but clear the screen to magenta, but it's a
start.
2016-05-13 11:29:51 -07:00