Allows custom effect shaders in JavaFX using OpenGL (GLSL) or DirectX (HLSL).
Examples can be found in the wiki and in the samples package.
A custom shader can be applied to any JavaFX node hierarchy by using setEffect
:
StackPane pane = new StackPane(getOtherContent());
// Instead of using existing JavaFX effects like SepiaTone or ColorAdjust,
// we can apply our own effect with custom shaders:
MyCustomShaderEffect effect = new MyCustomShaderEffect();
pane.setEffect(effect.getFXEffect());
// Custom parameters can be set and used in the shader:
effect.setMyCustomParameter(2.0);
Instructions on how to implement a custom shader effect can be found in the wiki.
A custom material can be applied to any Shape3D by using setMaterial
:
Sphere sphere = new Sphere(100);
// Instead of being limited to PhongMaterial,
// we can apply our own material with custom shaders:
MyCustomShaderMaterial material = new MyCustomShaderMaterial();
sphere.setMaterial(material.getFXMaterial());
// Custom parameters or textures can be set and used in the shader:
material.setMyCustomParameter(3.0);
material.setMyCustomTexture(new Image("myCustomTexture.png"));
To include JFXShader in a Maven project, add the following dependency to the pom.xml:
<dependency>
<groupId>de.teragam</groupId>
<artifactId>jfxshader</artifactId>
<version>1.3.1</version>
</dependency>
This library is bound to the restrictions of the JavaFX effects system. The following limitations apply:
fxc
compiler. The following command can be used to compile
HLSL shaders: fxc.exe /nologo /T ps_3_0 /Fo .\shader.obj .\shader.hlsl
prism.forceGPU
system property
to true
.prism.dirtyopts
system property to false
.