Home Technical Talk

Removing RGB Tint en-mass

polycounter lvl 18
Offline / Send Message
JonMurphy polycounter lvl 18
Ah, the joys of switching assets to a different engine. confused.gif

Anyway, the issue is this. We have an environment, in MAX 5. All the materials have a structure like this:

Diffuse - RGB Tint - Bitmap

Unfortunately, the engine we are switching to, the exporters do not recognise the RGB Tint, and is dropping the bitmap, so we have a very flat world. Resources are tight atm, so rather than re-tooling the exporter, I need to find a solution in MAX. I would like to keep the RGB Tint in the materials, as this gives me the opportunity to lay down blocks of colour to multiplay over bitmaps.

I need to figure out a MAXScript to take

Diffuse - RGB Tint - Bitmap

and give me:

Diffuse - Bitmap

Unfortunately, I don't have my MAXScript books with me here at work, or I would be plugging away now. Was wondering if any MAXScript gurus knew of anything already out there that could do this, or a suitable script that can be jerry-rigged into the task?

Replies

  • Eric Chadwick
    Kinda like MaterialReplacer, but not really.
    http://plugins.angstraum.at/

    One way that might work is to use BFF to convert the scene to a script file, then replace all the RGB Tints with a global replacer (I like ReplaceEm ), then load the script back in.

    Although a script jock will probably come along with a better way...
  • CrazyButcher
    Offline / Send Message
    CrazyButcher polycounter lvl 18
    not tested but maybe this does the job, assuming you use standardmaterial:

    -- remove rgbtint

    for m in scenematerials do (
    if (classof m == standardmaterial and classof m.diffusemap == rgb_tint) then
    (
    m.diffusemap = m.diffusemap.map1
    )
    )
  • JonMurphy
    Offline / Send Message
    JonMurphy polycounter lvl 18
    No dice on that, I'm afraid.

    The trouble is, I need to find away of copying the bitmap value sitting in the RGB tint slot, and pasting that into the diffuse.

    All materials are standard, but they are sitting in multi-sub lists.

    Not done MAXScript for materials before. frown.gif

    *dives back into help files*
  • CrazyButcher
    Offline / Send Message
    CrazyButcher polycounter lvl 18
    this here should work (at least did for me)

    <font class="small">Code:</font><hr /><pre>
    function relink_diffuse m = (
    if (classof m.diffusemap == rgb_tint) then
    (
    m.diffusemap = m.diffusemap.map1
    )
    )

    function process_mat m = (
    if (classof m == standardmaterial) then (
    relink_diffuse m
    )
    else if (classof m == multimaterial) then
    (
    for subs in m.materiallist do (
    process_mat subs
    )
    )
    )

    function removetint = (
    for m in scenematerials do (
    process_mat m
    )
    )
    </pre><hr />
  • JonMurphy
    Offline / Send Message
    JonMurphy polycounter lvl 18
    I get

    <font class="small">Code:</font><hr /><pre>-- Syntax error: at ), expected <factor>
    -- In line: )</pre><hr />

    When pasted into the MAXscript listener

    I have tried wrapping it in a utility, but I get feedback on the listener with that, and nothing happening.

    <font class="small">Code:</font><hr /><pre>Utility removergbtint "Remove RGB Tint"
    (

    Button remove "Remove RGB Tint"
    on remove pressed do
    (

    function relink_diffuse m = (

    if (classof m.diffusemap == rgb_tint) then

    (

    m.diffusemap = m.diffusemap.map1

    )

    )



    function process_mat m = (

    if (classof m == standardmaterial) then (

    relink_diffuse m

    )

    else if (classof m == multimaterial) then

    (

    for subs in m.materiallist do (

    process_mat subs

    )

    )

    )



    function removetint = (

    for m in scenematerials do (

    process_mat m

    )

    )

    )
    )</pre><hr />
    Using MAX 5 here
  • CrazyButcher
    Offline / Send Message
    CrazyButcher polycounter lvl 18
    oh you must run the function
    removetint() on pressed, I fixed your utility here

    http://planetquake.com/polycount/cottages/crazybutcher/code/removetint.ms
  • JonMurphy
    Offline / Send Message
    JonMurphy polycounter lvl 18
    I owe you many, many cookies smile.gif
Sign In or Register to comment.