本文整理汇总了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);
}