I was messing around with stage3d in openfl but AGAL is something i am not familiar with. Reading an older post, i found that AGAL is translated into GLSL on runtime when running on native targets. Is there a way to pass GLSL directly instead? At least for native targets, that would save a lot of time and effort.
There is a guy that created high level shader language on top of AGAL. This is written in AS3 though.
Probably more useful than Adobe’s online GLSL to AGAL converter, if it’s ported to Haxe. Adobe’s converter didn’t look mature enough when I looked at last time. It often created AGAL code that doesn’t correspond to original GLSL code without errors.
Although it would be possible to use GLSL directly with
Program3D.____uploadFromGLSL, you should be familiar with internal structure of Stage3D layer:
- You are still constrained to use specific shader variable name such as “vc0”.
- To make y coordinate system match with Stage3D’s, all vertex shader code has a special variable called “vcPositionScale”.
- You need to set sampler states manually, either with
Program3D.__setSampleState' orContext3D.setSamplerState`. This is usually controlled with ignoreSampler bit of AGAL bytecode. https://github.com/openfl/openfl/commit/683e0ebcfbcb7c976f2a740ea89f62bdb522468c
As it’s an internal function now, it could change anytime. I think that changes are not planned for now though, but I personally don’t want to recommend to other people.
By the way, is AGAL very difficult? I agree with you on a point that its syntax is not intuitive, but I think it’s not that difficult once you get familiar with the meaning of each instruction. Starling’s shader code is a good example as it has lots of comments.
And if you need features that are not supported on current AGAL implementation (such as array lookup, new instructions from AGAL2), then using GLSL might be easier.
Array lookup issue with AGAL:
Blur filer code from Starling: