Image masking using through camera projection, how to?

Started by Tangled-Universe, December 18, 2007, 03:56:11 PM

Previous topic - Next topic

Oshyan

Ah, ok. I think T-A was experiencing crashing though. That was my main concern. Your continued troubleshooting of this is much appreciated. If you can pin down what appears to be going wrong we can surely fix it.

- Oshyan

Tangled-Universe

Quote from: Oshyan on May 08, 2008, 12:18:32 AM
Ah, ok. I think T-A was experiencing crashing though. That was my main concern. Your continued troubleshooting of this is much appreciated. If you can pin down what appears to be going wrong we can surely fix it.

- Oshyan

Yes that's very much appreciated by me also Ben :)
I've posted an example tgd showing my workflow for masking and if I'm correct I didn't specify a projection camera in the imagemap-shaders.

Oshyan is right, I'm experiencing crashes, especially when using camera projection for masking populations or strata shaders.
With bmp's it's crashing inmediately, with tiff after a while (unstable result).
Unfortunately I haven't found the time to test different image-types besides bmp and tiff.
I'll post my findings about that a.s.a.p.

Thank you both!

Martin

nikita

The last time I checked, TG would crash when rendering an image map shader when projection through camera was active but no cam specified. That was with TP2 though.

From my experience, the image map shader works quite well - as long as you keep in mind that it projects a squared image with the dimensions max(horizontal fov, vertical fov)² as Oshyan explained on page one and bigben just noticed again.
If you have a render in a 4:3 format, and the mask is squared (dimensions are 1;1 in the image map shader, I think those values override the aspect ratio of the image(!)), it will indeed be 133% higher than needed.

Sorry in case I'm only telling you stuff you already knew all along. :)

bigben

I suspected it would be square. Changing the proportions of the mask image has no effect.  I can stop those tests.

As for crashes... I have used through camera projection for restricting populations without crashing before although the image was usually just a small white TIFF.  I use greyscale TIFFs with LZW compression.  I'll have a look at Martin's last set of files... a challenge for the train tomorrow morning  ;)

bigben

OK, had a quick play and yes it crashes on preview.
Converted to TIF and it still crashes.
Reconstructed a similar scene and it doesn't crash!

This is using the alpha version. If you want a file in the previous version just let me know. Looking at your TGD I couldn't really see anything that should cause a crash. Method 1 is one of the standard masks I use (apart from Through camera projection).  I don't think it has anything to do with the surface/mask nodes, nor the file format of the image... possibly some other render setting?  I'll have a closer look at the code in the morning.

Tangled-Universe

Quote from: bigben on May 08, 2008, 08:08:35 AM
OK, had a quick play and yes it crashes on preview.
Converted to TIF and it still crashes.
Reconstructed a similar scene and it doesn't crash!

This is using the alpha version. If you want a file in the previous version just let me know. Looking at your TGD I couldn't really see anything that should cause a crash. Method 1 is one of the standard masks I use (apart from Through camera projection).  I don't think it has anything to do with the surface/mask nodes, nor the file format of the image... possibly some other render setting?  I'll have a closer look at the code in the morning.


Thanks a lot Ben. I'll take a look at it when I'm back home... I'm also a registred user so this version shouldn't be a problem :)

To be very precise: using a tiff it crashes on preview, but using a bmp it crashes on connection. That difference gives me the impression it's some kind of a bug and like you said my method (1) is a standard one and there's also nothing out of the normal about my node-setup. It's easy and straight-forward.
It also has nothing to do with something specific in the tgd's I posted here or some rendersetting. It ALWAYS occurs in every scene I set up. No matter how simple, like the examples I posted.

Quote from: nikita on May 08, 2008, 05:53:59 AM
The last time I checked, TG would crash when rendering an image map shader when projection through camera was active but no cam specified. That was with TP2 though.

From my experience, the image map shader works quite well - as long as you keep in mind that it projects a squared image with the dimensions max(horizontal fov, vertical fov)² as Oshyan explained on page one and bigben just noticed again.
If you have a render in a 4:3 format, and the mask is squared (dimensions are 1;1 in the image map shader, I think those values override the aspect ratio of the image(!)), it will indeed be 133% higher than needed.

Sorry in case I'm only telling you stuff you already knew all along. :)

Thank you Nikita :)

To be honest I don't understand why the image-projection is square, why not the same as the rendercamera-setting?
I understand that's not a question for you to answer.
I've read your posts again (Ben, Oshyan and you) and it's still a bit unclear how to setup the image-mask properly if the projection is square.
What aspect ratio/dimensions must the mask be if I want to mask a 800x600 image for example?

