Shader not working properly with lightmapping scene
Hi, problem on video:
Without lightmaping - https://www.youtube.com/watch?v=cXgcBZjeTsM
With lightmapping - https://www.youtube.com/watch?v=ySb2jkG4JvQ
Its repdoduced on Unity 2019.2.12-18f1 and devices with Adreno 540, Mali G71mp10.
Portal shader:
 Shader "FX/Portal"
 {
     Properties
     {
         //[HideInInspector] _MainTex ("", 2D) = "white" {}
         _MainTex ("Texture", 2D) = "white" {} 
     }
         SubShader
     {
          Tags {"RenderType" = "Opaque"}
         LOD 100
 
         Offset -0.01, -0.01
 
         Pass {
             CGPROGRAM
             #include "UnityCG.cginc"
             #pragma vertex vert
             #pragma fragment frag
             #pragma multi_compile_fog
 
             struct appdata
             {
                 float4 vertex : POSITION;
                 float2 uv : TEXCOORD0;
             };
 
             struct v2f
             {
                 float4 uv : TEXCOORD0;
                 float4 vertex : SV_POSITION;
             };
 
             sampler2D _MainTex;
             float4 _MainTex_ST;
 
             v2f vert(appdata v)
             {
                 v2f o;
                 o.vertex = UnityObjectToClipPos(v.vertex);
                 o.uv = ComputeScreenPos(o.vertex);
                 return o;
             }
 
             fixed4 frag(v2f i) : SV_Target
             {
                 fixed4 col = tex2D(_MainTex, i.uv.xy / i.uv.w);
                 return col;
             }
             ENDCG
         }
     }
     //Fallback "Diffuse"
 }
Portal camera render code:
 Cams[0].Render(); // first render zero camera (main)
 for (int i = recursionSteps - 1; i > 0; i--)
 {
     Cams[i].Render(); // then all other cameras for recursion
     Graphics.Blit(RenderTextures[i], RenderTextures[0]); // Then combine them with zero.
 }
At the same time, everything works fine on a PC, on the old Adreno 330 it’s fine too..
Answer by mastersmit · Jan 17, 2020 at 02:05 PM
I didn’t do the right order of rendering cameras and blit. Thats correct:
 private TempRenderTexture, CurrentRenderTexture;
 for (int i = recursionSteps - 1; i >= 0; i--)
             {
                 Cams[i].targetTexture = TempRenderTexture;
                 Cams[i].Render();
                 Graphics.Blit(TempRenderTexture, CurrentRenderTexture);
                 Cams[i].targetTexture = null;
             }
Your answer
 
 
             Follow this Question
Related Questions
Cut through camera render and display LITERALLY NOTHINGNESS 0 Answers
Why is there difference between android device resolution and webcamtexture resolution 0 Answers
Age of Empires type Fog of War from Point Light 1 Answer
My outline shader gets covered by the background at certain angles. 0 Answers
 koobas.hobune.stream
koobas.hobune.stream 
                       
                
                       
			     
			 
                