Planetside Software Forums

General => Terragen Discussion => Topic started by: Kadri on April 01, 2021, 09:06:20 AM

Title: Photogrammetry
Post by: Kadri on April 01, 2021, 09:06:20 AM
By the way guys and girls.

I had something since a long while in my mind but the ongoing animation render and a little laziness prevented me to test it.

As Jordan is complaining about texturing Terragen exported objects...
It is certain that we need really better texture export for Terragen.

Did anyone tried photogrammetry software using Terragen rendered images?

We could easily render the needed 360 degree and what not images to get an object that does have the texture on it with UV.
Contrary to outdoor photos having to deal with this or that bad lighting, that would be very easy to do in Terragen.

Would be great if anyone would test this. Downside could be render time.
But without shadows and atmo (ideal for photogrammetry ) they should render actually much much faster then normal renders.

I don't know if this would be actually practical as this is a different workflow with another software ( photogrammetry) regarding time etc.
The downside might be obj size limit. Upside a really working UV textured object.

But just for fun it sounds nice to my ear :)
Title: Re: Photogrammetry
Post by: Dune on April 01, 2021, 10:10:47 AM
What kind of object are you thinking about? And how would you have to set up the camera to capture that? Inside the object? You wouldn't want any holes in the object.
Title: Re: Photogrammetry
Post by: Kadri on April 01, 2021, 10:34:04 AM
Quote from: Dune on April 01, 2021, 10:10:47 AMWhat kind of object are you thinking about? And how would you have to set up the camera to capture that? Inside the object? You wouldn't want any holes in the object.

Our main problem is landscapes rocks etc. But you can make everything Terragen exports as objects.

Camera is mostly 360 degree kinda photos step photos-renders taken from a certain different angle then before.

Depends on the object, images and photogrammetry software how many steps of photos-renders would be enough.
Holes work too. But the quality depends on all of those things together.
I don't know how inside would work but the principle is the same.
You might remember this:
https://planetside.co.uk/forums/index.php/topic,18805.msg183042.html#msg183042
That was a real life object of course.
Title: Re: Photogrammetry
Post by: WAS on April 01, 2021, 01:10:27 PM
Turn table viewing to create an object mesh. It should be doable, and be able to get very good results as we can make sure only the item in question is in the scene to be observed ny other software.
Title: Re: Photogrammetry
Post by: Kadri on April 01, 2021, 01:17:21 PM
Yes.
Title: Re: Photogrammetry
Post by: WAS on April 01, 2021, 01:25:35 PM
I am not too familiar with how its done but doesnt it need some sort of depthed lighting to see the objects geometry? So you end up with baked shadows?
Title: Re: Photogrammetry
Post by: Kadri on April 01, 2021, 01:39:12 PM
Quote from: WAS on April 01, 2021, 01:25:35 PMI am not too familiar with how its done but doesnt it need some sort of depthed lighting to see the objects geometry? So you end up with baked shadows?

Hmm...i can't remember Jordan.
Not sure if those are taking the shadows into account or just the changing structure or whatever.
Even if it is with shadows we could change at least the UV map.
I might try tomorrow maybe.
30 hours without sleep... :o
Title: Re: Photogrammetry
Post by: WAS on April 01, 2021, 01:44:56 PM
Oh yeah I'd get some sleep. I'm trying to find software that would be good to use but so far they all toggle to CPU modes because they only use Nvidia CUDA technology. :\
Title: Re: Photogrammetry
Post by: WAS on April 01, 2021, 05:30:00 PM
So I found this video while looking up phones that I may pickup and it actually has good info on how you may want to setup scene in TG lighting wise. Rotating the objects themselves may be easier than a camera on rail.

Title: Re: Photogrammetry
Post by: gao_jian11 on April 01, 2021, 11:35:46 PM
Yes, it is totally feasible. I conducted a simple test in 2019. At that time, RealityCapture BETA could be used for free for one month. I don't know if it's okay now.
I set up the camera around the rock, and then rendered an image at 5 frames intervals, and got the result in Figure 3. At that time, the shadow of the sun was not seriously considered. In short, there is a lot to do.
Title: Re: Photogrammetry
Post by: Dune on April 02, 2021, 02:33:35 AM
For a single rock like that, you could put it on a very small area, so you get rid of the whole planet.

