Globally set material for gridshapes without changing color

justintrigue's icon

Hello Again Community,

I've got a patch which is parsing incoming OSC messages and generating sphere gridshapes dynamically. I've got the colors of the individual spheres (see the 'balls' subpatcher) as arguments in their objects, but there's a jit.gl.material which is globally setting the texture of the spheres. Since this animation is reminiscent of planets in orbit, I wanted to try setting the texture of the global material object to the packaged dirt.wall. Doing so cancels out my sphere's selected colors. Anyone see what I need to do to retain the selected color, but apply a different texture from the global jit.gl.material object? Or do I need to add names/flags to make this work?

Thanks!

4944.spheres.maxpat
Max Patch
Rob Ramirez's icon

when you load the dirt.wall material file (either using the @matfile attribute, or from the material browser) it forces the jit.gl.material object to override any color values on your attached gl objects.

jit.gl.material will override attributes of attached objects, whenever you provide a value for that attribute, and loading a material file usually provides those attributes.

the solution is to not provide those attributes to the gl.material object, and instead manually build your material using the texture inputs and material options.

Max Patch
Copy patch and select New From Clipboard in Max.

the below patch should get you started, let me know if you have questions.
the built-in material files all live in Max6/Cycling '74/jitter-materials/dirt.wall.jitmtl
and are just text file that can be opened in any text editor.

justintrigue's icon

Thank you, Rob. The solution is beautifully simplistic! And thanks for all your work on the excellent tutorials you do on the site. They are certainly a source of inspiration!

Random question: Are there any Max/MSP/Jitter training programs, university programs or even instruction offered by Cycling 74 that you could recommend? I'm learning a ton just through the forums, but could use some traditional teaching regarding jitter expressions and the more complex objects available.

matmat's icon

hi
Peter Elsea wrote some amazing jitter tutorials: ftp://arts.ucsc.edu/pub/ems/maxtutors/Jit.tutorials/

Rob Ramirez's icon