Announcement

Collapse
No announcement yet.

SDK for 3dsMax: VRenderInstance best practices?

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

  • #16
    Thank you very much, Yavor! With your modified code I now get identical results to the Frost plugin....~2 gigs of ram and 6 seconds to render a million spheres.

    Might take me a while to get this new setup integrated into my plugin, but I will post my results here once I get it done.

    Also...passing only certain channels (like the transform) to instances in your new code is interesting....can I pass other channels that will act as overrides on those particular instances as well? For example, materialD...or even UVs? Or do I need to create unique source voxels for those mesh variations?

    Comment


    • #17
      Great that works now

      As for other channels - unfortunately the only other channel that is obtained from the original voxel is the INSTANCE_ID_CHANNEL - one integer with some ID for that instance. It is saved for example in StaticMeshVoxelPrimitive::instanceID. After it is obtained the voxel is swapped with the source voxel and the rest of the code works with the source.

      You can obtain it in the various intersection/shading methods through something like this:
      Code:
      // rc is VRayContext - shading methods have an input param const VR::VRayContext &rc
      GenericPrimitive *primitive=rc.rayresult.primitive;
      GenericPrimitive *ownerPrim=static_cast<GenericPrimitive*>(primitive->owner);
      uint32 primType = ownerPrim->type();
      
      if(primType==PRIM_TYPE_STATIC_MESH_VOXEL) {
          StaticMeshVoxelPrimitive *voxelPrimitive=static_cast<StaticMeshVoxelPrimitive*>(ownerPrim);
          ....
      Yavor Rubenov
      V-Ray for 3ds Max developer

      Comment


      • #18
        Thanks for the example Yavor, great to see some really light c++ files to start browsing through!

        Comment


        • #19
          Hey Yavor,

          So how do I go about getting motion blur on these instances? I figured out how to assign more than one TraceTransform to the TMS_CHANNEL, but when I assign different translations to the tms, I get no motion blur (I've confirmed that the translations are indeed being set, by checking their assignment with getTM). I see a timeflags int in the MeshVoxel class, but my attempts to set the highest 16 bits to 2 (for 2 tm indices) had no effect. I can't find any relevant notes in the SDK describing how to set moblur up either.

          Comment


          • #20
            Here I've added some more code:
            vraymeshgeom2.zip

            There was a missing method VR::Box getVoxelBBox(int i, int timeFlags) in the sample - I've added it and made it call the regular getVoxelBBox. The time flags param is actually needed mainly for alembic proxy files.

            I've also modified a bit the buildVoxel code:
            • the source voxel (index=0) doesn't generate vertex velocity - if it does it will be used on all instances and if the instances
            • instead the instance voxels now provide two transforms in the TMS_CHANNEL

            In addition - I've missed to modify the getVoxelBBox for voxel 0 and it was returning a wrong bounding box.
            And one final change - in getVoxelFlags I've added the MVF_HIDDEN_VOXEL flag for the source voxel - that way it is not rendered at all. This is not strictly necessary - it's an option if you don't want to show the source, placed at (0,0,0).
            Yavor Rubenov
            V-Ray for 3ds Max developer

            Comment


            • #21
              Hey, so I've tried your new code but am basically getting the same result as I was while trying to add more transforms myself...the transforms get loaded into the proper channel but the VrayMeshGeom object renders with no motion blur. It's worth noting I'm doing this in Vray 3.60.04....has something changed since then?

              Attached is an image showing the result I get. I placed a moving sphere to the right of my VrayMeshGeom object so you can see moblur is enabled. I also placed a plane behind everything to show that the VrayMeshGeom edges are crisp...no blur at all. I double checked the code and the 2nd transform offset for each VrayMeshGeom sphere is not equal to the first, so they should definitely be moving....but yet, no blur. Any ideas? I get the same result regardless of whether or not "animated" is checked in the VrayMeshGeom parameters.
              Attached Files

              Comment


              • #22
                There was some maximum value for the movement in getRandomSphere - what if just for the test you make it much bigger ?
                Yavor Rubenov
                V-Ray for 3ds Max developer

                Comment


                • #23
                  Yea, I tried making that much bigger (default is 10, I set to 5000)...still no motion blur. I set breakpoints after center/center1 are assigned to the TraceTransforms and the values are quite spread out....but no blur is computed. Are you seeing the blur on your end?

                  Comment


                  • #24
                    This is what I got - but with V-Ray Next:
                    Click image for larger version  Name:	vraymeshgeom.png Views:	1 Size:	175.2 KB ID:	1023818
                    I'm still looking through the 3.6 code to see if there is any difference that might be causing the difference.
                    Last edited by yavor.rubenov; 22-01-2019, 10:33 AM.
                    Yavor Rubenov
                    V-Ray for 3ds Max developer

                    Comment


                    • #25
                      Actually I tried it with the 3.6 branch - it is also working the same in there ?
                      Yavor Rubenov
                      V-Ray for 3ds Max developer

                      Comment


                      • #26
                        Hmmm...it's possible that while I was tweaking things trying to get motion blur working before you posted your latest .zip file, I broken something somewhere else in the project. I will reset everything from scratch and see if I maybe that's what the issue is.

                        Edit: so the only difference between a fresh VrayMeshGeom sample project and the code you sent, is that using my version of the SDK, the "mesh.setRayServer" function requires a RayServerInterface2 pointer, whereas in your code you were passing a RayServerInterface pointer. Same goes for the MeshTest init function, which I changed to RayServerInterface2 because that's what gets returned by a call to vray->getSequenceData().rayserver, thus a RayServerInterface2 pointer is what gets passed in vraymeshgeom.cpp line 555. Other than that, everything is the same and I still get no moblur. I guess I'll keep poking around in the meantime.
                        Last edited by tysonibele; 23-01-2019, 08:01 AM.

                        Comment


                        • #27
                          Ah, it's working now! I had forgotten to check "animated" in the VrayMeshGeom rollout in this latest round of tests. I had done that previously with no luck, so I guess a combination of reverting the whole project + turning that on finally fixed things.

                          Thanks again for all your help Yavor, fingers crossed that this was the last bit of help I needed before being able to roll out all these new changes into my plugin

                          Comment


                          • #28
                            The RayServerInterface2 <-> RayServerInterface difference is expected - in V-Ray Next we merged RayServerInterface2 to first one.
                            I'm attaching the changed files as I have them in the 3.6 branch - the original ones were from the V-Ray Next branch:
                            vraymeshgeom_36.zip

                            Actually I tried with the 3.6 branch as it is nowadays. You said you are using 3.60.04 and the current one is past 3.60.05. The changes should be minimal but just in case - can you try with a stable nightly V-Ray 3.6 version ?
                            Yavor Rubenov
                            V-Ray for 3ds Max developer

                            Comment


                            • #29
                              Aa nice to hear that it is working now. If there's anything else - do write back
                              Yavor Rubenov
                              V-Ray for 3ds Max developer

                              Comment


                              • #30
                                So I've got basically everything implemented in my plugin now and it's all working great....except there's something funky going on with texture map sampling. And I noticed this happening in the VrayMeshGeom sample project too....it seems that the "blur" value in bitmap texmaps is being translated improperly by vray instances. The value corresponds to the amount of texture blurring that will occur, based on an object's distance to the camera....however when rendering with instances the default value is causing super-blurred textures...and I'm guessing it's because somewhere in the VrayMeshGeom code the length of a ray to intersected geo is not being calculated correctly? I tried messing with the various values in the setIntersectionData functions, but am having no luck.

                                Attached are 2 example images of a single triangle instance rendering from my plugin, using the exact code you provided for the VrayMeshGeom project in instance.cpp. The triangle is approximately 200 scene units away from the camera. You can see when bitmap blur is set to 1 (default), the texture renders extremely blurry. When it's set to .01, the texture renders closer to expectations.

                                Any ideas what's causing this?

                                Comment

                                Working...
                                X