Camera modifier in 3ds Max 2024

Camera modifier in 3ds Max 2024

bodyulcg
Explorer Explorer
1,378 Views
4 Replies
Message 1 of 5

Camera modifier in 3ds Max 2024

bodyulcg
Explorer
Explorer

Faced one problem. I wrote a scripted modifier that worked in all the latest versions of 3ds Max including 2023. But in 3ds Max 2024 (including update 1) on the physical camera, the program freezes when starting the render. Also, the modifier cannot be added to the cameras of third-party render engines, such as VRay or FStormRender, due to the fact that it is not in the list of modifiers.

 

The code is something like this:

 

plugin modifier CameraMod
name:"Camera Mod"
classid:#(0x673ca7f0, 0x46ef9c4b)
(
    parameters main rollout:params
    (
        amount type:#float ui:spnAmount
    )
    
    rollout params "Parameters"
    (
        spinner spnAmount "Amount: "
    )
)

 

 

 

It turned out that if the built-in modifier can be added to third-party cameras, then it works fine on the physical and does not cause a freeze.

The first thing that came to mind was to inherit from the modifier class that can be added to FStormCamera. The full list is here. I used CamPerspCorrect. But when adding "extends:CamPerspCorrect" or any other class, 3ds Max crashes when opening old scenes that contain a non-inherited modifier.

 

Here's what I did, but I'm not sure if it's the right solution:

 

  • Renamed current class to CameraMod_Legacy and added "invisible:true".
  • Made a new class, with the old name but a new classid, inherited from CamPerspCorrect.
  • Made a conversion from legacy to a new modifier using #filePostOpen callback, but as an alternative it can be done in the legacy version in the load / postload event.

Whole code:

 

plugin modifier CameraMod_Legacy
name:"Camera Mod"
classid:#(0x673ca7f0, 0x46ef9c4b)
invisible:true
(
    parameters main rollout:params
    (
        amount type:#float ui:spnAmount
    )
    
    rollout params "Parameters"
    (
        spinner spnAmount "Amount: "
    )
)

plugin modifier CameraMod
name:"Camera Mod"
classid:#(0x673ca7f1, 0x46ef9c4b)
extends:CamPerspCorrect
replaceUI:true
(
    parameters main rollout:params
    (
        amount type:#float ui:spnAmount
    )
    
    rollout params "Parameters"
    (
        spinner spnAmount "Amount: "
    )
)

fn checkForLegacyCameraModInstances =
(
    local legacyInstances = getClassInstances CameraMod_Legacy
    for legacy in legacyInstances do
    (
        local new = CameraMod()

        for p in getPropNames legacy where isProperty new p do
            setProperty new p (getProperty legacy p)

        replaceInstances legacy new
     )
)

callbacks.addScript #filePostOpen "checkForLegacyCameraModInstances()"

 

 

Question:

Did I do everything right? Maybe instead of CamPerspCorrect, it's better to use another one, for example, EmptyModifier_Old (Attribute Holder (Old))?

0 Likes
1,379 Views
4 Replies
Replies (4)
Message 2 of 5

JasonLuckett
Advocate
Advocate

Why hasn't this been addressed Autodesk, this is over 6 months old and from a great little developer?

 

After finally updating to 2024 after the cursory 3 month wait for bugs to be ironed out, I hit this problem today and have discovered this problem.

 

This little script is very useful, it should be incorpoarted into your never updated physical camera.


Does anyone from Autodesk ever read these boards?

 

Thanks @bodyyulcg for chasing this.

 

Jason

0 Likes
Message 3 of 5

istan
Advisor
Advisor

I'd create a ticket and post it to: https://beta.autodesk.com 

0 Likes
Message 4 of 5

giuseppe.schiralli
Autodesk
Autodesk

We will look into this. I'll forward the code to our devs.

 

Can you please confirm that if the viewport is not set to the Physical camera (for example Perspective), a rendering using Arnold RenderView set to the Phys camera works fine?


If I read correctly, there are 3 problems:

- rendering freezes when the custom modifier is applied to a Phys camera, regression from Max 2023

- the modifier cannot be applied to a 3rd party camera, unless it extends an existing modifier

- compatibility issue with old scenes with a non-inherited modifier.

 

Thank you for the report.

 

-Giuseppe

 

 


Giuseppe Schiralli
3ds Max - QA Analyst>
0 Likes
Message 5 of 5

denisT.MaxDoctor
Advisor
Advisor

Based on the description above, I understand that this is not a camera modifier per se, but rather a modifier used as a container for custom parameters. In that case, it would be more correct to use a custom attribute added to the base camera object. This approach would avoid problems with any camera, including third-party cameras.