Handy if you want to edit it later and reimport, but if a nice rock can be made within TG and it's good enough, I wouldn't bother.
Title: Re: Photogrammetry
Post by: Kadri on April 02, 2021, 03:10:16 AM
Quote from: gao_jian11 on April 01, 2021, 11:35:46 PMYes, it is totally feasible. I conducted a simple test in 2019. At that time, RealityCapture BETA could be used for free for one month. I don't know if it's okay now.
I set up the camera around the rock, and then rendered an image at 5 frames intervals, and got the result in Figure 3. At that time, the shadow of the sun was not seriously considered. In short, there is a lot to do.

Nice test. Haven't tried RealityCapture.

I used 3DF Zephyr Free for my test. There are some restrictions i think but haven't looked much into it.
The object is very very low poly i got. Half Mb. I used only 800x 30 renders from only one Y high position.
All took under 1 hour or so. Rendering included. All in all a very low poly approach.
So it could be much better with different options and renders etc. as there are quite good objects around on the web.

But just using a front projection for an exported imported obj (if you need it at all of course) looks better from what i see after this test.
But there could be special uses maybe.
Title: Re: Photogrammetry
Post by: Kadri on April 02, 2021, 03:42:57 AM

I had a little closer look at the settings and got  this time  a 1.6 Mb obj with the same 30 renders.
Better but still very low of course. I wouldn't use this method except special needs as i said.
Title: Re: Photogrammetry
Post by: Kadri on April 02, 2021, 08:57:45 AM

I made a third attempt with 30 HD images.
Rendering included it took around 2 hours (depends on settings and hardware of course).

This time i got a 100 Mb obj file.
With a better preparation of the landscape, camera position, more images etc. it could be made better then this.

I used Poseray to smooth normals. But could have used higher settings.
The object comes into Terragen with different axes then 3DF Zephyr (maybe there are settings?)  so you have to change it.
Title: Re: Photogrammetry
Post by: WAS on April 02, 2021, 01:25:09 PM
Yeah Unless you con properly turn table tbe landscape you ate going to get poor results and possibly bad geometry info for shape

You will want to rotate the object itself with camera sitting still, and have everything off but lighting. Not even atmosphere if you can get away with it. But also a dark background helps too. 

For doing rocks, and such, you should be able to get good results if you use large unnoisy renders.
Title: Re: Photogrammetry
Post by: Kadri on April 02, 2021, 02:06:57 PM
Turntable is easy if you make the camera move in another software and import as chan or fbx file.
You actually use the same camera move all the time nearly by changing only scale.

I turned atmo off in these tests.
Title: Re: Photogrammetry
Post by: WAS on April 02, 2021, 02:11:05 PM
Not sure how that's easier then a plane or object rotating. You can keep focal lighting in same place too so resulting textures are all blended with for example forward head on lighting reducing baked shadows in the final texture. The benefit of a 3D world is our object can be just rotated and doesn't require moving around the object.
Title: Re: Photogrammetry
Post by: Kadri on April 02, 2021, 02:50:48 PM
Quote from: WAS on April 02, 2021, 02:11:05 PMNot sure how that's easier then a plane or object rotating. You can keep focal lighting in same place too so resulting textures are all blended with for example forward head on lighting reducing baked shadows in the final texture. The benefit of a 3D world is our object can be just rotated and doesn't require moving around the object.
If you can move rotate all nodes without any problem and the changing light angle-shadows aren't a problem (this could be easy by just using luminosity without lights). Then yes. But not sure if this is easier in all scenes then just moving the camera.
Title: Re: Photogrammetry
Post by: WAS on April 02, 2021, 03:51:51 PM
Im wondering if luminosity would work. It makes objects appear 2D and there is no depth from lighting to read to create a 3D object. Just boundaries to the background. May end up with roundish object or whatever based on boundaries to BG with no surface geometry but what it reads from textures alone.

And should be able to rotate most stuff if its applied with the correct logic as I found out with my planets. Setting up your scene janky and you'll have problems.

