コード例 #1
0
ファイル: DefaultShader.java プロジェクト: Sasun/libgdx
      @Override
      public void set(
          BaseShader shader, int inputID, Renderable renderable, Attributes combinedAttributes) {
        if (renderable.environment == null)
          shader.program.setUniform3fv(shader.loc(inputID), ones, 0, ones.length);
        else {
          renderable.worldTransform.getTranslation(tmpV1);
          if (combinedAttributes.has(ColorAttribute.AmbientLight))
            cacheAmbientCubemap.set(
                ((ColorAttribute) combinedAttributes.get(ColorAttribute.AmbientLight)).color);

          if (combinedAttributes.has(DirectionalLightsAttribute.Type)) {
            Array<DirectionalLight> lights =
                ((DirectionalLightsAttribute)
                        combinedAttributes.get(DirectionalLightsAttribute.Type))
                    .lights;
            for (int i = dirLightsOffset; i < lights.size; i++)
              cacheAmbientCubemap.add(lights.get(i).color, lights.get(i).direction);
          }

          if (combinedAttributes.has(PointLightsAttribute.Type)) {
            Array<PointLight> lights =
                ((PointLightsAttribute) combinedAttributes.get(PointLightsAttribute.Type)).lights;
            for (int i = pointLightsOffset; i < lights.size; i++)
              cacheAmbientCubemap.add(
                  lights.get(i).color, lights.get(i).position, tmpV1, lights.get(i).intensity);
          }

          cacheAmbientCubemap.clamp();
          shader.program.setUniform3fv(
              shader.loc(inputID), cacheAmbientCubemap.data, 0, cacheAmbientCubemap.data.length);
        }
      }
コード例 #2
0
ファイル: DefaultShader.java プロジェクト: Sasun/libgdx
 @Override
 public void set(
     BaseShader shader, int inputID, Renderable renderable, Attributes combinedAttributes) {
   for (int i = 0; i < bones.length; i++) {
     final int idx = i / 16;
     bones[i] =
         (renderable.bones == null
                 || idx >= renderable.bones.length
                 || renderable.bones[idx] == null)
             ? idtMatrix.val[i % 16]
             : renderable.bones[idx].val[i % 16];
   }
   shader.program.setUniformMatrix4fv(shader.loc(inputID), bones, 0, bones.length);
 }