Java 类com.badlogic.gdx.graphics.g3d.Renderable 实例源码

项目:Cubes_2    文件:CubesModelBatch.java   
@Override
public Renderable obtain() {
    Renderable renderable = super.obtain();
    // super.obtain resets the following
    // renderable.environment = null;
    // renderable.material = null;
    // renderable.meshPart.set("", null, 0, 0, 0);
    // renderable.shader = null;

    // renderable.userData = null;
    // built in as of libgdx 1.9.6
    // https://github.com/libgdx/libgdx/pull/4550

    // custom
    renderable.worldTransform.idt();

    return renderable;
}
项目:Cubes_2    文件:BreakingRenderer.java   
public static Renderable draw() {
    Player player = Cubes.getClient().player;
    ItemTool.MiningTarget currentlyMining = player.getCurrentlyMining();
    if (currentlyMining == null)
        return null;
    BlockReference position = currentlyMining.target;
    float percent = currentlyMining.time / currentlyMining.totalTime;
    percent -= 1f / (1f + num);
    if (percent <= 0f)
        return null;
    int n = (int) Math.floor(percent * num);

    float f = 1f / 128f;
    Renderable renderable = new Renderable();
    renderable.worldTransform.translate(position.blockX - f, position.blockY - f, position.blockZ - f);
    renderable.worldTransform.scl(1f + f + f);
    renderable.meshPart.primitiveType = GL20.GL_TRIANGLES;
    renderable.meshPart.offset = n * (6 * 6);
    renderable.meshPart.size = 6 * 6;
    renderable.meshPart.mesh = mesh;
    renderable.material = material;
    return renderable;
}
项目:Cubes_2    文件:WorldShaderProvider.java   
private void getShaderIf(int shader, Renderable renderable, boolean fogFlag, boolean aoFlag) {
    if (shaders[shader] == null) {
        if (shader == 0) {
            shaders[shader] = new CubesShader(renderable);
        } else {
            ArrayList<Feature> f = new ArrayList<Feature>();
            if (fogFlag)
                f.add(new FogFeature());
            if (aoFlag)
                f.add(new AmbientOcclusionFeature());
            shaders[shader] = new FeatureShader(renderable, f);
        }

        ShaderProgram program = shaders[shader].program;
        if (!program.isCompiled()) {
            Log.error("Failed to compile shader");
            Log.error("Shader log: \n" + program.getLog());
            Log.error("Fragment shader source: \n" + program.getFragmentShaderSource());
            Log.error("Vertex shader source: \n" + program.getVertexShaderSource());
            throw new CubesException("Failed to compile shader");
        }

        shaders[shader].init();
    }
}
项目:Cubes_2    文件:WorldShaderProvider.java   
@Override
public Shader getShader(Renderable renderable) {
    int shader = 0;

    boolean fogFlag = Settings.getBooleanSettingValue(Settings.GRAPHICS_FOG);
    if (renderable.userData instanceof RenderingSettings)
        fogFlag &= ((RenderingSettings) renderable.userData).fogEnabled;
    if (fogFlag)
        shader |= FEATURE_FOG;

    boolean aoFlag = renderable.meshPart.mesh.getVertexAttributes() == CubesVertexAttributes.VERTEX_ATTRIBUTES_AO;
    if (aoFlag)
        shader |= FEATURE_AO;

    getShaderIf(shader, renderable, fogFlag, aoFlag);

    return shaders[shader];
}
项目:Cubes_2    文件:SunRenderer.java   
public static void setWorldTransform(Renderable renderable, boolean isMoon) {
    Vector3 pos = Cubes.getClient().player.position;
    int r = 512;
    float f = (float) (Cubes.getClient().world.getTime() - (World.MAX_TIME / 4)) / (float) World.MAX_TIME;
    if (isMoon)
        f += 0.5f;
    f %= 1;

    float x = (pos.x + (r * Math.cos(f * 2 * Math.PI)));
    float y = (pos.y + (r * Math.sin(f * 2 * Math.PI)));
    float z = pos.z;

    renderable.worldTransform.setToTranslation(x, y, z);
    renderable.worldTransform.scl(75f);
    renderable.worldTransform.rotate(Vector3.Z, (f - 0.25f % 1) * 360);
}
项目:Cubes    文件:CubesModelBatch.java   
@Override
public Renderable obtain () {
  Renderable renderable = super.obtain();
  // super.obtain resets the following
  //renderable.environment = null;
  //renderable.material = null;
  //renderable.meshPart.set("", null, 0, 0, 0);
  //renderable.shader = null;

  // renderable.userData = null;
  // built in as of libgdx 1.9.6
  // https://github.com/libgdx/libgdx/pull/4550

  // custom
  renderable.worldTransform.idt();

  return renderable;
}
项目:Cubes    文件:BreakingRenderer.java   
public static Renderable draw() {
  Player player = Cubes.getClient().player;
  ItemTool.MiningTarget currentlyMining = player.getCurrentlyMining();
  if (currentlyMining == null) return null;
  BlockReference position = currentlyMining.target;
  float percent = currentlyMining.time / currentlyMining.totalTime;
  percent -= 1f / (1f + num);
  if (percent <= 0f) return null;
  int n = (int) Math.floor(percent * num);

  float f = 1f / 128f;
  Renderable renderable = new Renderable();
  renderable.worldTransform.translate(position.blockX - f, position.blockY - f, position.blockZ - f);
  renderable.worldTransform.scl(1f + f + f);
  renderable.meshPart.primitiveType = GL20.GL_TRIANGLES;
  renderable.meshPart.offset = n * (6 * 6);
  renderable.meshPart.size = 6 * 6;
  renderable.meshPart.mesh = mesh;
  renderable.material = material;
  return renderable;
}
项目:nhglib    文件:DepthMapShader.java   
private String createPrefix(Renderable renderable) {
    String prefix = "";

    if (params.useBones) {
        prefix += "#define numBones " + 12 + "\n";
        final int n = renderable.meshPart.mesh.getVertexAttributes().size();

        for (int i = 0; i < n; i++) {
            final VertexAttribute attr = renderable.meshPart.mesh.getVertexAttributes().get(i);

            if (attr.usage == VertexAttributes.Usage.BoneWeight) {
                prefix += "#define boneWeight" + attr.unit + "Flag\n";
            }
        }
    }

    return prefix;
}
项目:LibGDX-PBR    文件:PBRShader.java   
protected final int[] getAttributeLocations(Renderable renderable) {
    final IntIntMap attributes = new IntIntMap();
    final VertexAttributes attrs = renderable.meshPart.mesh.getVertexAttributes();
    final int c = attrs.size();
    for (int i = 0; i < c; i++) {
        final VertexAttribute attr = attrs.get(i);
        final int location = program.getAttributeLocation(attr.alias);
        if (location >= 0)
            attributes.put(attr.getKey(), location);
    }

    tempArray.clear();
    final int n = attrs.size();
    for (int i = 0; i < n; i++) {
        tempArray.add(attributes.get(attrs.get(i).getKey(), -1));
    }
    return tempArray.items;
}
项目:LibGDX-PBR    文件:PBRShader.java   
@Override
public void render(Renderable renderable) {
    program.setUniformMatrix(u_worldTrans, renderable.worldTransform);
    program.setUniformf(albedo, albedoColor);
    program.setUniformf(metallic, metallicValue);
    program.setUniformf(ambientOcclusion, ambientOcclusionValue);
    program.setUniformf(vLight0, new Vector3(2.00f,-2.00f,-2.00f));

    ref.bind(0);
    program.setUniformi(sCubemapTexture, 0);

    program.setUniformf(vRoughness, new Vector2(rougness,5));

    if (currentMesh != renderable.meshPart.mesh) {
        if (currentMesh != null)
            currentMesh.unbind(program, tempArray.items);
        currentMesh = renderable.meshPart.mesh;
        currentMesh.bind(program, getAttributeLocations(renderable));
    }

    renderable.meshPart.mesh.render(program,
            renderable.meshPart.primitiveType,
            renderable.meshPart.offset,
            renderable.meshPart.size,false);
}
项目:LibGDX-PBR    文件:PBRSadherTexture.java   
protected final int[] getAttributeLocations(Renderable renderable) {
    final IntIntMap attributes = new IntIntMap();
    final VertexAttributes attrs = renderable.meshPart.mesh.getVertexAttributes();
    final int c = attrs.size();
    for (int i = 0; i < c; i++) {
        final VertexAttribute attr = attrs.get(i);
        final int location = program.getAttributeLocation(attr.alias);
        if (location >= 0)
            attributes.put(attr.getKey(), location);
    }

    tempArray.clear();
    final int n = attrs.size();
    for (int i = 0; i < n; i++) {
        tempArray.add(attributes.get(attrs.get(i).getKey(), -1));
    }
    return tempArray.items;
}
项目:Argent    文件:ShadowMapShader.java   
@Override
public void render(final Renderable renderable, final Attributes combinedAttributes)  {
    boolean firstCall = true;
    for(final LightWrapper light : lights) {
        light.applyToShader(program);
        if(firstCall){
            context.setDepthTest(GL20.GL_LEQUAL);
            context.setBlending(false, GL20.GL_ONE, GL20.GL_ONE);
            super.render(renderable, combinedAttributes);
            firstCall = false;
        }else{
            context.setDepthTest(GL20.GL_EQUAL);
            context.setBlending(true, GL20.GL_ONE, GL20.GL_ONE);
            renderable.meshPart.render(program, false);
        }
    }
}
项目:Argent    文件:VolumetricDepthShader.java   
@Override
public void render(final Renderable renderable, final Attributes combinedAttributes) {
    renderable.meshPart.primitiveType = GL20.GL_TRIANGLES;
    final boolean[] firstCall = {true};
    lights.forEach(l -> {
        l.applyToShader(program);
        if(Gdx.input.isKeyJustPressed(Input.Keys.L))
        for (String s : program.getUniforms()) {
            System.out.println(s);
        }
        if(true) {
            context.setDepthTest(GL20.GL_LEQUAL);
            context.setBlending(false, GL20.GL_ONE, GL20.GL_ONE);
            super.render(renderable, combinedAttributes);
            firstCall[0] = false;
        }else{
            context.setDepthTest(GL20.GL_EQUAL);
            context.setBlending(true, GL20.GL_ONE, GL20.GL_ONE);
            MeshPart part = renderable.meshPart;
            part.mesh.render(program, part.primitiveType, part.offset, part.size, false);
        }
    });
}
项目:origin    文件:ShadowShader.java   
@Override
    public void render(Renderable renderable, Attributes combinedAttributes)
    {

//      context.setCullFace(GL_BACK);
        // Classic depth test
        context.setDepthTest(GL20.GL_LEQUAL);
        // Deactivate blending on first pass
        context.setBlending(false, GL20.GL_ONE, GL20.GL_ONE);

        context.setDepthMask(true);

        if (!combinedAttributes.has(BlendingAttribute.Type))
            context.setBlending(false, GL20.GL_SRC_ALPHA, GL20.GL_ONE_MINUS_SRC_ALPHA);

        super.render(renderable, combinedAttributes);


//      program.begin();
//      super.render(renderable, combinedAttributes);
//      program.end();
    }
