Usage: 1. Create Projector: Create an empty GameObject, and then add the Projector component from Component. You can also Import Package->Projector to import the Projector package.
Projector principle
Projector can project a Material to all objects within the set frustum superior. Usually contains two map cookies and falloff. Cookie is the projected pattern, and the function of Falloff is mainly to determine the alpha of the projection, that is, light and dark, based on distance. The left side of Falloff is white, with an alpha value of 1, which corresponds to the brightest projection when the distance is closest. The right side is close to black, with an alpha value of 0, which means that as the projection distance becomes farther, the projection will gradually become closer to transparent or even invisible.
【Achievable】
0 Character selection aperture
1 Ordinary dot shadow (blob shadow)
2 Fake Dynamic shadow
3 Light projection
4 Projector (according to the Material map, it can be a picture, video, or the scene seen by another camera)
5 The effect of 3D or 2D flashlight
Use steps
1. Create Projector.
2: Notes
1. Make sure Cookie Texture must be set to Clamp
2. In order to avoid projector bleeding, Cookie Texture enables the Border Mipmaps option, or directly disables Mipmap
3.FallOff
whether it is orthographic or not.
If FallOff is not used, the cookies with the brightest alpha of 1 will be projected, and will be projected in both directions of the frustrum, causing the "double projection" effect that we do not want to see. If you use the Falloff map that comes with the system package. The shadow fades with distance.
【Example Demonstration】
Example 0: Aperture under the character’s feet
Used by projector The shader is as follows, plus a script to control the rotation of the projector.
Shader "Custom/Circle" {
}
或者用Vertex&Fragment
Shader
}
Example 1: Ordinary dot shadow (blob shadow)
Add under the character, remember to add the character's layer to the 'Ignore Layer' under the projector settings That’s it.
##Shader "Projector/Multiply" {
}
2 Fake Dynamic shadow (Fake Dynamic shadow)
is to use 3d Max or Maya or Unity first bakes the shadows corresponding to the animation and makes them into sequence frames. Then use the projector's material to create the corresponding frame animation.
3 Light projection
Basically replace the black blob cookie with a white cookie in the middle.
4 Projector (according to the Material map, it can be a picture, video, or the scene seen by another camera)
Another camera draws to RenderTexture, and then the projector's material can be used as RenderTexture
5 The effect of a 3D or 2D flashlight is that the direction and range settings of the projector are consistent with the flashlight. Just throw out the light color of the flashlight.
The above is the detailed content of How to use Projector in Unity3D. For more information, please follow other related articles on the PHP Chinese website!