|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object com.threed.jpct.util.GLSLShader
A simple helper class for GLSL-based shaders. The purpose of this is to ease
shader handling somewhat, but it isn't a full blown shader framework and it
isn't meant to be one. You can always write your own shaders by hand using
the IRenderHook interface (which is what this class implements too).
If the shader fails to compile or any other problem arises, the shader won't
be used and an error message will be given.
Keep in mind that assigning a shader disables the fixed function pipeline
completely for this object. Everything the fixed function pipeline does has
to be rebuild in the shader if needed.
Albeit an implementation of IRenderHook and mainly meant to be used in
combination with Object3Ds, you may use this class on its own to ease shader
management for shaders that aren't applied on Object3Ds, for example in an
IPostProcessor of yours. To do this, call beforeRendering() to activate the
shader, afterRendering() to disable it and onDispose() if you don't need it
anymore.
Note: Because jPCT doesn't support vertex attributes ATM, there are no
setters for these.
Constructor Summary | |
GLSLShader(java.lang.String vertexShaderSrc,
java.lang.String fragmentShaderSrc)
Creates a new instance. |
Method Summary | |
void |
afterRendering(int polyId)
Disables the shader. |
void |
beforeRendering(int polyID)
Activates the shader. |
void |
clear()
Disables the shader. |
void |
excludeShadowMap(boolean exclude)
If set to true (default), no shaders will be applied when rendering into a depth map. |
static int |
guessShaderModel()
Guesses the shader model. |
void |
onDispose()
Releases resourced used by the shader. |
boolean |
repeatRendering()
Always returns false. |
void |
setDelayedDisabling(boolean delayed)
If set to true, the engine can optimize shader usage better but it's not guaranteed, that the shader will be disabled after usage. |
void |
setMinShaderModel(int min)
Sets the minimum shader model that this shader needs. |
void |
setShadowHelper(ShadowHelper helper)
|
void |
setStaticUniform(java.lang.String name,
float val)
Sets a new float uniform. |
void |
setStaticUniform(java.lang.String name,
float[] val)
Sets a new float[] uniform. |
void |
setStaticUniform(java.lang.String name,
int val)
Sets a new integer uniform. |
void |
setStaticUniform(java.lang.String name,
Matrix m)
Sets a new Matrix uniform. |
void |
setStaticUniform(java.lang.String name,
SimpleVector val)
Sets a new SimpleVector uniform. |
void |
setUniform(java.lang.String name,
float val)
Sets a new float uniform. |
void |
setUniform(java.lang.String name,
float[] val)
Sets a new SimpleVector uniform. |
void |
setUniform(java.lang.String name,
int val)
Sets a new integer uniform. |
void |
setUniform(java.lang.String name,
Matrix m)
Sets a new Matrix uniform. |
void |
setUniform(java.lang.String name,
SimpleVector val)
Sets a new SimpleVector uniform. |
Methods inherited from class java.lang.Object |
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
public GLSLShader(java.lang.String vertexShaderSrc, java.lang.String fragmentShaderSrc)
vertexShaderSrc
- the source of the vertex shaderfragmentShaderSrc
- the source of the fragment shaderMethod Detail |
public void setMinShaderModel(int min)
min
- the minimum shader model. Default is -1, which means: All are
fine.public void beforeRendering(int polyID)
beforeRendering
in interface IRenderHook
polyID
- the ID of the polygon that is first in the current list that
is about to render.public void setDelayedDisabling(boolean delayed)
delayed
- should it be delayed?public void afterRendering(int polyId)
afterRendering
in interface IRenderHook
polyId
- the ID of the polygon that is first in the current list that is
about to render.public void clear()
clear
in interface IRenderHook
public void onDispose()
onDispose
in interface IRenderHook
public boolean repeatRendering()
repeatRendering
in interface IRenderHook
public void setShadowHelper(ShadowHelper helper)
public void excludeShadowMap(boolean exclude)
exclude
- exclude it or not?setShadowHelper(com.threed.jpct.util.ShadowHelper)
public void setStaticUniform(java.lang.String name, int val)
name
- the name of the uniformval
- the valuepublic void setStaticUniform(java.lang.String name, float val)
name
- the name of the uniformval
- the valuepublic void setStaticUniform(java.lang.String name, float[] val)
name
- the name of the uniformval
- the value. Supports array-lengths from 1 to 4.public void setStaticUniform(java.lang.String name, SimpleVector val)
name
- the name of the uniformval
- the valuepublic void setStaticUniform(java.lang.String name, Matrix m)
name
- the name of the uniformm
- the matrix. It won't be transposed.public void setUniform(java.lang.String name, int val)
name
- the name of the uniformval
- the valuepublic void setUniform(java.lang.String name, float val)
name
- the name of the uniformval
- the valuepublic void setUniform(java.lang.String name, SimpleVector val)
name
- the name of the uniformval
- the valuepublic void setUniform(java.lang.String name, float[] val)
name
- the name of the uniformval
- the value. Supports array-lengths from 1 to 4.public void setUniform(java.lang.String name, Matrix m)
name
- the name of the uniformm
- the matrix. It won't be transposed.public static int guessShaderModel()
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |