本文整理汇总了Java中com.badlogic.gdx.graphics.g3d.shaders.DefaultShader类的典型用法代码示例。如果您正苦于以下问题:Java DefaultShader类的具体用法?Java DefaultShader怎么用?Java DefaultShader使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
DefaultShader类属于com.badlogic.gdx.graphics.g3d.shaders包,在下文中一共展示了DefaultShader类的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: UberShader
import com.badlogic.gdx.graphics.g3d.shaders.DefaultShader; //导入依赖的package包/类
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());
}
}
示例2: ParticleShader
import com.badlogic.gdx.graphics.g3d.shaders.DefaultShader; //导入依赖的package包/类
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);
}
示例3: create
import com.badlogic.gdx.graphics.g3d.shaders.DefaultShader; //导入依赖的package包/类
@Override
public void create() {
assets = new AssetManager();
String model = "Bambo_House.g3db";
assets.load(model, Model.class);
assets.finishLoading();
modelInstance = new ModelInstance(assets.get(model, Model.class), new Matrix4().setToScaling(0.6f, 0.6f, 0.6f));
DefaultShader.Config config = new Config();
config.defaultCullFace = GL20.GL_NONE;
ShaderProvider shaderProvider = new DefaultShaderProvider(config);
modelBatch = new ModelBatch(shaderProvider);
ModelBuilder builder = new ModelBuilder();
float groundSize = 1000f;
ground = new ModelInstance(builder.createRect(-groundSize, 0, groundSize, groundSize, 0, groundSize, groundSize, 0, -groundSize, -groundSize, 0, -groundSize, 0,
1, 0, new Material(), Usage.Position | Usage.Normal), new Matrix4().setToTranslation(0, -0.01f, 0));
environment = new Environment();
environment.set(new ColorAttribute(ColorAttribute.AmbientLight, 0.4f, 0.4f, 0.4f, 1f));
environment.add(new DirectionalLight().set(0.8f, 0.8f, 0.8f, -1f, -0.8f, -0.2f));
VirtualReality.renderer.listeners.add(this);
// VirtualReality.head.setCyclops(true);
}
示例4: VolumetricDepthShader
import com.badlogic.gdx.graphics.g3d.shaders.DefaultShader; //导入依赖的package包/类
public VolumetricDepthShader(final Renderable renderable, final ShaderProgram shaderProgramModelBorder, List<VolumetricLight> lights) {
this.renderable = renderable;
this.program = shaderProgramModelBorder;
this.lights = lights;
register(DefaultShader.Inputs.worldTrans, DefaultShader.Setters.worldTrans);
register(DefaultShader.Inputs.projViewTrans, DefaultShader.Setters.projViewTrans);
register(DefaultShader.Inputs.normalMatrix, DefaultShader.Setters.normalMatrix);
}
示例5: load
import com.badlogic.gdx.graphics.g3d.shaders.DefaultShader; //导入依赖的package包/类
/** Loads the asset.
* @param file the resolved file to load
* @param parameter */
@Override
public ShaderProgram load(AssetManager assetManager, String fileName, FileHandle file, ShaderParameter parameter) {
// TODO: verifier _testShader.getLog() et _testShader.isCompiled();
if(parameter != null)
_shader = new ShaderProgram(Gdx.files.internal(parameter.VertexShaderPath), Gdx.files.internal(fileName));
else
_shader = new ShaderProgram(DefaultShader.getDefaultVertexShader(), Gdx.files.internal(fileName).readString());
return _shader;
}
示例6: createShader
import com.badlogic.gdx.graphics.g3d.shaders.DefaultShader; //导入依赖的package包/类
@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;
}
示例7: create
import com.badlogic.gdx.graphics.g3d.shaders.DefaultShader; //导入依赖的package包/类
@Override
public void create () {
spriteBatch = new SpriteBatch();
font = new BitmapFont();
modelBatch = new ModelBatch();
DefaultShader.defaultCullFace = GL20.GL_FRONT;
camera = new PerspectiveCamera(67, Gdx.graphics.getWidth(), Gdx.graphics.getHeight());
camera.near = 0.5f;
camera.far = 1000;
controller = new FirstPersonCameraController(camera);
Gdx.input.setInputProcessor(controller);
lights = new Environment();
lights.set(new ColorAttribute(ColorAttribute.AmbientLight, 0.4f, 0.4f, 0.4f, 1.f));
lights.add(new DirectionalLight().set(1, 1, 1, 0, -1, 0));
Texture texture = new Texture(Gdx.files.internal("data/g3d/tiles.png"));
TextureRegion[][] tiles = TextureRegion.split(texture, 32, 32);
MathUtils.random.setSeed(0);
voxelWorld = new VoxelWorld(tiles[0], 20, 4, 20);
PerlinNoiseGenerator.generateVoxels(voxelWorld, 0, 63, 10);
float camX = voxelWorld.voxelsX / 2f;
float camZ = voxelWorld.voxelsZ / 2f;
float camY = voxelWorld.getHighest(camX, camZ) + 1.5f;
camera.position.set(camX, camY, camZ);
}
示例8: createPrefix
import com.badlogic.gdx.graphics.g3d.shaders.DefaultShader; //导入依赖的package包/类
public static String createPrefix(final Renderable renderable, final Config config) {
String prefix = DefaultShader.createPrefix(renderable, config);
final long mask = renderable.material.getMask();
// Atmosphere ground only if camera height is set
if ((mask & AtmosphereAttribute.CameraHeight) == AtmosphereAttribute.CameraHeight)
prefix += "#define atmosphereGround\n";
return prefix;
}
示例9: init
import com.badlogic.gdx.graphics.g3d.shaders.DefaultShader; //导入依赖的package包/类
public void init() {
vertexShaderArea.setSyntaxEditingStyle(SyntaxConstants.SYNTAX_STYLE_CPLUSPLUS);
vertexShaderArea.setCodeFoldingEnabled(true);
fragmentShaderArea.setSyntaxEditingStyle(SyntaxConstants.SYNTAX_STYLE_CPLUSPLUS);
fragmentShaderArea.setCodeFoldingEnabled(true);
shaderInfo = new ArrayList();
newShaderBtn.addActionListener(e -> add());
shaderCompileBtn.addActionListener(e -> {
displayDetectedUniforms();
save();
});
applyShaderBtn.addActionListener(e -> apply());
deleteShaderBtn.addActionListener(e -> delete());
uniformList.setModel(new DefaultListModel<>());
// TREE
DefaultMutableTreeNode rootNode = new DefaultMutableTreeNode("Editor");
// collectionTree.setModel(new DefaultTreeModel(rootNode));
collectionTree.getSelectionModel().setSelectionMode(TreeSelectionModel.SINGLE_TREE_SELECTION);
collectionTree.addTreeSelectionListener(e -> select());
DefaultMutableTreeNode autoWireNode = new DefaultMutableTreeNode("Autowired Uniforms");
UNIFORMS().keySet().stream().sorted((o1, o2) -> o1.alias.compareToIgnoreCase(o2.alias)).forEach(k -> {
autoWireNode.add(new DefaultMutableTreeNode(k.alias));
});
shaderNode = new DroppableTreeNode("Shaders");
DefaultTreeModel model = new DefaultTreeModel(rootNode);
collectionTree.setModel(model);
premadeNode = new DefaultMutableTreeNode("Native Shaders");
// Uber Shader
DynamicShader.Info uberShaderInfo = new DynamicShader.Info(false);
uberShaderInfo.name = "Uber Shader";
uberShaderInfo.desc = "The default LibGdx shader";
uberShaderInfo.vertex = DefaultShader.getDefaultVertexShader();
uberShaderInfo.fragment = DefaultShader.getDefaultFragmentShader();
premadeNode.add(new DefaultMutableTreeNode(uberShaderInfo));
DynamicShader.Info uberDepthShaderInfo = new DynamicShader.Info(false);
uberDepthShaderInfo.name = "Uber Depth Shader";
uberDepthShaderInfo.desc = "The default LibGdx Depth Shader";
uberDepthShaderInfo.vertex = DepthShader.getDefaultVertexShader();
uberDepthShaderInfo.fragment = DepthShader.getDefaultFragmentShader();
premadeNode.add(new DefaultMutableTreeNode(uberDepthShaderInfo));
rootNode.add(autoWireNode);
rootNode.add(premadeNode);
rootNode.add(shaderNode);
DefaultComboBoxModel<DynamicShader.GLPrimitiveType> primitiveModel = new DefaultComboBoxModel<>();
for (DynamicShader.GLPrimitiveType type : DynamicShader.GLPrimitiveType.values())
primitiveModel.addElement(type);
shaderPrimitiveSelect.setModel(primitiveModel);
// readFromDisk();
finalRendererText.setText(getFinalShader() != null ? getFinalShader().name : "");
collectionTree.addTreeSelectionListener(e -> {
DynamicShader.Info info = getFinalShader();
finalRendererText.setText(info != null ? info.name : "Error");
if (realtime)
if (info != null)
Gdx.app.postRunnable(editorController::compile);
});
}
示例10: ModelShaderProvider
import com.badlogic.gdx.graphics.g3d.shaders.DefaultShader; //导入依赖的package包/类
public ModelShaderProvider()
{
_config = new DefaultShader.Config(
Gdx.files.internal(SHADER_DIR + VERTEX).readString(),
Gdx.files.internal(SHADER_DIR + FRAGMENT).readString());
}
示例11: createPrefix
import com.badlogic.gdx.graphics.g3d.shaders.DefaultShader; //导入依赖的package包/类
public static String createPrefix(final Renderable renderable, final Config config)
{
String prefix = DefaultShader.createPrefix(renderable, config);
if (!config.depthBufferOnly) prefix += "#define PackedDepthFlag\n";
return prefix;
}
示例12: DefaultShaderProvider
import com.badlogic.gdx.graphics.g3d.shaders.DefaultShader; //导入依赖的package包/类
public DefaultShaderProvider (final DefaultShader.Config config) {
this.config = (config == null) ? new DefaultShader.Config() : config;
}
示例13: createShader
import com.badlogic.gdx.graphics.g3d.shaders.DefaultShader; //导入依赖的package包/类
@Override
protected Shader createShader (final Renderable renderable) {
return new DefaultShader(renderable, config);
}
示例14: getShader
import com.badlogic.gdx.graphics.g3d.shaders.DefaultShader; //导入依赖的package包/类
private Shader getShader (Renderable renderable) {
Shader shader = useGPU ? new ParticleShader(renderable, new ParticleShader.Config(mode)) :
new DefaultShader(renderable);
shader.init();
return shader;
}