Exhaustive list of all the built-it uniforms avaiable in Jitter shaders
This is a list of the built-in uniforms available in Jitter shaders in Max 9
MATRICES:
type="mat4" state="MODELVIEW_PROJECTION_MATRIX" == P * V * M
type="mat4" state="PREV_MODELVIEW_PROJECTION_MATRIX" == the previous frames modelview-projection matrix
type="mat4" state="VIEW_PROJECTION_MATRIX == P * V
type="mat4" state="MODELVIEW_MATRIX" == V * M
type="mat4" state="VIEW_MATRIX" == V
type="mat4" state="WORLD_MATRIX" == transforms into world coordinates
type="mat4" state="PROJECTION_MATRIX" == P
type="mat4" state="CAM_PROJECTION_MATRIX" == (gl3 only) Provides the current rendering camera projection matrix; in most cases is equivalent to PROJECTION_MATRIX except in cases where a full-screen quad is rendering, e.g. in a jit.gl.slab/pix (or jit.gl.pass)
type="mat3" state="NORMAL_MATRIX" == it orients normals in eye space
type="mat4" state="TEXTURE0_MATRIX" == Transforms normalized texture coordinates into rect coordinates
CAMERA:
type="float" state="FAR_CLIP" == Camera far clipping distance
type="float" state="NEAR_CLIP" == Camera near clipping distance
type="vec3" state="FAR_CORNER" == far corner of the view frustum
type="vec3" state="CAMERA_POSITION" == camera position in world space
type="vec3" state="CAMERA_DIRECTION" == camera direction in world space
type="vec2" state="VIEWPORT" == the pixel size of rendering window
type="vec2" state="INVERSE_VIEWPORT" == the inverse of the viewport dims
LIGHT:
type="mat4" state="LIGHT_VIEWPROJ_MATRIX0-7" == transforms positions to light space
type="float" state="LIGHT_RANGE0-7 " == distance reached by the light
type="vec3" state="LIGHT0-7_POSITION" == position of the light
type="vec3" state="LIGHT0-7_DIRECTION" == direction of the light
type="vec4" state="LIGHT0-7_AMBIENT" == ambient light color
type="vec4" state="LIGHT0-7_DIFFUSE" == diffuse light color
type="vec4" state="LIGHT0-7_SPECULAR" == specular reflection color
type="float" state="LIGHT0-7_CUTOFF" == the spotlight cutoff in degrees (=spotlight angle)
type="float" state="LIGHT0-7_EXPONENT" == exponent implied in the reflected light calculation
MATERIAL:
type="vec4" state="DIFFUSE" == material diffuse color
type="vec4" state="AMBIENT" == material ambient color
type="vec4" state="SPECULAR" == material specular color
type="vec4" state="EMISSION" == material emission color
state="FRONT_MATERIAL" == gives the values from the @mat_X attributes of the 3Dobj to which the shader is attached.
VERTEX:
type="vec3" state="POSITION" == XYZ Position
type="vec4" state="COLOR" == RGBA Color
type="vec3" state="NORMAL" == Normal vectors
type="vec3" state="TANGENT" == Tangent vectors
type="vec3" state="BITANGENT" == Bitangent vectors
type="vec3" state="VERTEX_ATTR" == Custom vertex attribute
type="vec3" state="VERTEX_ATTRn" == (where "n" is an integer number) Nth custom vertex attribute
type="float" state="EDGEFLAG" == unused, ignore
TEXTURES:
type="vec2" state="TEXDIM0" == XY Dimension of texture 0
type="vec2" state="TEXCOORD" == XY texture coordinates
TIME:
type="int" state="FRAME" == index of the current frame
type="float" state="TIME" == time elapsed since the shader has been compiled
type="float" state="GLOBALTIME" == time elapsed since the rendering context has been activated
type="float" state="DELTA_TIME" == time elapsed between successive frames
RENDER TARGETS (in jit.gl.pass):
COLOR == the rendered image (rgba)
NORMALS == view-space normals (rgb) + normalized depth (a)
VELOCITY == normalized velocity vectors (rg)
ENVIRONMENT == The currently active environment map, accessible as cubemap
DEPTHPEEL == 4 layers of depth values (first front-face, first back-face, second front-face, second back-face). Depth is represented by the z coordinate of the view-space fragment's position (negative)
ROUGHMETAL == the roughness (r) and metalness (g) values. Works only when jit.gl.pbr is used for shading
ALBEDO == the fragments' albedo color
Thank you for this Matteo!
You are right, the MODEL_MATRIX doesn't exist. The Model Space is just the position of the vertices as they come from inside the model, in which usually the 0,0,0 is the center of the model itself.
If you need the coordinates in WORLD SPACE you can use the WORLD_MATRIX built-in.
FRONT_MATERIAL will give you the values from the @mat_X attributes of the 3Dobj to which the shader is attached. layout (std140) uniform FrontMaterialParameters {
Check the shader generated by the jit.gl.material object with the get_gl3_shader message to see how this works.
MaterialParameters frontMaterial;
};
You probably know this already but maybe can be useful for others: in the Max documentation "Appendix C: The JXS File Format" one can find all the built-in variables for the GLSL jxs shader format.
Thank you very much Federico!
I honestly missed that appendix...I added the missing entries in the original post, but some are still a bit obscure to me:
type="mat4" state="PREV_MODELVIEW_PROJECTION_MATRIX" == ???
type="mat4" state="CAM_PROJECTION_MATRIX" == This one doesn't exist in the documentation, but i found it in mrt.ssao.render.gl3.jxs
type="vec3" state="FAR_CORNER" == far corner of the view frustum???
type="vec2" state="VIEWPORT" == ???
type="vec2" state="INVERSE_VIEWPORT" == ???
type="float" state="LIGHT0-7_CUTOFF" == spot light falloff???
type="float" state="EDGEFLAG" == ???
Ok so I think I can only add my contribution with VIEWPORT, which is simply the size in pixels of the rendering window.
Keep it up Matteo! GLSL needs to be demystified
PREV_MODELVIEW_PROJECTION_MATRIX - the previous frames modelview-projection matrix, used for velocity based effects (e.g. jit.gl.pass @fxname motionblur)
CAM_PROJECTION_MATRIX - gl3 only, provides the current rendering cameras projection matrix, which in most cases is equivalent to PROJECTION_MATRIX except in cases where a full-screen quad is rendering, e.g. in a jit.gl.slab/pix (or jit.gl.pass). used in the gl3 engines ssao effect
FAR_CORNER == far corner of the view frustum??? - yup. used for depth rebuilding i think, can't quite remember. ssao shader maybe?
VIEWPORT - as federico says above, the pixel size of rendering window
INVERSE_VIEWPORT - just as it sounds, the inverse of the viewport dims
LIGHT0-7_CUTOFF - the spotlight cutoff in degrees, another name for the spotlight angle
EDGEFLAG - unused, ignore
Thank you so much, Federico and Rob!
I updated the list in the first post.
I'll soon indicate for each built-it uniform a .jxs file in which it gets used, so that each variable can be seen in action in a reference patch.
btw, I wanted a "PREV_MODELVIEW_PROJECTION_MATRIX"-like variable so bad, and it was right under my nose...
cool, thanks much for taking the initiative here!
btw the PREV_MODELVIEW_PROJECTION_MATRIX is not yet implemented in gl3, but I hope to fix that sooner than later
Insane help here, and some example of code in action would indeed be of enormous value :o, I'm following you guys : )
Hi Riccardo, this tutorial I made today should be a fitting example of code in action:
https://youtu.be/gKIVuVCfBws
Oww, I felt like being halfway to convert it and here you come. Thanks for the enlightening coding.
texture2D became texture... what about texture2DRect? If textureRect is the solution, this wasn't my real problem :o
I've been feeding a shader with two textures, the first for extrusion purpose, the second is the texture to be applied over the distorted shape. If i use "outColor = color" I can see my grey shape being distorted from the first texture, but when I'm trying to use my second texture, I'm getting this...


I'm hoping the problem lies here, if it is not, I can share the full code attached to a simple patcher as example.
Best regards
Hi Riccardo, I think you get this error because you are using a vec4 as a second argument to the function "texture", which takes a vec2 as a second argument.
I think you mixed up multiplying the texcoord by the texture matrix, for which you need a vec4, and using the texcoord to read the texture with the "texture" function.
It totally make sense. Still I'm playing with an invisible shape ohoh.
I'll give it some more tries.
I found another one:
state="BACK_MATERIAL"
What is this? I guess it something related/opposite to FRONT_MATERIAL
undocumented and unsupported at this time
ah ok, thanks!
I found this in one of the gl3 example patches
quick note to say that as of 8.2 (and the bundled gl3), PREV_MODELVIEW_PROJECTION_MATRIX should now be functioning as expected in a gl3 context.
Great!!! Thanks!
I don't know if this list is still a valid reference for someone, but i updated it with the new built-in uniforms available in Max 9.
Super useful, thank you Matteo!