1

我想使用GLSL-Unit来缩小片段着色器。但是,如果我确实运行此命令:

sunbox$ glsl-compiler --input=/Users/sunbox/Sites/bessa-app/xyz.fshader

我收到这些错误消息:

/usr/local/bin/glsl-compiler: line 1: syntax error near unexpected token `b'
/usr/local/bin/glsl-compiler: line 1: `var COMPILED=true,goog=goog||{};goog.global=this;goog.DEBUG=true;goog.LOCALE="en";goog.provide=function(b){if(!COMPILED){if(goog.isProvided_(b))throw Error('Namespace "'+b+'" already declared.');delete goog.implicitNamespaces_[b];for(var f=b;f=f.substring(0,f.lastIndexOf("."));){if(goog.getObjectByName(f))break;goog.implicitNamespaces_[f]=true}}goog.exportPath_(b)};'

那么,我如何简单地缩小片段着色器呢?

4

1 回答 1

3

我终于让它工作了。:D

对于所有感兴趣的人,您需要此文件: http ://code.google.com/p/glsl-unit/source/browse/bin/template_glsl_compiler.js

...并安装了NodeJS。然后在着色器文件中添加一个简单的注释:

//! FRAGMENT

precision lowp float;
uniform sampler2D image;
varying vec2 src_position;
void main() {
    gl_FragColor = texture2D(image, src_position);
}

...令人讨厌的是,您必须使用 .glsl 文件扩展名!:( 现在你可以运行这个命令:

sunbox$ node /Volumes/template_glsl_compiler.js  --input=/Volumes/test.glsl --variable_renaming=INTERNAL --output=/Volumes/test.fshader.min

就是这样。编译后的输出将是:

//! VERTEX

//! FRAGMENT
precision lowp float;uniform sampler2D image;varying vec2 a;void main(){gl_FragColor=texture2D(image,a);}

非常好!:)

于 2013-11-06T19:39:56.707 回答