Skip to content

Commit

Permalink
filter test updates
Browse files Browse the repository at this point in the history
  • Loading branch information
photonstorm committed Nov 9, 2013
1 parent 3f99b69 commit 46cf024
Show file tree
Hide file tree
Showing 10 changed files with 120 additions and 4 deletions.
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@ Try out 150+ [Phaser Examples](http://gametest.mobi/phaser/examples/)

[Un-official Getting Started with Phaser](http://www.antonoffplus.com/coding-an-html5-game-for-30-minutes-or-an-introduction-to-the-phaser-framework)

[Subscribe to our new Phaser Newsletter](https://confirmsubscription.com/h/r/369DE48E3E86AF1E). We'll email you when new versions are released as well as send you our regular Phaser game making magazine.

"Being negative is not how we make progress" - Larry Page, Google

Welcome to Phaser
Expand Down
Binary file added examples/assets/sprites/phaser.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
68 changes: 68 additions & 0 deletions examples/wip/filter.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
PIXI.GreyFilter = function()
{
PIXI.AbstractFilter.call( this );

this.passes = [this];

// set the uniforms
this.uniforms = {
grey: {type: 'f', value: 1},
};

this.OLDfragmentSrc = [
"precision mediump float;",
"varying vec2 vTextureCoord;",
"varying float vColor;",
"uniform sampler2D uSampler;",
"uniform float grey;",
"void main(void) {",
"gl_FragColor = texture2D(uSampler, vTextureCoord);",
"gl_FragColor.rgb = mix(gl_FragColor.rgb, vec3(0.2126*gl_FragColor.r + 0.7152*gl_FragColor.g + 0.0722*gl_FragColor.b), grey);",
"gl_FragColor = gl_FragColor * vColor;",
"}"
];





}

PIXI.GreyFilter.prototype = Object.create( PIXI.AbstractFilter.prototype );
PIXI.GreyFilter.prototype.constructor = PIXI.GreyFilter;

/**
The strength of the grey. 1 will make the object black and white, 0 will make the object its normal color
@property grey
*/
Object.defineProperty(PIXI.GreyFilter.prototype, 'grey', {
get: function() {
return this.uniforms.grey.value;
},
set: function(value) {
this.uniforms.grey.value = value;
}
});

var game = new Phaser.Game(800, 600, Phaser.AUTO, 'phaser-example', { preload: preload, create: create, update: update, render: render });

function preload() {

game.load.image('atari1', 'assets/sprites/atari130xe.png');
game.load.image('coke', 'assets/sprites/cokecan.png');
game.load.image('mushroom', 'assets/sprites/mushroom2.png');

}

function create() {

game.add.sprite(60, 100, 'atari1');
game.add.sprite(360, 200, 'coke');

}

function update() {
}

function render() {
}
45 changes: 45 additions & 0 deletions examples/wip/filterconv.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
<?php
$output = "this.fragmentSrc = [\n";

if (isset($_POST['shader']))
{
$shader = explode("\n", $_POST['shader']);

for ($i = 0; $i < count($shader); $i++)
{
$output = $output . "\t\"" . trim($shader[$i]) . "\",\n";
}
}

$output .= "];";
?>
<!doctype html>
<html>
<head>
<meta charset="UTF-8" />
<title>phaser - filter conv</title>
<style>
body {
font-family: Arial;
font-size: 14px;
}
</style>
</head>
<body>

<form action="filterconv.php" method="post">

<h2>Input</h2>
<textarea name="shader" style="width: 800px; height: 400px"></textarea>

<h2>Output</h2>
<textarea style="width: 800px; height: 400px"><?php echo $output ?></textarea>

<br />

<input type="submit" value="Convert" />

</form>

</body>
</html>
Binary file added resources/Phaser Logo/PNG/Phaser-2D-Flat.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 resources/Phaser Logo/PNG/Phaser-2D-Flat.psd
Binary file not shown.
6 changes: 5 additions & 1 deletion src/animation/Animation.js
Original file line number Diff line number Diff line change
Expand Up @@ -270,7 +270,11 @@ Phaser.Animation.prototype = {
else
{
this.currentFrame = this._frameData.getFrame(this._frames[this._frameIndex]);
this._parent.setTexture(PIXI.TextureCache[this.currentFrame.uuid]);

if (this.currentFrame)
{
this._parent.setTexture(PIXI.TextureCache[this.currentFrame.uuid]);
}
}

return true;
Expand Down
1 change: 0 additions & 1 deletion src/pixi/display/DisplayObject.js
Original file line number Diff line number Diff line change
Expand Up @@ -474,7 +474,6 @@ PIXI.DisplayObject.prototype.removeFilter = function(data)
{
//if(!this.filter)return;
//this.filter = false;
console.log("YUOIO")
// modify the list..
var startBlock = data.start;

Expand Down
1 change: 0 additions & 1 deletion src/pixi/renderers/webgl/WebGLRenderGroup.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@ PIXI.WebGLRenderGroup = function(gl, transparent)

this.batchs = [];
this.toRemove = [];
console.log(this.transparent)
this.filterManager = new PIXI.WebGLFilterManager(this.transparent);
}

Expand Down
1 change: 0 additions & 1 deletion src/pixi/renderers/webgl/WebGLShaders.js
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,6 @@ PIXI._CompileShader = function(gl, shaderSrc, shaderType)
gl.compileShader(shader);

if (!gl.getShaderParameter(shader, gl.COMPILE_STATUS)) {
console.log(gl.getShaderInfoLog(shader));
return null;
}

Expand Down

0 comments on commit 46cf024

Please sign in to comment.