Difference between rendering to window or matrix
I am making a patch which composes two different matrixes on top of each other, keeping the alpha intact. I am currently doing this with 2 jit.gl.videoplanes because I need to be able to rotate, scale and move them dynamically. I need to render this to a matrix so I can then export the resulting matrix. There is already a fullscreen window showing other things and I don’t want to create an extra window just for this.
But the problem is that the result looks different in a matrix (or jit.pwindow) or a window. The window renders the desired effect (the right layer order and alpha) but rendering to a matrix creates a different composition somehow. What is the difference to rendering to matrix or window? I am using Max 5.1.3 and OS X.
I created a sample patch which does the same thing twice, only once rendering to a window and once to a pwindow. Load to images and use the bang button. It is best to load a PNG with alpha transparency on the first read.
-- Pasted Max Patch, click to expand. --Copy all of the following text. Then, in Max, select New From Clipboard.----------begin_max5_patcher---------- 921.3oc0Y1sbhBCFF9X8pHCG65P9g.zi5dcrSmNnj0lNZvEhstamduuj+JX6 X4GiZ6zYDS.CueO4M46C5KSmDrnXOqJ.bC3WfISdY5jI5tTcLw1dRvlr8KWm Uour.A64hEOFLybJIauT28ib47Uqm+DOmUrcclfAJ1jIK46A2tXMSjeOSjU+ E.Dba1No5b7kfP2v76BgTjsgoGpeVxyV6NiX2FtXMSpu4PamayjKefKVceIa ozHdb37vY.TTj5.FB0sp6CbWy.UrS5FITqabE+e5aLDU+iLcyy0JoNP+AB6j h4mK+6Vl4Vph46MAYvLPP.3N0085zopOl88FmPMGQH+iSx0.mRvB8erxrJV2 TZaIqhIj0PsPzBJDhBCPcfABsezlH8BsDMSgX8g33NHKo+jM5njcQlXkhou+ nAGmAeaYsEkU57rdzVFZfWRnYl.6OeIsS5cVbjK74ZVCUzHJJcdjuLVgC1Xo Odl2O7YtHu34KU5E5g4WR7lwCF8EI+xkkmjCSv3Qd9cHASuwT7YJYAD+0KYg w.5O3QvGjr.E5OOF7xlrPAp+Hmuo3INqdAYd1VI.N5xXPDpNCQ7IUFiMai0f h7WlXX30ZCwQf3gUOs+gU50hU1rEuk0PIy5GBKTsktG2+KUaxvlmtClR8F3R NSqfUrY6g6jMrGg0Fq0n7sDjcDrshp3iFU1HxMPtYEWE5iHRWrSJKDisB9H2 L4mNeB+XH1Qc5iZRaCqpJaE6CF8RVV9n2lk1JP+7cYQGGWzVkz6Rm0Is518e 7ZjtF.ruv.FcVfAtmvPeiBVyEu+Elokpp+CITUwtxktgxkYCzn2bVkjKz1l1 WTzAWzC77bl97NkugmusfKjUNnneROHRe.SaZcjYxdq1Zt.PdVsj5bePJkFQ Uq6Isjrt0IJ4z9vWxvTLRKRXHTq0nlV9.uPOKVRHddBFiID0Ziz1RNwCNh93 eUuuzw3eiMlglFmnXUkgzo8cnhM03dojF26E07hFnevGLD5YMEarnX5aVTj2 bnnn9.Q5vDrcADM17NGaZ4Cwh8rXOUM0qk3iMEERcvhSUCeH1N2Bcn6GEqe5 LSRIbhVrzT+n0t1NJcfRMg1.TyhnHheTZW1x2kJn6rnlGmwN2a7CdPqz93VG nTsqvs+ydLkUcPCaUntu6i5.5rnE3vhAqu0tmEg3s8rzpE6Y0dhZhzG.NPSf Y4eDtscEex109LUmdBrqtwqS+OfN6VlG -----------end_max5_patcher-----------
I think you should try to capture to a texture, then bang that texture to output to a matrix. An example of this can be found in the examples folder of the Max directory.
If you’re only using the matrix to record your video, I’d recommend using a screen capturing tool instead. IshowU is a good one for Mac. It’s quite fast, and saves you the hassle of rendering twice.
I am not capturing the screen, I am composing two images with run-time generating rotations etc and saving the resulting image to disk.
The thing I don’t understand why the same path renders differently to a window than to a matrix. Apparently there is a very big difference between the hardware and software renderer as you can see in the example. I would expect them to work the same. Strange.
>>I am not capturing the screen, I am composing two images with run-time >>generating rotations etc and saving the resulting image to disk.
Could you explain the difference in output between the two? Either you get it from a screen capture, or from a render to a matrix, which you then save. Same difference?
Oh and yes, there definitely are some differences between hardware and software rendering. Theoretically, there shouldn’t be, software could even process a lot more complicated things, but at a much slower speed, so generally, a lot of things are left out in software rendering, making it look far worse.
A few things about the software renderer.
1. it is slow. I can also recommend rendering using hardware, rendering to texture and reading back to a jit.matrix. Rendering to texture typically voids using multi-sampling, so you may wish to render at double resolution and then perform an averaging downsample in software for FSAA.
2. The windows software renderer is less feature complete than Apple’s. With the apple software renderer under earlier versions of OS X, you can also get better results if you set the @quality 1 attribute of the jit.gl.render object.
3. Some of what you describe sounds like it is perhaps related to not using depth buffering. You need to be sure that @depth_enable 1 is set on your jit.gl.render object (which it should be by default)
Here a screenshot of the differences, both methods are completely the same, but one renders to a pwindow and the other to a window. Both renderers have @depth_enable 1 (in the inspector)
The window output is correct: an image with another image in top with alpha blending. In the pwindow, you only seem to see the bottom of the 2 images (the one that is rendered first) and the second seems to be ignored.
Any ideas why? It seems to me this is all quite straightforward and there shouldn't be such a great distance.
Or is there a better way to do this overlaying thing to save to a disk? The bottom image should be rotated and moved and scaled according to runtime variables. I was planning on doing this by rotating the jit.gl.videoplane.
Hey, I just found out that if I set the depth_clear to 1 in the inspector of the pwindow renderer it starts working.
But I can only set this attribute by freezing it in the inspector. Adding @depth_clear 1 to the object doesn’t seem to stick.
Forums > Jitter