|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object com.threed.jpct.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.
Note: If you want to assign additional vertex attributes to your shader, you
can't do this here but in the Mesh class.
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.
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 |
compile(java.util.List attribs)
For compatibility with jPCT-AE. |
void |
excludeShadowMap(boolean exclude)
If set to true (default), no shaders will be applied when rendering into a depth map. |
int |
getProgram()
Returns the id of the shader program. |
static int |
guessShaderModel()
Guesses the shader model. |
void |
onDispose()
Releases resourced used by the shader. |
boolean |
repeatRendering()
Always returns false. |
void |
setCurrentObject3D(Object3D obj)
Does nothing in the default implementation. |
void |
setCurrentShader(GLSLShader shader)
Does nothing in the default implemention. |
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 |
setFloatArrayUniform(java.lang.String name,
float[] val)
Sets a new float[] uniform. |
void |
setMinShaderModel(int min)
Sets the minimum shader model that this shader needs. |
void |
setShadowHelper(ShadowHelper helper)
Sets the ShadowHelper instance. |
void |
setStaticFloatArrayUniform(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,
float[] val)
Sets a new float|vecX 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,
Matrix[] vals)
Sets a new array of Matrix uniform. |
void |
setStaticUniform(java.lang.String name,
SimpleVector val)
Sets a new SimpleVector uniform. |
void |
setStaticUniform(java.lang.String name,
SimpleVector[] vals)
Sets a new array of SimpleVector uniform. |
void |
setTransparency(float transparency)
Does nothing in the default implementation. |
void |
setUniform(java.lang.String name,
float val)
Sets a new float uniform. |
void |
setUniform(java.lang.String name,
float[] val)
Sets a new float|vecX 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,
Matrix[] vals)
Sets a new array of Matrix uniform. |
void |
setUniform(java.lang.String name,
SimpleVector val)
Sets a new SimpleVector uniform. |
void |
setUniform(java.lang.String name,
SimpleVector[] vals)
Sets a new array of SimpleVectors uniform. |
void |
setUniformCache(boolean cacheEnabled)
Does nothing in desktop jPCT. |
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 setCurrentObject3D(Object3D obj)
setCurrentObject3D
in interface IRenderHook
obj
- the current Object3Dpublic void setCurrentShader(GLSLShader shader)
setCurrentShader
in interface IRenderHook
shader
- the shader or null if none is usedpublic void setTransparency(float transparency)
setTransparency
in interface IRenderHook
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 setUniformCache(boolean cacheEnabled)
cacheEnabled
- does nothing...public int getProgram()
public void compile(java.util.List attribs)
attribs
- 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)
helper
- the ShadowHelperpublic 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 setStaticFloatArrayUniform(java.lang.String name, float[] val)
name
- the name of the uniformval
- the value.public void setStaticUniform(java.lang.String name, SimpleVector val)
name
- the name of the uniformval
- the valuepublic void setStaticUniform(java.lang.String name, SimpleVector[] vals)
name
- the name of the uniformvals
- the valuespublic void setStaticUniform(java.lang.String name, Matrix m)
name
- the name of the uniformm
- the matrix. It won't be transposed.public void setStaticUniform(java.lang.String name, Matrix[] vals)
name
- the name of the uniformvals
- the valuespublic 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, SimpleVector[] vals)
name
- the name of the uniformvals
- the valuespublic void setUniform(java.lang.String name, Matrix[] vals)
name
- the name of the uniformvals
- the valuespublic 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 setFloatArrayUniform(java.lang.String name, float[] val)
name
- the name of the uniformval
- the value.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 |