项目:origin    文件:ModelShaderProvider.java   
@Override
public Shader getShader(Renderable renderable)
{
    // небольшой такой КОСТЫЛЬ из за убогости LibGDX
    // явно укажем версию шейдеров. и немного поправим совместимость...
    ShaderProgram.prependVertexCode = SHADER_VERSION + "\n";

    ShaderProgram.prependFragmentCode = SHADER_VERSION + "\n";

    Shader shader = super.getShader(renderable);

    ShaderProgram.prependVertexCode = null;
    ShaderProgram.prependFragmentCode = null;

    return shader;
}
项目:origin    文件:ModelShader.java   
@Override
    public void render(final Renderable renderable)
    {
//      if (!renderable.material.has(BlendingAttribute.Type))
//      {
//          context.setBlending(false, GL20.GL_SRC_ALPHA, GL20.GL_ONE_MINUS_SRC_ALPHA);
//      }
//      else
//      {
//          context.setBlending(true, GL20.GL_SRC_ALPHA, GL20.GL_ONE_MINUS_SRC_ALPHA);
//      }

        //      if (!renderable.material.has(BlendingAttribute.Type))
//      {
//          context.setDepthTest(GL20.GL_LEQUAL);
//          context.setBlending(false, GL20.GL_ONE, GL20.GL_ONE);
//      }
//      else
//      {
//          context.setDepthTest(GL20.GL_EQUAL);
//          context.setBlending(true, GL20.GL_ONE, GL20.GL_ONE);
//      }
        super.render(renderable);
    }