nikita

Quote from: Tangled-Universe on May 08, 2008, 10:32:29 AM
Thank you Nikita :)

To be honest I don't understand why the image-projection is square, why not the same as the rendercamera-setting?
I understand that's not a question for you to answer.
I've read your posts again (Ben, Oshyan and you) and it's still a bit unclear how to setup the image-mask properly if the projection is square.
What aspect ratio/dimensions must the mask be if I want to mask a 800x600 image for example?
The mage map shader doesn't even know the aspect ratio of the render (remember, it's only connected to the camera node, not the render node). It also ignores the aspect ratio of your image, because the area the image occupies is being set directly in the image map shader. Since the default values for "horizontal" and "vertical" size are 1 and 1, your image is projected on a square area (when projected along an axis, it's 1m x 1m in size).
If your image is 4:3, you can fit it to the field of view by setting size to 1 ; 0.75. (0.75=3/4)

Tangled-Universe

#37
I see what you mean, the math is no problem :P
So in conclusion I'd have to paint a mask then resize it to a square image and then resize it back in TG2 using those factors?
At least, for matching the image with the render.
The crashes still occur, see post below.

Tangled-Universe

Quote from: bigben on May 08, 2008, 08:08:35 AM
OK, had a quick play and yes it crashes on preview.
Converted to TIF and it still crashes.
Reconstructed a similar scene and it doesn't crash!

This is using the alpha version. If you want a file in the previous version just let me know. Looking at your TGD I couldn't really see anything that should cause a crash. Method 1 is one of the standard masks I use (apart from Through camera projection).  I don't think it has anything to do with the surface/mask nodes, nor the file format of the image... possibly some other render setting?  I'll have a closer look at the code in the morning.


Thanks Ben.
Unfortunately I think you missed something about my point here. Like I explained in my previous post it is no problem using the image to mask a surface layer for color.
The tgd you posted above is only a mask for color.

If you insert a strata and outcrop-shader, connect the imagemap into the blendshader and then activate it it crashes inmediately. But if you connect surfacelayer 01 with the imagemap attached to it it crashes 'just' after a few seconds.
If you insert a population and use surfacelayer 01 with the imagemap attached to it as a density function it doesn't crash inmediately or after a few seconds but it crashes as soon as you hit the populate button.

Please PS, there should be a way to sort this out.

bigben

Quote from: Tangled-Universe on May 08, 2008, 01:28:47 PM

Thanks Ben.
Unfortunately I think you missed something about my point here. Like I explained in my previous post it is no problem using the image to mask a surface layer for color.
The tgd you posted above is only a mask for color.

If you insert a strata and outcrop-shader, connect the imagemap into the blendshader and then activate it it crashes inmediately. But if you connect surfacelayer 01 with the imagemap attached to it it crashes 'just' after a few seconds.
If you insert a population and use surfacelayer 01 with the imagemap attached to it as a density function it doesn't crash inmediately or after a few seconds but it crashes as soon as you hit the populate button.

Please PS, there should be a way to sort this out.

But there are none of those nodes in TU-MaskProblem.tgd and it crashes every time when you connect one of your node branches to the planet which is why I think your problem is something more fundamental.  If you can't successfully render the mask then nothing you connect it to is going to work.

To explore this further I opened your file and recreated every node prior to the planet in the same TGD, using your BMP as an image. I copied the Base Colours node from one of my other TGDs. This doesn't crash!  Connect the surface from Method 1 or 2 and it will crash rendering a preview (usually shortly after the preview render has completed)... every time! There must be a clue somewhere in the code to see what is different between each node.


nikita

Quote from: Tangled-Universe on May 08, 2008, 01:08:06 PM
I see what you mean, the math is no problem :P
So in conclusion I'd have to paint a mask then resize it to a square image and then resize it back in TG2 using those factors?
At least, for matching the image with the render.
The crashes still occur, see post below.
I guess the easiest way is to make image, image map size and render size the same aspect ratio. That way the mask should cover exactly what you see.

bigben

Quote from: Tangled-Universe on May 08, 2008, 01:08:06 PM
I see what you mean, the math is no problem :P
So in conclusion I'd have to paint a mask then resize it to a square image and then resize it back in TG2 using those factors?
At least, for matching the image with the render.
The crashes still occur, see post below.

Missed this one.  In theory, render image, draw mask, set canvas size to height = width (not resize image).

Quote from: bigben on May 08, 2008, 05:05:52 PM
To explore this further I opened your file and recreated every node prior to the planet in the same TGD, using your BMP as an image. I copied the Base Colours node from one of my other TGDs. This doesn't crash!  Connect the surface from Method 1 or 2 and it will crash rendering a preview (usually shortly after the preview render has completed)... every time! There must be a clue somewhere in the code to see what is different between each node.

Had a bit more of a play and it's getting into twilight zone territory. I opened up the TGD where I had duplicated method 1 and then gradually connected the nodes from the original Method 1 branch.

Compute terrain -> Base Colour - OK
Base Colour -> Surface 04 - OK
Image map -> Fractal breakup of Surface 04 - OK

That leaves only Surface 01 -> Planet - Crash after preview completes

Copied both nodes to a text file but I can't see anything that is substantially different  ???

I've done about all I can to isolate where the problem is but I have no idea of the cause.

Tangled-Universe

Quote from: bigben on May 08, 2008, 06:00:46 PM
Quote from: Tangled-Universe on May 08, 2008, 01:08:06 PM
I see what you mean, the math is no problem :P
So in conclusion I'd have to paint a mask then resize it to a square image and then resize it back in TG2 using those factors?
At least, for matching the image with the render.
The crashes still occur, see post below.

Missed this one.  In theory, render image, draw mask, set canvas size to height = width (not resize image).

Quote from: bigben on May 08, 2008, 05:05:52 PM
To explore this further I opened your file and recreated every node prior to the planet in the same TGD, using your BMP as an image. I copied the Base Colours node from one of my other TGDs. This doesn't crash!  Connect the surface from Method 1 or 2 and it will crash rendering a preview (usually shortly after the preview render has completed)... every time! There must be a clue somewhere in the code to see what is different between each node.

Had a bit more of a play and it's getting into twilight zone territory. I opened up the TGD where I had duplicated method 1 and then gradually connected the nodes from the original Method 1 branch.

Compute terrain -> Base Colour - OK
Base Colour -> Surface 04 - OK
Image map -> Fractal breakup of Surface 04 - OK

That leaves only Surface 01 -> Planet - Crash after preview completes

Copied both nodes to a text file but I can't see anything that is substatially different  ???

I've done about all I can to isolate where the problem is but I have no idea of the cause.

Like said some times before...thanks a bunch for all your time and effort Ben. And also Nikita of course.
I'm glad you agree with me something fundamental isn't correct.

I think the best we can do now is sit and wait for Planetside to elaborate on this.
Both Matt and Oshyan are quite busy I think (still waiting on some reply's in other threads) so I'll wait a couple of days for a response, otherwise I'll PM one of them.

Martin

bigben

You're welcome. Don't be surprised if someone suggests a clean re-install  ;)

And a little more info for Planetside:
Tested with TGDCLI (alpha)
Preview render completes (actually displays "Finished Rendering") prior to crashing
CLI output just ends with a standard Unhandled exception error
Memory usage not out of the ordinary

Matt

Quote from: bigben on May 07, 2008, 11:49:37 PM
No crashing, just a misalignment.

When the render camera is attached the image is stretched vertically. I'll have a play tonight with different render proportions, but looking at this example in isolation it may be that the image width is set to the width of the render, and  the height is made the same as the width.

Width:Height here = 1.33 and mask image stretched by 133% to match rendered output

That's correct. If you connect a camera, the shader doesn't know what aspect ratio the camera should be, so it makes it square. This is because your camera might not be the render camera, so it would be wrong for the shader to make assumptions about the aspect ratio. To adjust the ratio you then have to change the Y component of the size parameter in the Image Map Shader (in this case 0.75).

If you do not connect a camera, the camera projection is based on the rendered view, and since it knows the aspect ratio of the render it will fit automatically if the size is set to 1 1 in the Image Map Shader.

I've done it this way so that:

1) there is a way automatically align to the image without worrying about image size or aspect ratio (by leaving the camera link empty, this is the default behaviour)

2) when you need to use a different projection for whatever reason it is independent of your render settings so that you can apply textures anywhere and they will not change if you decide to render an image with a different aspect ratio.

Rule of thumb: if you want to use front projection, don't connect the render camera. It will automatically use the render projection. If you want to project from a different direction, connect a camera to define that projection.

Matt
Just because milk is white doesn't mean that clouds are made of milk.