Notifications
Clear all

[Closed] Colour access in Scripted Plug-In?

I’m looking to have access to the colour channels of a texture in a scripted material or textureMap plug-in.

Say for example I want to change the saturation of a texure, or multiply its green channel by the red channel of another texture. I know I can change the whole texture map by loading it, modifying it and then writing it out again using bitmap, getPixel and setPixel.

I was wondering if it is also possible to have it behave more like a shader and process the texture colour as it is requested by the renderer.

So instead of processing the whole map before render I would like something like a scripted shader with just a simple function which will modify the output colour of the map as it passes through. Is this possible using maxscript?

I hope this makes sense.

Thanks,
Rens

8 Replies

Unfortunately there is no native access to colour information of textures at rendertime for maxScript.

I tried writing a plugin that would allow users to create scripted texturemaps, but I could never get it to work.

If it helps in some way, I did write a script extension that allows you to query a texture map at a specific point while in the UI. Get WahooneyMXS here.

If that doesn’t help you’ll have to find a more conventional solution to your problem.

I see, yes I’ll have to script my way around it then.

Thanks!

 rdg

I remember something like a RSL-compatible material – years ago.
Something that let you use rsl code to build a material and render it with scanline?
Maybe my memory is too pink …

Georg

1 Reply
(@pixel_monkey)
Joined: 10 months ago

Posts: 0

That would be the MaxShade plugin and it worked with 3rd party plugins as well. However, it has not been recompiled since it was added to sourceforge in 2004. Also, the source code seems to not be available there.

Note: I found what looks to be the source code available here. So if anyone cares to recompile it have at it.

-Eric

Thank you, I’ll have a look, see if I can find it.

Right now I’m looking to get the dot product of two vectors (3 channels) and then multiply the resulting scalar (1 channel) with one of the channels of a texture map.

For example in XSI there are math shading nodes for mental ray, in which you plug your textures and it passes it along again, doing the math operation you’ve selected.
I’ve found something very similar for max on Jan Sandtrom’s website (link), but it seems that max won’t allow anything to go below 0, making some of the operations give unexpected results.
Check out the shaders named something like ‘JS_VectorMath_Vector’.

I tried the Schematic Material Editor which has a math node, but it’s just add, multiply and such.

So for now it seems like I’ll have to either code a shader myself (for scanline or mr), or use a scripted material which calculates the maps before rendering. Not too fluid in the shader coding so it seems I’ll have to use a scripted mat. I’ll keep looking for the shader you described.

 rdg

thanks Eric!
Since 2004 my sl compatiblity was getting better, too.
Would be cool if somebody can recompile this.

Though I don’t know if this would allow the texturemap access …

Georg

Rens,
Have you checked out Color Correct by Cuneyt Ozdas?

ColorCorrect is a 3DS Max texture plug-in which alters the colors of any (bitmap or procedural) texture so that you can fine tune the colors or create a variation of it. It eliminates going back and forth between Photoshop and max and also lets artists to use the same map in different parts of the scene to reduces memory consumption. To give you full control all the parameters are mappable. I was inspired by CC tool of discreet’s Flint software (at that time 3ds max was not a Discreet product).
You can get the latest Beta here.

-Eric

Thanks guys, MaxShade seems so awesome to work with, too bad it’s not updated anymore.

PiXeL_MoNKeY – Yep, I’ve used CC a couple of max versions ago. Very useful, but right now I need to get things like the dot product of a map value and a vector. Seems like MaxShade would be perfect for the job as you basically script your shader.

rdg – From what I’ve seen in the docs you can drop maps like diff, spec into the MaxShade material plugin. I assume you can access those ports in the rsl shader.