But as for easy? Doing camera rigs in a other program is pretty contrary.  Even most real world scanning like in the video, he rotates the turntable and kept his camera on arm in front for lighting.
Title: Re: Photogrammetry
Post by: Kadri on April 02, 2021, 05:10:24 PM
Quote from: WAS on April 02, 2021, 03:51:51 PM...
But as for easy? Doing camera rigs in a other program is pretty contrary.  Even most real world scanning like in the video, he rotates the turntable and kept his camera on arm in front for lighting.

That is the real world. You do what is better and easier.
Which one is? Turning the small object or rotating the camera around the object?
The part where i am not sure is the lighting shadowing use.
If that is better then using that method should be preferred in Terragen too.

If you can easily rotate the ground in Terragen that is better. If not you have to move the camera.
Using another program for the camera move is harder yes. But you could do it one time in Terragen and then exporting the scene-camera (chan-Fbx) and using this all the time you want over and over again.
Title: Re: Photogrammetry
Post by: WAS on April 02, 2021, 06:39:31 PM
Yeah, in some circumstances you'll probably have to use a camera on rail or set positions. For example if your texturing and displacement relies on shaders which cuts off the flow from transform shaders or object rotation.

And that is true you could used it overv and over, that is, if your scene is within scale. A lot of shaders could be using alt keys, slope limits, etc, and scale could change that so you'd need new cameras.

And clearly i'm talking about translating real-world methods to 3D, and where you can easily cut things out because you're in control of the world.
Title: Re: Photogrammetry
Post by: WAS on April 03, 2021, 03:47:16 AM
So I am trying out this software in the morning. Hearing good things and found some info for blender. 

https://alicevision.org/
Title: Re: Photogrammetry
Post by: David on April 03, 2021, 08:12:11 AM
If I understand you correctly you are trying to find a way to eliminate shadows on you exterior source photos?


If this helps, I shoot rock-faces either in shadow or overcast lighting. But crucially, in both cases I also use a powerful Elinchrom Quadra ring flash with a high quality lens. Ring flashes are idea for illuminating shadows in crevices and from overhangs because their light is parallel to the lens axis. The attached renders were created from 300 x 103MB images and processed in Reality Capture. RC delivers cleaner models in less time than Metashape, though with more images Metashape can produce excellent models too. This model comprises approx 1,200,000 polys. It was GPU rendered in Lightwave and Octane and they each took only a few minutes. Unfortunately, with these programs I can't get the skies or the range of water effects that Terragen offers.


Rockface detail.jpg  Lightwave screenshot.jpg
Title: Re: Photogrammetry
Post by: Kadri on April 03, 2021, 09:29:29 AM
Thanks for the help.
We are actually talking about which way would be the best to get Terragen landscapes out (for UV texturing for example) and using in Photogrammetry to get it ones again into Terragen or other software.

That object looks nice. 300 photos are quite a lot. What do you think would be best to get something out from Terragen?
As render times would be a problem for so many photos-renders.
I mean what do you think would be acceptable as a minimum? Resolution and render amount...?
And do we need shadows for calculating to get better models or are they not needed or even problematic?
From your post it looks like shadows aren't needed at all for good model calculation.
This would be very easy to do then in Terragen (lighting wise) and in any other software that is.
Title: Re: Photogrammetry
Post by: David on April 03, 2021, 10:06:06 AM
Sorry, there's still something I'm not understanding here. Are you wanting to export a landscape mesh out of Terragen? If so I think that is possible with Terragen 4. Or are you hoping to use Terragen renders as images for photogrammetry? If so that sounds like a lengthy business.

Regarding shadows, no, you don't need them for successful photogrammetry so long as there is good colour texture information that isn't a single flat overall colour.
Title: Re: Photogrammetry
Post by: Kadri on April 03, 2021, 10:17:10 AM
Quote from: David on April 03, 2021, 10:06:06 AMSorry, there's still something I'm not understanding here. Are you wanting to export a landscape mesh out of Terragen? If so I think that is possible with Terragen 4. Or are you hoping to use Terragen renders as images for photogrammetry? If so that sounds like a lengthy business.

Regarding shadows, no, you don't need them for successful photogrammetry so long as there is good colour texture information that isn't a single flat overall colour.

