Skip to content

Commit

Permalink
basically working
Browse files Browse the repository at this point in the history
  • Loading branch information
eanders-ms committed Nov 25, 2020
1 parent 242f9ce commit 677868d
Show file tree
Hide file tree
Showing 7 changed files with 7,033 additions and 158 deletions.
Binary file added assets/img/arcade-hsp.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/img/default.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 2 additions & 0 deletions assets/index.html

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

328 changes: 174 additions & 154 deletions assets/js/custom.js

Large diffs are not rendered by default.

71 changes: 71 additions & 0 deletions assets/js/seriously/effects/seriously.colorcube.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
/* global define, require */
(function (root, factory) {
'use strict';

if (typeof define === 'function' && define.amd) {
// AMD. Register as an anonymous module.
define(['seriously'], factory);
} else if (typeof exports === 'object') {
// Node/CommonJS
factory(require('seriously'));
} else {
if (!root.Seriously) {
root.Seriously = { plugin: function (name, opt) { this[name] = opt; } };
}
factory(root.Seriously);
}
}(window, function (Seriously) {
'use strict';

// based on tutorial by to Gregg Tavares
// http://www.youtube.com/watch?v=rfQ8rKGTVlg&t=24m30s
// todo: find a way to not invert every single texture

Seriously.plugin('colorcube', {
commonShader: true,
shader: function (inputs, shaderSource) {
shaderSource.fragment = [
'precision mediump float;',

'uniform sampler2D source;',
'uniform sampler2D colorCube;',
'varying vec2 vTexCoord;',

'vec3 sampleAs3DTexture(sampler2D tex, vec3 coord, float size) {',
' float sliceSize = 1.0 / size;', // space of 1 slice
' float slicePixelSize = sliceSize / size;', // space of 1 pixel
' float sliceInnerSize = slicePixelSize * (size - 1.0);', // space of size pixels
' float zSlice0 = min(floor(coord.z * size), size - 1.0);',
' float zSlice1 = min(zSlice0 + 1.0, size - 1.0);',
' float xOffset = slicePixelSize * 0.5 + coord.x * sliceInnerSize;',
' float s0 = xOffset + (zSlice0 * sliceSize);',
' float s1 = xOffset + (zSlice1 * sliceSize);',
' vec3 slice0Color = texture2D(tex, vec2(s0, 1.0 - coord.y)).rgb;',
' vec3 slice1Color = texture2D(tex, vec2(s1, 1.0 - coord.y)).rgb;',
' float zOffset = mod(coord.z * size, 1.0);',
' return mix(slice0Color, slice1Color, zOffset);',
'}',

'void main(void) {',
' vec4 originalColor = texture2D(source, vTexCoord);',
' vec3 color = sampleAs3DTexture(colorCube, originalColor.rgb, 8.0);',
' gl_FragColor = vec4(color, originalColor.a);',
'}'
].join('\n');
return shaderSource;
},
inPlace: true,
inputs: {
source: {
type: 'image',
uniform: 'source'
},
cube: {
type: 'image',
uniform: 'colorCube'
}
},
title: 'Color Cube',
description: ''
});
}));
Loading

0 comments on commit 677868d

Please sign in to comment.