use of com.talosvfx.talos.runtime.utils.ShaderDescriptor in project HyperLap2D by rednblackgames.
the class ResourceManager method findShaderDescriptorOnLoad.
private ShaderDescriptor findShaderDescriptorOnLoad(String assetName) {
ShaderDescriptor asset = shaderDescriptorObjectMap.get(assetName);
if (asset == null) {
// Look in all paths, and hopefully load the requested asset, or fail (crash)
final FileHandle file = new FileHandle(talosResPath + File.separator + assetName);
asset = new ShaderDescriptor();
if (file.exists()) {
asset.setData(file.readString());
}
}
return asset;
}
use of com.talosvfx.talos.runtime.utils.ShaderDescriptor in project talos by rockbite.
the class TalosAssetProvider method findShaderDescriptorOnLoad.
private ShaderDescriptor findShaderDescriptorOnLoad(String assetName) {
ShaderDescriptor asset = shaderDescriptorObjectMap.get(assetName);
if (asset == null) {
// Look in all paths, and hopefully load the requested asset, or fail (crash)
final FileHandle file = findFileByName(assetName);
asset = new ShaderDescriptor();
if (file != null && file.exists()) {
asset.setData(file.readString());
}
}
return asset;
}
use of com.talosvfx.talos.runtime.utils.ShaderDescriptor in project talos by rockbite.
the class ShadedSpriteModuleWrapper method configureSlots.
@Override
protected void configureSlots() {
addOutputSlot("output", ShadedSpriteModule.OUTPUT);
dropLabel = new Label("drop .shdr file here", getSkin());
dropLabel.setAlignment(Align.center);
dropLabel.setWrap(true);
contentWrapper.add(dropLabel).padTop(10f).padBottom(10f).size(180, 50).left().expand();
FileActorBinder.register(this, "shdr");
addListener(new FileActorBinder.FileEventListener() {
@Override
public void onFileSet(FileHandle fileHandle) {
try {
String shaderFilePath = fileHandle.path();
shaderFileName = fileHandle.name();
setShaderLabel(shaderFileName);
setShaderDescriptor(new ShaderDescriptor(fileHandle), shaderFileName);
} catch (Exception e) {
}
}
});
}
use of com.talosvfx.talos.runtime.utils.ShaderDescriptor in project talos by rockbite.
the class ShadedSpriteModule method updateShader.
private void updateShader(ShaderDescriptor shaderDescriptor) {
this.shaderDescriptor = shaderDescriptor;
if (shaderDescriptor != null) {
ShadedDrawable drawable = (ShadedDrawable) outputValue.getDrawable();
drawable.setShader(shaderDescriptor.getFragCode());
for (String uniformName : shaderDescriptor.getUniformMap().keys()) {
ShaderDescriptor.UniformData data = shaderDescriptor.getUniformMap().get(uniformName);
if (data.type == ShaderDescriptor.Type.TEXTURE) {
TextureRegion textureRegion = graph.getEffectDescriptor().getAssetProvider().findAsset(data.payload, TextureRegion.class);
textureMap.put(uniformName, textureRegion);
}
}
drawable.setTextures(textureMap);
}
}
use of com.talosvfx.talos.runtime.utils.ShaderDescriptor in project talos by rockbite.
the class ShadedSpriteModule method setModuleGraph.
@Override
public void setModuleGraph(ParticleEmitterDescriptor graph) {
super.setModuleGraph(graph);
final AssetProvider assetProvider = graph.getEffectDescriptor().getAssetProvider();
if (shdrFileName != null && !shdrFileName.isEmpty()) {
setShaderData(assetProvider.findAsset(shdrFileName, ShaderDescriptor.class), shdrFileName);
}
updateShader(shaderDescriptor);
}
Aggregations