X-ray effect of "Unity3d" Torch Light

Source: Internet
Author: User

Welcome to Unity Learning,Unity training ,UnityEnterprise TrainingEducation Area, there are manyUnity3d Resources,Unity3d Training Video,Unity3d Tutorials,Unity3d Frequently Asked questions,Unity3d Project Source code, the "Dog Planing Learning Network" Unity's Ultimate Academy, dedicated to building the industry unity3d Training , learning the first brand.
   You can modify the alpha representation of a blocking material when there is a barrier between the character and the camera, such as a wall.
Using Unityengine;
Using System.Collections;
public class Example:monobehaviour {
void Update () {
Raycasthit[]
Hits
hits = Physics.raycastall (Transform.position, Transform.forward, 100.0F);
int i = 0;
while (I hits. Length) {
Raycasthit hit = Hits ;
Renderer Renderer = hit.collider.renderer;
if (renderer) {
Renderer.material.shader = Shader.find ("Transparent/diffuse");
Renderer.material.color = new Color (RENDERER.MATERIAL.COLOR.R,
RENDERER.MATERIAL.COLOR.G,
Renderer.material.color.b,
0.3F);
}
i++;
}
}
}
  You can also show the perspective of a person like the light of a torch.
  

  Draw occluded part ZTest Off, ZTest Greater
Draw the ZTest part of the mask on, ztestlequal
Effect

  

  
  
For more information, please visit the "Dog Planing Learning Network" Unity Ultimate Academy

Statement: This document comes from the "Dog Planing Learning Network" Community-unity Extreme College, is a self-published Unity3d study articles, if anything violates your relevant interests, please communicate with the official, we will deal with the real-time.


  

X-ray effect of "Unity3d" Torch Light

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.