Graphics.Blit changed between 5.2.2f1 and 5.4.2f2 ?

hello,
I use Graphics.Blit with my minimap function and all worked well until i changed from Unity 5.2.2f1 to 5.4.2f2.
beside my minimap got messed up now the Blit-function also produces the warning:
“Tiled GPU perf. warning: RenderTexture color surface (256x256) was not cleared/discarded”

the C# Codeline which produces the warning:

Graphics.Blit(FoWShape, FoWTex, blitMat);

where:
FoWShape is a Texture2D
FoWTex is a RenderTexture (8Bit fixed point)
blitMat using a shader with blending: Source * Src Color + Destination * One

so my question is if anyone knows maybe a syntax-change or anything else to fix that.

thanks in advance

Did you try reading the release notes to see what is changed?

My understanding is that certain GPU configurations - tiled in this case - have reduced performance if the render surface isn’t cleared each frame. This is just a guess, but this is likely a warning stating that you may have performance issues because you’re not clearing it.

So are you? If the render texture is attached to a camera have you set the clear mode so? If not, are you specifically clearing it? Or are you discarding the contents when done?

thanks for your replies

  • @TJHeuvel-net :* of course i have looked into the release notes by searching for “graphics.blit” where i found nothing helpful.

  • @Dave-Carlile :* right its just a warning and it doesnt hurt the performance but the problem is not the warning itself but the whole funktion doesnt work anymore.
    i use the blit function to draw a bitmap on a rendertexture which is used in combination with the minimap-texture to get a fog-of-war effect. so no camera is involved directly here. the output is just the final material drawn on a plane.

but however now we found another solution with using graphics.drawtexture instead of graphics.blit which works fine both on win and android.
there is also no performance drop now compared to the blit-version but i have to test that a little bit deeper.

but the Graphics.Blit still doesnt work, so what we have done is just a workaround with Graphics.DrawTexture.

what we also found out was:
when a texture is set to automatic-compression in V5.2 having no artefacts, it will create artefacts in V5.4 until we changed the texture-compression to RGB24 (in our case). maybe helpful for somebody

Just to add to this.

In V5.2 the Graphics.Blit used the mainTextureScale & mainTextureOffset of the material specified, so we could place a smaller source texture within the dest

In v5.4 the Blit ignores the mainTextureScale & mainTextureOffset and always scales the source to the dest size.

So I guess the answer is one of the following…

  • It was working correct before and is now it’s broken.
  • It was broken before and now it’s correct.
  • We are stupid and using it wrong.

For me personally, it could be no 3, as I am pretty new to Unity. If the answer is no 2, then is there a way of scaling and positioning the source texture within the destination?

Regards,

Les

I just found out the same - Graphics.Blit ignores mainTextureScale and overrides it with default.

I bet it’s somewhere in between #1 and #2… I with Unity had provided mean to control mainTextureScale in other way when they made this change.

@ : you can write a custom shader which takes extra parameters and rescale your texture using those.