Yes you can export mesh from Terragen.
The problem is with texturing the same way.
There are different methods for getting this of course like Ortho rendering, front projection etc.

This thread is kinda an extension from 1-2 other threads about this.
I don't care so much about texturing (still would be great of course) exactly as it is in Terragen.
But Jordan (Was) wants an exact detailed texture as it is in Terragen.

That is the real reason for this thread actually. I thought if this would be a temporary solution.

If we could get the mesh exported with the textures directly from Terragen as it is, this thread would be only for fun mostly.
I think Matt will bring this in another update most probably. But we don't know when, if it happens at all of course.

Good to know that shadows aren't a problem.
Title: Re: Photogrammetry
Post by: Kadri on April 03, 2021, 10:21:08 AM
Quote from: David on April 03, 2021, 10:06:06 AM...are you hoping to use Terragen renders as images for photogrammetry? If so that sounds like a lengthy business.
...

If we need 300 renders it could be as you said. As even with disabled shadow and atmosphere that could take quite while to render.
With my CPU Ryzen 9 3950X it took more then one hour for 30 HD images. It depends on the scene too.
Would take basically one day for an object more or less.

Thus the reason i wanted to know about the minimums for doing this resolution and photo amount wise
Title: Re: Photogrammetry
Post by: David on April 03, 2021, 12:34:37 PM
Thanks for the explanation. I can't offer much help as to how many renders you will need except to say ....  as many as your patience allows! All the photogrammetry programs will be grateful for all the images you can throw at them. Good luck.
Title: Re: Photogrammetry
Post by: Kadri on April 03, 2021, 01:21:23 PM
Thank you.
Title: Re: Photogrammetry
Post by: WAS on April 03, 2021, 01:23:18 PM
I still see plenty of shadows in his raw, and this is what tells programs to create geometry based on lighting depth. Its very similar to creating heightmaps etc from image. If the program can't see geometry, it can only work off the colors of the textures. You want light from POV though, like a ring light, however fo have a correct angle for lighting for depth. Same deal for bitmap approximations of textures or scans of textures. Additionally if you have stuff like distort by normal, this creates illusions of weird shadows for luminosity because its warping textures by surface normal.

You can go ahead and render a simple rock sphere on black BG with luminosity for texture, it will appear 2D and flat. So all the programs could do is built geometry based on the border shapes of the object, and some displacement of what it can see of textures which would just be the textures, no surface depth.
Title: Re: Photogrammetry
Post by: Kadri on April 03, 2021, 01:26:43 PM
Quote from: WAS on April 03, 2021, 01:23:18 PMI still see plenty of shadows in his raw, and this is what tells programs to create geometry based on lighting depth. Its very similar to creating heightmaps etc from image. If the program can't see geometry, it can only work off the colors of the textures. You want light from POV though, like a ring light, however fo have a correct angle for lighting for depth. Same deal for bitmap approximations of textures or scans of textures. Additionally if you have stuff like distort by normal, this creates illusions of weird shadows for luminosity because its warping textures by surface normal.

You can go ahead and render a simple rock sphere on black BG with luminosity for texture, it will appear 2D and flat. So all the programs could do is built geometry based on the border shapes of the object, and some displacement of what it can see of textures which would just be the textures, no surface depth.
Curious Jordan. I will try and see how such a rock would look. I don't know how it will look.
Title: Re: Photogrammetry
Post by: WAS on April 03, 2021, 01:27:40 PM
Here is a rock with luminosity. Geometry is pretty lost because of now shadows, but some is there becasue of multiplied voronoi by colour, which also produces the displacement. So there is some depth provided by that, but the rest is created by distort by normal creating the illusion of shadows to the left, which would trick a photogrammetry program I think in luminosity mode, and maybe with shadows too.

This took 11 minutes to render with lighting, or 1 minute with luminosity, so it may be worth trying anyway. May do it since it'll take awhile to get the 11 minute ones I need.
Title: Re: Photogrammetry
Post by: WAS on April 03, 2021, 01:28:23 PM
PS forgot to turn of GISD so some darkness there. Ooops. But maybe that would help? Could even use larger settings for more depth of the obj?
Title: Re: Photogrammetry
Post by: Kadri on April 03, 2021, 01:31:11 PM

