Maxon Developers Maxon Developers
    • Documentation
      • Cinema 4D Python API
      • Cinema 4D C++ API
      • Cineware API
      • ZBrush Python API
      • ZBrush GoZ API
      • Code Examples on Github
    • Forum
    • Downloads
    • Support
      • Support Procedures
      • Registered Developer Program
      • Plugin IDs
      • Contact Us
    • Categories
      • Overview
      • News & Information
      • Cinema 4D SDK Support
      • Cineware SDK Support
      • ZBrush 4D SDK Support
      • Bugs
      • General Talk
    • Recent
    • Tags
    • Users
    • Login

    Problems with sampling a PluginShader

    Scheduled Pinned Locked Moved SDK Help
    8 Posts 0 Posters 584 Views
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • H Offline
      Helper
      last edited by

      THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED

      On 12/05/2009 at 17:17, xxxxxxxx wrote:

      User Information:
      Cinema 4D Version:   10.1/11 
      Platform:   Windows  ;   Mac OSX  ; 
      Language(s) :     C++  ;

      ---------
         Hi,

      I have a channel shader (class ShaderData), to give color to the clones created by my clone generator. When the clones are created, I store each clone's UVW coordinate.

      In my shader's Output() function, I use the UVW coordinate of the clone that's being hit by the ray, to sample from another shader (class PluginShader), in this example it's a checkerboard (but it doesn't matter, which shader I use).
      So it's not important where the ray hits a clone, it will always get *one* UVW coordinate for each clone.

      Now here's the result:
      _<_img border="0" src= "http://dev.c4d-jack.de/public/surfacespread/shader/surfacespread_shader_frommaterial.jpg"_>_

      Looks kinda odd, hm? I know the color of each sphere is being sampled from the very same UVW position. But I get these strange artefacts. Sometimes, the Sample() function just seems to return random values.

      What I noticed:
      1. If I - just for fun - call the sampled shader's InitRender() and FreeRender() functions in my Output function, instead of my InitRender and FreeRender (as I normally do), the artefacts get much worse.

      2. It does not happen when I set Cinema's "Render Threads" to "1 (No MP)" in the preferences. So I guess it has something to do with multithreading.

      3. Each time I render, the artefacts look a bit different. It really seems to be random.

      4. If I only have one clone (so always the same UVW coordinate is used for sampling), no artefacts occur.

      I hope somebody know more about this.

      Greetings & a thousand thanks in advance,
      Jack

      1 Reply Last reply Reply Quote 0
      • H Offline
        Helper
        last edited by

        THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED

        On 13/05/2009 at 06:23, xxxxxxxx wrote:

        Any idea on this?

        Cheers,
        Jack

        1 Reply Last reply Reply Quote 0
        • H Offline
          Helper
          last edited by

          THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED

          On 13/05/2009 at 08:51, xxxxxxxx wrote:

          Lets see if I understand this correctly 🙂 You place clones on a surface. For each clone you accordining UVW coordinate of the surface. In your shader you sample another shader with the UVW coordinate of currently rendered clone.

          Where do you store the UVW coordinates? Does it look the same with best anti-aliasing?

          cheers,
          Matthias

          1 Reply Last reply Reply Quote 0
          • H Offline
            Helper
            last edited by

            THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED

            On 13/05/2009 at 09:04, xxxxxxxx wrote:

            Hi Matthias!

            Yes, you understood it perfectly right.

            I store the UVW coordinates in the clones' container. I do this with lots of data for the shader, not only UVW, and it always works.

            With best AntiAliasing, the artefacts get more and smoother 😉 That's totally logical, because the error happens on a per-ray basis. With best AA more rays are fired, so on the one hand bad errors get a little better, but on the other hand, new errors appear in new places.

            And again, it only happens with 2 ore more renderthreads. If I use Cinema single-threaded, everything works perfectly. Obviously, the renderer confuses the results that come from different threads.

            I can send you the - well commented code - and tell you the lines which are responsible. The shader is actually very small, there's not much in it. Just if you're interested ^_^

            Greetings,
            Jack

            1 Reply Last reply Reply Quote 0
            • H Offline
              Helper
              last edited by

              THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED

              On 13/05/2009 at 09:10, xxxxxxxx wrote:

              Yes, I would like to have a look at the code.

              cheers,
              Matthias

              1 Reply Last reply Reply Quote 0
              • H Offline
                Helper
                last edited by

                THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED

                On 13/05/2009 at 15:18, xxxxxxxx wrote:

                You've got mail 😉
                Thanks for the offer!

                Frank,
                Jack

                1 Reply Last reply Reply Quote 0
                • H Offline
                  Helper
                  last edited by

                  THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED

                  On 13/05/2009 at 15:38, xxxxxxxx wrote:

                  Best of luck there, Jack!! 🙂

                  I wanna see where this is going. 😄

                  1 Reply Last reply Reply Quote 0
                  • H Offline
                    Helper
                    last edited by

                    THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED

                    On 13/05/2009 at 19:00, xxxxxxxx wrote:

                    Quote: Originally posted by kuroyume0161 on 13 May 2009
                    >
                    > * * *
                    >
                    >
                    > I wanna see where this is going.
                    >
                    > * * *

                    Yeah, me too ^_^

                    Greetings,
                    Jack

                    1 Reply Last reply Reply Quote 0
                    • First post
                      Last post