REAL MIROR

benjamin vyger's icon

Hello,

I'd like to create a true mirror reflecting light from several 3D elements.

In my patch, I have ten jit.gl.gridshape cubes with ten different textures.

In fact, we can call these cubes "screens."

I'd like a kind of composition of these ten screens reproduced on a rectangle.

For better understanding, here's a screenshot of the ten cubes in 3D space.

On the top left it is a camera looking at the 10 cubes " screens". Just above a mirror (without the perspective).

Morever, screens are moving like that

TFL's icon

What you want to achieve is not clear to me.

A "real" mirror can easily be done by adding a new camera to the scene, place it behind the mirror area, point it toward the direction of what the mirror is supposed to reflect, capture the camera output and draw it on the videoplane or plane gridshape representing the mirror.

But then the rest of your message and screenshots confuses me.

benjamin vyger's icon

Hi!

Happy to hear you. It's exactly what I need, but I was tired, yesterday

The camera is at the top right and we have to place the mirror area just behind.

The camera has to point toward the direction of the arrow.

Can you, please, show me how to capture the camera output and draw it on the videoplane or plane gridshape representing the mirror ?

Here the patch to run videos on cubes, it needs to have Vsynth plug-in. I don't understand why.

MirrorFromTexture.maxpat
Max Patch

TFL's icon

Your patch doesn't seem to work on my side, I just get a black screen with lots of error messages in the console (mostly because of myTexture being used as a texture name at multiple places).

it needs to have Vsynth plug-in. I don't understand why.

Maybe because you rely on [r draw] to drive your [jit.gl.render]?

I would ditch the Vsynth render bpatcher and replace [r draw] by a [metro 16 @active 1], or, better, remove [jit.gl.render] and [jit.window] too and use a [jit.world] instead.

Can you, please, show me how to capture the camera output and draw it on the videoplane or plane gridshape representing the mirror ?

When using [jit.gl.render] or [jit.world], an implicit [jit.gl.camera], as you have to have a camera to "see" your scene. The first [jit.gl.camera] object you will create will replace that implicit camera, and it will be used for the final output. You will then need to create a second [jit.gl.camera @capture 1] for your mirror and connect its output to a [jit.gl.gridshape] for example.
Then it's a matter of correctly positioning and rotating the mirrors camera relatively to the mirrors shape.

Here is a basic example:

Max Patch
Copy patch and select New From Clipboard in Max.

benjamin vyger's icon

Hi,

Thanks a lot for your explanation.

From your patch, I changed the cone with two cubes textured with two videos.

It works very well!

But as, I have ten cubes to reflect, I would like to encapsulate the most of object as possible, as I tried in the red patch . Thanks for your next ideas!

Max Patch
Copy patch and select New From Clipboard in Max.

TFL's icon

If all of your gridshapes are cubes, I would use [jit.gl.multiple]. Here's an example showing how to use it with multiple textures.

Max Patch
Copy patch and select New From Clipboard in Max.

benjamin vyger's icon

Thanks a lot.!!!

Everything works.

TFL's icon

The position, scale, rotation and texture number are stored in matrices sent to [jit.gl.multiple]

You need to change the value of the cell K to change the position/scale/rotation/texture of shape n° K.

Here is a very basic example (I got rid of the scale matrix for the sake of simplicity).

Max Patch
Copy patch and select New From Clipboard in Max.

In other words, instead of sending position X Y Z messages to gridshapes, you send setcell K val X Y Z messages to the position matrix and then bang that matrix to send it to the position inlet of [jit.gl.multiple].

If you're not familiar with matrices I highly advice you to read that page and check some "introduction to jitter" videos on YT. The jit.gl.multiple reference page and helper patch are also important to understand what is going on here.