RenderWithShader Question

Hey,

I need help to understand RenderWithShadder. I want to make come kind of per object glow effect. So I use RenderWithShader with shaders tags.

I create an other camera by script to render my glow effect in a renderTexture. so far the camera and renderTexture creation works. My problem is that the renderTexture is all black. like if no tag is matched.

here’s my code:

C#

    void OnEnable()
    {
// Create my render Texture
        replaceRenderTexture = new RenderTexture((int)camera.pixelWidth, (int)camera.pixelHeight, 16, RenderTextureFormat.ARGB32);
        replaceRenderTexture.wrapMode = TextureWrapMode.Clamp;
        replaceRenderTexture.useMipMap = false;
        replaceRenderTexture.filterMode = FilterMode.Bilinear;
        replaceRenderTexture.Create();

// The final material on camera
        material.SetTexture("_Glow", replaceRenderTexture);
// Create my Glow Camera
        shaderCamera = new GameObject("GlowCamera", typeof(Camera)).camera;
        shaderCamera.gameObject.hideFlags = HideFlags.HideAndDontSave;
        shaderCullingMask = ~ignoreLayers;
        shaderCamera.enabled = false;
        shaderCamera.targetTexture = replaceRenderTexture;
    }


    public void OnPreRender()
    {
//Settings for glow Camera
        shaderCamera.CopyFrom(camera);
        shaderCamera.enabled = false;
        shaderCamera.backgroundColor = Color.clear;
        shaderCamera.clearFlags = CameraClearFlags.SolidColor;
        shaderCamera.renderingPath = RenderingPath.Forward;
        shaderCamera.targetTexture = replaceRenderTexture;
        shaderCamera.rect = normalizedRect;
        shaderCamera.cullingMask = shaderCullingMask;
//Render with replacement shader
        shaderCamera.RenderWithShader(glowOnlyShader, "RenderType");

    }

    void OnRenderImage(RenderTexture sourceTexture, RenderTexture destTexture)
    {
//Set glow texture to be my renderTexture from glow camera
//The texture is always black it doesn't catch replacement tags
        material.SetTexture ("_Glow", replaceRenderTexture);
        shaderCamera.ResetReplacementShader();
 
        Graphics.Blit (sourceTexture, destTexture, material);

    }

Glow Camera shader (glowOnlyShader) tags:

Tags{
            "Queue"="Geometry"
            "IgnoreProjector"="True"
            "RenderType"="HiberGlowOpaque"
        }

Object tags:

Tags {
            "RenderType"="HiberGlowOpaque"
        }

My “glow per object” asset in the store does what you want, if you want to check it out.

Thanks, but I already have some packages that does that. I’m only trying to understand why my texture is all black