PDA

View Full Version : Colour access in Scripted Plug-In?


Rens
07-25-2007, 11:57 PM
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

Wahooney
07-26-2007, 09:12 AM
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 (http://www.wahooney.net/download.php?view.59).

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

Rens
07-26-2007, 09:21 AM
I see, yes I'll have to script my way around it then.

Thanks! :thumbsup:

rdg
07-26-2007, 06:46 PM
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

Rens
07-26-2007, 07:30 PM
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 (http://www.pixero.com/downloads_mr.html)), 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.

PiXeL_MoNKeY
07-26-2007, 07:47 PM
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 ...

GeorgThat would be the MaxShade (http://sourceforge.net/projects/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 (http://public.planetmirror.com/pub/sourceforge/m/ma/maxshade/?fl=). So if anyone cares to recompile it have at it. :P

-Eric

rdg
07-27-2007, 08:17 AM
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

PiXeL_MoNKeY
07-27-2007, 02:06 PM
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 (http://www.cuneytozdas.com/forum/topic.asp?TOPIC_ID=526).

-Eric

Rens
07-27-2007, 08:13 PM
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.

CGTalk Moderation
07-27-2007, 08:13 PM
This thread has been automatically closed as it remained inactive for 12 months. If you wish to continue the discussion, please create a new thread in the appropriate forum.