Created
February 28, 2017 20:08
-
-
Save clbarnes/7c8525bb562e58ddd738ef6ef69f152f to your computer and use it in GitHub Desktop.
Simple shader
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Get the screen width and height | |
var width = window.innerWidth; | |
var height = window.innerHeight; | |
// Chooses either WebGL if supported or falls back to Canvas rendering | |
var renderer = new PIXI.autoDetectRenderer(width, height); | |
// Add the render view object into the page | |
document.body.appendChild(renderer.view); | |
// The stage is the root container that will hold everything in our scene | |
var stage = new PIXI.Container(); | |
// Load an image and create an object | |
var logo = PIXI.Sprite.fromImage('tst_im.png'); | |
// Set it at the center of the screen | |
logo.x = width / 2; | |
logo.y = height / 2; | |
// Make sure the center point of the image is at its center, instead of the default top left | |
logo.anchor.set(0.5); | |
// Add it to the screen | |
stage.addChild(logo); | |
$.get('shader.glsl', function(shaderCode) { | |
var simpleShader = new PIXI.AbstractFilter('', shaderCode); | |
logo.filters = [simpleShader]; | |
renderer.render(stage); | |
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
void main(){ | |
gl_FragColor.rgba = vec4(1,1,1,1); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment