use of com.gempukku.libgdx.graph.data.GraphProperty in project gdx-graph by MarcinSc.
the class ModelShaderPreviewWidget method createShader.
private void createShader(final Graph<? extends GraphNode, ? extends GraphConnection, ? extends GraphProperty> graph) {
try {
timeKeeper = new DefaultTimeKeeper();
graphShader = GraphShaderBuilder.buildModelShader("Test", WhitePixel.sharedInstance.texture, graph, true);
frameBuffer = new FrameBuffer(Pixmap.Format.RGBA8888, width, height, false);
createModel();
MapWritablePropertyContainer globalPropertyContainer = new MapWritablePropertyContainer();
for (GraphProperty property : graph.getProperties()) {
if (property.getLocation() == PropertyLocation.Global_Uniform) {
ShaderFieldType propertyType = ShaderFieldTypeRegistry.findShaderFieldType(property.getType());
globalPropertyContainer.setValue(property.getName(), propertyType.convertFromJson(property.getData()));
}
}
shaderContext.setGlobalPropertyContainer(globalPropertyContainer);
localPropertyContainer = new MapWritablePropertyContainer();
for (GraphProperty property : graph.getProperties()) {
if (property.getLocation() == PropertyLocation.Uniform) {
ShaderFieldType propertyType = ShaderFieldTypeRegistry.findShaderFieldType(property.getType());
Object value = propertyType.convertFromJson(property.getData());
if (propertyType.isTexture()) {
if (value != null) {
try {
Texture texture = new Texture(Gdx.files.absolute((String) value));
graphShader.addManagedResource(texture);
localPropertyContainer.setValue(property.getName(), new TextureRegion(texture));
} catch (Exception exp) {
localPropertyContainer.setValue(property.getName(), WhitePixel.sharedInstance.textureRegion);
}
} else {
localPropertyContainer.setValue(property.getName(), WhitePixel.sharedInstance.textureRegion);
}
}
}
}
shaderContext.setTimeProvider(timeKeeper);
shaderInitialized = true;
} catch (Exception exp) {
exp.printStackTrace();
if (graphShader != null)
graphShader.dispose();
}
}
use of com.gempukku.libgdx.graph.data.GraphProperty in project gdx-graph by MarcinSc.
the class EndScreenShaderBoxProducer method createPipelineGraphBox.
@Override
public GraphBox createPipelineGraphBox(Skin skin, String id, JsonValue data) {
final ScreenShaderPreviewBoxPart previewBoxPart = new ScreenShaderPreviewBoxPart();
previewBoxPart.initialize(data);
GraphBoxImpl result = new GraphBoxImpl(id, getConfiguration()) {
@Override
public void graphChanged(GraphChangedEvent event, boolean hasErrors, Graph<? extends GraphNode, ? extends GraphConnection, ? extends GraphProperty> graph) {
if (event.isData() || event.isStructure()) {
previewBoxPart.graphChanged(hasErrors, graph);
}
}
};
addConfigurationInputsAndOutputs(result);
result.addGraphBoxPart(new SectionBoxPart("Rendering config"));
BlendingBoxPart blendingBox = new BlendingBoxPart();
blendingBox.initialize(data);
result.addGraphBoxPart(blendingBox);
result.addGraphBoxPart(new SectionBoxPart("Preview"));
result.addGraphBoxPart(previewBoxPart);
return result;
}
Aggregations