Announcement

Collapse
No announcement yet.

How to remap Refraction by using the Ray depth ?

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

  • How to remap Refraction by using the Ray depth ?

    Hi Guys,

    I would like to know what would be the correct workflow to achieve this.

    I would like to :
    - get the length of the refracted ray inside the object.
    - remap this length beetween 0cm to 5cm to a floating value beetween 0 to 1
    - use the normalize float in a color ramp that i will plug in the fog color
    - use the normalize float in a float ramp that i will plug in the refraction roughness

    My goal is to be able to control
    - refraction color
    - refraction roughness
    Throw a ramp to get a full control on the aspect of the refraction.

    I'm coming from a Mantra / Prman Background so maybe the way i want to do it is stupid in the vray world,
    so if any other methods is better to achieve this i would be happy to know it !

    Thanks for your time !

    I have attach a screenshot of what i try to do without success at the moment !

    Cheers

    E

    Click image for larger version

Name:	vray_transmission.jpg
Views:	1
Size:	367.6 KB
ID:	883949

  • #2
    After some trial it look that ray depth is not what i thought.
    It returns an integer that represent the number of time the ray has been refracted previously.
    So in my case it return 0.

    Path Length does look to match my needs better but it represent the distance beetween camera and the shaded point.
    This is what houdini use to fake his transmission attenuation.

    But i was trying to know if we can access when a ray is refracted : his length inside the object.
    So for exemple if we have a cube of 10 cm facing the camera we can access the refracted ray depth beetween 0cm to 10cm

    My goal here is to get
    - white refraction with gloss at 1 when the ray is close to 0cm - 2cm
    - pink refraction with gloss at 0.5 when the ray is close to 8cm - 10cm

    It is definitly not physical but it was the effect i was trying to achieve ...
    do you think there is still a path to achieve this in vray ?
    Last edited by sebkaine; 12-04-2016, 04:27 AM.

    Comment


    • #3
      I have try to use the fastSSS in refractive mode. It is not excactly what i want but i am getting closer. (img1)

      I have also try a volume fog with a drop off , the volume is exactly how i would like my refraction to be layout.
      gradually the more you are into the surface the more it is opaque. The key point is the subtle gradient that i can't achieve with fog / fog bias at the moment. (img2)

      I'm still exploring , and still not perfectly happy yet !


      Click image for larger version

Name:	test_fastSSS.jpg
Views:	1
Size:	101.7 KB
ID:	860412

      Click image for larger version

Name:	cube_volume.jpg
Views:	1
Size:	29.8 KB
ID:	860414
      Attached Files
      Last edited by sebkaine; 12-04-2016, 10:28 AM.

      Comment


      • #4
        Im not quite sure what result you are trying to accomplish. But it sort of sounds like you want fog color with translucency sss checked and tweaked for your need. Have you tried that yet?
        Do you have an image of what you want achieve, or can you explain how you want the material to behave. Do you want to control the color of the fog color depending on how deep inside the object you are? Translucency+fog color sort of does this, but not with more colors than 2 I guess. Perhaps an OSL shader could do it however.
        CG Artist - RnD and CG Supervision at Industriromantik

        Comment


        • #5
          Many Thanks for your answer Algehov !

          it sort of sounds like you want fog color with translucency sss checked and tweaked for your need
          I think you are right. From all the test i have done 2 options were pretty close
          - blurred refraction + fog + translucency sss with a VrayMtl
          - sss in refractive mode with a large scale with a fastSSS2

          The problem is that i am a Vray Noob so i might not use those shaders at their full potential.
          From all my test it confirm your suggestion the best rendertime + better look is obtain with VrayMtl with fog + translucency

          I have succeed to get exactly the look i want but to do so i have to do it in comp with 3 pass (img3) :
          - 1 pass is a transparent glass : Reflection (GGX 1 / ior 1.6 / rough 0.9) + Refraction ( ior / 1.6 / rough 0.7 / no fog )
          - 1 pass is black glass with absorption : Reflection (GGX 1 / ior 1.6 / rough 0.9) + Refraction ( ior / 1.6 / rough 0.7 / fog at 0.7 )
          - 1 pass is a volume shader used in emission mode with a smooth drop-of

          The complex part is that the red part will be animated, with a custom attribute store in the geo.
          The cube will go from dark(img2) to ligthen state(img1) base on this attribute store in vertex.

          So i need to find a way to read a vertex color , plug it in the shader to get the animation of the light.

          Do you think this kind of look can be achieve directly in a single shader ?

          I have try to use the VrayBlendMTL but it give very weird and unpredictable result when i try to mix refraction with fog ?
          That is why i was trying to access the refraction ray depth to be able to remap the color the way i want it precisly

          Cheers

          E


          Click image for larger version

