The alpha channel-based shadow volume implementation in Unity

Source: Internet
Author: User

Transferred from: http://blog.163.com/wmk_2000_ren/blog/static/138846192201019114117466/

Realized, the Aras great God has given,

http://forum.unity3d.com/threads/shadow-volumes-in-unity-on-the-wiki.9452/

Http://wiki.unity3d.com/index.php/Shadow_Volumes_in_Alpha

The principle also has a ready-made paper to explain clearly. Can not be on Google, link back to fill ...

I'm almost using Chinese to retell the whole process.

First, the reason is based on Alpha because the template cache is not always available, and Alpha doesn't have to worry about having no effect. This is achieved using alpha, although not necessarily in the project because of the high fill rate.

Ideas are as follows:

The first step is to change the frame buffer's alpha value to One-fourth.

The second step is to draw the shaded surface. The alpha value of the front becomes twice times and the reverse is halved. At this point, the alpha value of the shaded area becomes 1/2 and 1, not the shaded area.

The third step is to do four framebuffer operation, the first time is to Double alpha, the shadow region's alpha value becomes 1, the other region becomes 1/2. The second is to invert the alpha value, the alpha value of the blend zero Oneminusdstalpha to 0, the other area is 1/2, the alpha is doubled for the third time, the value of the shaded area is 0, and the other area becomes 1, and the fourth time it is assigned the color.

Concrete implementation, will involve some details, more trouble, slowly fill.

"Untiy 3d Shaderlab development of practical explanation" there is also relevant content: source code in the example project Shadowvolumes

(go) The alpha channel-based shadow volume implementation in Unity

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.