Class DefaultShader
- java.lang.Object
-
- com.badlogic.gdx.graphics.g3d.shaders.BaseShader
-
- com.badlogic.gdx.graphics.g3d.shaders.DefaultShader
-
- All Implemented Interfaces:
Shader
,Disposable
- Direct Known Subclasses:
DepthShader
public class DefaultShader extends BaseShader
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
DefaultShader.Config
static class
DefaultShader.Inputs
static class
DefaultShader.Setters
-
Nested classes/interfaces inherited from class com.badlogic.gdx.graphics.g3d.shaders.BaseShader
BaseShader.GlobalSetter, BaseShader.LocalSetter, BaseShader.Setter, BaseShader.Uniform, BaseShader.Validator
-
-
Field Summary
-
Fields inherited from class com.badlogic.gdx.graphics.g3d.shaders.BaseShader
camera, context, program
-
-
Constructor Summary
Constructors Constructor Description DefaultShader(Renderable renderable)
DefaultShader(Renderable renderable, DefaultShader.Config config)
DefaultShader(Renderable renderable, DefaultShader.Config config, ShaderProgram shaderProgram)
DefaultShader(Renderable renderable, DefaultShader.Config config, java.lang.String prefix)
DefaultShader(Renderable renderable, DefaultShader.Config config, java.lang.String prefix, java.lang.String vertexShader, java.lang.String fragmentShader)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description void
begin(Camera camera, RenderContext context)
Initializes the context for exclusive rendering by this shader.protected void
bindLights(Renderable renderable, Attributes attributes)
protected void
bindMaterial(Attributes attributes)
boolean
canRender(Renderable renderable)
Checks whether this shader is intended to render theRenderable
.int
compareTo(Shader other)
Compare this shader against the other, used for sorting, light weight shaders are rendered first.static java.lang.String
createPrefix(Renderable renderable, DefaultShader.Config config)
void
dispose()
Releases all resources of this object.void
end()
Cleanup the context so other shaders can render.boolean
equals(DefaultShader obj)
boolean
equals(java.lang.Object obj)
int
getDefaultCullFace()
int
getDefaultDepthFunc()
static java.lang.String
getDefaultFragmentShader()
static java.lang.String
getDefaultVertexShader()
void
init()
Initializes the Shader, must be called before the Shader can be used.void
render(Renderable renderable, Attributes combinedAttributes)
void
setDefaultCullFace(int cullFace)
void
setDefaultDepthFunc(int depthFunc)
-
-
-
Field Detail
-
implementedFlags
protected static long implementedFlags
-
defaultCullFace
@Deprecated public static int defaultCullFace
Deprecated.Replaced byDefaultShader.Config.defaultCullFace
Set to 0 to disable culling
-
defaultDepthFunc
@Deprecated public static int defaultDepthFunc
Deprecated.Replaced byDefaultShader.Config.defaultDepthFunc
Set to 0 to disable depth test
-
u_projTrans
public final int u_projTrans
-
u_viewTrans
public final int u_viewTrans
-
u_projViewTrans
public final int u_projViewTrans
-
u_cameraPosition
public final int u_cameraPosition
-
u_cameraDirection
public final int u_cameraDirection
-
u_cameraUp
public final int u_cameraUp
-
u_cameraNearFar
public final int u_cameraNearFar
-
u_time
public final int u_time
-
u_worldTrans
public final int u_worldTrans
-
u_viewWorldTrans
public final int u_viewWorldTrans
-
u_projViewWorldTrans
public final int u_projViewWorldTrans
-
u_normalMatrix
public final int u_normalMatrix
-
u_bones
public final int u_bones
-
u_shininess
public final int u_shininess
-
u_opacity
public final int u_opacity
-
u_diffuseColor
public final int u_diffuseColor
-
u_diffuseTexture
public final int u_diffuseTexture
-
u_diffuseUVTransform
public final int u_diffuseUVTransform
-
u_specularColor
public final int u_specularColor
-
u_specularTexture
public final int u_specularTexture
-
u_specularUVTransform
public final int u_specularUVTransform
-
u_emissiveColor
public final int u_emissiveColor
-
u_emissiveTexture
public final int u_emissiveTexture
-
u_emissiveUVTransform
public final int u_emissiveUVTransform
-
u_reflectionColor
public final int u_reflectionColor
-
u_reflectionTexture
public final int u_reflectionTexture
-
u_reflectionUVTransform
public final int u_reflectionUVTransform
-
u_normalTexture
public final int u_normalTexture
-
u_normalUVTransform
public final int u_normalUVTransform
-
u_ambientTexture
public final int u_ambientTexture
-
u_ambientUVTransform
public final int u_ambientUVTransform
-
u_alphaTest
public final int u_alphaTest
-
u_ambientCubemap
protected final int u_ambientCubemap
-
u_environmentCubemap
protected final int u_environmentCubemap
-
u_dirLights0color
protected final int u_dirLights0color
-
u_dirLights0direction
protected final int u_dirLights0direction
-
u_dirLights1color
protected final int u_dirLights1color
-
u_pointLights0color
protected final int u_pointLights0color
-
u_pointLights0position
protected final int u_pointLights0position
-
u_pointLights0intensity
protected final int u_pointLights0intensity
-
u_pointLights1color
protected final int u_pointLights1color
-
u_spotLights0color
protected final int u_spotLights0color
-
u_spotLights0position
protected final int u_spotLights0position
-
u_spotLights0intensity
protected final int u_spotLights0intensity
-
u_spotLights0direction
protected final int u_spotLights0direction
-
u_spotLights0cutoffAngle
protected final int u_spotLights0cutoffAngle
-
u_spotLights0exponent
protected final int u_spotLights0exponent
-
u_spotLights1color
protected final int u_spotLights1color
-
u_fogColor
protected final int u_fogColor
-
u_shadowMapProjViewTrans
protected final int u_shadowMapProjViewTrans
-
u_shadowTexture
protected final int u_shadowTexture
-
u_shadowPCFOffset
protected final int u_shadowPCFOffset
-
dirLightsLoc
protected int dirLightsLoc
-
dirLightsColorOffset
protected int dirLightsColorOffset
-
dirLightsDirectionOffset
protected int dirLightsDirectionOffset
-
dirLightsSize
protected int dirLightsSize
-
pointLightsLoc
protected int pointLightsLoc
-
pointLightsColorOffset
protected int pointLightsColorOffset
-
pointLightsPositionOffset
protected int pointLightsPositionOffset
-
pointLightsIntensityOffset
protected int pointLightsIntensityOffset
-
pointLightsSize
protected int pointLightsSize
-
spotLightsLoc
protected int spotLightsLoc
-
spotLightsColorOffset
protected int spotLightsColorOffset
-
spotLightsPositionOffset
protected int spotLightsPositionOffset
-
spotLightsDirectionOffset
protected int spotLightsDirectionOffset
-
spotLightsIntensityOffset
protected int spotLightsIntensityOffset
-
spotLightsCutoffAngleOffset
protected int spotLightsCutoffAngleOffset
-
spotLightsExponentOffset
protected int spotLightsExponentOffset
-
spotLightsSize
protected int spotLightsSize
-
lighting
protected final boolean lighting
-
environmentCubemap
protected final boolean environmentCubemap
-
shadowMap
protected final boolean shadowMap
-
ambientCubemap
protected final AmbientCubemap ambientCubemap
-
directionalLights
protected final DirectionalLight[] directionalLights
-
pointLights
protected final PointLight[] pointLights
-
spotLights
protected final SpotLight[] spotLights
-
attributesMask
protected final long attributesMask
The attributes that this shader supports
-
config
protected final DefaultShader.Config config
-
-
Constructor Detail
-
DefaultShader
public DefaultShader(Renderable renderable)
-
DefaultShader
public DefaultShader(Renderable renderable, DefaultShader.Config config)
-
DefaultShader
public DefaultShader(Renderable renderable, DefaultShader.Config config, java.lang.String prefix)
-
DefaultShader
public DefaultShader(Renderable renderable, DefaultShader.Config config, java.lang.String prefix, java.lang.String vertexShader, java.lang.String fragmentShader)
-
DefaultShader
public DefaultShader(Renderable renderable, DefaultShader.Config config, ShaderProgram shaderProgram)
-
-
Method Detail
-
getDefaultVertexShader
public static java.lang.String getDefaultVertexShader()
-
getDefaultFragmentShader
public static java.lang.String getDefaultFragmentShader()
-
init
public void init()
Description copied from interface:Shader
Initializes the Shader, must be called before the Shader can be used. This typically compiles aShaderProgram
, fetches uniform locations and performs other preparations for usage of the Shader.
-
createPrefix
public static java.lang.String createPrefix(Renderable renderable, DefaultShader.Config config)
-
canRender
public boolean canRender(Renderable renderable)
Description copied from interface:Shader
Checks whether this shader is intended to render theRenderable
. Use this to make sure a call to theShader.render(Renderable)
method will succeed. This is expected to be a fast, non-blocking method. Note that this method will only return true if it is intended to be used. Even when it returns false the Shader might still be capable of rendering, but it's not preferred to do so.- Parameters:
renderable
- The renderable to check against this shader.- Returns:
- true if this shader is intended to render the
Renderable
, false otherwise.
-
compareTo
public int compareTo(Shader other)
Description copied from interface:Shader
Compare this shader against the other, used for sorting, light weight shaders are rendered first.
-
equals
public boolean equals(java.lang.Object obj)
- Overrides:
equals
in classjava.lang.Object
-
equals
public boolean equals(DefaultShader obj)
-
begin
public void begin(Camera camera, RenderContext context)
Description copied from interface:Shader
Initializes the context for exclusive rendering by this shader. Use theShader.render(Renderable)
method to render aRenderable
. When done rendering theShader.end()
method must be called.- Specified by:
begin
in interfaceShader
- Overrides:
begin
in classBaseShader
- Parameters:
camera
- The camera to use when renderingcontext
- The context to be used, which must be exclusive available for the shader until the call to theShader.end()
method.
-
render
public void render(Renderable renderable, Attributes combinedAttributes)
- Overrides:
render
in classBaseShader
-
end
public void end()
Description copied from interface:Shader
Cleanup the context so other shaders can render. Must be called when done rendering using theShader.render(Renderable)
method, which must be preceded by a call toShader.begin(Camera, RenderContext)
. After a call to this method an call to theShader.render(Renderable)
method will fail until theShader.begin(Camera, RenderContext)
is called.- Specified by:
end
in interfaceShader
- Overrides:
end
in classBaseShader
-
bindMaterial
protected void bindMaterial(Attributes attributes)
-
bindLights
protected void bindLights(Renderable renderable, Attributes attributes)
-
dispose
public void dispose()
Description copied from interface:Disposable
Releases all resources of this object.- Specified by:
dispose
in interfaceDisposable
- Overrides:
dispose
in classBaseShader
-
getDefaultCullFace
public int getDefaultCullFace()
-
setDefaultCullFace
public void setDefaultCullFace(int cullFace)
-
getDefaultDepthFunc
public int getDefaultDepthFunc()
-
setDefaultDepthFunc
public void setDefaultDepthFunc(int depthFunc)
-
-