LibGDX 0.9.9 - Apply cubemap in environment

后端 未结 4 888
感情败类
感情败类 2020-12-16 07:57

I am using LibGDX 0.9.9. I am trying to render cubemap and fog. So my code snippet below:

public void show() {
    modelBatch = new ModelBatch();
    environ         


        
4条回答
  •  死守一世寂寞
    2020-12-16 08:31

    The default shader (the glsl files) currently don't support a cubemap. You'll have to provide your own glsl files to use a cubemap. The DefaultShader (the CPU part of the shader that is used by default) will bind the cubemap to the uniform called: u_environmentCubemap. Also, the macro environmentCubemapFlag will be defined by the DefaultShader if the material contains an environment cubemap attribute. Use the following snippet in your shader to use the cubemap:

    #ifdef environmentCubemapFlag
    uniform samplerCube u_environmentCubemap;
    #endif
    

    Here's a relevant example snippet to use cubemap (and normal map): https://github.com/libgdx/libgdx/blob/master/tests/gdx-tests-android/assets/data/g3d/shaders/reflect.glsl Here's a more advanced example snippet: https://github.com/libgdx/libgdx/blob/master/tests/gdx-tests-android/assets/data/g3d/shaders/test.glsl

    You can specify your custom shader like this:

    modelBatch = new ModelBatch(Gdx.files.internal("data/vertex.glsl"), Gdx.files.internal("data/fragment.glsl"));
    

    More info about using a custom shader: http://blog.xoppa.com/creating-a-shader-with-libgdx/

提交回复
热议问题