本文整理汇总了C#中UnityEngine.Camera.RenderToCubemap方法的典型用法代码示例。如果您正苦于以下问题:C# Camera.RenderToCubemap方法的具体用法?C# Camera.RenderToCubemap怎么用?C# Camera.RenderToCubemap使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类UnityEngine.Camera
的用法示例。
在下文中一共展示了Camera.RenderToCubemap方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Start
// Use this for initialization
void Start()
{
cam = GetComponent<Camera>();
var rtex = new RenderTexture(cubemapSize, cubemapSize, 16);
rtex.isCubemap = true;
rtex.hideFlags = HideFlags.HideAndDontSave;
mat.SetTexture("_Cube", rtex);
cam.RenderToCubemap(rtex, 0);
}
示例2: Make
public static Cubemap Make(Camera camera)
{
Cubemap cmap = new Cubemap(4096, TextureFormat.ARGB32, false);
if (camera.RenderToCubemap(cmap))
{
return cmap;
}
return null;
}
示例3: copy_internal
private void copy_internal(Texture dstCube, Texture srcCube, bool dstRGBM, bool srcRGBM, bool linear, Camera cam, Material skyMat, Matrix4x4 matrix)
{
bool prevHDR = cam.hdr;
CameraClearFlags prevFlags = cam.clearFlags;
int prevMask = cam.cullingMask;
cam.clearFlags = CameraClearFlags.Skybox;
cam.cullingMask = 0;
cam.hdr = !dstRGBM; // might need HDR camera buffer when we're not rendering to RGBM encoded pixels
skyMat.name = "Internal HDR to RGBM Skybox";
skyMat.shader = Shader.Find("Hidden/Marmoset/RGBM Cube");
//toggleKeywordPair("MARMO_LINEAR", "MARMO_GAMMA", linear);
toggleKeywordPair("MARMO_RGBM_INPUT_ON", "MARMO_RGBM_INPUT_OFF", srcRGBM);
toggleKeywordPair("MARMO_RGBM_OUTPUT_ON", "MARMO_RGBM_OUTPUT_OFF", dstRGBM);
skyMat.SetMatrix("_SkyMatrix", matrix);
skyMat.SetTexture("_CubeHDR", srcCube);
Material prevSkyMat = UnityEngine.RenderSettings.skybox;
UnityEngine.RenderSettings.skybox = skyMat;
RenderTexture RT = dstCube as RenderTexture;
Cubemap cube = dstCube as Cubemap;
if(RT) cam.RenderToCubemap(RT);
else if(cube) cam.RenderToCubemap(cube);
cam.hdr = prevHDR;
cam.clearFlags = prevFlags;
cam.cullingMask = prevMask;
UnityEngine.RenderSettings.skybox = prevSkyMat;
}
示例4: convolve_internal
private void convolve_internal(Texture dstTex, Texture srcCube, bool dstRGBM, bool srcRGBM, bool linear, Camera cam, Material skyMat, Matrix4x4 matrix)
{
bool prevHDR = cam.hdr;
CameraClearFlags prevFlags = cam.clearFlags;
int prevMask = cam.cullingMask;
cam.clearFlags = CameraClearFlags.Skybox;
cam.cullingMask = 0;
cam.hdr = !dstRGBM; // might need HDR camera buffer when we're not rendering to RGBM encoded pixels
skyMat.name = "Internal Convolve Skybox";
skyMat.shader = Shader.Find("Hidden/Marmoset/RGBM Convolve");
//toggleKeywordPair("MARMO_LINEAR", "MARMO_GAMMA", linear);
toggleKeywordPair("MARMO_RGBM_INPUT_ON", "MARMO_RGBM_INPUT_OFF", srcRGBM);
toggleKeywordPair("MARMO_RGBM_OUTPUT_ON", "MARMO_RGBM_OUTPUT_OFF", dstRGBM);
skyMat.SetMatrix("_SkyMatrix", matrix);
skyMat.SetTexture("_CubeHDR", srcCube);
bindRandomValueTable(skyMat,"_PhongRands", srcCube.width);
Material prevSkyMat = UnityEngine.RenderSettings.skybox;
UnityEngine.RenderSettings.skybox = skyMat;
Cubemap dstCube = dstTex as Cubemap;
RenderTexture dstRT = dstTex as RenderTexture;
if( dstCube ) {
if( generateMipChain ) {
int mipCount = mset.QPow.Log2i(dstCube.width) - 1;
int mip = highestMipIsMirror ? 1 : 0;
for( ; mip<mipCount; ++mip ) {
int mipSize = 1 << (mipCount-mip);
float mipExp = mset.QPow.clampedDownShift(this.maxExponent, highestMipIsMirror ? (mip-1) : mip, 1);
skyMat.SetFloat("_SpecularExp", mipExp);
skyMat.SetFloat ("_SpecularScale", this.convolutionScale);
Cubemap mipCube = new Cubemap(mipSize, dstCube.format, false);
cam.RenderToCubemap(mipCube);
for(int f=0; f<6; ++f) {
CubemapFace face = (CubemapFace)f;
dstCube.SetPixels(mipCube.GetPixels(face), face, mip);
}
Cubemap.DestroyImmediate(mipCube);
}
dstCube.Apply(false);
} else {
skyMat.SetFloat("_SpecularExp", this.maxExponent);
skyMat.SetFloat ("_SpecularScale", this.convolutionScale);
cam.RenderToCubemap(dstCube);
}
} else if(dstRT) {
skyMat.SetFloat("_SpecularExp", this.maxExponent);
skyMat.SetFloat ("_SpecularScale", this.convolutionScale);
cam.RenderToCubemap(dstRT);
}
cam.clearFlags = prevFlags;
cam.cullingMask = prevMask;
cam.hdr = prevHDR;
UnityEngine.RenderSettings.skybox = prevSkyMat;
}