当前位置: 首页>>代码示例>>Java>>正文


Java ShaderProgram.getUniformLocation方法代码示例

本文整理汇总了Java中com.badlogic.gdx.graphics.glutils.ShaderProgram.getUniformLocation方法的典型用法代码示例。如果您正苦于以下问题:Java ShaderProgram.getUniformLocation方法的具体用法?Java ShaderProgram.getUniformLocation怎么用?Java ShaderProgram.getUniformLocation使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在com.badlogic.gdx.graphics.glutils.ShaderProgram的用法示例。


在下文中一共展示了ShaderProgram.getUniformLocation方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: createShader

import com.badlogic.gdx.graphics.glutils.ShaderProgram; //导入方法依赖的package包/类
public void createShader(){
    String vertexShaderSrc =  "attribute vec4 a_position;    \n" +
            "void main()                  \n" +
            "{                            \n" +
            "   gl_Position = a_position;  \n" +
            "}                            \n";
    String fragmentShaderSrc = "#ifdef GL_ES\n" +
            "precision mediump float;\n" +
            "#endif\n" +
            "uniform vec4 u_color;    \n" +
            "void main()                                  \n" +
            "{                                            \n" +
            "  gl_FragColor =  u_color;\n" +
            "}                                            \n";

    shader=new ShaderProgram(vertexShaderSrc,fragmentShaderSrc);

    u_color = shader.getUniformLocation("u_color");
}
 
开发者ID:CypherCove,项目名称:gdx-cclibs,代码行数:20,代码来源:FullScreenFader.java

示例2: init

import com.badlogic.gdx.graphics.glutils.ShaderProgram; //导入方法依赖的package包/类
@Override
public void init() {
    loadReflection("rnl_phong_m00");

    String vert = Gdx.files.internal("Shaders/VS_ShaderPlain.vsh").readString();
    String frag = Gdx.files.internal("Shaders/ShaderPlain.fsh").readString();
    program = new ShaderProgram(vert, frag);
    if (!program.isCompiled()){
        throw new GdxRuntimeException(program.getLog());
    }
    u_worldTrans = program.getUniformLocation("u_worldTrans");
    u_projTrans = program.getUniformLocation("u_projTrans");
    vLight0 = program.getUniformLocation("vLight0");
    albedo = program.getUniformLocation("albedo");
    metallic = program.getUniformLocation("metallic");
    sCubemapTexture = program.getUniformLocation("sCubemapTexture");
    vRoughness = program.getUniformLocation("vRoughness");
    ambientOcclusion = program.getUniformLocation("ambientOcclusion");
}
 
开发者ID:PWorlds,项目名称:LibGDX-PBR,代码行数:20,代码来源:PBRShader.java

示例3: init

import com.badlogic.gdx.graphics.glutils.ShaderProgram; //导入方法依赖的package包/类
@Override
public void init() {
    loadReflection("rnl_phong_m00");

    String vert = Gdx.files.internal("Shaders/VS_PBR_ShaderTexture.vsh").readString();
    String frag = Gdx.files.internal("Shaders/PBR_ShaderTexture.fsh").readString();
    program = new ShaderProgram(vert, frag);
    if (!program.isCompiled()){
        throw new GdxRuntimeException(program.getLog());
    }
    u_worldTrans = program.getUniformLocation("u_worldTrans");
    u_projTrans = program.getUniformLocation("u_projTrans");
    vLight0 = program.getUniformLocation("vLight0");
    albedoTexture = program.getUniformLocation("albedoTexture");
    metallicTexture = program.getUniformLocation("metallicTexture");
    sCubemapTexture = program.getUniformLocation("sCubemapTexture");
    roughnessTexture = program.getUniformLocation("roughnessTexture");
    ambientOcclusionTexture = program.getUniformLocation("ambientOcclusionTexture");
    normalTexture = program.getUniformLocation("normalTexture");
    heightTexture = program.getUniformLocation("heightTexture");
}
 
开发者ID:PWorlds,项目名称:LibGDX-PBR,代码行数:22,代码来源:PBRSadherTexture.java

示例4: ShaderBatch

import com.badlogic.gdx.graphics.glutils.ShaderProgram; //导入方法依赖的package包/类
public ShaderBatch(float brightness, float contrast)
{
	ShaderProgram.pedantic = false;
	ShaderProgram shader = new ShaderProgram(vertexShader, fragmentShader);
	setShader(shader);
	shader.begin();
	int brightnessLoc = shader.getUniformLocation("brightness");
	int contrastLoc = shader.getUniformLocation("contrast");
	shader.setUniformf(brightnessLoc, brightness);
	shader.setUniformf(contrastLoc, contrast);
	shader.end();
}
 
开发者ID:MMORPG-Prototype,项目名称:MMORPG_Prototype,代码行数:13,代码来源:ShaderBatch.java

示例5: compileShader

import com.badlogic.gdx.graphics.glutils.ShaderProgram; //导入方法依赖的package包/类
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);
        }
    });
}
 
开发者ID:ncguy2,项目名称:Argent,代码行数:41,代码来源:LightRenderer.java


注:本文中的com.badlogic.gdx.graphics.glutils.ShaderProgram.getUniformLocation方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。