• 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
0
Question by gatcha · Oct 28, 2014 at 06:02 PM · light3d-to-2d

Eraser Effect with Flash light - Projection issue 3D -> 2D

Hi everyone ,

I am trying to make a eraser effect with a flash light on a helmet. My game is in 2D mode and the light (beam include) is in 3D, like this :

alt text

To make the eraser effect, I use a black mask then I draw a white triangle and a circle in openGL : alt text Code example of my GL drawing :

 EraserMaterial.SetPass(i);
 GL.Begin(GL.TRIANGLES);
 GL.Color(Color.white);
 GL.TexCoord2(0.5f, 1.0f);
 GL.Vertex3(A.x,A.y, 0.0f);
 GL.TexCoord2(1.0f, 0.0f);
 GL.Vertex3(C.x,C.y, 0.0f);
 GL.TexCoord2(0.0f, 0.0f);
 GL.Vertex3(B.x,B.y, 0.0f);
 GL.End();

BUT (there is always one =\ ), as you can see on the second image :

My problem is that I don't know how I can get with precision the flat(2D) coordinates of the 3D light. Moreover I don't know how I can get the shape of the beam in 2D

I have tried some transformations with the Z rotation angle and the X rotation angle. like:

x = Mathf.Cos(Mathf.Deg2Rad 80) Mathf.Cos(Mathf.Deg2Rad (rotZ - 90)) K80; // rotX = [80°,70°]

that gives me approximately the center of the end circle but its not good.

I am seriously lost, it's the first time I work with 3D and furthermore with 3D transform in 2D

Please by any chance, someone have a idea how i can do it ?

Maybe there is somewhere a rotation matrix that work ?

There are maybe another method to make this kind of effect ?

Thanks in advance for any lead you can give me.


(ps : the camera is in perspective mode)

1.png (351.6 kB)
3.png (262.7 kB)
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 gatcha · Oct 29, 2014 at 08:41 AM 0
Share

Anyone ? $$anonymous$$aybe there is something to do with the mesh vertex ?

avatar image AlwaysSunny · Oct 29, 2014 at 08:43 AM 0
Share

Please use comments for anything that isn't an answer to the question. Also, commenting does bump the question to the top of the list, but please do so responsibly.

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.

Welcome to Unity Answers

If you’re new to Unity Answers, please check our User Guide to help you navigate through our website and refer to our FAQ for more information.

Before posting, make sure to check out our Knowledge Base for commonly asked Unity questions.

Check our Moderator Guidelines if you’re a new moderator and want to work together in an effort to improve Unity Answers and support our users.

Follow this Question

Answers Answers and Comments

3 People are following this question.

avatar image avatar image avatar image

Related Questions

light intensity change with easing problem!! 1 Answer

Unity pro 4, shadow problems 0 Answers

Why Does Lightmapping make everything Super Bright? 0 Answers

Using shadows as Triggers? 1 Answer

Can't get dynamic shadows working 1 Answer


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