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
    • Unread
    • Recent
    • Tags
    • Users
    • Login

    COF Shader: How to differentiate faces?

    SDK Help
    0
    6
    633
    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
      Helper
      last edited by

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

      On 07/06/2003 at 08:44, xxxxxxxx wrote:

      User Information:
      Cinema 4D Version:   8.100 
      Platform:    Mac  ;  
      Language(s) :   C.O.F.F.E.E  ;

      ---------
      Hi,

      I'm at a couple of plugins which need to create different values when the ray hit's a frontface or a backface.

      How can I differentiate (in COFFEE) if the current ray is entering or leaving the object?

      Any help is heartly appreciated!
      Cheers

      Klaus

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

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

        On 09/06/2003 at 05:32, xxxxxxxx wrote:

        If the ray comes from the outside, the angle between the face normal and the ray vector is smaller than 90°. So all you have to do is to calculate the angle between both vectors (which are both given by C4D).

        There are some native usefull vector functions you can use.

        hope that helped you somehow.

        -zet

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

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

          On 09/06/2003 at 06:16, xxxxxxxx wrote:

          Yeah, that was what I thought. The dot product of td->ray und td->bumpn should give the cos of the angle between them, so a quick check against 0 should easily decide that question.

          It doesn't work though... mh, just a question: both of these rays are normalized, aren't they?

          Thanks

          Kabe

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

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

            On 09/06/2003 at 06:27, xxxxxxxx wrote:

            uhm I don't know but it shouldn't be hard to prove that as the length of a 'normal' vector is alway 1.

            0<=phi<=PI

            cos(phi) = a0 dot b0

            a0=normalized vector of vector a

            cu

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

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

              On 09/06/2003 at 06:33, xxxxxxxx wrote:

              unfortunately I was not able to solve it that way. In fact the solution turned out to be much simpler (though I'm unshure if it also takes care of bump...).

              Just check vd->cosc.

              Kabe

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

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

                On 09/06/2003 at 22:39, xxxxxxxx wrote:

                Just an addition - when in doubt about [ray], which doesn't have a documentation in the COFFEE docs, thenk check the C++ SDK!

                Kabe

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