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

    ShaderData Question

    Scheduled Pinned Locked Moved SDK Help
    7 Posts 0 Posters 443 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 01/07/2010 at 21:49, xxxxxxxx wrote:

      User Information:
      Cinema 4D Version:   11.5 
      Platform:   Windows  ;   
      Language(s) :     C++  ;

      ---------
      Hi folks,

      I am working on a shader that will randomly choose pixels and color them white.

      I know that sd->p is the pixel ,    but if I try to do something like this,

      if(sd->p.x = frand(0, 100))

      I never choose the pixel because the sd->p is never the same as the random function.  In fact the likelihood of that ever happening is pretty slim.  🙂

      so I am looking for a way to randomly choose pixels in a shader and to output that pixel as Vector(1,1,1)  (White).

      Is there an index for each pixel,   or a way to find the pixel count?   Saying that out loud sound crazy to me because it seems like there would be way too many pixel to iterate through and it would be excruciatingly slow.   But is there a way to choose a random pixel and then if the current pixel is equal to that number output the vector (1,1,1)

      Hopefully that makes sense..  🙂

      Thanks,

      ~Shawn

      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 02/07/2010 at 00:11, xxxxxxxx wrote:

        i could think of using overlayed (multiplied) noise functions and than check wether the result is exactly 1, or if this stays black, use >0.98 or something like that. but i dont know if this will flicker during animation (if this counts at all)

        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 02/07/2010 at 01:30, xxxxxxxx wrote:

          What type is sd? If it is a VolumeData then p is not the pixel but the point in space that is been rendered. To get the actual rendered pixel position you have to use VolumeData::GetXY().

          for example:

            
          Vector MyShader::Output(PluginShader *chn, ChannelData *cd)  
          {  
            ...  
              
            LONG x, y, scale;  
            cd->vd->GetXY(&x, &y, &scale);  
            
            //these are the pixel coordinates including subpixel coordinates for anti-aliasing  
            Real xpix = Real(x)/Real(scale);  
            Real ypix = Real(y)/Real(scale);  
            
            ...  
          }  
          

          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 02/07/2010 at 05:31, xxxxxxxx wrote:

            Thanks guys.   the sd I am reffering to is a channeldata so p is the pixel in this case right?

            is there a pixelcount somewhere that I am missing?   or a way to randomly choose pixels ?

            Thanks,

            ~Shawn

            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 02/07/2010 at 06:20, xxxxxxxx wrote:

              ChannelData::p is the texture position in UVW coordiantes. This has nothing to do with pixel.

              The pixel count is easily calculated bu accessing the document's RenderData.

              pixelcount = xresolution * yresolution

              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 02/07/2010 at 06:34, xxxxxxxx wrote:

                okay.  I see.. Thanks 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 06/07/2010 at 21:21, xxxxxxxx wrote:

                  Is there a way to determine the uvw count?  I am trying to capture random uvw coordinates of a sky object.   I would like to basically say if channeldata.p = a random coordinate then output that coordinate white.  i a having trouble check one uv coordinate against all of them...  Any thoughts on how i would achieve this?

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