Sunday, June 14, 2015

Hardware Pixel Blending Haxe

Apparently this shader code:
from this thread:
Is the answer to my problems.


pixel bender:
OpenGLSimpleView or HerokuShader

i want to write my version of drawTiles() 
using openfl-stage3d, so it would be possible 
to use custom shade

In looking at how NME is structured it seems plausible 
that there could be a GPUProg object stored in 
GraphicsJob and then passed to HardwareContext. 
This would give the ability to use shaders on points, 
lines, and fill objects as well as Tilesheet. I think 
this would be abstract enough to use for HLSL as well.

Here is my concept of how it could work in Haxe. 
There should probably be some type of caching for 
duplicate shaders although Haxe will only see the 
final linked program.

// static function, returns a GPUProg object?
var program = Graphics.compileShader(vertexShader, pixelShader); 

// in rendering code

// is this needed or could it be automatically detached at endFill?

I'm willing to take a shot at this but would love 
feedback if you feel this isn't heading in the right direction.

EDIT: Any reason OGLProg::createShader 
adds the precision information for OpenGL ES2? 
You can do that directly in the shader using the #ifdef directive.

#ifdef GL_ES
precision highp float;

EDIT2: Okay, I created a branch in GitHub 
and edited sample 20-Tile with custom shaders. 
It works as expected as long as you use the 
attribute/uniform variables defined in OGLProg. 
Might be fun to allow custom variables in the future.

1 year later: Updates:

No comments:

Post a Comment