Announcement

Collapse
No announcement yet.

VrayToonMtl: create diffuse ramp and specular ramp through maxscript - how to?

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • VrayToonMtl: create diffuse ramp and specular ramp through maxscript - how to?

    Hi to all!

    I try in VrayToonMtl create keys for Diffuse Ramp and specify color and position for each key through a maxscript, but for some reason this does not work.
    This is a snippet of the script with which I am trying to do this:

    Code:
    toonMtl=VrayToonMtl()
    diffRamp_pos=#(0.0, 1.0, 0.5, 0.75)
    diffRamp_colors=#((color 0 0 0), (color 255 255 255), (color 255 0 0), (color 0 255 0))
    toonMtl.positions=diffRamp_pos
    toonMtl.colors=diffRamp_colors
    for k=1 to diffRamp_pos.count do
    (
    toonMtl.keyCol=diffRamp_colors[k]
    toonMtl.keyNum = k-1
    toonMtl.keyPos = diffRamp_pos[k]
    )
    What is strange - when I then take the parameters from the material, they show that the positions and color are assigned, but no keys are created.
    It is only possible to create the corresponding keys manually by clicking on the gradient ramp and selecting the "Add Key" option in the material editor.
    Can this be done at all through a script or is it impossible?
    Thanks!
    Last edited by 3DZver; 06-06-2020, 08:57 AM.
    V-RayMax Converter PRO
    MAXTools

  • #2
    I raise the topic. Really no one can with this question? And for some reason, even the developers are silent
    V-RayMax Converter PRO
    MAXTools

    Comment


    • #3
      Hi there is overlapping of the parameters of the Diffuse and Specular ramps. This is definitely a bug. but as of the moment consider them read only as it is undetermined which ones will get updated. We will fix this, sorry about the inconvenience.

      Best regards,
      Alexander
      Alexander Kazandzhiev
      V-Ray for 3ds Max developer

      Comment


      • #4
        Originally posted by alexander.kazandzhiev View Post
        Hi there is overlapping of the parameters of the Diffuse and Specular ramps. This is definitely a bug. but as of the moment consider them read only as it is undetermined which ones will get updated. We will fix this, sorry about the inconvenience.

        Best regards,
        Alexander
        Thanks for the detailed answer. Regarding the overlapping of the Diffuse ramp and Specular ramp parameters - I also noticed this and this should have been my second question)
        I will wait for fix this bug!
        V-RayMax Converter PRO
        MAXTools

        Comment


        • #5
          After installing V-Ray 5 hotfix 2, I found that a bug with overlapping Diffuse ramp and Specular ramp parameters was fixed. Now these parameters can be controlled separately via maxscript. Thanks to the developers for this!
          Unfortunately, there is still the problem of creating ramp keys via maxscript.
          At the moment, through maxscript is possible to control (change color and position) only those keys that were previously created manually: "mouse right click-> Add Key", but new keys are not created.
          Can we hope that in future versions this feature will appear?
          Last edited by 3DZver; 06-08-2020, 04:53 AM.
          V-RayMax Converter PRO
          MAXTools

          Comment


          • #6
            Hi,

            It's quite obscure, but there are 4 arrays that are used for the diagram keys' map/color/position/interpolation respectively:
            Code:
              .diffuse_ramp_submaps
              .diffuse_ramp_colors
              .diffuse_ramp_positions
              .diffuse_ramp_interpolations
            and
            Code:
              .reflection_ramp_submaps
              .reflection_ramp_colors
              .reflection_ramp_positions
              .reflection_ramp_interpolations
            So to add new key one should append a new element to all the four arrays, e.g.:
            Code:
            append toonMtl.diffuse_ramp_submaps undefined
            append toonMtl.diffuse_ramp_colors (color 255 0 0)
            append toonMtl.diffuse_ramp_positions 0.6
            append toonMtl.diffuse_ramp_interpolations 0
            I think we could improve this, will try some ideas. As I see it the most convenient would be to add a method so one could do "toonMtl.addDiffuseRampKey(undefined, (color 0 0 0), 0.6, 0)"

            Best regards,
            Alexander
            Last edited by alexander.kazandzhiev; 12-08-2020, 04:00 AM. Reason: Wrong reflection_ramp parameters were quoted
            Alexander Kazandzhiev
            V-Ray for 3ds Max developer

            Comment


            • #7
              Hi, Alexander

              Thanks for the detailed answer!
              I found an error in my code, due to which keys were not created for me: instead of completely replacing the entire arrays with new values, I had to use the "append" command to add new values ​​to the arrays of positions and colors. I also forgot to include the "submaps" array.
              Indeed, when adding new position and color values ​​to the corresponding arrays with the "append" command, new keys are created automatically and everything works correctly.
              However, it would be much more convenient if a special function is added to create new keys in the future, according to your example "toonMtl.addDiffuseRampKey (undefined, (color 0 0 0), 0.6, 0)"
              Thank you!
              Last edited by 3DZver; 15-08-2020, 06:05 AM.
              V-RayMax Converter PRO
              MAXTools

              Comment

              Working...
              X