private RenderTexture RenderPreviewShadowmap(Light light, float scale, Vector3 center, Vector3 floorPos, out Matrix4x4 outShadowMatrix)
{
Camera camera = this.m_PreviewUtility.m_Camera;
camera.orthographic = true;
camera.orthographicSize = scale * 2f;
camera.nearClipPlane = 1f * scale;
camera.farClipPlane = 25f * scale;
camera.transform.rotation = light.transform.rotation;
camera.transform.position = center - ((Vector3) (light.transform.forward * (scale * 5.5f)));
CameraClearFlags clearFlags = camera.clearFlags;
camera.clearFlags = CameraClearFlags.Color;
Color backgroundColor = camera.backgroundColor;
camera.backgroundColor = new Color(0f, 0f, 0f, 0f);
RenderTexture targetTexture = camera.targetTexture;
RenderTexture texture2 = RenderTexture.GetTemporary(0x100, 0x100, 0x10);
texture2.isPowerOfTwo = true;
texture2.wrapMode = TextureWrapMode.Clamp;
texture2.filterMode = FilterMode.Bilinear;
camera.targetTexture = texture2;
this.SetPreviewCharacterEnabled(true, false);
this.m_PreviewUtility.m_Camera.Render();
RenderTexture.active = texture2;
GL.PushMatrix();
GL.LoadOrtho();
this.m_ShadowMaskMaterial.SetPass(0);
GL.Begin(7);
GL.Vertex3(0f, 0f, -99f);
GL.Vertex3(1f, 0f, -99f);
GL.Vertex3(1f, 1f, -99f);
GL.Vertex3(0f, 1f, -99f);
GL.End();
GL.LoadProjectionMatrix(camera.projectionMatrix);
GL.LoadIdentity();
GL.MultMatrix(camera.worldToCameraMatrix);
this.m_ShadowPlaneMaterial.SetPass(0);
GL.Begin(7);
float x = 5f * scale;
GL.Vertex(floorPos + new Vector3(-x, 0f, -x));
GL.Vertex(floorPos + new Vector3(x, 0f, -x));
GL.Vertex(floorPos + new Vector3(x, 0f, x));
GL.Vertex(floorPos + new Vector3(-x, 0f, x));
GL.End();
GL.PopMatrix();
Matrix4x4 matrixx = Matrix4x4.TRS(new Vector3(0.5f, 0.5f, 0.5f), Quaternion.identity, new Vector3(0.5f, 0.5f, 0.5f));
outShadowMatrix = (matrixx * camera.projectionMatrix) * camera.worldToCameraMatrix;
camera.orthographic = false;
camera.clearFlags = clearFlags;
camera.backgroundColor = backgroundColor;
camera.targetTexture = targetTexture;
return texture2;
}