public class Shader
extends java.lang.Object
You can set your own shader programs in the toolkit! Yeah, that's as complex as it sounds. The underyling toolkit makes a distinction between the name of the shader and the scene name. The scene name is used as a way to replace the default shaders we use for triangles and lines. This would let you replace the shaders you're already using with your own. See the addShaderProgram:sceneName: method in the MaplyBaseViewController. You can also add your own shader and hook it up to any features that can call out a specific shader, such as the MaplyQuadImageTilesLayer. When writing a new shader, go take a look at DefaultShaderPrograms.mm, particularly the vertexShaderTri and fragmentShaderTri. The documentation here is for the uniforms and attributes the system is going to hook up for you. All of these are optional, but obviously nothing much will happen if you don't use the vertices.
Modifier and Type | Class and Description |
---|---|
static class |
Shader.AttributeType |
Modifier and Type | Field and Description |
---|---|
static java.lang.String |
BillboardEyeShader |
static java.lang.String |
BillboardGroundShader |
static java.lang.String |
DefaultLineShader |
static java.lang.String |
DefaultMarkerShader |
static java.lang.String |
DefaultModelTriShader |
static java.lang.String |
DefaultScreenSpaceMotionShader |
static java.lang.String |
DefaultScreenSpaceShader |
static java.lang.String |
DefaultTriangleShader |
static java.lang.String |
DefaultTriMultiTexRampShader |
static java.lang.String |
DefaultTriMultiTexShader |
static java.lang.String |
DefaultTriNightDayShader |
static java.lang.String |
DefaultTriScreenTexShader |
static java.lang.String |
DefaultWideVectorGlobeShader |
static java.lang.String |
DefaultWideVectorShader |
static java.lang.String |
NoBackfaceLineShader |
static java.lang.String |
NoLightTriangleShader |
Modifier | Constructor and Description |
---|---|
protected |
Shader() |
|
Shader(RenderControllerInterface inControl)
Initialise with an empty program we'll fill in later.
|
|
Shader(java.lang.String name,
java.lang.String vertexSrc,
java.lang.String fragSrc,
RenderControllerInterface inControl)
Initialize with the file names for the shader program.
|
Modifier and Type | Method and Description |
---|---|
void |
addTexture(java.lang.String name,
MaplyTexture texture)
Add a texture for use in the shader.
|
void |
addVarying(java.lang.String name)
Varyings will be passed from one shader to another using transform feedback.
|
void |
delayedSetup(java.lang.String name,
java.lang.String vertexSrc,
java.lang.String fragSrc)
This is called after an a minimal setup.
|
void |
finalize() |
long |
getID()
Returns the internal Maply ID for the shader.
|
java.lang.String |
getName()
Returns the shader's name.
|
boolean |
setUniform(java.lang.String name,
double uni)
Set a float uniform in the shader with the given name.
|
boolean |
setUniform(java.lang.String name,
int uni)
Set an int uniform in the shader with the given name.
|
boolean |
setUniform(java.lang.String name,
Point2d pt)
Set a pair of doubles in the shader with the given name.
|
boolean |
setUniform(java.lang.String name,
Point3d pt)
Set a pair of doubles in the shader with the given name.
|
boolean |
setUniform(java.lang.String name,
Point4d pt)
Set a pair of doubles in the shader with the given name.
|
boolean |
setUniformByIndex(java.lang.String name,
double uni,
int index)
Set a float uniform in the shader with a given name at the given index.
|
boolean |
setUniformByIndexNative(java.lang.String name,
double uni,
int index) |
boolean |
setUniformColor(java.lang.String name,
int color)
Set the 4 component color value for a uniform.
|
boolean |
setUniformColorByIndex(java.lang.String name,
int color,
int index)
Set the 4 component color value for a uniform with the given index (e.g.
|
boolean |
setUniformNative(java.lang.String name,
double uni) |
boolean |
setUniformNative(java.lang.String name,
int uni) |
boolean |
valid()
Check if the shader is valid.
|
public static final java.lang.String DefaultTriangleShader
public static final java.lang.String NoLightTriangleShader
public static final java.lang.String DefaultLineShader
public static final java.lang.String NoBackfaceLineShader
public static final java.lang.String DefaultModelTriShader
public static final java.lang.String DefaultTriScreenTexShader
public static final java.lang.String DefaultTriMultiTexShader
public static final java.lang.String DefaultTriMultiTexRampShader
public static final java.lang.String DefaultMarkerShader
public static final java.lang.String DefaultTriNightDayShader
public static final java.lang.String BillboardGroundShader
public static final java.lang.String BillboardEyeShader
public static final java.lang.String DefaultWideVectorShader
public static final java.lang.String DefaultWideVectorGlobeShader
public static final java.lang.String DefaultScreenSpaceMotionShader
public static final java.lang.String DefaultScreenSpaceShader
public Shader(java.lang.String name, java.lang.String vertexSrc, java.lang.String fragSrc, RenderControllerInterface inControl)
See initWithName:vertex:fragment:viewC: for more details on how this works.
name
- The name of the shader program. Used for identification and sometimes lookup.vertexSrc
- The string containing the full vertex program.fragSrc
- The string containing the full fragment program.inControl
- The controller where we'll register the new shader.public Shader(RenderControllerInterface inControl)
inControl
- The control we'll associate this program with.protected Shader()
public void delayedSetup(java.lang.String name, java.lang.String vertexSrc, java.lang.String fragSrc)
name
- The name of the shader program. Used for identification and sometimes lookup.vertexSrc
- The string containing the full vertex program.fragSrc
- The string containing the full fragment program.public boolean valid()
The shader setup can fail in a number of ways. Check this after creating the shader to see if it succeeded. If not, look to getError to see why.
public java.lang.String getName()
public void addTexture(java.lang.String name, MaplyTexture texture)
name
- Name to be used in the shader.texture
- Texture to pass into the shader.public boolean setUniform(java.lang.String name, double uni)
public boolean setUniformByIndex(java.lang.String name, double uni, int index)
public boolean setUniformNative(java.lang.String name, double uni)
public boolean setUniformByIndexNative(java.lang.String name, double uni, int index)
public boolean setUniform(java.lang.String name, int uni)
public boolean setUniformNative(java.lang.String name, int uni)
public boolean setUniform(java.lang.String name, Point2d pt)
pt
- Point to set the uniform to.public boolean setUniform(java.lang.String name, Point3d pt)
pt
- Point to set the uniform to.public boolean setUniform(java.lang.String name, Point4d pt)
pt
- Point to set the uniform to.public boolean setUniformColorByIndex(java.lang.String name, int color, int index)
public boolean setUniformColor(java.lang.String name, int color)
public void addVarying(java.lang.String name)
name
- Name of the output of the vertex stage to turn into a varying.public long getID()
public void finalize()
finalize
in class java.lang.Object