ShaderData Question



  • 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



  • 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)



  • 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



  • 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



  • 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



  • 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.



  • 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?


Log in to reply