Page 1 of 1

Render Texture multiple not being mirrored

Posted: 17 Jun 2021, 02:02
If I open your Widget 3D example. Instead of NoesisGUI being full screen, it's rendered on a surface using Render Texture. If I copy that object and place it next to it, they do both work, but they mirror each other, I need them to be seperated processes. Is that possible to achieve?

Re: Render Texture multiple not being mirrored

Posted: 21 Jun 2021, 09:56
by sfernandez
I just opened that project, selected the "Screen" gameobject, click on Duplicate, and then changed the Position X in its transform to see both screens.
They are rendered both correctly.

Please make sure you didn't have the quad where the Render Texture is applied inverted.

Re: Render Texture multiple not being mirrored

Posted: 21 Jun 2021, 11:56
Hello Sfernandez, thanks for your reply

I did the exact same. Don't you see that if you toggle the lights on in one of them, the other one does the same? That might be what is supposed to happen, but that is not what I want :), I want the new instance to be it's own instance. And it actually is, because something interesting happens when I dig a little deeper. Let's say I am looking at them, one to the left and the other to the right. Both have the lights turned off. If I then turn the lights on in the left one, it looks like it also happens in the right one, but if I then move the mouse to the right one, the lights are off, because that is the actual setting in that instance. I hope it makes sense, else I can make a video for you :).

Re: Render Texture multiple not being mirrored

Posted: 21 Jun 2021, 12:29
by sfernandez
Oh, I though you were referring to the render being mirrored.

What you are seeing is normal because the second quad is rendering using the same material and rendertexture. If you want to be independant, it needs to have its own material and render texture.

Re: Render Texture multiple not being mirrored

Posted: 21 Jun 2021, 12:37
Thank you! Okay, I was actually wondering if that was the case, but I couldn't make it fit, because I was wondering how a prefab would work then. I tried to wrap the both the lights and the "screen" in one gameobject and then make it all into a prefab. That would still use the same material. How would I make that "dynamic", so that using the prefab would not result in the same problem?

Re: Render Texture multiple not being mirrored

Posted: 22 Jun 2021, 11:48
I managed to solve my problem.

I removed the ScreenF material from the Mesh Renderer Materials list in the inspector. I also removed the Target Texture from the Noesis View component. The Quad gameobject is wrapped in Screen gameobject which I then added a new SriptComponent to with 2 properties. Material and Render Texture. Put the ScreenF Material and Render Texture in there. The idea is that instead of using the same exact instance of them in each gameobject, which results in the problem, they will now be used as templates and the script will create a new copy of them, like this:
public Material material;
public RenderTexture renderTexture;

void Start()
        renderTexture = Instantiate(renderTexture);
        var quad = gameObject.transform.GetChild(0).gameObject;
        var meshRenderer = quad.GetComponent<MeshRenderer>();

        material = Instantiate(material);
        material.mainTexture = renderTexture;
        meshRenderer.material = material;
        NoesisView noesisView = quad.GetComponent<NoesisView>();
        noesisView.Texture = renderTexture;
I am not a Unity expert, so there are probably better ways to achieve this and I would appreciate feedback, but this seems to work and achieve my goal, to dynamically create new instances of NoesisGUI. Muhahaha Power overwhelming!

Re: Render Texture multiple not being mirrored

Posted: 28 Jun 2021, 10:53
by sfernandez
Glad you finally make it work.
It looks fine to me, but maybe someone can come up with a better approach for instancing this.