本文整理汇总了Java中com.badlogic.gdx.graphics.glutils.ShaderProgram.begin方法的典型用法代码示例。如果您正苦于以下问题:Java ShaderProgram.begin方法的具体用法?Java ShaderProgram.begin怎么用?Java ShaderProgram.begin使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.badlogic.gdx.graphics.glutils.ShaderProgram
的用法示例。
在下文中一共展示了ShaderProgram.begin方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: initShader
import com.badlogic.gdx.graphics.glutils.ShaderProgram; //导入方法依赖的package包/类
private ShaderProgram initShader(Texture colorMapTex, Texture maskMapTex, Texture normalMapTex, TransVec dim,
float amIntensity, float dirIntensity, float shadIntensity, float sprtSize, float lum, float thresh, ShaderProgram shader) {
shader.begin();
{
maskMapTex.bind(2);
normalMapTex.bind(1);
colorMapTex.bind(0);
super.batcher.setShader(shader);
shader.setUniformi(maskMap, 2);
shader.setUniformi(normalMap, 1);
shader.setUniformi(colorMap, 0);
shader.setUniformf(fieldSize, dim.x, dim.y);
shader.setUniformf(ambientIntensity, amIntensity);
shader.setUniformf(directIntensity, dirIntensity);
shader.setUniformf(shadowIntensity, shadIntensity);
shader.setUniformf(spriteSize, sprtSize);
shader.setUniformf(height, lum);
shader.setUniformf(threshold, thresh);
}
shader.end();
return shader;
}
示例2: initShader
import com.badlogic.gdx.graphics.glutils.ShaderProgram; //导入方法依赖的package包/类
protected ShaderProgram initShader(Texture lMap, ShaderProgram shader,
Color color, TransVec angles, TransVec fSize, float coeff,
float correction, TransVec radius, TransVec umbra) {
shader.begin();
{
lMap.bind(0);
super.batcher.setShader(shader);
shader.setUniformi(LIGHTMAP, 0);
shader.setUniformf("u_color", color.r, color.g, color.b);
shader.setUniformf("u_angles", angles.x, angles.y);
shader.setUniformf("u_fieldSize", fSize.x, fSize.y);
shader.setUniformf("u_coeff", coeff);
shader.setUniformf("u_angCorrect", correction);
shader.setUniformf("u_radius", radius.x, radius.y);
shader.setUniformf("u_umbra", umbra.x, umbra.y);
}
shader.end();
return shader;
}
示例3: renderIrradiance
import com.badlogic.gdx.graphics.glutils.ShaderProgram; //导入方法依赖的package包/类
private Cubemap renderIrradiance(Cubemap environmentCubemap) {
ShaderProgram irradianceShader = new ShaderProgram(
Gdx.files.internal("shaders/equi_to_cube_shader.vert"),
Gdx.files.internal("shaders/irradiance_shader.frag"));
FrameBufferCubemap frameBufferCubemap = FrameBufferCubemap.createFrameBufferCubemap(Pixmap.Format.RGB888,
(int) irradianceWidth, (int) irradianceHeight, true);
environmentCubemap.bind(0);
irradianceShader.begin();
irradianceShader.setUniformMatrix("u_projection", perspectiveCameras.first().projection);
irradianceShader.setUniformi("u_environmentMap", 0);
frameBufferCubemap.begin();
for (int i = 0; i < 6; i++) {
irradianceShader.setUniformMatrix("u_view", perspectiveCameras.get(i).view);
Gdx.gl.glClear(GL20.GL_COLOR_BUFFER_BIT | GL20.GL_DEPTH_BUFFER_BIT);
cubeMesh.render(irradianceShader, GL20.GL_TRIANGLES);
frameBufferCubemap.nextSide();
}
frameBufferCubemap.end();
irradianceShader.end();
irradianceShader.dispose();
return frameBufferCubemap.getColorBufferTexture();
}
示例4: renderBRDF
import com.badlogic.gdx.graphics.glutils.ShaderProgram; //导入方法依赖的package包/类
private Texture renderBRDF() {
ShaderProgram brdfShader = new ShaderProgram(
Gdx.files.internal("shaders/brdf_shader.vert"),
Gdx.files.internal("shaders/brdf_shader.frag"));
FrameBuffer frameBuffer = FrameBuffer.createFrameBuffer(Pixmap.Format.RGB888, (int) brdfWidth, (int) brdfHeight, true);
brdfShader.begin();
frameBuffer.begin();
Gdx.gl.glViewport(0, 0, (int) brdfWidth, (int) brdfHeight);
Gdx.gl.glClear(GL20.GL_COLOR_BUFFER_BIT | GL20.GL_DEPTH_BUFFER_BIT);
quadMesh.render(brdfShader, GL20.GL_TRIANGLES);
frameBuffer.end();
brdfShader.end();
brdfShader.dispose();
return frameBuffer.getColorBufferTexture();
}
示例5: run
import com.badlogic.gdx.graphics.glutils.ShaderProgram; //导入方法依赖的package包/类
@Override
public void run (ShaderProgram program) {
int texId = sm.getCurrentTextureId();
fbo.begin();
program.begin();
fbo2.getColorBufferTexture().bind(texId);
program.setUniformi("u_texture", sm.getCurrentTextureId());
program.setUniformf("u_viewport", width, height);
addUniforms(program);
quad.render(program, GL20.GL_TRIANGLES);
if (saveBytes)
data = getFrameBufferPixels(0, 0, width, height, false, data);
program.end();
fbo.end();
swapBuffers();
}
示例6: setShader
import com.badlogic.gdx.graphics.glutils.ShaderProgram; //导入方法依赖的package包/类
public void setShader (ShaderProgram shader) {
if (drawing) {
flush();
shader.end();
}
this.shader = shader;
if (drawing) {
shader.begin();
applyMatrices();
}
}
示例7: 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();
}
示例8: initShader
import com.badlogic.gdx.graphics.glutils.ShaderProgram; //导入方法依赖的package包/类
protected ShaderProgram initShader(Texture srcMap, ShaderProgram program,
float widht, float height, float dirX, float dirY) {
program.begin();
{
srcMap.bind(0);
super.batcher.setShader(program);
program.setUniformi(SOURCEMAP, 0);
program.setUniformf("u_fieldSize", widht, height);
program.setUniformf("u_direction", dirX, dirY);
} program.end();
return program;
}
示例9: initShader
import com.badlogic.gdx.graphics.glutils.ShaderProgram; //导入方法依赖的package包/类
protected ShaderProgram initShader(Texture sourceMap, float lwidht, float lheight,
TransVec angles, float correct, ShaderProgram shader) {
shader.begin();
{
sourceMap.bind(0);
super.batcher.setShader(shader);
shader.setUniformi(SOURCEMAP, 0);
shader.setUniformf("resolution", lwidht, lheight);
shader.setUniformf("u_angles", angles.x, angles.y);
shader.setUniformf("u_angCorrect", correct);
} shader.end();
return shader;
}
示例10: initShader
import com.badlogic.gdx.graphics.glutils.ShaderProgram; //导入方法依赖的package包/类
protected ShaderProgram initShader(Texture sourceMap, float lwidht, float lheight,
float threshold, TransVec angles, float correct, ShaderProgram shader) {
shader.begin();
{
sourceMap.bind(0);
super.batcher.setShader(shader);
shader.setUniformi(SOURCEMAP, 0);
shader.setUniformf("resolution", lwidht, lheight);
shader.setUniformf("u_THRESHOLD", threshold);
} shader.end();
return shader;
}
示例11: initShader
import com.badlogic.gdx.graphics.glutils.ShaderProgram; //导入方法依赖的package包/类
private ShaderProgram initShader(Texture target, Texture blend, ShaderProgram shader) {
shader.begin();
{
blend.bind(1);
target.bind(0);
super.batcher.setShader(shader);
shader.setUniformi(this.blendMap, 1);
shader.setUniformi(this.targetMap, 0);
super.shaderLoader.accept(shader);
}
shader.end();
return shader;
}
示例12: render
import com.badlogic.gdx.graphics.glutils.ShaderProgram; //导入方法依赖的package包/类
public void render() {
boolean needed = rayHandler.lightRenderedLastFrame > 0;
if (lightMapDrawingDisabled)
return;
frameBuffer.getColorBufferTexture().bind(0);
// at last lights are rendered over scene
if (rayHandler.shadows) {
final Color c = rayHandler.ambientLight;
ShaderProgram shader = shadowShader;
if (RayHandler.isDiffuse) {
shader = diffuseShader;
shader.begin();
rayHandler.diffuseBlendFunc.apply();
shader.setUniformf("ambient", c.r, c.g, c.b, c.a);
} else {
shader.begin();
rayHandler.shadowBlendFunc.apply();
shader.setUniformf("ambient", c.r * c.a, c.g * c.a,
c.b * c.a, 1f - c.a);
}
// shader.setUniformi("u_texture", 0);
lightMapMesh.render(shader, GL20.GL_TRIANGLE_FAN);
shader.end();
} else if (needed) {
rayHandler.simpleBlendFunc.apply();
withoutShadowShader.begin();
// withoutShadowShader.setUniformi("u_texture", 0);
lightMapMesh.render(withoutShadowShader, GL20.GL_TRIANGLE_FAN);
withoutShadowShader.end();
}
Gdx.gl20.glDisable(GL20.GL_BLEND);
}
示例13: renderEnvironmentFromHDRData
import com.badlogic.gdx.graphics.glutils.ShaderProgram; //导入方法依赖的package包/类
private Cubemap renderEnvironmentFromHDRData(HDRData2 data) {
Texture equirectangularTexture;
ShaderProgram equiToCubeShader = new ShaderProgram(
Gdx.files.internal("shaders/equi_to_cube_shader.vert"),
Gdx.files.internal("shaders/equi_to_cube_shader.frag"));
equirectangularTexture = data.getTexture();
GLFrameBuffer.FrameBufferCubemapBuilder builder = new GLFrameBuffer.FrameBufferCubemapBuilder(
(int) environmentWidth, (int) environmentHeight);
builder.addColorTextureAttachment(GL30.GL_RGB8, GL30.GL_RGB, GL30.GL_UNSIGNED_BYTE);
builder.addDepthRenderBufferAttachment();
FrameBufferCubemap frameBufferCubemap = builder.build();
equirectangularTexture.bind(0);
equiToCubeShader.begin();
equiToCubeShader.setUniformMatrix("u_projection", perspectiveCameras.first().projection);
equiToCubeShader.setUniformi("u_equirectangularMap", 0);
frameBufferCubemap.begin();
for (int i = 0; i < 6; i++) {
equiToCubeShader.setUniformMatrix("u_view", perspectiveCameras.get(i).view);
Gdx.gl.glClear(GL20.GL_COLOR_BUFFER_BIT | GL20.GL_DEPTH_BUFFER_BIT);
cubeMesh.render(equiToCubeShader, GL20.GL_TRIANGLES);
frameBufferCubemap.nextSide();
}
frameBufferCubemap.end();
equiToCubeShader.end();
equiToCubeShader.dispose();
return frameBufferCubemap.getColorBufferTexture();
}
示例14: begin
import com.badlogic.gdx.graphics.glutils.ShaderProgram; //导入方法依赖的package包/类
/** Call this to start rendering using given shader.
*
* @param shadIdn - a shader with this identifier must be loaded earlier
* @return this ShaderProgram for chaining */
public ShaderProgram begin (String shadIdn) {
if (currentShader != null)
throw new IllegalArgumentException(
"Previous shader '" + currentShaderIdn + "' not finished! Call end() before another begin().");
ShaderProgram res = get(shadIdn);
if (res != null) {
currentShader = res;
currentShaderIdn = shadIdn;
currentTextureId = 0;
res.begin();
} else
throw new IllegalArgumentException("Shader '" + shadIdn + "' not found!");
return res;
}
示例15: run
import com.badlogic.gdx.graphics.glutils.ShaderProgram; //导入方法依赖的package包/类
public void run (ShaderProgram program) {
int texId = sm.getCurrentTextureId();
fbo.begin();
program.begin();
getResult().bind(texId);
program.setUniformi("u_texture", texId);
program.setUniformf("u_viewport", width, height);
addUniforms(program);
quad.render(program, GL20.GL_TRIANGLES);
if (saveBytes)
data = getFrameBufferPixels(0, 0, width, height, false, data);
program.end();
fbo.end();
}