我在这里遇到了一个小问题,由于GLSL问题,我的渲染循环无法渲染我的世界。
程序更新渲染循环中的制服:
map[mapPos].light = Lighting.checkSunLight(mapPosY, mapPosX, this); // It works good.. returns float
Shaders.blockS.begin();
Shaders.blockS.setUniformf("lightBlock", map[mapPos].light); // Problem is here!!!
Shaders.blockS.end();
batch.draw(map[mapPos].getBlockTexture(), (mapPosX * Block.WIDTH), (mapPosY * Block.HEIGHT), Block.WIDTH, Block.HEIGHT); // Doesn't draw the block.
如果您对片段着色器感到好奇 -
varying vec4 vColor;
varying vec2 vTexCoord;
uniform vec2 screenSize;
uniform sampler2D u_texture;
uniform vec4 gameTime;
uniform float lightBlock;
const float RADIUS = 0.75;
const float SOFTNESS = 0.6;
void main() {
vec4 texColor = texture2D(u_texture, vTexCoord);
vec4 timedColor = (vColor + gameTime);
vec2 position = (gl_FragCoord.xy / screenSize.xy) - vec2(0.5);
float len = length(position);
float vignette = smoothstep(RADIUS, RADIUS-SOFTNESS, len);
texColor.rgb = mix(texColor.rgb, texColor.rgb * vignette, 0.5);
gl_FragColor = vec4(texColor.rgb * timedColor.rgb * lightBlock, texColor.a);
}
迂腐是
ShaderProgram.pedantic= false;
答案 0 :(得分:0)
我已修复它,我只是将着色器程序的.end()
函数移到了最后一行。