Planetside Software Forums

General => Terragen Discussion => Topic started by: reck on April 20, 2008, 10:30:08 AM

Title: Adding small displacement to imported object
Post by: reck on April 20, 2008, 10:30:08 AM
I'm trying to add small scale displacement to an object that i've imported. I don't want it applied to the whole object only part of it. So i've gone into the objects network and found the default shader for the part of the object that I want displaced and added a power fractal shader between the default shader and the multishader. The problem I get is that once I add the power fractal the part of the object thats controlled by that default shader just balloons up and grows instead of just displacing small parts of it. I thought maybe I should be plugging the power factal into the default shaders displacement function field but that didn't seem to do anything.
Title: Re: Adding small displacement to imported object
Post by: Mandrake on April 20, 2008, 11:45:15 AM
When you right click on the obj. and enter internal network you can go to any of the 16 available materials in your model and displace them. double click the material and go to displacement tab. you can add the displacement function (power fractal) from there.
Title: Re: Adding small displacement to imported object
Post by: Mandrake on April 20, 2008, 12:37:38 PM
I made a simple text obj with two materials. I displaced the black edge with a power fractal.
I had to make sure. ;)
Title: Re: Adding small displacement to imported object
Post by: reck on April 20, 2008, 01:22:11 PM
I can't get it to work Mandrake.

This is the object with no displacement.

http://img178.imageshack.us/img178/4766/nodisplacelm6.jpg

When I add a power fractal the object turns black like this.

http://img517.imageshack.us/img517/8089/displacell2.jpg

The settings for the power fractal were:

feature scale: 0.5
Lead in scale: 0.5
Smallest scale: 0.1

Displacement amplitute: 0.5

This is the node setup for this object.

http://img517.imageshack.us/img517/125/nodeshn1.jpg

If I turn apply high colour off it gets rid of the black but I don't get any displacement even if I put in 8 for displacement and feature scale.

Title: Re: Adding small displacement to imported object
Post by: old_blaggard on April 20, 2008, 01:31:28 PM
Ooh, you probably don't want displacement amplitude to be that high - try reducing it to 0.05 and see what happens.
Title: Re: Adding small displacement to imported object
Post by: Mandrake on April 20, 2008, 01:55:31 PM
Does your internal network looks something like this, only with numbers for displacement.
Title: Re: Adding small displacement to imported object
Post by: reck on April 20, 2008, 01:58:07 PM
I've just tried again with these settings but it still isn't working.

feature scale: 0.05
lead-in scale: 0.05
smallest scale: 0.01

displacement amplitude: 0.05
Title: Re: Adding small displacement to imported object
Post by: reck on April 20, 2008, 02:04:28 PM
Quote from: Mandrake on April 20, 2008, 01:55:31 PM
Does your internal network looks something like this, only with numbers for displacement.


I just checked and displacement multiplier was set to 0.01, so I changed it to 0 and it's now it's stopped rendering in black. The problem is that i'm not getting any effect at on the object when I alter the values, it seems no matter what settings I use nothing is changing each time I render.
Title: Re: Adding small displacement to imported object
Post by: Mandrake on April 20, 2008, 02:27:19 PM
Your not using the displacement settings in the power fractal are you? Don't, use the ones in the mat. See above
Title: Re: Adding small displacement to imported object
Post by: reck on April 20, 2008, 02:39:37 PM
Quote from: Mandrake on April 20, 2008, 02:27:19 PM
Your not using the displacement settings in the power fractal are you? Don't, use the ones in the mat. See above

I was experiementing with both. I've now turned off the "apply displacement" option in the power fractal so i'm just using the setting in the default shader now. As soon as I enter a figure greater than 0 in displacement multiplier I get the black back.

This is with displacement set to 0.05

Title: Re: Adding small displacement to imported object
Post by: Mandrake on April 20, 2008, 02:44:46 PM
What's the scale of your obj? If it's real small, displacement is going to be problematic.  .00002
Title: Re: Adding small displacement to imported object
Post by: reck on April 20, 2008, 03:01:28 PM
I've just made it a 100 times bigger but its made no difference.

This is with displacement set to 0.0002, looks like something strange with it.
Title: Re: Adding small displacement to imported object
Post by: Mandrake on April 20, 2008, 03:04:31 PM
Can ya email me that Hershey's Kiss?
Title: Re: Adding small displacement to imported object
Post by: reck on April 20, 2008, 03:20:17 PM
I've uploaded the file and object.

