The reflection effect is often needed to create a game scene, especially in marble and ceramic materials that help to enhance the texture and ambience of the scene.
Speaking of reflection, the common practice in the game is to use the current scene cubemap as a reflection source
And CubeMap is the result of the current scene +skybox.
A production CubeMap
- Sky Ball "online can be downloaded to a lot. Unitypackage, only the new version of Unity 5.0 after the Skybox moved to Lightmap settings, the old version under Rendersettings set"
- CubeMap "5.3. Version 4 in this case the third level resource directory created cubemap, the old version in the second level directory can be found"
- Create a sphere in the center of the scene, where you think you can reflect the panorama
- Create the CubeMap script code "new JS script in the Editor folder of the resource directory Rendercubemapwizard, paste the following code in it"
//Render scene from a given point to a static cube map.//Place this script in Editor folder of your project.The cubemap with one of reflective shaders! class rendercubemapwizard extends scriptablewizard { varRenderfromposition:transform;varCubemap:cubemap; function onwizardupdate () {helpstring ="Select Transform to render from and cubemap to render into"; IsValid = (renderfromposition! =NULL) && (CubeMap! =NULL); } function onwizardcreate () { //create temporary camera for rendering varGo =NewGameobject ("Cubemapcamera", Camera);//Place it on the objectGo.transform.position = renderfromposition.position; Go.transform.rotation = quaternion.identity;//Render into CubeMapGo. Getcomponent.<camera> (). Rendertocubemap (CUBEMAP);//Destroy temporary cameraDestroyimmediate (GO); } @MenuItem ("Gameobject/render into Cubemap")Static function rendercubemap () {Scriptablewizard.displaywizard.<rendercubemapwizard> ("Render cubemap","render!"); } }
- For a moment, the script compiles a new render into CubeMap button under the Gameobject menu bar, opening
and drag and drop the sphere sphere and the CubeMap object to the position. When you are done, click render! in the lower right corner. ——————— CubeMap can be generated in seconds
Second, using Shaderforge to make reflective shader
Simple Forge Shader
Texture 2d– Model Diffuse map
cubemap– the CubeMap file that was just generated
cubemap– control the reflective strength of CubeMap [you can also use other variables not unique]
multiply– multiplication node is responsible for multiplying the reflection intensity
After generating shader back to the scene resource folder, the scene of a ground map material ball shader replaced with our own production of shader can, effect!
PS: Of course you can also DIY to increase the self-light increase the high-light method is not fixed
Shader Forge Primary Article | Application of reflective MATERIAL