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

项目: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];
}
项目: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    文件: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;
}
项目: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    文件: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);
    }
}
项目: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);
}
项目:amatsukaze    文件: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);
    }
}
项目:amatsukaze    文件: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);
}
项目: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];
}
项目: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    文件: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);
}
项目:LibGDX-PBR    文件:PBRTestAPP.java   
public static Renderable createRenderableFromMesh(Mesh mesh, Material material, Shader shader, Environment environment) {
    Renderable outRend=new Renderable();
    outRend.meshPart.mesh=mesh;
    outRend.meshPart.primitiveType=GL20.GL_TRIANGLES;
    if(material!=null) outRend.material=material;
    if(environment!=null) outRend.environment=environment;
    outRend.meshPart.offset=0;
    //strada.shader=elrShader;
    if(shader!=null) outRend.shader=shader;
    outRend.meshPart.size=mesh.getNumIndices();
    return outRend;
}
项目:Argent    文件:LightRenderer.java   
public void compileShader() {
    try { getRawShader(); } catch (Exception e) { e.printStackTrace(); }
    String frag = rawFragShader;
    String vert = rawVertShader;

    vert = TextUtils.replaceLine("#version", "", vert);

    vert = "#version 120\n" +
            "\n" +
            "#define LIGHT_COUNT "+lightPoints.size()+"\n" +
            "\n" +
            vert;

    shaderProgram = new ShaderProgram(vert, frag);

    if(!shaderProgram.isCompiled()) {
        System.out.println(shaderProgram.getLog());
        System.out.println();
        System.out.println("Vertex");
        System.out.println(shaderProgram.getVertexShaderSource());
        System.out.println();
        System.out.println("Fragment");
        System.out.println(shaderProgram.getFragmentShaderSource());
        System.out.println();
    }

    for(int i = 0; i < lightPoints.size(); i++){
        Quaternion quat = lightPoints.get(i);
        int loc = shaderProgram.getUniformLocation("u_lightPos[" + i + "]");
        float[] pack = new float[]{quat.x, quat.y, quat.z, quat.w};
        shaderProgram.setUniform4fv(loc, pack, 0, pack.length);
    }

    modelBatch = new ModelBatch(new DefaultShaderProvider(){
        @Override
        protected Shader createShader(Renderable renderable) {
            return new DepthMapShader(renderable, shaderProgram);
        }
    });
}
项目:Argent    文件:LightWrapper.java   
public LightWrapper(T light) {
    this.light = light;
    shaderProgram = WorldRenderer.setupShader("depth/light");
    if(!shaderProgram.isCompiled())
        throw new GdxRuntimeException("Unable to compile shader: "+shaderProgram.getLog());
    batch = new ModelBatch(new DefaultShaderProvider() {
        @Override
        protected Shader createShader(Renderable renderable) {
            return new DepthMapShader(renderable, shaderProgram);
        }
    });
}
项目:libgdxcn    文件:BaseShaderProvider.java   
@Override
public void dispose () {
    for (Shader shader : shaders) {
        shader.dispose();
    }
    shaders.clear();
}
项目:libgdxcn    文件:ShaderCollectionTest.java   
@Override
protected Shader createShader (Renderable renderable) {
    if (config.vertexShader != null && config.fragmentShader != null && tempFolder != null
        && Gdx.app.getType() == ApplicationType.Desktop) {
        String prefix = DefaultShader.createPrefix(renderable, config);
        Gdx.files.absolute(tempFolder).child(name + ".vertex.glsl").writeString(prefix + config.vertexShader, false);
        Gdx.files.absolute(tempFolder).child(name + ".fragment.glsl").writeString(prefix + config.fragmentShader, false);
    }
    BaseShader result = new MultiPassShader(renderable, config);
    if (tempFolder != null && Gdx.app.getType() == ApplicationType.Desktop)
        Gdx.files.absolute(tempFolder).child(name + ".log.txt").writeString(result.program.getLog(), false);
    return result;
}
项目:gaiasky    文件:AtmosphereShader.java   
@Override
public int compareTo(Shader other) {
    if (other == null)
        return -1;
    if (other == this)
        return 0;
    return 0;
}
项目:amatsukaze    文件:ShaderCollectionTest.java   
@Override
protected Shader createShader (Renderable renderable) {
    if (config.vertexShader != null && config.fragmentShader != null && tempFolder != null
        && Gdx.app.getType() == ApplicationType.Desktop) {
        String prefix = DefaultShader.createPrefix(renderable, config);
        Gdx.files.absolute(tempFolder).child(name + ".vertex.glsl").writeString(prefix + config.vertexShader, false);
        Gdx.files.absolute(tempFolder).child(name + ".fragment.glsl").writeString(prefix + config.fragmentShader, false);
    }
    BaseShader result = new MultiPassShader(renderable, config);
    if (tempFolder != null && Gdx.app.getType() == ApplicationType.Desktop)
        Gdx.files.absolute(tempFolder).child(name + ".log.txt").writeString(result.program.getLog(), false);
    return result;
}
项目:Cubes_2    文件:WorldShaderProvider.java   
@Override
public int compareTo(Shader other) {
    return other == null ? -1 : 0;
}
项目:Cubes    文件:WorldShaderProvider.java   
@Override
public int compareTo(Shader other) {
  return other == null ? -1 : 0;
}
项目:thunderboard-android    文件:DemoMotionGdxAdapter.java   
protected Shader createShader(Renderable renderable) {
    return new EmissiveShader(renderable, this.config);
}
项目:nhglib    文件:DeferredShader.java   
@Override
public int compareTo(Shader other) {
    return 0;
}
项目:nhglib    文件:DepthMapShader.java   
@Override
public int compareTo(final Shader other) {
    return 0;
}
项目:nhglib    文件:PBRShader.java   
@Override
public int compareTo(Shader other) {
    return 0;
}
项目:LibGDX-PBR    文件:PBRShader.java   
@Override
public int compareTo(Shader other) {
    return 0;
}
项目:LibGDX-PBR    文件:PBRSadherTexture.java   
@Override
public int compareTo(Shader other) {
    return 0;
}
项目:exterminate    文件:DefShaderProvider.java   
@Override
protected Shader createShader (final Renderable renderable) {
    return new DefShader(renderable, config);
}
项目:exterminate    文件:ModelShaderProvider.java   
@Override
protected Shader createShader (final Renderable renderable) {
    return new ModelShader(renderable, config);
}
项目:Argent    文件:SimpleTextureShader.java   
@Override
public int compareTo(final Shader other)
{
    return 0;
}
项目:Argent    文件:ShadowMapShader.java   
@Override
public int compareTo(final Shader other)
{
    return 0;
}
项目:Argent    文件:VolumetricDepthShader.java   
@Override
public int compareTo(final Shader other) {
    return 0;
}
项目:Argent    文件:NormalTextureShader.java   
@Override
public int compareTo(final Shader other)
{
    return 0;
}
项目:Argent    文件:DepthMapShader.java   
@Override
public int compareTo(final Shader other)
{
    return 0;
}
项目:Chemtris    文件:Storage.java   
@Override
protected Shader createShader(Renderable renderable) {
    return new WireframeShader(renderable, config);
}
项目:Chemtris    文件:Element.java   
@Override
protected Shader createShader(Renderable renderable) {
    return new WireframeShader(renderable, config);
}
项目:Chemtris    文件:GameModel.java   
@Override
protected Shader createShader(Renderable renderable) {
    return new WireframeShader(renderable, config);
}
项目:Chemtris    文件:Platform.java   
@Override
protected Shader createShader(Renderable renderable) {
    return new WireframeShader(renderable, config);
}
项目:origin    文件:ShadowShader.java   
@Override
public int compareTo(Shader other)
{
    return 0;
}
项目:origin    文件:ModelShaderProvider.java   
@Override
protected Shader createShader(Renderable renderable)
{
    return new ModelShader(renderable, _config);
}
项目:origin    文件:ShadowShaderProvider.java   
@Override
protected Shader createShader(Renderable renderable)
{
    return new ShadowShader(renderable, _shaderProgram);
}