http://www.mediafire.com/?j2jgwtrnmod

It's part of a windmill.

Title: Re: Adding small displacement to imported object
Post by: Mandrake on April 20, 2008, 03:23:08 PM
I'm giving it a look
Title: Re: Adding small displacement to imported object
Post by: Mandrake on April 20, 2008, 04:21:03 PM
Think I figured it out, be back in a few
Title: Re: Adding small displacement to imported object
Post by: reck on April 20, 2008, 04:28:32 PM
 :)
Title: Re: Adding small displacement to imported object
Post by: Mandrake on April 20, 2008, 04:34:25 PM
I ended up with compute normal pluged into the input of the power fractal and displaced along lateral lines, withy all sorts of tweaked setting, but the whole dang time I think it was because you didn't have Plan Y selected under images. (I think)

So do Plan Y first then start all over with the dissplacement
Title: Re: Adding small displacement to imported object
Post by: Ogre on April 21, 2008, 12:15:56 PM
Also check the direction of the normals on your model. I had a similar experience and the normals on my model were flipped pointing to the interior of the model.
Title: Re: Adding small displacement to imported object
Post by: reck on April 21, 2008, 03:33:49 PM
Mandrake, thanks for taking a look. I don't think the plan Y setting should have any effect though, that's for when your using images on your object right? This object just uses colour, no images. I did change it to plan y anyway but it didn't help and neither did the compute normal unfortunately.

Ogre i've just gone back and checked the normals and the are pointing outwards.

I've attached an image to show what i'm trying to achieve, this took about 2 minutes and was created with the sphere object in tg. So if it works ok on the sphere why can't I do this on my object?
Title: Re: Adding small displacement to imported object
Post by: Mandrake on April 21, 2008, 04:39:53 PM
Yep, I knew that was what you were looking for but every time I'd get close, the polys would disappear. hehe
I don't know why I can't get it to cooperate.
Title: Re: Adding small displacement to imported object
Post by: Mohawk20 on April 21, 2008, 05:26:05 PM
I'm playing with your object as well, and the first thing I'm trying is to get the displacement you want shown in colour only, so I replugged the powerfractal from displacement into colour and made the high colour red and the low colour blue.

When using pretty large scales for a terrain, I only get a purple colour. No red or blue specles, just pure purple.

When scaling down the fractal, I got more colour variation.

I got some reasonable effects when setting the scales really low!!
Here are some picts to show:
Title: Re: Adding small displacement to imported object
Post by: j meyer on April 21, 2008, 05:26:49 PM
Took a quick look at your model in wings3d and there is definitely
something wrong with your normals.
Title: Re: Adding small displacement to imported object
Post by: Mohawk20 on April 21, 2008, 05:55:19 PM
Having played with this some more, I set the displacement the same as the scale, and plugging the powerfractal back into the displacement input, I had some trouble. Changed the displacement multiplyer in the default shader from 0.5 to 0.1 got me the following result: (see image below).

So I think there might be a problem in the object itself, maybe it has to few polygons to actually displace it properly. At least, that would be the problem in any 3D app like 3DsMax...
From other treads I gather the terrain is VERY high poly.

So I guess you'll have to try how displacement maps act...
Title: Re: Adding small displacement to imported object
Post by: reck on April 21, 2008, 06:22:27 PM
So if the problem is with my object any idea how I can fix it? Should I forget about tg and try and get this displacement working in Blender? When I did that displacement on the sphere I thought it looked quite good so I was hoping it would look the same on my model.

I've turned on "show normals" in blender and it appears as though all the normals are pointing outwards.

Title: Re: Adding small displacement to imported object
Post by: Mohawk20 on April 21, 2008, 06:23:55 PM
And if you increase the amount of polygons? Would that work?
Title: Re: Adding small displacement to imported object
Post by: reck on April 22, 2008, 04:06:23 AM
Mohawk, i'll try and find some time tonight (after the football  ;D) so increase the poly count of the modal and try again.
Title: Re: Adding small displacement to imported object
Post by: j meyer on April 22, 2008, 09:34:08 AM
Some screenshots,which show you that there is some normal problem.
Did you model this with blender?Anyway,couldn't fix it by flipping normals
in TG or some other easy way unfortunately.Maybe i look into this again,
but i can't promise.
Title: Re: Adding small displacement to imported object
Post by: Mohawk20 on April 22, 2008, 10:45:58 AM
I'll open it up in 3DsMax and see what I can do...
Title: Re: Adding small displacement to imported object
Post by: Ogre on April 22, 2008, 12:43:27 PM
According to Maya the Normals on most of the object were flipped. I fixed and attached.

