原因
面試了一家VR房地產(chǎn)公司,給了幾張圖片,要求做出VR漫游效果。通過3個(gè)小時(shí)研究,我發(fā)現(xiàn)問題還是在shader這一塊,故貼出代碼,如果其他小朋友遇到就可以嘗試一下,下面的方法
問題:
將圖片直接扔到材質(zhì)球中,結(jié)果并不能很好的顯示,而且場(chǎng)景光線很暗。原有的光線并不能很好的展示。
怎么做?
首先將素材打開

Paste_Image.png

Paste_Image.png
其次拖入工程,選取下面的模式

Paste_Image.png
創(chuàng)建一個(gè)材質(zhì)球

Paste_Image.png
建立一個(gè)shader

Paste_Image.png
shader代碼
如果看不懂,請(qǐng)看我之前的兩篇博客。就可以看明白下面寫的什么了。
Shader "Custom/SYShader" {
Properties
{
_Color("Color", Color) = (1,1,1,1)
_MainTex("Texture", 2D) = "white"{}
}
SubShader
{
//Ambient pass
Pass
{
Name "BASE"
Tags{ "LightMode" = "Always" /* Upgrade NOTE: changed from PixelOrNone to Always */ }
Color[_PPLAmbient]
SetTexture[_BumpMap]
{
constantColor(.5,.5,.5)
combine constant lerp(texture) previous
}
SetTexture[_MainTex]
{
constantColor[_Color]
Combine texture * previous DOUBLE, texture *constant
}
}
//Vertex lights
Pass{
Name "BASE"
Tags{ "LightMode" = "Vertex" }
Material
{
Diffuse[_Color]
Emission[_PPLAmbient]
Shininess[_Shininess]
Specular[_SpecColor]
}
SeparateSpecular On
Lighting On
cull off
SetTexture[_BumpMap]
{
constantColor(.5,.5,.5)
combine constant lerp(texture) previous
}
SetTexture[_MainTex]
{
Combine texture *previous DOUBLE, texture *primary
}
}
}
FallBack "Diffuse", 1
}
}
再創(chuàng)建一個(gè)Sphere物體,放大10倍,最后將材質(zhì)球應(yīng)用就Ok了!

Paste_Image.png