Announcement

Collapse
No announcement yet.

RT GPU and OSLTex and Siger

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

  • RT GPU and OSLTex and Siger

    Hi Guys

    I'm switching to GPU, but my materials are mostly Siger reflections with it's custom OSLTex ComplexFresnel.

    I can use the n and k values I'm getting from Siger's OSL and punch it into the V-Ray version as per here:
    https://docs.chaosgroup.com/display/...Fresnel+shader

    But the Siger one has additional values for example, gamma, hue shift and saturation. How can I translate those into the pure ChaosGroup version?

    The point of all this is that my Siger Materials are useless in RT GPU and I need to convert ALL of them manually to be compatible with RT GPU
    Kind Regards,
    Morne

  • #2
    We do reimplement some 3rd party textures in the GPU code (f.e. ColorCorrect, MultiTexture and recently ForestColor), unfortunately the Siger textures are not among them right now.

    It should be possible to write a GLSL shader that implements the functionality of the Siger textures exactly, but we will need to look into it.

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

    Comment


    • #3
      Hello Morne,

      Here is the GLSL equivalent of complex_ior.osl that works with RT GPU:
      Code:
      #version 110
      
      float fresnel(float n, float k, float c)
      {
      	float k2 = k*k;
      	float rs_num = n*n + k2 - 2.0*n*c + c*c;
      	float rs_den = n*n + k2 + 2.0*n*c + c*c;
      	float rs = rs_num/rs_den;
      	float rp_num = (n*n + k2)*c*c - 2.0*n*c + 1.0;
      	float rp_den = (n*n + k2)*c*c + 2.0*n*c + 1.0;
      	float rp = rp_num/rp_den;
      	return clamp(0.5*(rs+rp), 0.0, 1.0);
      }
      
      uniform vec3 n = vec3(0.27105, 0.67693, 1.3164);
      uniform vec3 k = vec3(3.6092, 2.6247, 2.2921);
      
      void main()
      {
      	float thetaCos = abs(dot(vr_Direction, vr_Normal));
      	float r = fresnel(n[0], k[0], thetaCos);
      	float g = fresnel(n[1], k[1], thetaCos);
      	float b = fresnel(n[2], k[2], thetaCos);
      	gl_FragColor = vec4(r, g, b, 1.0);
      }
      Best regards,
      Ivan

      Comment


      • #4
        Originally posted by Morne View Post
        Hi Guys

        I'm switching to GPU, but my materials are mostly Siger reflections with it's custom OSLTex ComplexFresnel.

        I can use the n and k values I'm getting from Siger's OSL and punch it into the V-Ray version as per here:
        https://docs.chaosgroup.com/display/...Fresnel+shader

        But the Siger one has additional values for example, gamma, hue shift and saturation. How can I translate those into the pure ChaosGroup version?

        The point of all this is that my Siger Materials are useless in RT GPU and I need to convert ALL of them manually to be compatible with RT GPU
        Siger basically just has a Color Correction node to the complex_ior.osl for gamma, hue shift and saturation.

        Click image for larger version

Name:	Clean Chrome.png
Views:	1
Size:	106.2 KB
ID:	866371
        "I have not failed. I've just found 10,000 ways that won't work."
        Thomas A. Edison

        Comment


        • #5
          Originally posted by ikomitov View Post
          Hello Morne,

          Here is the GLSL equivalent of complex_ior.osl that works with RT GPU:
          Code:
          #version 110
          
          float fresnel(float n, float k, float c)
          {
              float k2 = k*k;
              float rs_num = n*n + k2 - 2.0*n*c + c*c;
              float rs_den = n*n + k2 + 2.0*n*c + c*c;
              float rs = rs_num/rs_den;
              float rp_num = (n*n + k2)*c*c - 2.0*n*c + 1.0;
              float rp_den = (n*n + k2)*c*c + 2.0*n*c + 1.0;
              float rp = rp_num/rp_den;
              return clamp(0.5*(rs+rp), 0.0, 1.0);
          }
          
          uniform vec3 n = vec3(0.27105, 0.67693, 1.3164);
          uniform vec3 k = vec3(3.6092, 2.6247, 2.2921);
          
          void main()
          {
              float thetaCos = abs(dot(vr_Direction, vr_Normal));
              float r = fresnel(n[0], k[0], thetaCos);
              float g = fresnel(n[1], k[1], thetaCos);
              float b = fresnel(n[2], k[2], thetaCos);
              gl_FragColor = vec4(r, g, b, 1.0);
          }
          Best regards,
          Ivan
          Thanks Ivan. Is there a way to "click" the compile button in Maxscript?
          All I see is this:
          Code:
          Showproperties(vrayglsltex())
            .shader_file : filename
            .material : material
            .shader_node : integer
            .refraction_ior : float
            .incident_ior : float
            .max_ray_depth : integer
            .animation_time : float
            .show_preview : boolean
            .clamp_shader_result : boolean
            .clamping_limit : float
            .use_quick_shader : boolean
            .shader_sourcecode : string
            .message_log : string
            .tweakCount : integer
            .isShaderLoaded : boolean
            .useQuickShader : boolean
          If I'm coding a script to replace all the Siger custom OSL's in the scene with this, I need to have a way to also compile each one with code...


          Originally posted by eyepiz View Post
          Siger basically just has a Color Correction node to the complex_ior.osl for gamma, hue shift and saturation
          Yes I'm hoping to stick the GLSL into a Color Correction and hopefully that works with RT GPU
          Kind Regards,
          Morne

          Comment


          • #6
            Anybody with suggestions?
            Kind Regards,
            Morne

            Comment


            • #7
              Hi Morne

              Is it possible to share the script you're using?
              Also, I tested Ivans GLSL and it seems to work fine on CPU but not on GPU. Do you face the same issue in your case?
              CPU
              Click image for larger version