Quote from: Mohawk20 on April 22, 2008, 10:45:58 AM
I'll open it up in 3DsMax and see what I can do...

Sorry but I could not let 3d max get a hold of it.... :P
Title: Re: Adding small displacement to imported object
Post by: Mohawk20 on April 22, 2008, 12:47:13 PM
Quote from: Ogre on April 22, 2008, 12:43:27 PM
According to Maya the Normals on most of the object were flipped. I fixed and attached.
Sorry but I could not let 3d max get a hold of it.... :P

Ohw well, you beat me to it anyways... good job, hope it helps... I'll play with it as soon as I get home in about 3 hours!
Title: Re: Adding small displacement to imported object
Post by: Ogre on April 22, 2008, 12:49:33 PM
Reck

Here is a screen capture of the model before and after. I am not sure what your program is showing or what may have changed on export.
Title: Re: Adding small displacement to imported object
Post by: Matt on April 22, 2008, 03:32:07 PM
With imported objects Terragen does not account for displacement when calculating shadows (the shadow-casting object is not displaced, but the shadows are cast onto a displaced surface). This means that if any part of the object has negative displacement it will be plunged into shadow. Some of the renders I've seen in this thread look like that may be happening.

To test this, simply disable shadows in the renderer.

If that's the problem, there's an easy solution. You can prevent the negative displacement by increasing the displacement offset. If using the Default Shader to perform displacement, there's a displacement offset parameter. If you're using the Power Fractal's built-in displacement options then you can adjust the offset there. I would start with something like double whatever amplitude you have chosen.

Matt
Title: Re: Adding small displacement to imported object
Post by: Mohawk20 on April 22, 2008, 03:59:37 PM
Quote from: Matt on April 22, 2008, 03:32:07 PM
(the shadow-casting object is not displaced, but the shadows are cast onto a displaced surface)

I hope I misunderstand, because this sounds like imported objects cannot be displaced..?
Title: Re: Adding small displacement to imported object
Post by: Matt on April 22, 2008, 04:03:39 PM
You will see the displacement on the object and it will affect the shading. It's just that ray-traced shadows don't work 100% correctly. As long as your displacements are not too large and you use a displacement offset that's just large enough to fix the unwanted black parts, then it usually looks fairly good.

There can be some other side effects if displacements are large. The renderer may cut off parts of the object in extreme cases. But it works reasonably well.

Matt
Title: Re: Adding small displacement to imported object
Post by: Mohawk20 on April 22, 2008, 05:12:06 PM
Okay, thanks for clarifying.
One last question though... the settings must be extremely low for this to have a nice scale on the object. Why is that? Because of the object, because of flaws in the object, or because an external factor?

I can't seem to get it to work, and it's late on this side of the planet, so I leave it to you, Ogre and Reck, to figure it out in the mean time.
Title: Re: Adding small displacement to imported object
Post by: reck on April 22, 2008, 06:05:01 PM
j meyer, I went back and checked the normals again and I did find a handful of faces where the normals were flipped the wrong way. I think there were only 6 faces so it seems there is more to it then this. I used Blender to create the object and then ran it through poseray.


Ogre, I downloaded your fixed version, thanks, but there doesn't appear to be any improvement in the way the object renders in TG. As you can see in the previous screengrab I posted, Blender is showing the normals flipped the correct way so I can only assume either the export feature of Blender flipped them inwards or poseray did.
Title: Re: Adding small displacement to imported object
Post by: reck on April 22, 2008, 06:07:45 PM
Hmm I think Matt has identified the problem. As he suggested i've disabled the shadows and re-rendered and straight away it fixed the problem (apart from having no shadows).

Now that we know what the cause is I can take a look at Matt's "easy solution" involving the displacement offset.  ;D

Title: Re: Adding small displacement to imported object
Post by: reck on April 22, 2008, 06:22:28 PM
I'm not having much look getting the displacement offset to fix the problem. As soon as I turn shadows back on I just get a black image no matter what I set the offset to.