I terminated my 3Dcoat test as the bar was barely moving. I waited for half a day.
At least it didn't crashed this time earlier.
I used a 1.1 Gb obj file for this. The files i used some years ago were smaller...around 500 Mb or so.


I forgot to disable GI too in my tests.
Title: Re: Photogrammetry
Post by: WAS on April 03, 2021, 01:39:33 PM
Here is just some random PF applied that doesn't have any multiplication by the scalars producing dispalcement. Here is a good exmaple where there is no info to provide geometry.

The only place depth is noticeable is around the terminator, where displacement is overlaying other disp.
Title: Re: Photogrammetry
Post by: Kadri on April 03, 2021, 01:43:03 PM
Have you enabled shadows , atmo and disabled luminosity after you imported the obj ?
Title: Re: Photogrammetry
Post by: WAS on April 03, 2021, 01:45:45 PM
It's a TG object, that I would be doing a turntable of to create an object for.

I'm just demonstrating that I don't know if luminosity would work. And you should try to use a solid background for photogrammetry where possible. If any hues of the atmosphere match the rock in greyscale to the software, it will be included in geometry.



Applying the displacement as a scalar to the texture helps a little bit. I turned on GISD again, but it doesn't seem to make much difference on luminosity, since it's glowing.
Title: Re: Photogrammetry
Post by: WAS on April 03, 2021, 01:51:29 PM
So here is with colour, and sun again, but this time I turned off specular highlights in the sun, which immediately produced a softer appearance in lighting in 3D preview. That alone is causing the render to go a loooot faster. Instead of 11 minutes this one took 2:38.
Title: Re: Photogrammetry
Post by: Kadri on April 03, 2021, 02:32:52 PM
I see.

I am trying to make the camera motion in Lightwave. This is kind of those motions what i don't like.
Close to exporting now. Then i will try exporting from Terragen. If i can get there of course :)
Title: Re: Photogrammetry
Post by: Kadri on April 03, 2021, 02:42:35 PM
Jordan can you upload that object right here for me to test.
The scene is ready to render.
just laziness :P
Title: Re: Photogrammetry
Post by: Kadri on April 03, 2021, 02:45:23 PM
Here is the FBX file by the way.
Just put your object  at "O,5,0" and change the camera FOV to a wider range.
This is a very crude move i just throw it together very fast.
Title: Re: Photogrammetry
Post by: WAS on April 03, 2021, 02:53:10 PM
Here is the rock turntable test I been doing. I am waiting until night to render it. I'd check to make sure the shaders are actually rotating correctly too, I think they are but it's hard to tell through 3D preview.

Thanks for the camera rig!
Title: Re: Photogrammetry
Post by: Kadri on April 03, 2021, 02:56:05 PM

I think of doing this with another kind of object and displacement maybe...To see the displacement better.
But i will try yours first.
2 people doing this is better.
Title: Re: Photogrammetry
Post by: WAS on April 03, 2021, 03:07:17 PM
I wanted to do a spire with my geonosis displacement but forgot as I crashed bringing it into a mew project and lowering scales and just did a rock to test
Title: Re: Photogrammetry
Post by: PabloMack on April 03, 2021, 03:29:33 PM
Quote from: WAS on April 01, 2021, 05:30:00 PMRotating the objects themselves may be easier than a camera on rail.
I made my own turn-table for this purpose. I bought a circular bearing (for only about $15 on Amazon) that is rated for 1000 lbs and built it into a Lazy Susan. I marked off the angles to make it easier to shoot a full 360 series using the Agisoft photogrammetry software. You can see a photo of the turn table below:

https://www.amazon.com/gp/product/B0045DV04I/ref=ppx_yo_dt_b_search_asin_title?ie=UTF8&psc=1

TurnTable.jpg
Title: Re: Photogrammetry
Post by: WAS on April 03, 2021, 03:52:58 PM
Wow that's pretty darn cheap, especially considering the prices on turntables meant for heavy stuff. Whoa.
Title: Re: Photogrammetry
Post by: Kadri on April 04, 2021, 12:44:41 PM
Quote from: Kadri on April 03, 2021, 01:31:11 PMI terminated my 3Dcoat test as the bar was barely moving. I waited for half a day.
At least it didn't crashed this time earlier.
I used a 1.1 Gb obj file for this. The files i used some years ago were smaller...around 500 Mb or so.
...

