本文整理汇总了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");
}
示例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");
}
示例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");
}
示例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();
}
示例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);
}
});
}