Search Unity

How do i render to the editor Scene View texture?

Discussion in 'General Graphics' started by asqewfcq2egf, Dec 31, 2021.

  1. asqewfcq2egf

    asqewfcq2egf

    Joined:
    Nov 16, 2018
    Posts:
    15
    I have a custom SRP and am trying to add a final Blit pass to it (to apply gamma correction and other things), using Jasper Flick's method of drawing a fullscreen triangle, seen here.

    It works in game view, but in the scene view i just get an empty grey image. It seems like i just can't target the scene view texture.

    Code (CSharp):
    1. static void Blit(ScriptableRenderContext context) {
    2.         buffer.SetGlobalTexture(ShaderIDs.screenTex, ShaderIDs.frameBuffer);
    3.         buffer.SetRenderTarget(BuiltinRenderTextureType.CameraTarget, RenderBufferLoadAction.DontCare, RenderBufferStoreAction.DontCare);
    4.         buffer.DrawProcedural( Matrix4x4.identity, sett.viewportBlitMaterial, -1, MeshTopology.Triangles, 3 );
    5.         context.ExecuteCommandBuffer(buffer);
    6.         buffer.Clear();
    7. }
    'sett.viewportBlitMaterial' is the blit shader
    'screenTex' is the texture that the shader reads from
    'frameBuffer' is the temporary rendertexture that all prior rendering is done with
     
    GuardHei likes this.
  2. GuardHei

    GuardHei

    Joined:
    Feb 10, 2018
    Posts:
    89
    Ignore these: (Wondering the same question, kinda weird that CameraTarget doesn't actually represent the target of scene view camera)

    Turns out it's a bug on my side, Cameratarget does work as intended.
     
    Last edited: Jan 5, 2022