项目:origin    文件:DepthShaderProvider.java   
@Override
public Shader getShader(Renderable renderable)
{
    // небольшой такой КОСТЫЛЬ из за убогости LibGDX
    // явно укажем версию шейдеров. и немного поправим совместимость...
    ShaderProgram.prependVertexCode =
            SHADER_VERSION + "\n";

    ShaderProgram.prependFragmentCode =
            SHADER_VERSION + "\n";

    Shader shader = super.getShader(renderable);

    ShaderProgram.prependVertexCode = null;
    ShaderProgram.prependFragmentCode = null;

    return shader;
}
项目:Mundus    文件:SkyboxShader.java   
@Override
public void render(Renderable renderable) {

    // texture uniform
    CubemapAttribute cubemapAttribute = ((CubemapAttribute) (renderable.material
            .get(CubemapAttribute.EnvironmentMap)));
    if (cubemapAttribute != null) {
        set(UNIFORM_TEXTURE, cubemapAttribute.textureDescription);
    }

    // Fog
    Fog fog = ((MundusEnvironment) renderable.environment).getFog();
    if (fog == null) {
        set(UNIFORM_FOG, 0);
    } else {
        set(UNIFORM_FOG, 1);
        set(UNIFORM_FOG_COLOR, fog.color);
    }

    renderable.meshPart.render(program);
}
项目:Mundus    文件:TerrainShader.java   
@Override
public void render(Renderable renderable) {
    final MundusEnvironment env = (MundusEnvironment) renderable.environment;

    setLights(env);
    setTerrainSplatTextures(renderable);
    set(UNIFORM_TRANS_MATRIX, renderable.worldTransform);

    // Fog
    final Fog fog = env.getFog();
    if (fog == null) {
        set(UNIFORM_FOG_DENSITY, 0f);
        set(UNIFORM_FOG_GRADIENT, 0f);
    } else {
        set(UNIFORM_FOG_DENSITY, fog.density);
        set(UNIFORM_FOG_GRADIENT, fog.gradient);
        set(UNIFORM_FOG_COLOR, fog.color);
    }

    // bind attributes, bind mesh & render; then unbinds everything
    renderable.meshPart.render(program);
}
项目:GdxDemo3D    文件:UberShader.java   
public UberShader(Renderable renderable, Config config) {
    super(renderable, config);

    String prefix = DefaultShader.createPrefix(renderable, config);

    if (renderable.material.has(VertexColorTextureBlend.Red)) {
        prefix += "#define redVertexColorBlendFlag\n";
    }
    if (renderable.material.has(VertexColorTextureBlend.Green)) {
        prefix += "#define greenVertexColorBlendFlag\n";
    }
    if (renderable.material.has(VertexColorTextureBlend.Blue)) {
        prefix += "#define blueVertexColorBlendFlag\n";
    }

    program = new ShaderProgram(prefix + config.vertexShader, prefix + config.fragmentShader);
    if (!program.isCompiled()) {
        Gdx.app.debug(TAG, program.getLog());
    }
}
项目:GdxDemo3D    文件:GameRenderer.java   
public GameRenderer(Viewport viewport, Camera camera, GameEngine engine) {
    this.viewport = viewport;
    this.camera = camera;
    this.engine = engine;

    shapeRenderer = new MyShapeRenderer();
    shapeRenderer.setAutoShapeType(true);

    spriteBatch = new SpriteBatch();
    font = new BitmapFont();
    font.setColor(Color.WHITE);
    font.setUseIntegerPositions(false);
    font.getData().setScale(0.01f);
    shadowBatch = new ModelBatch(new DepthShaderProvider());

    ShaderProgram.pedantic = false;
    final String vertUber = Gdx.files.internal("shaders/uber.vert").readString();
    final String fragUber = Gdx.files.internal("shaders/uber.frag").readString();
    modelBatch = new ModelBatch(new DefaultShaderProvider(vertUber, fragUber) {
        @Override
        protected Shader createShader(final Renderable renderable) {
            return new UberShader(renderable, config);
        }
    });
}
项目:libgdxcn    文件:ShaderTest.java   
@Override
public void create () {
    modelBatch = new ModelBatch(new BaseShaderProvider() {
        @Override
        protected Shader createShader (Renderable renderable) {
            return new TestShader();
        }
    });

    cam = new PerspectiveCamera(67, Gdx.graphics.getWidth(), Gdx.graphics.getHeight());
    cam.position.set(10f, 10f, 10f);
    cam.lookAt(0, 0, 0);
    cam.near = 0.1f;
    cam.far = 300f;
    cam.update();

    camController = new CameraInputController(cam);
    Gdx.input.setInputProcessor(camController);

    Material material = new Material(new TestAttribute(1f));
    ModelBuilder builder = new ModelBuilder();
    model = builder.createCone(5, 5, 5, 20, material, Usage.Position);
    instance = new ModelInstance(model);
    testAttribute = (TestAttribute)instance.materials.get(0).get(TestAttribute.ID);
}
项目:ForgE    文件:VoxelBatch.java   
private void renderWireframe() {
  context.begin(); {
    shapeRenderer.setProjectionMatrix(camera.combined);
    shapeRenderer.begin(ShapeRenderer.ShapeType.Line); {
      for (int i = 0; i < renderables.size; i++) {
        Renderable renderable = renderables.get(i);
        if (BaseRenderable.class.isInstance(renderable)) {
          BaseRenderable baseRenderable = (BaseRenderable)renderable;
          if (baseRenderable.wireframe != null) {
            shapeRenderer.setTransformMatrix(renderable.worldTransform);
            baseRenderable.wireframe.render(shapeRenderer, Color.WHITE);
          }
        }
      }
    } shapeRenderer.end();
  } context.end();
}
项目:libgdxcn    文件:DepthShader.java   
@Override
public void render (final Renderable renderable) {
    if (renderable.material.has(BlendingAttribute.Type)) {
        final BlendingAttribute blending = (BlendingAttribute)renderable.material.get(BlendingAttribute.Type);
        renderable.material.remove(BlendingAttribute.Type);
        final boolean hasAlphaTest = renderable.material.has(FloatAttribute.AlphaTest);
        if (!hasAlphaTest)
            renderable.material.set(alphaTestAttribute);
        if (blending.opacity >= ((FloatAttribute)renderable.material.get(FloatAttribute.AlphaTest)).value)
            super.render(renderable);
        if (!hasAlphaTest)
            renderable.material.remove(FloatAttribute.AlphaTest);
        renderable.material.set(blending);
    } else
        super.render(renderable);
}
项目:libgdxcn    文件:ParticleShader.java   
public ParticleShader(final Renderable renderable, final Config config, final ShaderProgram shaderProgram) {
    this.config = config;
    this.program = shaderProgram;
    this.renderable = renderable;
    materialMask = renderable.material.getMask() | optionalAttributes;
    vertexMask = renderable.mesh.getVertexAttributes().getMask();

    if (!config.ignoreUnimplemented && (implementedFlags & materialMask) != materialMask)
        throw new GdxRuntimeException("Some attributes not implemented yet ("+materialMask+")");

    // Global uniforms
    register(DefaultShader.Inputs.viewTrans, DefaultShader.Setters.viewTrans);
    register(DefaultShader.Inputs.projViewTrans, DefaultShader.Setters.projViewTrans);
    register(DefaultShader.Inputs.projTrans, DefaultShader.Setters.projTrans);
    register(Inputs.screenWidth, Setters.screenWidth);
    register(DefaultShader.Inputs.cameraUp, Setters.cameraUp);
    register(Inputs.cameraRight, Setters.cameraRight);
    register(Inputs.cameraInvDirection, Setters.cameraInvDirection);
    register(DefaultShader.Inputs.cameraPosition, Setters.cameraPosition);

    // Object uniforms
    register(DefaultShader.Inputs.diffuseTexture, DefaultShader.Setters.diffuseTexture);
}
项目:libgdxcn    文件:ShaderCollectionTest.java   
@Override
public Shader getShader (Renderable renderable) {
    try {
        return super.getShader(renderable);
    } catch (Throwable e) {
        if (tempFolder != null && Gdx.app.getType() == ApplicationType.Desktop)
            Gdx.files.absolute(tempFolder).child(name + ".log.txt").writeString(e.getMessage(), false);
        if (!revert()) {
            Gdx.app.error("ShaderCollectionTest", e.getMessage());
            throw new GdxRuntimeException("Error creating shader, cannot revert to default shader", e);
        }
        error = true;
        Gdx.app.error("ShaderTest", "Could not create shader, reverted to default shader.", e);
        return super.getShader(renderable);
    }
}
项目:Cubes_2    文件:WorldShaderProvider.java   
@Override
public void render(Renderable renderable) {
    if (renderable.userData instanceof RenderingSettings
            && ((RenderingSettings) renderable.userData).lightOverride != -1) {
        program.setUniformf(u_lightoverride, ((RenderingSettings) renderable.userData).lightOverride);
        lightoverride = true;
    } else if (lightoverride) {
        program.setUniformf(u_lightoverride, -1f);
        lightoverride = false;
    }
    super.render(renderable);
}
项目:Cubes_2    文件:AreaRenderer.java   
@Override
public void getRenderables(Array<Renderable> renderables, Pool<Renderable> pool) {
    if (area == null || !update() || meshs.size() == 0)
        return;
    renderedThisFrame++;
    for (AreaMesh mesh : meshs) {
        renderedMeshesThisFrame++;
        renderables.add(mesh.renderable(pool));
    }
}
项目:Cubes    文件:WorldShaderProvider.java   
@Override
public Shader getShader(Renderable renderable) {
  int shader = 0;

  boolean fogFlag = Settings.getBooleanSettingValue(Settings.GRAPHICS_FOG);
  if (renderable.userData instanceof RenderingSettings) fogFlag &= ((RenderingSettings) renderable.userData).fogEnabled;
  if (fogFlag) shader |= FEATURE_FOG;

  boolean aoFlag = renderable.meshPart.mesh.getVertexAttributes() == CubesVertexAttributes.VERTEX_ATTRIBUTES_AO;
  if (aoFlag) shader |= FEATURE_AO;

  if (shaders[shader] == null) {
    if (shader == 0) {
      shaders[shader] = new CubesShader(renderable);
    } else {
      ArrayList<Feature> f = new ArrayList<Feature>();
      if (fogFlag) f.add(new FogFeature());
      if (aoFlag) f.add(new AmbientOcclusionFeature());
      shaders[shader] = new FeatureShader(renderable, f);
    }

    ShaderProgram program = shaders[shader].program;
    if (!program.isCompiled()) {
      Log.error("Failed to compile shader");
      Log.error("Shader log: \n" + program.getLog());
      Log.error("Fragment shader source: \n" + program.getFragmentShaderSource());
      Log.error("Vertex shader source: \n" + program.getVertexShaderSource());
      throw new CubesException("Failed to compile shader");
    }
    shaders[shader].init();
  }
  return shaders[shader];
}
项目:Cubes    文件:WorldShaderProvider.java   
@Override
public void render(Renderable renderable) {
  if (renderable.userData instanceof RenderingSettings && ((RenderingSettings) renderable.userData).lightOverride != -1) {
    program.setUniformf(u_lightoverride, ((RenderingSettings) renderable.userData).lightOverride);
    lightoverride = true;
  } else if (lightoverride) {
    program.setUniformf(u_lightoverride, -1f);
    lightoverride = false;
  }
  super.render(renderable);
}
项目:Cubes    文件:AreaRenderer.java   
@Override
public void getRenderables(Array<Renderable> renderables, Pool<Renderable> pool) {
  if (area == null || !update() || meshs.size() == 0) return;
  renderedThisFrame++;
  for (AreaMesh mesh : meshs) {
    renderedMeshesThisFrame++;
    renderables.add(mesh.renderable(pool));
  }
}
项目:Cubes    文件:SunRenderer.java   
public static void setWorldTransform(Renderable renderable, boolean isMoon) {
  Vector3 pos = Cubes.getClient().player.position;
  int r = 512;
  float f = (float) (Cubes.getClient().world.getTime() - (World.MAX_TIME / 4)) / (float) World.MAX_TIME;
  if (isMoon) f += 0.5f;
  f %= 1;

  float x = (float) (pos.x + (r * Math.cos(f * 2 * Math.PI)));
  float y = (float) (pos.y + (r * Math.sin(f * 2 * Math.PI)));
  float z = pos.z;

  renderable.worldTransform.setToTranslation(x, y, z);
  renderable.worldTransform.scl(75f);
  renderable.worldTransform.rotate(Vector3.Z, (f - 0.25f % 1) * 360);
}
项目:nhglib    文件:DepthShaderProvider.java   
@Override
protected Shader createShader(final Renderable renderable) {
    DepthMapShader.Params params = new DepthMapShader.Params();
    params.useBones = ShaderUtils.useBones(renderable);

    return new DepthMapShader(renderable, params);
}
项目:nhglib    文件:DepthMapShader.java   
@Override
public void render(final Renderable renderable) {
    if (!renderable.material.has(BlendingAttribute.Type)) {
        context.setBlending(false, GL20.GL_SRC_ALPHA, GL20.GL_ONE_MINUS_SRC_ALPHA);
    } else {
        context.setBlending(true, GL20.GL_SRC_ALPHA, GL20.GL_ONE_MINUS_SRC_ALPHA);
    }

    updateBones(renderable);
    super.render(renderable);
}
项目:nhglib    文件:DepthMapShader.java   
private void updateBones(Renderable renderable) {
    if (renderable.bones != null) {
        bones = new float[renderable.bones.length * 16];

        for (int i = 0; i < bones.length; i++) {
            final int idx = i / 16;
            bones[i] = (idx >= renderable.bones.length || renderable.bones[idx] == null) ?
                    idtMatrix.val[i % 16] : renderable.bones[idx].val[i % 16];
        }

        program.setUniformMatrix4fv("u_bones", bones, 0, bones.length);
    }
}
项目:nhglib    文件:PBRShaderProvider.java   
@Override
protected Shader createShader(Renderable renderable) {
    PBRShader.Params params = new PBRShader.Params();
    params.albedo = ShaderUtils.hasAlbedo(renderable);
    params.metalness = ShaderUtils.hasMetalness(renderable);
    params.roughness = ShaderUtils.hasRoughness(renderable);
    params.normal = ShaderUtils.hasPbrNormal(renderable);
    params.ambientOcclusion = ShaderUtils.hasAmbientOcclusion(renderable);
    params.useBones = ShaderUtils.useBones(renderable);
    params.lit = ShaderUtils.hasLights(environment);
    params.gammaCorrection = ShaderUtils.useGammaCorrection(environment);
    params.imageBasedLighting = ShaderUtils.useImageBasedLighting(environment);

    return new PBRShader(renderable, environment, params);
}
项目:nhglib    文件:PBRShader.java   
@Override
public boolean canRender(Renderable instance) {
    boolean diffuse = ShaderUtils.hasAlbedo(instance) == params.albedo;
    boolean metalness = ShaderUtils.hasMetalness(instance) == params.metalness;
    boolean roughness = ShaderUtils.hasRoughness(instance) == params.roughness;
    boolean normal = ShaderUtils.hasPbrNormal(instance) == params.normal;
    boolean ambientOcclusion = ShaderUtils.hasAmbientOcclusion(instance) == params.ambientOcclusion;
    boolean bones = ShaderUtils.useBones(instance) == params.useBones;
    boolean lit = ShaderUtils.hasLights(instance.environment) == params.lit;
    boolean gammaCorrection = ShaderUtils.useGammaCorrection(instance.environment) == params.gammaCorrection;
    boolean imageBasedLighting = ShaderUtils.useImageBasedLighting(instance.environment) == params.imageBasedLighting;

    return diffuse && metalness && roughness && normal && ambientOcclusion && bones &&
            lit && gammaCorrection && imageBasedLighting;
}
项目:nhglib    文件:PointSpriteSoftParticleBatch.java   
protected void allocRenderable() {
    renderable = new Renderable();
    renderable.meshPart.primitiveType = GL20.GL_POINTS;
    renderable.meshPart.offset = 0;
    renderable.material = new Material(new BlendingAttribute(GL20.GL_ONE, GL20.GL_ONE_MINUS_SRC_ALPHA, 1f),
            new DepthTestAttribute(GL20.GL_LEQUAL, false), TextureAttribute.createDiffuse((Texture) null));
}
项目:nhglib    文件:ShaderUtils.java   
public static boolean hasDiffuse(Renderable renderable) {
    boolean res = false;
    TextureAttribute attribute = (TextureAttribute) renderable.material.get(TextureAttribute.Diffuse);

    if (attribute != null && attribute.textureDescription.texture != null) {
        res = true;
    }

    return res;
}
项目:nhglib    文件:ShaderUtils.java   
public static boolean hasNormal(Renderable renderable) {
    boolean res = false;
    TextureAttribute attribute = (TextureAttribute) renderable.material.get(TextureAttribute.Normal);

    if (attribute != null && attribute.textureDescription.texture != null) {
        res = true;
    }

    return res;
}