Shader plugin - polygons



  • On 15/01/2015 at 06:28, xxxxxxxx wrote:

    I read that a shader plugin calculates the output for each visible point.

    Now, what if I want to perform the output on polygons.
    For example, put (render) a given texture on every polygon?

    Can I read polygon data inside the shader?

    Or should I use uvw data? 
    If so, how to read the uvw data in the shader?

    -Pim



  • On 15/01/2015 at 07:28, xxxxxxxx wrote:

    Hello,

    what do you mean with "perform the output on polygons"? A shader is used to shade visible fragments.

    To vary for each polygon of an object you would need to know the polygon index. Currently both RayObject and RayHitID are not supported in the Python implementation, so this may not be possible in Python.

    The UVW data for the given fragment is stored in the "uvw" element of the VolumeData member of   the given ChannelData structure.

    best wishes,
    Sebastian



  • On 15/01/2015 at 08:16, xxxxxxxx wrote:

    Originally posted by xxxxxxxx

    what do you mean with "perform the output on polygons"?

    What I mean is for example to put (render) a given texture on every polygon?

    So, I need to use raycollision to determine in which polygon the current point is?

    When you use a selection, the shader seems to know that (and thus the polygon)?

    -Pim



  • On 16/01/2015 at 09:36, xxxxxxxx wrote:

    Hello,

    as said before, a Shader works on fragment level, it shades a (part of a) surface, not a whole polygon. If you want to apply a texture you can use the given UV-coordinates to sample the texture and apply the color to the current fragment.

    When ShaderData.Output is called you are already inside the render process. The "current point" is described by the data found in BaseVolumeData. Since a shader may be called many times during the render process, ShaderData.Output should be as fast as possible. So GeRayCollider should not be used.

    The desired information you need is only available in the C++ SDK by accessing the surface identity of the BaseVolumeData.

    In Cinema 4D selections are typically not assigned to shaders but to materials.

    best wishes,
    Sebastian



  • On 17/01/2015 at 07:32, xxxxxxxx wrote:

    Thanks for the explanation.
    I indeed mixed up shaders and textures / materials. Only textures / materials have selections.

    What I want to do is to scale a texture inside every polygon. Thus the texture is shown and fits in every polygon.
    I can do it with Mograph and a python effector, but I was wondering if I can do it in another way (shader, material, ...)?

    -Pim



  • On 19/01/2015 at 01:16, xxxxxxxx wrote:

    Hello,

    could you tell us how you can do it using a python effector?

    best wishes,
    Sebastian



  • On 19/01/2015 at 02:27, xxxxxxxx wrote:

    Using a mograph cloner, I put clones on the polygon center of an object.
    With a python effector I calculate the surface area (the size) of each polygon and set the size of the clone accordingly. I offset the clone a little and put a texture on it.
    This way I get the texture on all polygones sized to the sizeof the polygon.

    I will make a short tutorial for this python effector on my blog.

    Initially I thought this was best done using a shader, but based on your answer this is not so easy.
    That is why I used this "workaround" .

    -Pim



  • On 19/01/2015 at 05:19, xxxxxxxx wrote:

    Instead of a workaround using MoGraph and a PolysizeEffector, you could simply set the Projection of your texture to UVW Mapping, and do a Max UV on all the UV Polygons.
    "This scales each selected UV polygon to fit the texture. On the mapped object, each selected polygon will display the entire texture."

    https://dl.dropboxusercontent.com/u/37341180/douwe-max-uv.c4d



  • On 19/01/2015 at 06:27, xxxxxxxx wrote:

    Thanks, brilliant solution.
    By the way, parts of the polygon effector I created are based on your D-Polysize Effector.

    -Pim


Log in to reply