Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/opengl/4.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Opengl LWGJL混合问题_Opengl_Libgdx_Alpha_Lighting - Fatal编程技术网

Opengl LWGJL混合问题

Opengl LWGJL混合问题,opengl,libgdx,alpha,lighting,Opengl,Libgdx,Alpha,Lighting,我正在尝试使用光照贴图创建这样的效果,但仅使用混合函数和渲染: 基本上,让光照贴图在全白色时具有100%的透明度,并从那里淡出,如上面的视频所示 现在,它是混合的,但它非常黑暗,你可以从图片中看到(忽略星空艺术): 这是因为我的混合模式吗?我想不出来,希望你能!谢谢 代码: public ShaderProgram shader; public Texture texture; public Sprite sprite; public Sprite lightSprite; public Te

我正在尝试使用光照贴图创建这样的效果,但仅使用混合函数和渲染:

基本上,让光照贴图在全白色时具有100%的透明度,并从那里淡出,如上面的视频所示

现在,它是混合的,但它非常黑暗,你可以从图片中看到(忽略星空艺术):

这是因为我的混合模式吗?我想不出来,希望你能!谢谢

代码:

public ShaderProgram shader;
public Texture texture;
public Sprite sprite;

public Sprite lightSprite;
public Texture lightText;
public ShapeRenderer shape;
SpriteBatch spriteBatch;

@Override
public void create() {
    shape = new ShapeRenderer();
    spriteBatch = new SpriteBatch();
    texture = new Texture(Gdx.files.internal("image.png"));
    sprite = new Sprite(texture);

    lightText = new Texture(Gdx.files.internal("light.png"));
    lightSprite = new Sprite(lightText);

    ShaderProgram.pedantic = false;
    shader = new ShaderProgram(Gdx.files.internal("shaders/passthrough.vert"), Gdx.files.internal("shaders/passthrough.frag"));
    System.out.println(shader.getLog());

    spriteBatch.setShader(shader);
}

@Override
public void render() {
    Gdx.gl.glClearColor(0, 0, 0, 1);
    Gdx.gl.glClear(GL20.GL_COLOR_BUFFER_BIT);

    /*
    Draw image
     */
    spriteBatch.setShader(shader);
    spriteBatch.begin();
    sprite.draw(spriteBatch);


    spriteBatch.setShader(null);
    spriteBatch.setBlendFunction(GL30.GL_DST_COLOR, GL30.GL_SRC_ALPHA);
    lightSprite.draw(spriteBatch, 1.0f);
    spriteBatch.end();
    lightSprite.setPosition(Gdx.input.getX(), Gdx.input.getY());
    spriteBatch.setBlendFunction(GL20.GL_SRC_ALPHA, GL20.GL_ONE_MINUS_SRC_ALPHA);
}
}`

我使用的着色器只会使屏幕更暗,这也是: 垂直: FRAG:


lightmap:

youtube视频已删除,pastebin链接已过期。你的问题真的不应该依赖于外部链接,如果可以避免的话,我很抱歉!我附上了正确的视频。