|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object com.threed.jpct.util.ShadowHelper
The ShadowHelper-class eases shadow mapping. While shadow mapping in jPCT is
possible without this helper class, you have to have a good knowledge of how
shadow mapping works in practice to implement it yourself using the methods
that jPCT is offering for it.
To simplify shadow mapping, this helper exists and it should be sufficient
for most shadow applications.
jPCT uses a fixed function approach with depth textures for shadow mapping.
It is advised to initialize this class after enabling the OpenGL renderer
when render-to-texture should be done by using FBOs because otherwise, it's
not known if the hardware actually supports it and the helper has to rely on
the setting in Config alone. The software renderer doesn't support shadow
mapping. It will only cost you performance for no visual benefit when using
this class on a software rendered scene.
Config.glShadowZBias
,
Config.glUseFBO
,
Serialized FormConstructor Summary | |
ShadowHelper(World world,
FrameBuffer buffer,
Projector lightSource,
int maxSize)
Creates a new shadow helper. |
Method Summary | |
void |
addCaster(Object3D caster)
Adds a caster. |
void |
addReceiver(Object3D rec)
Adds a receiver. |
void |
dispose()
Disposes the helper. |
void |
drawScene()
Draws the scene using the most current shadow map. |
void |
drawScene(boolean complete)
Draws the scene using the most current shadow map. |
void |
finalize()
|
int |
getCasterCount()
Gets the number of casters in the helper. |
Projector |
getLightSource()
Returns the directional light source. |
int |
getReceiverCount()
Gets the number of receivers in the helper. |
Texture |
getShadowMap()
Returns the shadow map's texture. |
boolean |
isInitialized()
Returns true, if the helper has been correctly initialized. |
boolean |
isRenderingShadowMap()
Returns true if, at the time of the call, the helper is working on the shadow map itself. |
boolean |
isRenderingShadowPass()
Returns true if, at the time of the call, the helper is doing the shadow pass. |
void |
removeCaster(Object3D caster)
Removes a caster. |
static void |
resetTextureCounter()
Resets the texture counter. |
void |
setAdditionalColorMode(boolean disabled)
Sets how an objects additional color will be treated. |
void |
setAmbientLight(java.awt.Color col)
Sets the ambient lighting used during the shadow pass. |
void |
setBorder(int width)
Sets a border around the actual shadow map to prevent the shadows from bleeding into parts of the scene that are not covered by the projector's view. |
void |
setCullingMode(boolean inverted)
Sets the culling mode. |
void |
setFiltering(boolean pcf)
Enabled percentage closer filtering on the shadow edges. |
void |
setFrameBuffer(FrameBuffer buffer)
Sets a new FrameBuffer. |
void |
setLightMode(boolean disabled)
Sets the lighting mode. |
void |
setLightSource(Projector lightSource)
Sets the directional light source to another one. |
void |
setRevertMode(boolean mode)
If enabled, every MODE_ADD texture operation will be reverted to a MODE_MODULATE when doing the shadow pass. |
void |
updateShadowMap()
Updates the shadow map as seen from the directional light source. |
Methods inherited from class java.lang.Object |
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
public ShadowHelper(World world, FrameBuffer buffer, Projector lightSource, int maxSize)
world
- the world that includes the objects to be shadowedbuffer
- the framebuffer into which the world will be renderedlightSource
- the directional light source that casts the shadowsmaxSize
- the maximum size of the shadow map. This isn't necessarily the
used size but an upper bound for it.Method Detail |
public static void resetTextureCounter()
public Projector getLightSource()
public void setLightSource(Projector lightSource)
lightSource
- the new sourcepublic void setBorder(int width)
width
- public void setFrameBuffer(FrameBuffer buffer)
buffer
- the new FrameBufferpublic void setRevertMode(boolean mode)
mode
- the modepublic void setCullingMode(boolean inverted)
inverted
- should it be inverted?public void setFiltering(boolean pcf)
pcf
- should we use it?public void addReceiver(Object3D rec)
rec
- the receiverpublic boolean isInitialized()
public void addCaster(Object3D caster)
caster
- the new casterpublic void removeCaster(Object3D caster)
caster
- the caster to removepublic void setLightMode(boolean disabled)
disabled
- should the light be disabled during shadow pass? Default is
true.public void setAdditionalColorMode(boolean disabled)
disabled
- should the additional color be disabled during shadow pass?
Default is false.public void setAmbientLight(java.awt.Color col)
col
- the color of the light source. Default is 60,60,60public void drawScene()
public void drawScene(boolean complete)
complete
- if true, everything is rendered. If its false, the last call
to draw() will be omitted (in case you want to do something
else before making it).public boolean isRenderingShadowMap()
public boolean isRenderingShadowPass()
public int getReceiverCount()
public int getCasterCount()
public Texture getShadowMap()
public void updateShadowMap()
public void dispose()
public void finalize()
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |