Welcome, Guest. Please login or register.
Did you miss your activation email?

Login with username, password and session length

Advanced search

1405678 Posts in 68531 Topics- by 62224 Members - Latest Member: Navy

March 25, 2023, 07:05:20 AM

Need hosting? Check out Digital Ocean
(more details in this thread)
TIGSource ForumsDeveloperTechnical (Moderator: ThemsAllTook)Camera not rendering to cubemap!
Pages: [1]
Author Topic: Camera not rendering to cubemap!  (Read 1533 times)
Level 10

The archivest master, leader of all documents

View Profile
« on: April 11, 2022, 03:58:18 PM »


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");
        //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;
    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;
        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...

Level 10

View Profile
« Reply #1 on: April 14, 2022, 06:45:31 PM »

May I ask what version of Unity you are using? Is this pre-SRP?

Level 10

The archivest master, leader of all documents

View Profile
« Reply #2 on: April 15, 2022, 11:55:49 PM »

I'm def not using srp, it's built in and 2020.3.23.f1 personal

However a friend helpt me figured it out, the rendertexture wasn't properly connecting for some reason, moved it to the setCameraData() function and it works. Though I'm still tacking weird bugs elsewhere... Which is another thread, probably, once I lost enough hair.

Thanks for stopping by!

Pages: [1]
Jump to:  

Theme orange-lt created by panic