Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 12 Next capture
2021 2022 2023
1 capture
12 Jun 22 - 12 Jun 22
sparklines
Close Help
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
  • Asset Store
  • Get Unity

UNITY ACCOUNT

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account
  • Blog
  • Forums
  • Answers
  • Evangelists
  • User Groups
  • Beta Program
  • Advisory Panel

Navigation

  • Home
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
    • Blog
    • Forums
    • Answers
    • Evangelists
    • User Groups
    • Beta Program
    • Advisory Panel

Unity account

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account

Language

  • Chinese
  • Spanish
  • Japanese
  • Korean
  • Portuguese
  • Ask a question
  • Spaces
    • Default
    • Help Room
    • META
    • Moderators
    • Topics
    • Questions
    • Users
    • Badges
  • Home /
avatar image
1
Question by bluemike · Jan 27, 2017 at 06:20 PM · shaderprojectormatrix

What is the value of unity_ProjectorClip ?

Hi

Unity's Projector is a very powerful tool, but it is hard to find documentation about its internal implementation.

I am trying to build my own projector, actually something that projects several images from several positions. For this I need to "reproduce" Unity's projector. I don't want to use Unity's projector, and instead I'm putting a Camera component with basically the same projection values as what I would have written in the Projector component.

Somehow I managed to decipher the value of unity_Projector matrix, which is:

 k_ProjectorOffsetMatrix * camera.projectionMatrix * camera.worldToCameraMatrix 

Where the k_ProjectorOffsetMatrix is the following linear transformation magic value:

 k_ProjectorOffsetMatrix = Matrix4x4.TRS ( Vector3.one * .5f, Quaternion.identity, -Vector3.one * .5f);

(Hope this will help someone)

But regarding the second matrix unity_ProjectorClip, I'm stuck. I know this is something that takes into account the near/far clip planes, and maybe also the side boundaries, but I just can't manage to reverse-engineer its value. This matrix is needed for sampling the "falloff" texture that prevents projected image from appearing beyond the projection frustum, and is used in the following way, based on the ProjectorMultiply.shader code:

      v2f vert(appdata_tan v)
      {
          v2f o;
          o.pos = mul (UNITY_MATRIX_MVP, v.vertex);
          o.uv_Main = mul (_Projector, v.vertex);
          **o.uv_Clip = mul (_ProjectorClip, v.vertex);**
          return o;
      }
       
      half4 frag (v2f i) : COLOR
      {
          half4 tex = tex2Dproj(_ShadowTex, i.uv_Main);
          **half4 falloff = tex2D(_FalloffTex, i.uv_Clip.xy);
          tex = lerp(float4(1,1,1,1),tex,falloff.a);**
          return tex;
      }

For the falloff texture, it can be a one-dimentional white texture where just the last pixel is black. Somehow, i.e. with the right unity_ProjectorClip value, it will cause the alpha value of the pixel to be white on the far clip plane and beyond.

I have all the bricks, but a little help to get to the arrival line would be much appreciated.

Michael

Comment
Add comment · Show 2
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image equalsequals · Apr 10, 2017 at 05:15 PM 0
Share

I am also attempting to reverse-engineer this $$anonymous$$atrix, but am stuck.

From what I can gather, it exists as an additional Transformation on top of the Projector's $$anonymous$$VP matrix, which is why you can simply take the object-space vertex position and multiply it by this matrix to get the result.

It seems to take the z value of that vertex in "clip-space" and maps it to the 'u' coordinate of the provided ramp texture. But it actually appears to "cut off" outside of the frustum.

avatar image thieum · Mar 01, 2018 at 05:51 PM 0
Share

Hi, following the thread. I can't help to decode the function matrix, apart from saying that the legacy _Projector and _ProjectorClip functions are automatically replaced on import (2017.x) and seem broken: The unity_Projector function fails to discard the "shadow" texture on its side at certain distances, whatever the alpha provided in the "shadow" texture, resulting in the horrible bleeding seen in almost every projector implementation! I'd like to learn more too, but, my 2 cents contribution is: each function has a different TEXCOORD. I guess the coordinates belong to the projector where texcoord(0) is the base projection plane and texcoord(1) the pyramidal shape...

0 Replies

· Add your reply
  • Sort: 

Your answer

Hint: You can notify a user about this post by typing @username

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this Question

Answers Answers and Comments

6 People are following this question.

avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

Why does not perspective projectors work well? 0 Answers

Modify Light Projector Shader to be Additive 0 Answers

Change projection matrix for each objects 0 Answers

Cutting "holes" using projector/shader? 0 Answers

Is projecting programmatically generated shapes using a projector possible? 0 Answers


Enterprise
Social Q&A

Social
Subscribe on YouTube social-youtube Follow on LinkedIn social-linkedin Follow on Twitter social-twitter Follow on Facebook social-facebook Follow on Instagram social-instagram

Footer

  • Purchase
    • Products
    • Subscription
    • Asset Store
    • Unity Gear
    • Resellers
  • Education
    • Students
    • Educators
    • Certification
    • Learn
    • Center of Excellence
  • Download
    • Unity
    • Beta Program
  • Unity Labs
    • Labs
    • Publications
  • Resources
    • Learn platform
    • Community
    • Documentation
    • Unity QA
    • FAQ
    • Services Status
    • Connect
  • About Unity
    • About Us
    • Blog
    • Events
    • Careers
    • Contact
    • Press
    • Partners
    • Affiliates
    • Security
Copyright © 2020 Unity Technologies
  • Legal
  • Privacy Policy
  • Cookies
  • Do Not Sell My Personal Information
  • Cookies Settings
"Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S. and elsewhere (more info here). Other names or brands are trademarks of their respective owners.
  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges