Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Mirror does not work when using an overlay camera #8

Open
akauper opened this issue Aug 12, 2020 · 4 comments
Open

Mirror does not work when using an overlay camera #8

akauper opened this issue Aug 12, 2020 · 4 comments

Comments

@akauper
Copy link

akauper commented Aug 12, 2020

If a base and overlay camera are being used in the scene the mirror will not work as expected.

@akauper
Copy link
Author

akauper commented Aug 12, 2020

A quick fix:
In Mirror.cs after line 207 add:

var camData = camera.GetUniversalAdditionalCameraData();
if (camData.renderType == CameraRenderType.Overlay)
         return;

Tokars pushed a commit to Tokars/kMirrors that referenced this issue Dec 9, 2020
@qiushuisuoyue
Copy link

A multisampled texture being bound to a non-multisampled sampler. Disabling in order to avoid undefined behavior. Please use Texture2DMS in the shader.
UnityEngine.Rendering.Universal.UniversalRenderPipeline:RenderSingleCamera (UnityEngine.Rendering.ScriptableRenderContext,UnityEngine.Camera)
kTools.Mirrors.Mirror:RenderMirror (UnityEngine.Rendering.ScriptableRenderContext,UnityEngine.Camera) (at Library/PackageCache/com.kink3d.mirrors@79b0526e5d/Runtime/Mirror.cs:261)
kTools.Mirrors.Mirror:BeginCameraRendering (UnityEngine.Rendering.ScriptableRenderContext,UnityEngine.Camera) (at Library/PackageCache/com.kink3d.mirrors@79b0526e5d/Runtime/Mirror.cs:236)
UnityEngine.GUIUtility:ProcessEvent (int,intptr,bool&)

a base and overlay camera are being used in the scene the mirror will not work as expected.

@qiushuisuoyue
Copy link

sampler2D _ReflectionMap;
float4 _ReflectionMap_ST;

        v2f vert (appdata v)
        {
            v2f o;
            o.vertex = TransformObjectToHClip(v.vertex.xyz);
            o.uv = TRANSFORM_TEX(v.uv, _ReflectionMap);
            o.screenPos = ComputeScreenPos(o.vertex);
            return o;
        }

        half4 frag(v2f i) : SV_Target
        {
            float2 uv = i.screenPos.xy / i.screenPos.w;
            half4 col = tex2D(_ReflectionMap, uv);
            return col;
        }

unity 2021.2.3

@Nightfury420
Copy link

A quick fix: In Mirror.cs after line 207 add:

var camData = camera.GetUniversalAdditionalCameraData();
if (camData.renderType == CameraRenderType.Overlay)
         return;

Damm, THANK YOU!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants