-2
我在這裏遇到了一個小問題,由於GLSL問題,我的渲染循環沒有渲染我的世界。
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;
您可以檢查該行是否出現OpenGL錯誤? – Njol