Class ShaderUtil
In some shader program making method:
| Letter | Means |
|---|---|
| V | Vertex shader |
| T | Tessellation (Control and Evaluation) shader |
| G | Geometry shader |
| F | Fragment shader |
| C | Compute shader |
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic final recordstatic interfacestatic class -
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final bytestatic final byte -
Method Summary
Modifier and TypeMethodDescriptionstatic voidapplyImageBilateralFilter(int source, boolean useRed, byte radius, float sigmaSpace, float sigmaRange, int texWidth, int texHeight, boolean bit16OutMode) Separated GPU bilateral filter.static voidapplyImageBilateralFilter(int source, boolean useRed, byte radius, float sigmaSpace, float sigmaRange, int texWidth, int texHeight, int result, boolean bit16OutMode) Separated GPU bilateral filter.static voidapplyImageBilateralFilter(int source, int sourceOffsetX, int sourceOffsetY, boolean useRed, byte radius, float sigmaSpace, float sigmaRange, int texWidth, int texHeight, int result, int resultOffsetX, int resultOffsetY, boolean bit16OutMode) Separated GPU bilateral filter.static voidapplyImageGaussianBlur(int source, boolean useRed, byte step, int texWidth, int texHeight, boolean bit16OutMode) Simple gaussian blur computing, only for RGBA and R texture.static voidapplyImageGaussianBlur(int source, boolean useRed, byte step, int texWidth, int texHeight, int result, boolean bit16OutMode) Simple gaussian blur computing, only for RGBA and R texture.static voidapplyImageGaussianBlur(int source, int sourceOffsetX, int sourceOffsetY, boolean useRed, byte step, int texWidth, int texHeight, int result, int resultOffsetX, int resultOffsetY, boolean bit16OutMode) Simple gaussian blur computing, only for RGBA and R texture.static voidapplyRadialBlur(int source, org.lwjgl.util.vector.Vector2f center, short samples, float radius, float alphaStrength, boolean isAdditiveBlend) Classical radial blur effect.static voidapplyRadialBlur(int source, org.lwjgl.util.vector.Vector2f center, short samples, float radius, float alphaStrength, int dstX, int dstY, int dstWidth, int dstHeight, boolean isAdditiveBlend) Classical radial blur effect.static voidblitFBO(int read, int draw) static voidblitFBO(int read, int draw, int width, int height) static voidblitFBO(int read, int draw, int srcX1, int srcY1, int dstX1, int dstY1) static voidblitFBO(int read, int draw, int srcX0, int srcY0, int srcX1, int srcY1, int dstX0, int dstY0, int dstX1, int dstY1) static voidblitToScreen(int fbo) static voidcopyFromScreen(int fbo) static longcreateBindlessImage(int texture, int internalFormat) static longcreateBindlessImage(int texture, int level, boolean layered, int layer, int access, int internalFormat) static longcreateBindlessTexture(int texture) static intcreateComputeShaders(String loggerTag, String... source) static intcreateComputeShaders(String loggerTag, ShaderUtil.LinkCondition beforeLinkExc, String... source) static intcreateComputeShadersFormPath(String loggerTag, String... shadersPath) static intcreateComputeShadersFormPath(String loggerTag, ShaderUtil.LinkCondition beforeLinkExc, String... shadersPath) static intcreateShader(String loggerTag, String shader, int shaderType) static intcreateShaderProgram(String loggerTag, int[] types, String... shaders) static intcreateShaderProgram(String loggerTag, ShaderUtil.LinkCondition beforeLinkExc, int[] types, String... shaders) static intcreateShaderProgramFromPath(String loggerTag, String... shadersPath) static intcreateShaderProgramFromPath(String loggerTag, ShaderUtil.LinkCondition beforeLinkExc, String... shadersPath) static intcreateShaderVF(String loggerTag, String vert, String frag) static intcreateShaderVF(String loggerTag, ShaderUtil.LinkCondition beforeLinkExc, String vert, String frag) static intcreateShaderVFFormPath(String loggerTag, String vertPath, String fragPath) static intcreateShaderVFFormPath(String loggerTag, ShaderUtil.LinkCondition beforeLinkExc, String vertPath, String fragPath) static intcreateShaderVGF(String loggerTag, String vert, String geom, String frag) static intcreateShaderVGF(String loggerTag, ShaderUtil.LinkCondition beforeLinkExc, String vert, String geom, String frag) static intcreateShaderVGFFromPath(String loggerTag, String vertPath, String geomPath, String fragPath) static intcreateShaderVGFFromPath(String loggerTag, ShaderUtil.LinkCondition beforeLinkExc, String vertPath, String geomPath, String fragPath) static intstatic intcreateShaderVTF(String loggerTag, ShaderUtil.LinkCondition beforeLinkExc, String vert, String tessC, String tessE, String frag) static intcreateShaderVTFFromPath(String loggerTag, String vertPath, String tessCPath, String tessEPath, String fragPath) static intcreateShaderVTFFromPath(String loggerTag, ShaderUtil.LinkCondition beforeLinkExc, String vertPath, String tessCPath, String tessEPath, String fragPath) static intcreateShaderVTGF(String loggerTag, String vert, String tessC, String tessE, String geom, String frag) static intcreateShaderVTGF(String loggerTag, ShaderUtil.LinkCondition beforeLinkExc, String vert, String tessC, String tessE, String geom, String frag) static intcreateShaderVTGFFromPath(String loggerTag, String vertPath, String tessCPath, String tessEPath, String geomPath, String fragPath) static intcreateShaderVTGFFromPath(String loggerTag, ShaderUtil.LinkCondition beforeLinkExc, String vertPath, String tessCPath, String tessEPath, String geomPath, String fragPath) static int[]genLegacySDF(int source, int checkChannel, int sourceOffsetX, int sourceOffsetY, int localWidth, int localHeight, int extraWidth, int extraHeight, float outsideThreshold, byte step, float resultInsidePreMultiply, float resultOutsidePreMultiply) CPU multi-thread parallel SDF generation method.static int[]genLegacySDF(int source, int checkChannel, int sourceOffsetX, int sourceOffsetY, int localWidth, int localHeight, int extraWidth, int extraHeight, float outsideThreshold, byte step, float resultInsidePreMultiply, float resultOutsidePreMultiply, int resultTex, int resultOffsetX, int resultOffsetY) CPU multi-thread parallel SDF generation method.static intgenNormalMapFromRGB(int source, int sourceOffsetX, int sourceOffsetY, int srcLocalWidth, int srcLocalHeight, ShaderUtil.NormalMapGenParam param) GPU normal map generation from RGB texture for sprites.static intgenNormalMapFromRGB(int source, int sourceOffsetX, int sourceOffsetY, int srcLocalWidth, int srcLocalHeight, ShaderUtil.NormalMapGenParam param, int resultTex, int resultOffsetX, int resultOffsetY) GPU normal map generation from RGB texture for sprites.static intgenNormalMapFromRGB(int source, int srcLocalWidth, int srcLocalHeight, ShaderUtil.NormalMapGenParam param) GPU normal map generation from RGB texture for sprites.static intgenNormalMapFromRGB(int source, int srcLocalWidth, int srcLocalHeight, ShaderUtil.NormalMapGenParam param, int resultTex) GPU normal map generation from RGB texture for sprites.static int[]genSDF(int source, int checkChannel, int localWidth, int localHeight, int extraWidth, int extraHeight, float outsideThreshold, byte step, float resultInsidePreMultiply, float resultOutsidePreMultiply) Fast GPU SDF generation method.static int[]genSDF(int source, int checkChannel, int localWidth, int localHeight, int extraWidth, int extraHeight, float outsideThreshold, byte step, float resultInsidePreMultiply, float resultOutsidePreMultiply, boolean bit16OutMode) Fast GPU SDF generation method.static int[]genSDF(int source, int checkChannel, int localWidth, int localHeight, int extraWidth, int extraHeight, float outsideThreshold, byte step, float resultInsidePreMultiply, float resultOutsidePreMultiply, int resultTex) Fast GPU SDF generation method.static int[]genSDF(int source, int checkChannel, int localWidth, int localHeight, int extraWidth, int extraHeight, float outsideThreshold, byte step, float resultInsidePreMultiply, float resultOutsidePreMultiply, int resultTex, boolean bit16OutMode) Fast GPU SDF generation method.static int[]genSDF(int source, int checkChannel, int sourceOffsetX, int sourceOffsetY, int localWidth, int localHeight, int extraWidth, int extraHeight, float outsideThreshold, byte step, float resultInsidePreMultiply, float resultOutsidePreMultiply, boolean bit16OutMode) Fast GPU SDF generation method.static int[]genSDF(int source, int checkChannel, int sourceOffsetX, int sourceOffsetY, int localWidth, int localHeight, int extraWidth, int extraHeight, float outsideThreshold, byte step, float resultInsidePreMultiply, float resultOutsidePreMultiply, int resultTex, int resultOffsetX, int resultOffsetY, boolean bit16OutMode) Fast GPU SDF generation method.static StringgetShaderName(int type) static intgetTypeFromFormat(String format) static intgetTypeFromPath(String path) static intimageDFT(int source, boolean useRed, int texWidth, int texHeight, boolean f16OutMode) GPU DFT(Discrete Fourier Transform), slow but still faster more than CPU computing.static intimageDFT(int source, boolean useRed, int texWidth, int texHeight, int result, boolean f16OutMode) GPU DFT(Discrete Fourier Transform), slow but still faster more than CPU computing.static intimageDFT(int source, int sourceOffsetX, int sourceOffsetY, boolean useRed, int texWidth, int texHeight, boolean f16OutMode) GPU DFT(Discrete Fourier Transform), slow but still faster more than CPU computing.static intimageDFT(int source, int sourceOffsetX, int sourceOffsetY, boolean useRed, int texWidth, int texHeight, int result, int resultOffsetX, int resultOffsetY, boolean f16OutMode) GPU DFT(Discrete Fourier Transform), slow but still faster more than CPU computing.static intimageIDFT(int source, boolean useRed, int texWidth, int texHeight, boolean f16InMode, boolean f16OutMode) GPU IDFT(Inverse Discrete Fourier Transform), slow but still faster more than CPU computing.static intimageIDFT(int source, boolean useRed, int texWidth, int texHeight, int result, boolean f16InMode, boolean f16OutMode) GPU IDFT(Inverse Discrete Fourier Transform), slow but still faster more than CPU computing.static intimageIDFT(int source, int sourceOffsetX, int sourceOffsetY, boolean useRed, int texWidth, int texHeight, boolean f16InMode, boolean f16OutMode) GPU IDFT(Inverse Discrete Fourier Transform), slow but still faster more than CPU computing.static intimageIDFT(int source, int sourceOffsetX, int sourceOffsetY, boolean useRed, int texWidth, int texHeight, int result, int resultOffsetX, int resultOffsetY, boolean f16InMode, boolean f16OutMode) GPU IDFT(Inverse Discrete Fourier Transform), slow but still faster more than CPU computing.static ShaderUtil.LinkConditionmakeShaderBindingLocation(ShaderUtil.BindingLocationStruct... bindingLocations) static voidreleaseBindlessImage(long image) static voidreleaseBindlessTexture(long texture)
-
Field Details
-
BIND_VERTEX_ATTRIB
public static final byte BIND_VERTEX_ATTRIB- See Also:
-
BIND_FRAGMENT_OUTPUT
public static final byte BIND_FRAGMENT_OUTPUT- See Also:
-
-
Method Details
-
getShaderName
-
getTypeFromPath
-
getTypeFromFormat
-
makeShaderBindingLocation
public static ShaderUtil.LinkCondition makeShaderBindingLocation(ShaderUtil.BindingLocationStruct... bindingLocations) -
createShaderVF
public static int createShaderVF(@Nullable String loggerTag, @Nullable ShaderUtil.LinkCondition beforeLinkExc, String vert, String frag) - Parameters:
loggerTag- for locating in log when created or failed.beforeLinkExc- accept ainttype program id, executing something after all of theglAttachShadercalls but beforeglLinkProgramcalls.
-
createShaderVF
- Parameters:
loggerTag- for locating in log when created or failed.
-
createShaderVFFormPath
public static int createShaderVFFormPath(@Nullable String loggerTag, @Nullable ShaderUtil.LinkCondition beforeLinkExc, String vertPath, String fragPath) - Parameters:
loggerTag- for locating in log when created or failed.beforeLinkExc- accept ainttype program id, executing something after all of theglAttachShadercalls but beforeglLinkProgramcalls.
-
createShaderVFFormPath
public static int createShaderVFFormPath(@Nullable String loggerTag, String vertPath, String fragPath) - Parameters:
loggerTag- for locating in log when created or failed.
-
createShaderVGF
public static int createShaderVGF(@Nullable String loggerTag, @Nullable ShaderUtil.LinkCondition beforeLinkExc, String vert, String geom, String frag) - Parameters:
loggerTag- for locating in log when created or failed.beforeLinkExc- accept ainttype program id, executing something after all of theglAttachShadercalls but beforeglLinkProgramcalls.
-
createShaderVGF
public static int createShaderVGF(@Nullable String loggerTag, String vert, String geom, String frag) - Parameters:
loggerTag- for locating in log when created or failed.
-
createShaderVGFFromPath
public static int createShaderVGFFromPath(@Nullable String loggerTag, @Nullable ShaderUtil.LinkCondition beforeLinkExc, String vertPath, String geomPath, String fragPath) - Parameters:
loggerTag- for locating in log when created or failed.beforeLinkExc- accept ainttype program id, executing something after all of theglAttachShadercalls but beforeglLinkProgramcalls.
-
createShaderVGFFromPath
public static int createShaderVGFFromPath(@Nullable String loggerTag, String vertPath, String geomPath, String fragPath) - Parameters:
loggerTag- for locating in log when created or failed.
-
createShaderVTF
public static int createShaderVTF(@Nullable String loggerTag, @Nullable ShaderUtil.LinkCondition beforeLinkExc, String vert, String tessC, String tessE, String frag) - Parameters:
loggerTag- for locating in log when created or failed.beforeLinkExc- accept ainttype program id, executing something after all of theglAttachShadercalls but beforeglLinkProgramcalls.
-
createShaderVTF
public static int createShaderVTF(@Nullable String loggerTag, String vert, String tessC, String tessE, String frag) - Parameters:
loggerTag- for locating in log when created or failed.
-
createShaderVTFFromPath
public static int createShaderVTFFromPath(@Nullable String loggerTag, @Nullable ShaderUtil.LinkCondition beforeLinkExc, String vertPath, String tessCPath, String tessEPath, String fragPath) - Parameters:
loggerTag- for locating in log when created or failed.beforeLinkExc- accept ainttype program id, executing something after all of theglAttachShadercalls but beforeglLinkProgramcalls.
-
createShaderVTFFromPath
public static int createShaderVTFFromPath(@Nullable String loggerTag, String vertPath, String tessCPath, String tessEPath, String fragPath) - Parameters:
loggerTag- for locating in log when created or failed.
-
createShaderVTGF
public static int createShaderVTGF(@Nullable String loggerTag, @Nullable ShaderUtil.LinkCondition beforeLinkExc, String vert, String tessC, String tessE, String geom, String frag) - Parameters:
loggerTag- for locating in log when created or failed.beforeLinkExc- accept ainttype program id, executing something after all of theglAttachShadercalls but beforeglLinkProgramcalls.
-
createShaderVTGF
public static int createShaderVTGF(@Nullable String loggerTag, String vert, String tessC, String tessE, String geom, String frag) - Parameters:
loggerTag- for locating in log when created or failed.
-
createShaderVTGFFromPath
public static int createShaderVTGFFromPath(@Nullable String loggerTag, @Nullable ShaderUtil.LinkCondition beforeLinkExc, String vertPath, String tessCPath, String tessEPath, String geomPath, String fragPath) - Parameters:
loggerTag- for locating in log when created or failed.beforeLinkExc- accept ainttype program id, executing something after all of theglAttachShadercalls but beforeglLinkProgramcalls.
-
createShaderVTGFFromPath
public static int createShaderVTGFFromPath(@Nullable String loggerTag, String vertPath, String tessCPath, String tessEPath, String geomPath, String fragPath) - Parameters:
loggerTag- for locating in log when created or failed.
-
createComputeShaders
public static int createComputeShaders(@Nullable String loggerTag, @Nullable ShaderUtil.LinkCondition beforeLinkExc, String... source) - Parameters:
loggerTag- for locating in log when created or failed.beforeLinkExc- accept ainttype program id, executing something after all of theglAttachShadercalls but beforeglLinkProgramcalls.source- may only have one shader source normally.
-
createComputeShaders
- Parameters:
loggerTag- for locating in log when created or failed.source- may only have one shader source normally.
-
createComputeShadersFormPath
public static int createComputeShadersFormPath(@Nullable String loggerTag, @Nullable ShaderUtil.LinkCondition beforeLinkExc, String... shadersPath) - Parameters:
loggerTag- for locating in log when created or failed.beforeLinkExc- accept ainttype program id, executing something after all of theglAttachShadercalls but beforeglLinkProgramcalls.shadersPath- may only have one shader source normally.
-
createComputeShadersFormPath
- Parameters:
loggerTag- for locating in log when created or failed.shadersPath- may only have one shader source normally.
-
createShader
- Parameters:
loggerTag- for locating in log when created or failed.
-
createShaderProgram
public static int createShaderProgram(@Nullable String loggerTag, @Nullable ShaderUtil.LinkCondition beforeLinkExc, int[] types, String... shaders) - Parameters:
loggerTag- for locating in log when created or failed.beforeLinkExc- accept ainttype program id, executing something after all of theglAttachShadercalls but beforeglLinkProgramcalls.
-
createShaderProgram
- Parameters:
loggerTag- for locating in log when created or failed.
-
createShaderProgramFromPath
public static int createShaderProgramFromPath(@Nullable String loggerTag, @Nullable ShaderUtil.LinkCondition beforeLinkExc, String... shadersPath) - Parameters:
loggerTag- for locating in log when created or failed.beforeLinkExc- accept ainttype program id, executing something after all of theglAttachShadercalls but beforeglLinkProgramcalls.shadersPath- must be under the format:Shader Type Legal Format Vertex *.vert *.vsh Tess-Control *.tesc Tess-Evaluation *.tese Geometry *.geom *.gsh Fragment *.frag *.fsh Compute *.comp *.csh
-
createShaderProgramFromPath
- Parameters:
loggerTag- for locating in log when created or failed.shadersPath- should be in the format:Shader Type Legal Format Vertex *.vert *.vsh Tess-Control *.tesc Tess-Evaluation *.tese Geometry *.geom *.gsh Fragment *.frag *.fsh Compute *.comp *.csh
-
createBindlessTexture
public static long createBindlessTexture(int texture) -
createBindlessImage
public static long createBindlessImage(int texture, int internalFormat) -
createBindlessImage
public static long createBindlessImage(int texture, int level, boolean layered, int layer, int access, int internalFormat) -
releaseBindlessTexture
public static void releaseBindlessTexture(long texture) -
releaseBindlessImage
public static void releaseBindlessImage(long image) -
blitFBO
public static void blitFBO(int read, int draw, int srcX0, int srcY0, int srcX1, int srcY1, int dstX0, int dstY0, int dstX1, int dstY1) -
blitFBO
public static void blitFBO(int read, int draw, int srcX1, int srcY1, int dstX1, int dstY1) -
blitFBO
public static void blitFBO(int read, int draw, int width, int height) -
blitFBO
public static void blitFBO(int read, int draw) -
copyFromScreen
public static void copyFromScreen(int fbo) -
blitToScreen
public static void blitToScreen(int fbo) -
genLegacySDF
public static int[] genLegacySDF(int source, int checkChannel, int sourceOffsetX, int sourceOffsetY, int localWidth, int localHeight, int extraWidth, int extraHeight, float outsideThreshold, byte step, float resultInsidePreMultiply, float resultOutsidePreMultiply, int resultTex, int resultOffsetX, int resultOffsetY) CPU multi-thread parallel SDF generation method.Vanilla supported.
- Parameters:
source- must be RGBA8 texture.checkChannel- valid value:GL11.GL_RED,GL11.GL_GREEN,GL11.GL_BLUE,GL11.GL_ALPHA,GL11.GL_RGB; default isGL11.GL_ALPHA.sourceOffsetX- the source texture region left-bottom origin x-position.sourceOffsetY- the source texture region left-bottom origin y-position.extraWidth- border width for sdf texture, positive integer value required.extraHeight- border height for sdf texture, positive integer value required.outsideThreshold- when pixel check value less than or equal the value, it will be considered as outside.step- 8 or 9 for general usage, range from 0 to 30; also you can useCalculateUtil.getExponentPOTMin(Math.max(localWidth, localHeight))for automatic step calculation.resultInsidePreMultiply- 0.01 or (1.0f / required thickness) for general usage.resultOutsidePreMultiply- 0.01 or (1.0f / max(extraWidth, extraHeight)) for general usage.resultTex- texture to store result, must beGL11.GL_INTENSITY8texture and size must be greater than or equal to the final size.resultOffsetX- the result texture region left-bottom origin x-position.resultOffsetY- the result texture region left-bottom origin x-position.- Returns:
- generated sdf texture with
GL11.GL_INTENSITY8POT at [0.0, 1.0], texture return 0 if failed; int[] = {texture, validWidth, validHeight, glRealWidth, glRealHeight}
-
genLegacySDF
public static int[] genLegacySDF(int source, int checkChannel, int sourceOffsetX, int sourceOffsetY, int localWidth, int localHeight, int extraWidth, int extraHeight, float outsideThreshold, byte step, float resultInsidePreMultiply, float resultOutsidePreMultiply) CPU multi-thread parallel SDF generation method.Vanilla supported.
- Parameters:
source- must be RGBA8 texture.checkChannel- valid value:GL11.GL_RED,GL11.GL_GREEN,GL11.GL_BLUE,GL11.GL_ALPHA,GL11.GL_RGB; default isGL11.GL_ALPHA.sourceOffsetX- the source texture region left-bottom origin x-position.sourceOffsetY- the source texture region left-bottom origin y-position.extraWidth- border width for sdf texture, positive integer value required.extraHeight- border height for sdf texture, positive integer value required.outsideThreshold- when pixel check value less than or equal the value, it will be considered as outside.step- 8 or 9 for general usage, range from 0 to 30; also you can useCalculateUtil.getExponentPOTMin(Math.max(localWidth, localHeight))for automatic step calculation.resultInsidePreMultiply- 0.01 or (1.0f / required thickness) for general usage.resultOutsidePreMultiply- 0.01 or (1.0f / max(extraWidth, extraHeight)) for general usage.- Returns:
- generated sdf texture with
GL11.GL_INTENSITY8POT at [0.0, 1.0], texture return 0 if failed; int[] = {texture, validWidth, validHeight, glRealWidth, glRealHeight}
-
genSDF
public static int[] genSDF(int source, int checkChannel, int sourceOffsetX, int sourceOffsetY, int localWidth, int localHeight, int extraWidth, int extraHeight, float outsideThreshold, byte step, float resultInsidePreMultiply, float resultOutsidePreMultiply, int resultTex, int resultOffsetX, int resultOffsetY, boolean bit16OutMode) Fast GPU SDF generation method.OpenGL 4.3 required, compute shader supported required.
- Parameters:
source- must be RGBA8 texture.checkChannel- valid value:GL11.GL_RED,GL11.GL_GREEN,GL11.GL_BLUE,GL11.GL_ALPHA,GL11.GL_RGB; default isGL11.GL_ALPHA.sourceOffsetX- the source texture region left-bottom origin x-position.sourceOffsetY- the source texture region left-bottom origin y-position.extraWidth- border width for sdf texture, positive integer value required.extraHeight- border height for sdf texture, positive integer value required.outsideThreshold- when pixel check value less than or equal the value, it will be considered as outside.step- 8 or 9 for general usage, range from 0 to 30; also you can useCalculateUtil.getExponentPOTMin(Math.max(localWidth, localHeight))for automatic step calculation.resultInsidePreMultiply- 0.01 or (1.0f / required thickness) for general usage.resultOutsidePreMultiply- 0.01 or (1.0f / max(extraWidth, extraHeight)) for general usage.resultTex- texture to store result, must be R8 texture and size must be greater than or equal to the final size.resultOffsetX- the result texture region left-bottom origin x-position.resultOffsetY- the result texture region left-bottom origin x-position.bit16OutMode- true for R16 texture, false for R8 texture.- Returns:
- generated sdf texture with R8/R16 NPOT at [0.0, 1.0], texture return 0 if failed; int[] = {texture, width, height}
-
genSDF
public static int[] genSDF(int source, int checkChannel, int localWidth, int localHeight, int extraWidth, int extraHeight, float outsideThreshold, byte step, float resultInsidePreMultiply, float resultOutsidePreMultiply, int resultTex, boolean bit16OutMode) Fast GPU SDF generation method.OpenGL 4.3 required, compute shader supported required.
- Parameters:
source- must be RGBA8 texture.checkChannel- valid value:GL11.GL_RED,GL11.GL_GREEN,GL11.GL_BLUE,GL11.GL_ALPHA,GL11.GL_RGB; default isGL11.GL_ALPHA.extraWidth- border width for sdf texture, positive integer value required.extraHeight- border height for sdf texture, positive integer value required.outsideThreshold- when pixel check value less than or equal the value, it will be considered as outside.step- 8 or 9 for general usage, range from 0 to 30; also you can useCalculateUtil.getExponentPOTMin(Math.max(localWidth, localHeight))for automatic step calculation.resultInsidePreMultiply- 0.01 or (1.0f / required thickness) for general usage.resultOutsidePreMultiply- 0.01 or (1.0f / max(extraWidth, extraHeight)) for general usage.resultTex- texture to store result, must be R8 texture and size must be greater than or equal to the final size.bit16OutMode- true for R16 texture, false for R8 texture.- Returns:
- generated sdf texture with R8/R16 NPOT at [0.0, 1.0], texture return 0 if failed; int[] = {texture, width, height}
-
genSDF
public static int[] genSDF(int source, int checkChannel, int localWidth, int localHeight, int extraWidth, int extraHeight, float outsideThreshold, byte step, float resultInsidePreMultiply, float resultOutsidePreMultiply, int resultTex) Fast GPU SDF generation method.OpenGL 4.3 required, compute shader supported required.
- Parameters:
source- must be RGBA8 texture.checkChannel- valid value:GL11.GL_RED,GL11.GL_GREEN,GL11.GL_BLUE,GL11.GL_ALPHA,GL11.GL_RGB; default isGL11.GL_ALPHA.extraWidth- border width for sdf texture, positive integer value required.extraHeight- border height for sdf texture, positive integer value required.outsideThreshold- when pixel check value less than or equal the value, it will be considered as outside.step- 8 or 9 for general usage, range from 0 to 30; also you can useCalculateUtil.getExponentPOTMin(Math.max(localWidth, localHeight))for automatic step calculation.resultInsidePreMultiply- 0.01 or (1.0f / required thickness) for general usage.resultOutsidePreMultiply- 0.01 or (1.0f / max(extraWidth, extraHeight)) for general usage.resultTex- texture to store result, must be R8 texture and size must be greater than or equal to the final size.- Returns:
- generated sdf texture with R8 NPOT at [0.0, 1.0], texture return 0 if failed; int[] = {texture, width, height}
-
genSDF
public static int[] genSDF(int source, int checkChannel, int sourceOffsetX, int sourceOffsetY, int localWidth, int localHeight, int extraWidth, int extraHeight, float outsideThreshold, byte step, float resultInsidePreMultiply, float resultOutsidePreMultiply, boolean bit16OutMode) Fast GPU SDF generation method.OpenGL 4.3 required, compute shader supported required.
- Parameters:
source- must be RGBA8 texture.sourceOffsetX- the source texture region left-bottom origin x-position.sourceOffsetY- the source texture region left-bottom origin y-position.checkChannel- valid value:GL11.GL_RED,GL11.GL_GREEN,GL11.GL_BLUE,GL11.GL_ALPHA,GL11.GL_RGB; default isGL11.GL_ALPHA.extraWidth- border width for sdf texture, positive integer value required.extraHeight- border height for sdf texture, positive integer value required.outsideThreshold- when pixel check value less than or equal the value, it will be considered as outside.step- 8 or 9 for general usage, range from 0 to 30; also you can useCalculateUtil.getExponentPOTMin(Math.max(localWidth, localHeight))for automatic step calculation.resultInsidePreMultiply- 0.01 or (1.0f / required thickness) for general usage.resultOutsidePreMultiply- 0.01 or (1.0f / max(extraWidth, extraHeight)) for general usage.bit16OutMode- true for R16 texture, false for R8 texture.- Returns:
- generated sdf texture with R8/R16 NPOT at [0.0, 1.0], texture return 0 if failed; int[] = {texture, width, height}
-
genSDF
public static int[] genSDF(int source, int checkChannel, int localWidth, int localHeight, int extraWidth, int extraHeight, float outsideThreshold, byte step, float resultInsidePreMultiply, float resultOutsidePreMultiply, boolean bit16OutMode) Fast GPU SDF generation method.OpenGL 4.3 required, compute shader supported required.
- Parameters:
source- must be RGBA8 texture.checkChannel- valid value:GL11.GL_RED,GL11.GL_GREEN,GL11.GL_BLUE,GL11.GL_ALPHA,GL11.GL_RGB; default isGL11.GL_ALPHA.extraWidth- border width for sdf texture, positive integer value required.extraHeight- border height for sdf texture, positive integer value required.outsideThreshold- when pixel check value less than or equal the value, it will be considered as outside.step- 8 or 9 for general usage, range from 0 to 30; also you can useCalculateUtil.getExponentPOTMin(Math.max(localWidth, localHeight))for automatic step calculation.resultInsidePreMultiply- 0.01 or (1.0f / required thickness) for general usage.resultOutsidePreMultiply- 0.01 or (1.0f / max(extraWidth, extraHeight)) for general usage.bit16OutMode- true for R16 texture, false for R8 texture.- Returns:
- generated sdf texture with R8/R16 NPOT at [0.0, 1.0], texture return 0 if failed; int[] = {texture, width, height}
-
genSDF
public static int[] genSDF(int source, int checkChannel, int localWidth, int localHeight, int extraWidth, int extraHeight, float outsideThreshold, byte step, float resultInsidePreMultiply, float resultOutsidePreMultiply) Fast GPU SDF generation method.OpenGL 4.3 required, compute shader supported required.
- Parameters:
source- must be RGBA8 texture.checkChannel- valid value:GL11.GL_RED,GL11.GL_GREEN,GL11.GL_BLUE,GL11.GL_ALPHA,GL11.GL_RGB; default isGL11.GL_ALPHA.extraWidth- border width for sdf texture, positive integer value required.extraHeight- border height for sdf texture, positive integer value required.outsideThreshold- when pixel check value less than or equal the value, it will be considered as outside.step- 8 or 9 for general usage, range from 0 to 30; also you can useCalculateUtil.getExponentPOTMin(Math.max(localWidth, localHeight))for automatic step calculation.resultInsidePreMultiply- 0.01 or (1.0f / required thickness) for general usage.resultOutsidePreMultiply- 0.01 or (1.0f / max(extraWidth, extraHeight)) for general usage.- Returns:
- generated sdf texture with R8 NPOT at [0.0, 1.0], texture return 0 if failed; int[] = {texture, width, height}
-
applyRadialBlur
public static void applyRadialBlur(int source, @NotNull org.lwjgl.util.vector.Vector2f center, short samples, float radius, float alphaStrength, boolean isAdditiveBlend) Classical radial blur effect.Draw blur effect form source to attachment of current framebuffer, source texture size should be consistent with attachment of current framebuffer size.
GLWrapper.Shader.valid()required.- Parameters:
center- center of blur effect, mapping range from 0.0 to 1.0.samples- blur iteration, minimum value is 1 (No any effect), general value is 32, larger is better but slower.radius- the blur "strength", general value is 0.1, but higher value will need more samples to get better effect.alphaStrength- default value is 1.0.
-
applyRadialBlur
public static void applyRadialBlur(int source, @NotNull org.lwjgl.util.vector.Vector2f center, short samples, float radius, float alphaStrength, int dstX, int dstY, int dstWidth, int dstHeight, boolean isAdditiveBlend) Classical radial blur effect.Draw blur effect form source to attachment of current framebuffer, source texture size should be consistent with attachment of current framebuffer size.
GLWrapper.Shader.valid()required.- Parameters:
center- center of blur effect, mapping range from 0.0 to 1.0.samples- blur iteration, minimum value is 1 (No any effect), general value is 32, larger is better but slower.radius- the blur "strength", general value is 0.1, but higher value will need more samples to get better effect.alphaStrength- default value is 1.0.
-
applyImageGaussianBlur
public static void applyImageGaussianBlur(int source, int sourceOffsetX, int sourceOffsetY, boolean useRed, byte step, int texWidth, int texHeight, int result, int resultOffsetX, int resultOffsetY, boolean bit16OutMode) Simple gaussian blur computing, only for RGBA and R texture.- Parameters:
sourceOffsetX- the source texture region left-bottom origin x-position.sourceOffsetY- the source texture region left-bottom origin y-position.useRed- true for Red texture, false for RGBA texture.step- copy texture when less than1.resultOffsetX- the result texture region left-bottom origin x-position.resultOffsetY- the result texture region left-bottom origin x-position.bit16OutMode- true for 16bit per channel texture, false for 8bit per channel texture.
-
applyImageGaussianBlur
public static void applyImageGaussianBlur(int source, boolean useRed, byte step, int texWidth, int texHeight, int result, boolean bit16OutMode) Simple gaussian blur computing, only for RGBA and R texture.- Parameters:
useRed- true for Red texture, false for RGBA texture.step- copy texture when less than1.bit16OutMode- true for 16bit per channel texture, false for 8bit per channel texture.
-
applyImageGaussianBlur
public static void applyImageGaussianBlur(int source, boolean useRed, byte step, int texWidth, int texHeight, boolean bit16OutMode) Simple gaussian blur computing, only for RGBA and R texture.- Parameters:
useRed- true for Red texture, false for RGBA texture.step- copy texture when less than1.bit16OutMode- true for 16bit per channel texture, false for 8bit per channel texture.
-
applyImageBilateralFilter
public static void applyImageBilateralFilter(int source, int sourceOffsetX, int sourceOffsetY, boolean useRed, byte radius, float sigmaSpace, float sigmaRange, int texWidth, int texHeight, int result, int resultOffsetX, int resultOffsetY, boolean bit16OutMode) Separated GPU bilateral filter.- Parameters:
sourceOffsetX- the source texture region left-bottom origin x-position.sourceOffsetY- the source texture region left-bottom origin y-position.useRed- true for Red texture, false for RGBA texture.result- Not recommended use same result texture as source texture in separated bilateral filter, otherwise will lose some detail and edge.resultOffsetX- the result texture region left-bottom origin x-position.resultOffsetY- the result texture region left-bottom origin x-position.bit16OutMode- true for 16bit per channel texture, false for 8bit per channel texture.
-
applyImageBilateralFilter
public static void applyImageBilateralFilter(int source, boolean useRed, byte radius, float sigmaSpace, float sigmaRange, int texWidth, int texHeight, int result, boolean bit16OutMode) Separated GPU bilateral filter.Not recommended use this method, it uses same result texture as source texture that will lose some detail and edge.
- Parameters:
useRed- true for Red texture, false for RGBA texture.bit16OutMode- true for 16bit per channel texture, false for 8bit per channel texture.
-
applyImageBilateralFilter
public static void applyImageBilateralFilter(int source, boolean useRed, byte radius, float sigmaSpace, float sigmaRange, int texWidth, int texHeight, boolean bit16OutMode) Separated GPU bilateral filter.Not recommended use this method, it uses same result texture as source texture that will lose some detail and edge.
- Parameters:
useRed- true for Red texture, false for RGBA texture.bit16OutMode- true for 16bit per channel texture, false for 8bit per channel texture.
-
imageDFT
public static int imageDFT(int source, int sourceOffsetX, int sourceOffsetY, boolean useRed, int texWidth, int texHeight, int result, int resultOffsetX, int resultOffsetY, boolean f16OutMode) GPU DFT(Discrete Fourier Transform), slow but still faster more than CPU computing.- Parameters:
sourceOffsetX- the source texture region left-bottom origin x-position.sourceOffsetY- the source texture region left-bottom origin y-position.useRed- true for Red texture, false for RGBA texture.texWidth- spatial domain texture width, NOT frequency domain texture width.resultOffsetX- the result texture region left-bottom origin x-position.resultOffsetY- the result texture region left-bottom origin x-position.f16OutMode- true for f16 per channel texture, false for f32 per channel texture.- Returns:
- generated centered f16/f32 complex spectrum texture;
R with double size(left area R for real part of complex, right area R for imaginary part of complex) for useRed;
RGBA with double size(left area R+iG/B+iA complex, right area R+iG/B+iA complex) for not useRed;
returns 0 if failed.
-
imageDFT
public static int imageDFT(int source, boolean useRed, int texWidth, int texHeight, int result, boolean f16OutMode) GPU DFT(Discrete Fourier Transform), slow but still faster more than CPU computing.- Parameters:
useRed- true for Red texture, false for RGBA texture.texWidth- spatial domain texture width, NOT frequency domain texture width.f16OutMode- true for f16 per channel texture, false for f32 per channel texture.- Returns:
- generated centered f16/f32 complex spectrum texture;
R with double size(left area R for real part of complex, right area R for imaginary part of complex) for useRed;
RGBA with double size(left area R+iG/B+iA complex, right area R+iG/B+iA complex) for not useRed;
returns 0 if failed.
-
imageDFT
public static int imageDFT(int source, int sourceOffsetX, int sourceOffsetY, boolean useRed, int texWidth, int texHeight, boolean f16OutMode) GPU DFT(Discrete Fourier Transform), slow but still faster more than CPU computing.- Parameters:
sourceOffsetX- the source texture region left-bottom origin x-position.sourceOffsetY- the source texture region left-bottom origin y-position.useRed- true for Red texture, false for RGBA texture.texWidth- spatial domain texture width, NOT frequency domain texture width.f16OutMode- true for f16 per channel texture, false for f32 per channel texture.- Returns:
- generated centered f16/f32 complex spectrum texture;
R with double size(left area R for real part of complex, right area R for imaginary part of complex) for useRed;
RGBA with double size(left area R+iG/B+iA complex, right area R+iG/B+iA complex) for not useRed;
returns 0 if failed.
-
imageDFT
public static int imageDFT(int source, boolean useRed, int texWidth, int texHeight, boolean f16OutMode) GPU DFT(Discrete Fourier Transform), slow but still faster more than CPU computing.- Parameters:
useRed- true for Red texture, false for RGBA texture.texWidth- spatial domain texture width, NOT frequency domain texture width.f16OutMode- true for f16 per channel texture, false for f32 per channel texture.- Returns:
- generated centered f16/f32 complex spectrum texture;
R with double size(left area R for real part of complex, right area R for imaginary part of complex) for useRed;
RGBA with double size(left area R+iG/B+iA complex, right area R+iG/B+iA complex) for not useRed;
returns 0 if failed.
-
imageIDFT
public static int imageIDFT(int source, int sourceOffsetX, int sourceOffsetY, boolean useRed, int texWidth, int texHeight, int result, int resultOffsetX, int resultOffsetY, boolean f16InMode, boolean f16OutMode) GPU IDFT(Inverse Discrete Fourier Transform), slow but still faster more than CPU computing.- Parameters:
sourceOffsetX- the source texture region left-bottom origin x-position.sourceOffsetY- the source texture region left-bottom origin y-position.useRed- true for double size Red complex, false for double size RGBA complex.texWidth- spatial domain texture width, NOT frequency domain texture width.resultOffsetX- the result texture region left-bottom origin x-position.resultOffsetY- the result texture region left-bottom origin x-position.f16InMode- true for f16 per channel texture, false for f32 per channel texture.f16OutMode- true for f16 per channel texture, false for 8bit per channel texture.- Returns:
- generated 8bit/16bit per channel texture from complex spectrum, R for double size R complex, RGBA for double size RGBA complex, if failed return 0.
-
imageIDFT
public static int imageIDFT(int source, boolean useRed, int texWidth, int texHeight, int result, boolean f16InMode, boolean f16OutMode) GPU IDFT(Inverse Discrete Fourier Transform), slow but still faster more than CPU computing.- Parameters:
useRed- true for double size Red complex, false for double size RGBA complex.texWidth- spatial domain texture width, NOT frequency domain texture width.f16InMode- true for f16 per channel texture, false for f32 per channel texture.f16OutMode- true for f16 per channel texture, false for 8bit per channel texture.- Returns:
- generated 8bit/16bit per channel texture from complex spectrum, R for double size R complex, RGBA for double size RGBA complex, if failed return 0.
-
imageIDFT
public static int imageIDFT(int source, int sourceOffsetX, int sourceOffsetY, boolean useRed, int texWidth, int texHeight, boolean f16InMode, boolean f16OutMode) GPU IDFT(Inverse Discrete Fourier Transform), slow but still faster more than CPU computing.- Parameters:
sourceOffsetX- the source texture region left-bottom origin x-position.sourceOffsetY- the source texture region left-bottom origin y-position.useRed- true for double size Red complex, false for double size RGBA complex.texWidth- spatial domain texture width, NOT frequency domain texture width.f16InMode- true for f16 per channel texture, false for f32 per channel texture.f16OutMode- true for f16 per channel texture, false for 8bit per channel texture.- Returns:
- generated 8bit/16bit per channel texture from complex spectrum, R for double size R complex, RGBA for double size RGBA complex, if failed return 0.
-
imageIDFT
public static int imageIDFT(int source, boolean useRed, int texWidth, int texHeight, boolean f16InMode, boolean f16OutMode) GPU IDFT(Inverse Discrete Fourier Transform), slow but still faster more than CPU computing.- Parameters:
useRed- true for double size Red complex, false for double size RGBA complex.texWidth- spatial domain texture width, NOT frequency domain texture width.f16InMode- true for f16 per channel texture, false for f32 per channel texture.f16OutMode- true for f16 per channel texture, false for 8bit per channel texture.- Returns:
- generated 8bit/16bit per channel texture from complex spectrum, R for double size R complex, RGBA for double size RGBA complex, if failed return 0.
-
genNormalMapFromRGB
public static int genNormalMapFromRGB(int source, int sourceOffsetX, int sourceOffsetY, int srcLocalWidth, int srcLocalHeight, ShaderUtil.NormalMapGenParam param, int resultTex, int resultOffsetX, int resultOffsetY) GPU normal map generation from RGB texture for sprites.OpenGL 4.3 required, compute shader supported required.
- Parameters:
source- must be RGBA8 2D-texture.sourceOffsetX- the source texture region left-bottom origin x-position.sourceOffsetY- the source texture region left-bottom origin y-position.resultOffsetX- the result texture region left-bottom origin x-position.resultOffsetY- the result texture region left-bottom origin x-position.- Returns:
- returns NPOT-texture.
-
genNormalMapFromRGB
public static int genNormalMapFromRGB(int source, int srcLocalWidth, int srcLocalHeight, ShaderUtil.NormalMapGenParam param, int resultTex) GPU normal map generation from RGB texture for sprites.OpenGL 4.3 required, compute shader supported required.
- Parameters:
source- must be RGBA8 2D-texture.- Returns:
- returns NPOT-texture.
-
genNormalMapFromRGB
public static int genNormalMapFromRGB(int source, int sourceOffsetX, int sourceOffsetY, int srcLocalWidth, int srcLocalHeight, ShaderUtil.NormalMapGenParam param) GPU normal map generation from RGB texture for sprites.OpenGL 4.3 required, compute shader supported required.
- Parameters:
source- must be RGBA8 2D-texture.sourceOffsetX- the source texture region left-bottom origin x-position.sourceOffsetY- the source texture region left-bottom origin y-position.- Returns:
- returns NPOT-texture.
-
genNormalMapFromRGB
public static int genNormalMapFromRGB(int source, int srcLocalWidth, int srcLocalHeight, ShaderUtil.NormalMapGenParam param) GPU normal map generation from RGB texture for sprites.OpenGL 4.3 required, compute shader supported required.
- Parameters:
source- must be RGBA8 2D-texture.- Returns:
- returns NPOT-texture.
-