Announcement

Collapse
No announcement yet.

shader writing

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

  • shader writing

    Hi,

    I have a question on the V-Ray SDK.

    I extended the vray_texdirt example so that i can sample the curvatures of Objects. So far it works, but because it samples the curvature I need really too many rays to get a smooth result. I also have to set the max raylength in the subdivision settings to 1.0 to get rid of lines in my rendering. So it works but takes way too long and isn't accurate enough for my needs.

    Now I just found this interface "VUtils::NormalDerivativesInterface" . Could this be used to get the curvature of Objects, since the derivates of the normals should give you the change between the normals, what seems to be the same as what I think curvature describes. In the rayParams of a VRayContext I can only get DDdx and DPdx, but cant find DNdx anywhere...

    In the SDK there is just not enough information on how to handle it. Is there an example where it is used? And is there a way to get the normal derivates in UV-space, or what exactly is meant by x and y directions in the description? ( "Return the derivatives of the surface normal in the x and y directions for the given intersection point." ) Is it the x and y of the image plane? And if so, will there appear wrong results on edges?

    Any help is very welcome!

    Thanks, Fex

  • #2
    The normal derivatives computed by V-Ray are not continuous from one triangle to another (in fact, V-Ray just returns the difference between the vertex normals for each triangle), so I doubt that it will be of any use.

    The VRayDirt approach is a very inefficient way to do what you want. What you probably want to do is something similar to the VRayToon sample from the SDK which just takes the normal in a few (4 or points around the shaded point and computes the differences between their normals essentially approximating the normal derivatives on its own.

    Best regards,
    Vlado
    I only act like I know everything, Rogers.

    Comment


    • #3
      Hi Vlado,

      thank you for the hint with VRayToon. I had a first look at it and I I'll give it a try. Is it possible to implement the used evalGradient-method in my texture? What is the reason that the VRayToon is an atmospheric or volumetric effect? When i try to create it via create > vray > create from V-Ray plugin > Volume Shader Maya crashes.

      Another idea I'm thinking of is to directly derivate the normalpass. Is there a way to do that by looking at the rendered normalpass, so kind of post-pass? Because the normalpass looks quite smooth so the changes from on normal to the next should be of same smoothness, except on borders.

      Or the world normals could be baked onto a UV-texture for the objects. Then this texture could be derivated (somehow?!) and put onto the objects again. maybe this is the most accurate? because there should be no problems on borders I think.

      What I actually want to do is create a Z-Depth for reflections based on the curvature of objects, since it influences where the focus point must be to get sharp reflections. Thats why I need very accurate and smooth information about the curvature, with my sampling method its too noisy.

      Maybe you have some more ideas on this topic? Appreciate it very much!

      Thanks,
      Fex

      Comment


      • #4
        Originally posted by fexmedia View Post
        When i try to create it via create > vray > create from V-Ray plugin > Volume Shader Maya crashes.
        Can you give us the exact steps needed to reproduce this crash, because we couldn't?
        Also what version of Maya, V-Ray and OS are you using?
        V-Ray developer

        Comment


        • #5
          Of course. I just start Maya 2013 (here the 30 day trial), load V-Ray (student license), create a primitive cube or sphere and try to do: create > vray > create from V-Ray plugin > Volume Shader > VolumeVRayToon.

          I did the same a moment ago and it worked, then i created a new scene and tried to load it again and it crashes. Maybe it happens when hypershade is already open when the node is created.

          I also first can't see the parameters of the node (in case it was created succesfully). I can't see them until I switch the renderer from maya software to vray and the vraySettings node appears in hypershade. Then after clicking on vray settings and going back to VolumeVRayToon I can see the parameters. But if I then try to create another VRayToon Node Maya crashes again.

          So Maya 2013 30-day-trial, VRay4Maya Edu, Windows 7 64-bit. Do you also need hardware specs?

          Comment


          • #6
            Hi,

            Because we didn't manage to get that crash (even with an EDU version) I'd like to ask if it's not much trouble for you to make a screen recording of what you do when it crashes. There must be something that we're missing here.

            Thanks in advance.
            Alex Yolov
            Product Manager
            V-Ray for Maya, Chaos Player
            www.chaos.com

            Comment


            • #7
              Hi yolov,

              here's a link to a video when I try to load the plugin.
              https://dl.dropboxusercontent.com/u/...01%2016.32.avi

              hope that helps...

              Fex

              Comment


              • #8
                Originally posted by fexmedia View Post
                thank you for the hint with VRayToon. I had a first look at it and I I'll give it a try. Is it possible to implement the used evalGradient-method in my texture?
                Of course you would do a texture.

                What is the reason that the VRayToon is an atmospheric or volumetric effect?
                Because it needs to produce toon lines not only on objects, but also on the background.

                Another idea I'm thinking of is to directly derivate the normalpass. Is there a way to do that by looking at the rendered normalpass, so kind of post-pass? Because the normalpass looks quite smooth so the changes from on normal to the next should be of same smoothness, except on borders.
                You will get issues at the borders...

                Or the world normals could be baked onto a UV-texture for the objects. Then this texture could be derivated (somehow?!) and put onto the objects again. maybe this is the most accurate? because there should be no problems on borders I think.
                This might be the best way to make it work, yes. But you'll need to bake the normals to a map channel and I don't now how you would do this in Maya (you can do it in 3ds Max very easily though). Do you plan to use motion blur for this?

                Best regards,
                Vlado
                I only act like I know everything, Rogers.

                Comment


                • #9
                  Hi Vlado,

                  thank you for answering all my questions! But I still figured out some problems. I tried to bake world normals to a texture and I think it worked correctly (I did it with the MR bake sets, using the normal camera of a samplerInfo and the WorldMatrix of the camera and did a vectorMatrxProduct). Then I tried different ways to get the derivate of that texture, but never got the result i expected. I thought that sobel filter would do the job, but i wasn't able to get correct results. But besides I wasn't able to get the derivate of my texture I thought about another problem. For example if I have a sphere, the UVs of the faces will differ in size. So the UVs are not a true representations of the size and shape of the 3D-faces, means they can't be completely unfold. This means I have equal faces in 3D-space which can be different in size in the UV-space. But each face describes the same normal change from one edge to the other. So if the UVs of one face has 10 pixels from one edge to the other and another one 20 pixels, I will have a different value of curvature on both faces although in 3D-space they both have the same curvature. So if the normal change between the 2 edges is 10° I have in the first case (10px) a change of 1° per pixel, in the second case (20px) it's just 0.5° per pixel. I hope you get what I mean, hard to describe... But it looks like that this is also no opportunity.

                  Now I'll go back and try the toonShader-way, I'm just not sure if this will be accurate enough. Is it really that hard to get the real curvature of a surface?

                  Untill now I didn't think about motion-blur. Rendered 3D-Motionblur will probably make the result useless for postpro, but I think motionblur can also be assigned in post with motionvectors, then one should be able to combine both effects. Need to test that...

                  So thank you very much for your effort, if you ore anyone else still have some good ideas on how to get the curvature they are very welcome =) also if anyone knows a good way to get the derivate of an image it would be nice to know!

                  Best regards,
                  Fex
                  Last edited by fexmedia; 02-08-2013, 08:19 AM.

                  Comment

                  Working...
                  X