The displacement setting in the power fractal is turned off, i'm just using the displacement setting in the default shader. In the previous image I had the displacement multiplier set to 0.15. I started off setting the offset to 0.3, then 0.4,0.5,0.6 and then very small values such as 0.1, 0.05 and 0.002. In all cases I just get a black rendered object.
Title: Re: Adding small displacement to imported object
Post by: Matt on April 22, 2008, 06:48:14 PM
Can you try with a negative offset instead? Just in case the normals are wrong.

Alternatively, try enabling "flip normals" in the object reader.

Matt
Title: Re: Adding small displacement to imported object
Post by: DeathTwister on April 22, 2008, 11:40:48 PM
QuoteAccording to Maya the Normals on most of the object were flipped. I fixed and attached.

Quote from: Mohawk20 on April 22, 2008, 02:45:58 PM
I'll open it up in 3DsMax and see what I can do...

Sorry but I could not let 3d max get a hold of it.... Tongue

Chuckles.... been following this one, very interesting guys, be cool when it gets figured out. I see no Planetside Staff peeps either. Must mean ya'll walking virgin terratory here and they don't have a clue yet either, but I bet Oshyan is working on it /winks.

  If I can find the time I would like mess with this one as well, but not atm to busy, so good luck, I will follow this one,  Good thinking guys WTG.
Title: Re: Adding small displacement to imported object
Post by: sonshine777 on April 23, 2008, 01:11:18 AM
Quote from: DeathTwister on April 22, 2008, 11:40:48 PM
I see no Planetside Staff peeps either. Must mean ya'll walking virgin terratory here and they don't have a clue yet either, but I bet Oshyan is working on it /winks.

Matt has had three posts on this page alone, including the one just above yours. I think they have a clue and are on the job. ;D
Title: Re: Adding small displacement to imported object
Post by: j meyer on April 23, 2008, 10:25:45 AM
Managed to fix the normals in wings too and tested the model in
TG again and anything worked fine displacement included,but since
ogre had already posted his fixed version i deleted mine together
with the screenshots of the displaced model.The only peculiar thing
that occurred was that that scale values for the displacement had to be
smaller than expected.
Don't know what's going wrong for you.
If you want i can of course download it again and repeat the things
i did yesterday(no worry,can be done quickly) and post the results here.
Title: Re: Adding small displacement to imported object
Post by: Ogre on April 23, 2008, 10:27:05 AM
Reck - Regarding displacement and shadows. I tried something here http://forums.planetside.co.uk/index.php?topic=2097.msg20485#msg20485 using a color adjust shader that seemed to help.
Title: Re: Adding small displacement to imported object
Post by: reck on April 23, 2008, 02:27:21 PM
Thanks everyone for the help on this, it's finally working. In the end it was simple, well simple when someone who knows what they are doing tells you what to do. As Matt suggested I used negative offset and it worked first time. So the normals, for whatever reason, were pointing the wrong way.

Ogre, thanks for the link, i'll take a read.
Title: Re: Adding small displacement to imported object
Post by: Matt on April 23, 2008, 03:11:41 PM
Good to know that's what it was. If the normals are inverted then I would use flip normals on the object reader and then you can remove the displacement offset (or make it positive). This is a good idea because at the moment your displacement maps are all inverted.

Matt
Title: Re: Adding small displacement to imported object
Post by: Mandrake on April 26, 2008, 10:04:28 PM
Glad you got it sorted our reck, I'm glad it was not some slope type issue, that I feared..
Title: Re: Adding small displacement to imported object
Post by: reck on July 09, 2008, 04:40:28 PM
Hi, I've just created a new scene with this same object and I had to scale it up by a factor of 17. By scaling it up the displacment on the object has stopped working again, it comes out smooth. Presumably I need to scale something else up as well to get the displacments working again but i'm not sure what. I played around with a few sliders but nothing seems to work.
Title: Re: Adding small displacement to imported object
Post by: Mandrake on July 09, 2008, 05:09:14 PM
Pump the displacement up. Or the multiplier.
Title: Re: Adding small displacement to imported object
Post by: Tangled-Universe on July 09, 2008, 05:19:58 PM
Quote from: Mandrake on July 09, 2008, 05:09:14 PM
Pump the displacement up. Or the multiplier.

Indeed, it's pretty safe to try to increase the multiplier also by 17.
Title: Re: Adding small displacement to imported object
Post by: Matt on July 10, 2008, 02:16:03 PM
I would try this:

Quote from: Matt on April 23, 2008, 03:11:41 PM
If the normals are inverted then I would use flip normals on the object reader and then you can remove the displacement offset

Matt