本文整理匯總了C#中UnityEngine.ProceduralMaterial.GetProceduralVector方法的典型用法代碼示例。如果您正苦於以下問題:C# ProceduralMaterial.GetProceduralVector方法的具體用法?C# ProceduralMaterial.GetProceduralVector怎麽用?C# ProceduralMaterial.GetProceduralVector使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類UnityEngine.ProceduralMaterial
的用法示例。
在下文中一共展示了ProceduralMaterial.GetProceduralVector方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C#代碼示例。
示例1: RenderDiffuse
//
// This function creates a RenderToTexture for the diffuse map and stores it as a png in the Resources folders.
//
public void RenderDiffuse(ProceduralMaterial Diffuse, int slot)
{
GameObject rtObject = (GameObject)Instantiate(Resources.Load("RTTSubTerrain"));
Camera cam = rtObject.transform.Find("RTTSubCamera").GetComponent<Camera>();
// Create Render To Texture
Vector2 TexSize = new Vector2((float)Math.Pow(2,Diffuse.GetProceduralVector("$outputsize").x), (float)Math.Pow(2,Diffuse.GetProceduralVector("$outputsize").y));
RenderTexture rt = new RenderTexture((int)TexSize.x, (int)TexSize.y, 32);
cam.targetTexture = rt;
rtObject.transform.Find("RTTSubPlane").GetComponent<Renderer>().sharedMaterial.mainTexture = Diffuse.GetTexture ("_MainTex");
cam.Render();
RenderTexture.active = rt;
Texture2D dif = new Texture2D((int)TexSize.x, (int)TexSize.y, TextureFormat.ARGB32, false);
dif.ReadPixels(new Rect(0, 0, (int)TexSize.x, (int)TexSize.y), 0, 0);
// Clean up
cam.targetTexture = null;
RenderTexture.active = null; // added to avoid errors
DestroyImmediate(rt,true);
DestroyImmediate(rtObject,true);
// Write Diffuse map as PNG
byte[] bytes = dif.EncodeToPNG();
string filename = Application.dataPath + "/SubTerrain/Resources/" + gameObject.name+"_splat" + slot.ToString() + ".png";
System.IO.File.WriteAllBytes(filename, bytes);
AssetDatabase.ImportAsset( "Assets/SubTerrain/Resources/" + gameObject.name+"_splat" + slot.ToString() + ".png" );
DestroyImmediate(dif,true);
}