Name:	CPU.jpg
Views:	1
Size:	151.1 KB
ID:	866866

              GPU
              Click image for larger version

Name:	GPU.jpg
Views:	1
Size:	408.5 KB
ID:	866867

              Best Regards,
              LK
              Last edited by idnok; 06-03-2017, 06:44 AM.
              Regards,
              Ledian

              Comment


              • #8
                Originally posted by Morne View Post
                Anybody with suggestions?
                I think the shader will be auto-compiled when rendering, but I need to confirm.

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

                Comment


                • #9
                  Originally posted by idnok View Post
                  Hi Morne

                  Is it possible to share the script you're using?
                  Best Regards,
                  LK
                  The script is still in my head. I'm just getting all the bits together to make sure it will work before I spend time coding it...
                  I'll update here when I have all the info I need, and then share the script when it's done
                  Kind Regards,
                  Morne

                  Comment


                  • #10
                    Originally posted by vlado View Post
                    I think the shader will be auto-compiled when rendering, but I need to confirm.

                    Best regards,
                    Vlado
                    Thanks, Vlado. I should have just tested to see if it renders, before asking. Will get back to you, just on a project at the moment...
                    Kind Regards,
                    Morne

                    Comment


                    • #11
                      @idnok - That wrong render seems to not be working both in RT CPU and RT GPU.
                      I've reported that as a bug, thanks for the pointer !

                      Best,
                      Blago
                      V-Ray fan.
                      Looking busy around GPUs ...
                      RTX ON

                      Comment


                      • #12
                        Yes, you can compile shaders from MAX Script. If you invoke showinterfaces on your material instance, you'll see that it implements the TweakAccessor interface which has a couple of shader-loading methods. The load method is used to load a new shader file and the reload one can be used to recompile the current shader.

                        Code:
                        showinterfaces m
                          Interface: IMtlRender_Compability_MtlBase
                           Properties:
                           Methods:
                           Actions:
                          Interface: TweakAccessor
                           Properties:
                            .tweakCount : integer : Read
                            .isShaderLoaded : boolean : Read
                            .useQuickShader : boolean : Read|Write
                           Methods:
                            <fpvalue>getTweak <fpvalue>tweak
                            <void>setTweak <fpvalue>tweak <fpvalue>value
                            <void>load <TSTR>filePath
                            <void>reload()
                            <void>reset()
                            <void>clear()
                            <boolean>export <TSTR>filePath compress:<boolean>
                               compress default value: true
                           Actions:
                        OK
                        -- to compile
                        m.reload()
                        Alternatively, the shader_file property can be used to load shaders, e.g.

                        Code:
                        m.shader_file="X:\path\to\your\shader.frag"
                        Best regards,
                        Ivan

                        Comment


                        • #13
                          @idnok it seems there is a bug that prevents the 'quick shader' from being exported. I'll fix that asap, but for now, I'd suggest loading the shader from an external file as a workaround.

                          Best regards,
                          Ivan

                          Comment


                          • #14
                            @ikomitov that way it recognize the shader in RT as a fixed parameter instead. In this specific occasion it prevents you from changing 'n' & 'k' values.
                            Regards,
                            Ledian

                            Comment


                            • #15
                              Originally posted by Morne View Post
                              The script is still in my head. I'm just getting all the bits together to make sure it will work before I spend time coding it...
                              I'll update here when I have all the info I need, and then share the script when it's done
                              Thank you!
                              For now, let see how GLSL is gonna work on GPU!
                              Regards,
                              Ledian

                              Comment

                              Working...
                              X