Name:	compo_002.png
Views:	1
Size:	220.2 KB
ID:	860422

          Click image for larger version

Name:	compo_001.png
Views:	1
Size:	177.2 KB
ID:	860424

          Click image for larger version

Name:	pass.jpg
Views:	1
Size:	61.6 KB
ID:	860423
          Last edited by sebkaine; 13-04-2016, 04:24 AM.

          Comment


          • #6
            As a side note i have try to replicate the attenuation tricks use by houdini inside vray.
            In fact the vray path length variable is working find and it is the exact equivalent of length(I) inside houdini which is the core of the tricks they use.

            But as unreal as it looks , it seems that it is impossible to use an exponential function in the maya hypershade, you can only access to the pow function in mel.
            This remind me how prehistoric the hypershade can be ...

            I have try to bypass this with an expression but it doesn't work ...

            Asking a feature to AD is already a lost cause. So i am wondering if it would be possible to ask to chaosgroup to build a small VrayMathTool utilities node
            Where we could access all trivial math op like add / minus / mult / div / cos / sin / tan / log / exp / sqrt inside the same node , in order to be able to do
            all math basic shading op inside the hypershade ?

            Cheers

            E

            Click image for larger version

Name:	fake_attenuation.jpg
Views:	1
Size:	54.7 KB
ID:	860425
            Last edited by sebkaine; 13-04-2016, 02:00 AM.

            Comment


            • #7
              Go to Create > V-Ray > Create from V-Ray plugin > Texture > AColorOpTex (select the "No placement" option); set the Mode parameter to "power" and set the Color A/Mult A/Color B/Mult B parameters as needed. Note that by default Mult A and Mult B will be 0.0 and the texture will render black, so you'll need to change them.

              We also have a float texture that allows more operations, but it's not available from that menu - will have to make a note to add it. However you can also use the Maya shading nodes - plus/minus, and multiply/divide, and gamma correct (which is in fact an exponential node).

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

              Comment


              • #8
                Many thanks for your answer Vlado ! it's nice to know this , i will make some digging into those hidden nodes ...

                I have suceed to make the exp work with the multiply / divide that luckily include a pow() function also.
                To copy the houdini tricks i would now need to know what are the equivalent of N and I in vray
                - N = object normal in object space so i guess Vray Normal Obj in sampler info is a perfect match
                - I = Direction from the eye to the point being shaded and for this one i don't know what to use basically it is the vector you use to compute path length ?

                i have attach the complete mantra network i am trying to mimic.

                Cheers

                EClick image for larger version

Name:	mantra_network.jpg
Views:	1
Size:	110.3 KB
ID:	860434

                Comment


                • #9
                  I gave it a fast try Sebkaine, but its tricky to do it all in the same shader yes. Especially to get it that glowing on the inside. Whenever I boost the translucency to get a similar intensity it tends to cover the whole box and makes it looks more opaque. Perhaps with a lower effect, but an added light on the inside could help, but would be way harder for more complex geometry, compared to a box

                  I think your solution aint that bad, with doing it in post. But of course it has its drawbacks, and its a bit tedious to set up.

                  Intressting idea on the math nodes by the way!
                  CG Artist - RnD and CG Supervision at Industriromantik

                  Comment


                  • #10
                    Many Thanks for your answer Algehov !

                    It's cool that you confirm that having this directly is not so easy. At the end the look i want is quite unphysical and looks more like a hack than real transmission.
                    I can't imagine a medium that remap his absorption like this ...

                    I have do the ray depth remap technics i was trying to do in vray with Mantra and the result is not very good imo. It looks like a cheat and it's not good enough.
                    The vray blurred refraction is far more accurate and beautiful than the mantra one.

                    So i'm going to stick with vray and my 3 pass method, even if some hair will fall of my head at comp time !

                    I'm still interested to know if we can access :
                    - the incident vector beetween eyes to P
                    - the refraction ray depth

                    at the end the volume workflow is exactly what i need : to raymarch inside the cube and modify the color of the refraction along the Z step

                    Cheers

                    E

                    Comment


                    • #11
                      I found this that might be interesting for those who want basic math nodes in Maya.
                      http://www.thejaco.com/wp/tools/rf_mathnodes/

                      Comment

                      Working...
                      X