Shader parameters must have names that are recognized by panda. The old way of giving the shader parameters are shown in the table: (Note that the old method allowed only input types of float4 and float4x4's and sampler's. For the new shader inputs see bottom of the page)
In addition, the following variable extensions are reserved for the autoshader and should not be inclued in your variable names _ao, _glow, _gloss. (ie., my_map_ao will throw an error)
uniform sampler2D tex_0 |
The model's first texture. This requires that the model be textured in the normal manner. You may also use tex_1, tex_2, and so forth, if the model is multitextured. |
sampler3D or samplerCUBE |
If the model uses a 3D texture or a cubemap, use tex3D and texCUBE to access the color. |
uniform sampler2D tex_0_suffix |
Obtain a texture by concatenating a hyphen and the suffix to the filename of the model's first texture. For example, if tex_0 is "woman.jpg", then tex_0_normalmap is "woman-normalmap.jpg", and tex_0_specular is "woman-specular.jpg". You may also use tex_1_suffix, tex_2_suffix, and so forth. |
float3 vtx_position: POSITION |
Vertex Position. Vertex shader only. You may also use float4, in which case (w==1). |
float3 vtx_normal: NORMAL |
Vertex Normal. Vertex shader only. |
float4 vtx_color : COLOR |
Vertex color. Vertex shader only. |
float2 vtx_texcoord0: TEXCOORD0 |
Texture coordinate associated with the model's first texture. This requires that the model be textured in the normal manner. You may also use vtx_texcoord1, vtx_texcoord2, and so forth if the model is multitextured. Vertex shader only. |
float3 vtx_tangent0 |
Tangent vector associated with the model's first texture. This can only be used if the model has been textured in the normal manner, and if binormals have been precomputed. You may also use vtx_tangent1, vtx_tangent2, and so forth if the model is multitextured. Vertex shader only. |
float3 vtx_binormal0 |
Binormal vector associated with vtx_texcoord0. This can only be used if the model has been textured in the normal manner, and if binormals have been precomputed. You can also use vtx_binormal1, vtx_binormal2, and so forth if the model has been multitextured. Vertex shader only. |
floatX vtx_anything |
Panda makes it possible to store arbitrary columns of user-defined data in the vertex table; see GeomVertexData. You can access this data using this syntax. For example, vtx_chicken will look for a column named "chicken" in the vertex array. Vertex shader only. |
uniform float4x4 trans_x_to_y |
A matrix that transforms from coordinate system X to coordinate system Y. See the section on Shaders and Coordinate Spaces for more information.
|
uniform float4x4 tpose_x_to_y |
Transpose of trans_x_to_y |
uniform float4 row0_x_to_y |
Row 0 of trans_x_to_y. |
uniform float4 row1_x_to_y |
Row 1 of trans_x_to_y. |
uniform float4 row2_x_to_y |
Row 2 of trans_x_to_y. |
uniform float4 row3_x_to_y |
Row 3 of trans_x_to_y. |
uniform float4 col0_x_to_y |
Col 0 of trans_x_to_y. |
uniform float4 col1_x_to_y |
Col 1 of trans_x_to_y. |
uniform float4 col2_x_to_y |
Col 2 of trans_x_to_y. |
uniform float4 col3_x_to_y |
Col 3 of trans_x_to_y. |
uniform float4x4 mstrans_x |
Model-Space Transform of X, aka trans_x_to_model |
uniform float4x4 cstrans_x |
Clip-Space Transform of X, aka trans_x_to_clip |
uniform float4x4 wstrans_x |
World-Space Transform of X, aka trans_x_to_world |
uniform float4x4 vstrans_x |
View-Space Transform of X, aka trans_x_to_view |
uniform float4 mspos_x |
Model-Space Position of X, aka row3_x_to_model |
uniform float4 cspos_x |
Clip-Space Position of X, aka row3_x_to_clip |
uniform float4 wspos_x |
World-Space Position of X, aka row3_x_to_world |
uniform float4 vspos_x |
View-Space Position of X, aka row3_x_to_view |
uniform float4x4 mat_modelview |
Modelview Matrix |
uniform float4x4 inv_modelview |
Inverse Modelview Matrix |
uniform float4x4 tps_modelview |
Transposed Modelview Matrix |
uniform float4x4 itp_modelview |
Inverse Transposed Modelview Matrix |
uniform float4x4 mat_projection |
Projection Matrix |
uniform float4x4 inv_projection |
Inverse Projection Matrix |
uniform float4x4 tps_projection |
Transposed Projection Matrix |
uniform float4x4 itp_projection |
Inverse Transposed Projection Matrix |
uniform float4x4 mat_modelproj |
Composed Modelview/Projection Matrix |
uniform float4x4 inv_modelproj |
Inverse ModelProj Matrix |
uniform float4x4 tps_modelproj |
Transposed ModelProj Matrix |
uniform float4x4 itp_modelproj |
Inverse Transposed ModelProj Matrix |
uniform float4 anything |
A constant vector that was stored using setShaderInput . Parameter anything would match data supplied by the call setShaderInput("anything", Vec4(x,y,z,w)) |
uniform sampler2D anything
uniform sampler3D anything
uniform sampler2DArray anything |
A constant texture that was stored using setShaderInput . Parameter anything would match data supplied by the call setShaderInput("anything", myTex) |
uniform float4x4 anything |
A constant matrix that was stored using setShaderInput . Parameter anything would match data supplied by the call setShaderInput("anything", myNodePath). The matrix supplied is the nodepath's local transform. |
uniform float4 texpad_x |
X must be the name of a texture specified via shaderInput. Contains the U,V coordinates of the center of the texture. This will be (0.5,0.5) if the texture is not padded, but it will be less if the texture is padded. |
uniform float4 texpix_x |
X must be the name of a texture specified via shaderInput. Contains the U,V offset of a single pixel in the texture (ie, the reciprocal of the texture size). |
uniform float4x4 attr_material |
The contents of the material attribute. Row 0 is ambient, Row 1 is diffuse, Row 2 is emission, Row 3 is specular, with shininess in W. |
uniform float4 attr_color |
The contents of the color attribute. This is white unless the model has a flat color applied. |
uniform float4 attr_colorscale |
The contents of the color scale attribute. This is white unless the model has a color scale applied using nodePath.setColorScale. This variable is only available in 1.6.2 and above. |
uniform float4 alight_x |
X must be an AmbientLight specified via a shaderInput. Contains the color of the light. |
uniform float4x4 dlight_x |
X must be an DirectionalLight specified via a shaderInput. Row 0 is color, row 1 is specular, row 2 is model-space direction, row 3 is model-space pseudo half-angle. |
uniform float4 plane_x |
X must be an PlaneNode specified via a shaderInput. Contains the four terms of the plane equation. This variable is only available in 1.6.2 and above. |
uniform float4 clipplane_0 |
Contains the parameters of the first clipplane (also: clipplane_1, clipplane_2, etc. for subsequent clip planes) in world-space coordinates. This variable is only available in 1.6.2 and above. |
floatX l_position: POSITION |
Linearly interpolated Position, as supplied by the vertex shader to the fragment shader. Declare "out" in the vertex shader, "in" in the fragment shader. |
floatX l_color0: COLOR0 |
Linearly interpolated Primary color, as supplied by the vertex shader to the fragment shader. Declare "out" in the vertex shader, "in" in the fragment shader. |
floatX l_color1: COLOR1 |
Linearly interpolated Secondary color, as supplied by the vertex shader to the fragment shader. Declare "out" in the vertex shader, "in" in the fragment shader. |
floatX l_texcoord0: TEXCOORD0 |
Linearly interpolated Texture Coordinate 0, as supplied by the vertex shader to the fragment shader. You may also use l_texcoord1, l_texcoord2, and so forth. Declare "out" in the vertex shader, "in" in the fragment shader. |
out floatX o_color: COLOR |
Output Color, as supplied by the fragment shader to the blending units. Fragment shader only. (COLOR0 is also accepted.) |
out floatX o_aux: COLOR1 |
Output auxiliary color. Only available if an auxiliary was obtained for the shaders target buffer/window. Fragment shader only. |
In the latest version of Panda3D, new and advanced shader inputs are available. The available input types are
are now supported. For definition let us consider the shader parameter float3. It's type is float and format is Vec3 (meaning it can hold 3 elements) and a float3x3 input is of type float and format Mat3(meaning it can hold 9 elements)
The main concept of the shader inputs is that the Cg input format and type is independent to the Panda3D input. The only condition is that the number of elements passed by the user through the setShaderInput() function of Panda3D and the number of elements expected by the shader input should be the same. For example a parameter uniform float4x4 mat[4] (total of 16*4 elements) could be set with(the below list is just a sample and there are more ways to represent it):
But for some Cg input types there is no corresponding Panda3D type such as float3x2(Panda3D does not have a corresponding Mat3x2 class) Hence these input types can be initiated row-wise as
This row wise input can be sent to the Cg shader in any of the following ways(Note that the below list is just a sample and there are more ways to represent it)
Now, the issue of common input types such as float, double, int, long. The GPU registers generally can handle only floats. Hence even if we do send a double it will be automatically type casted into float. Hence for such type of inputs we can use above types.
Can be sent to your Cg shader program by(the below list is just a sample and there are more ways to represent it)
Below is a sample code snippet that shows how you can use the new shader inputs.
First import the necessary header to use the type of input. In our case it's Vec4. The next statement shows a Vec4 input type. Then set the Vec4 as a shader input to your model.