Hello!
I have an issue where I created a class to generate a lightprobe atlas texture for me, but the camera don't seem to render properly into teh rendertexture, I have no idea why...
someone can help me found what I did wrong?
private void setCameraData(){
//set camera
pivot = new GameObject("CaptureScene");
pivot.AddComponent<Camera>();
//Set camera parameters
lens = pivot.GetComponent<Camera>();
lens.backgroundColor = Color.blue;
lens.clearFlags = CameraClearFlags.SolidColor;
lens.allowMSAA = false;
lens.cullingMask = 1 << 8;//what mask?
//should probably have an alternative for regular scene rendering
lens.SetReplacementShader(capture, "RenderType");
//set rendertexture
sceneCapture = new RenderTexture(cubemapSize, cubemapSize, 24);
sceneCapture.dimension = UnityEngine.Rendering.TextureDimension.Cube;
sceneCapture.antiAliasing = 1;
sceneCapture.filterMode = FilterMode.Point;
sceneCapture.graphicsFormat = UnityEngine.Experimental.Rendering.GraphicsFormat.R8G8B8A8_UNorm;
sceneCapture.depth = 16;
sceneCapture.Create();
}
public void updateCell(int x, int y){
//this fonction capture a cubemap of the scene from the point of view of a given cell
//place camera
int midcell = cellsize / 2;
//-------------------- hashed position
pivot.transform.position = new Vector3((x * cellsize) + midcell, 0, (y * cellsize) + midcell);
pivot.transform.rotation = Quaternion.identity;
lens.RenderToCubemap(sceneCapture);
updateTile(x, y);
}
The rendertexture seems to be stuck into gray, I can't figuring out why. This is a refactor code, technically I got it to work initially in the old code, but there seems to be no notable difference with the new code except it's now in a class and cleaned up of dead code...