About 3DCoat. I should be clearer. I was using retopology. Not just only opening. That could be different.
Title: Re: Photogrammetry
Post by: David on April 04, 2021, 05:00:42 PM
Quote from: WAS 03/04/2021, 18:23:18

    'I still see plenty of shadows in his raw, and this is what tells programs to create geometry based on lighting depth.'




My mistake WAS for posting an open GL rather than an actual original RAW image. So here, side by side, is 1 of the images used to create the rockface on the right. All 300 images were just like this one - totally flat - almost albedo-like. Notice that the overhangs and crevices are all well lit so that 3D renderer is able to project it's own shadows without having to fight any ambient shadows in the scene.


Rockface.jpg
Title: Re: Photogrammetry
Post by: WAS on April 04, 2021, 05:52:00 PM
Oh that makes much more sense. It seems like what I saw with Kadri's tests, and the lack of surface depth lets the programs only really grab boundary geometry where it actually curved away from the camera, and protrudes against the BG. The subtler surface geometry just isn't present because it's not really seen until it's rotating away from the camera. And I do notice like I was saying, geometry being mistaken from texture alone (without the geometry of that area). In TG this is bad because it's hard to conform textures to geometry, and often textures are flat relatives to the object (similar to rock in this thread with random PF) where it completely hides surface geometry.
Title: Re: Photogrammetry
Post by: aknight0 on April 05, 2021, 05:20:32 PM
I did a lot of work with Terragen and photogrammetry a few years back.  It sort of works.  What we were doing was importing objects, rendering images of them, and then trying to reconstruct the object with photogrammetry.  Then you can use the original object as an easy baseline to compare against.  We were testing photogrammetry software and image planning, so we were more interested in relative accuracy, but we weren't ever able to create any models that looked as good as the originals.  

The structure-from-motion algorithm that most photogrammetry software use works by matching points in the images.  If it can identify the same point on the surface in several images, from different angles it can calculate the 3D position.  To make that easier, we'd often apply a high frequency power fractal over the surface to give more easily identifiable points to match.  That helped with getting better geometry in the end result, but won't help if texture is your end goal.  

The hard part of photogrammetry is usually calculating the camera positions and surface geometry, most software computes a texture map as a final step.  Since Terragen can export a mesh, and the camera positions and parameters are known, it might be worth checking to see if any of the software will let you import the mesh and camera positions, and jump straight to the last step of computing the texture map.
Title: Re: Photogrammetry
Post by: aknight0 on April 05, 2021, 05:27:12 PM
Sounds like there are possibilities with the tools usually used for baking textures on retopologized meshes.

https://www.3dflow.net/forums/forum/3df-zephyr-forum-english/3327-3df-zephyr-lite-import-retopologized-mesh-to-texture

https://www.agisoft.com/forum/index.php?topic=5567.0
Title: Re: Photogrammetry
Post by: Kadri on April 06, 2021, 03:33:45 PM
Quote from: aknight0 on April 05, 2021, 05:20:32 PMI did a lot of work with Terragen and photogrammetry a few years back.  It sort of works.  What we were doing was importing objects, rendering images of them, and then trying to reconstruct the object with photogrammetry.  Then you can use the original object as an easy baseline to compare against.  We were testing photogrammetry software and image planning, so we were more interested in relative accuracy, but we weren't ever able to create any models that looked as good as the originals. 

The structure-from-motion algorithm that most photogrammetry software use works by matching points in the images.  If it can identify the same point on the surface in several images, from different angles it can calculate the 3D position.  To make that easier, we'd often apply a high frequency power fractal over the surface to give more easily identifiable points to match.  That helped with getting better geometry in the end result, but won't help if texture is your end goal. 

The hard part of photogrammetry is usually calculating the camera positions and surface geometry, most software computes a texture map as a final step.  Since Terragen can export a mesh, and the camera positions and parameters are known, it might be worth checking to see if any of the software will let you import the mesh and camera positions, and jump straight to the last step of computing the texture map.

Thank you.

You next post is something good to know when needed.