我正在尝试开发一个只是一个简单的灰度着色器的着色器。游戏正在运行,但着色器没有任何效果,使用0.5 Alpha渲染之前的任何纹理现在看起来都像是用完整的alpha渲染。
Grayscale.vert
#ifdef GL_ES
precision mediump float;
precision mediump int;
#else
#define highp;
#endif
uniform sampler2D u_texture;
varying vec4 v_color;
varying vec2 v_texCoord;
const vec3 grayScaleMultiplier = vec3(0.299,0.587,0.114);
void main(){
vec4 texColor = texture2D(u_texture,v_texCoord);
vec3 gray = vec3(dot(texColor.rgb,grayScaleMultiplier));
gl_FragColor = vec4(gray.r,gray.g,gray.b,texColor.a);
}
Grayscale.frag
shaderProgram = new ShaderProgram(Gdx.files.internal("shaders/grayscale.vert"),Gdx.files.internal("shaders/grayscale.frag"));
testBatch.setShader(shaderProgram);
if(!shaderProgram.isCompiled()) {
System.out.println(shaderProgram.getLog());
}
如何应用着色器
Gdx.gl20.glClearColor(1,1,1,255);
Gdx.gl20.glClear(GL20.GL_COLOR_BUFFER_BIT);
mapLayerManager.render();
batch.begin();
for(AbstractEnemy enemy : allEnemys){
enemy.render(batch);
}
batch.end();
lightManager.render(batch);
shapeRenderer.begin();
shapeRenderer.setColor(0,0,0,100);
shapeRenderer.set(ShapeRenderer.ShapeType.Filled);
for(AbstractEnemy enemy : allEnemys){
enemy.render(shapeRenderer);
}
shapeRenderer.set(ShapeRenderer.ShapeType.Line);
shapeRenderer.setColor(0,0,0,255);
shapeRenderer.end();
batch.begin();
player.render(batch);
batch.end();
world.step(1/45f,6,2);
我的渲染调用
var myApp = angular.module('myApp', []);
myApp.controller('MainCtrl', ['$scope', function ($scope) {
console.log("in here");
var jsonData = require('../test_data.json');
console.log(jsonData);
}]);
我没有得到任何编译错误,我不知道出了什么问题。