Page 1 of 3 123 LastLast
Results 1 to 10 of 21
  1. #1
    Join Date
    Sep 2004
    Location
    USA
    Posts
    1,529

    Question Lee's Terrain R&D, Session 2, Pt. 17. problem.

    I am having a problem while following Lee's Terrain R&D, Session 2, Pt. 17. Everything seemed to be going good until I got to 12:24 in video time. At that point my terrain no longer looks like the one in the video. Where theirs is more flat and leveled, mine is still more jagged.

    Here is a picture of it;



    GetHeight looks just as they have it as far as I can tell. So does SampleMap for that matter.

    In TerrainPatch I have Size, Spacing and MaxHeight at the right numbers.

    And in CreatGrid I have removed Spacing after posX so that Spacing isn't applied twice.

    Is there anywhere else I should check?


    This is what I have for GetHeight;


    Code:
    var s1 = 0.1f;
                var s2 = 0.2f;
                var s3 = 0.5f;
                var s4 = 2f;
                var s5 = 14.1f;
    
                var w1 = 0.8f;
                var w2 = 0.75f;
                var w3 = 0.65f;
                var w4 = 0.75f;
    
                var h1 = SampleMap(x, z, s1, detailMap);
                var h2 = SampleMap(x, z, s2, detailMap);
                var h3 = SampleMap(x, z, s3, detailMap);
                var h4 = SampleMap(x, z, s4, detailMap);
                var h5 = SampleMap(x, z, s5, baseMap);
    
                var b1 = h1 * w1 + h2 * (1 - w1);
                var b2 = b1 * w2 + h3 * (1 - w2);
                var b3 = h2 * w3 + h4 * (1 - w3);
    
                var height = h5 * w4 + h3 * (1 - w4);
    
                height = Mathf.Pow(height * 2 - 1, 3) * maxHeight;
                
                if (height < 0)
                    height /= 2;
    
                return height;


    When I tried to keep going with the video I got something very different when I did the next terrain thing. I had all really high mountains.



    Click image for larger version. 

Name:	LT R&D S2 Pt 17 with problem.jpg 
Views:	149 
Size:	113.8 KB 
ID:	71566
    Last edited by Wolfknightly; 04-15-2011 at 12:23 AM. Reason: Forgot Picture

  2. #2
    Join Date
    Sep 2008
    Location
    Salisbury, UK
    Posts
    2,812
    Changing
    Code:
    var b3 = h2 * w3 + h4 * (1 - w3);
    to
    Code:
    var b3 = b2 * w3 + h4 * (1 - w3);
    should solve things...

    I found
    my current avatar on google, so props to THIS GUY who created the original...

  3. #3
    Join Date
    Sep 2004
    Location
    USA
    Posts
    1,529

    Question

    Thanks fatgav, but if that changed anything it was too small for me to be able to tell. I still have the same problem even after that change. And I have gone back and forth a bunch of times. I have refreshed in Unity and even shut it down and reopened it. So maybe it is something in the Sample Map.


    Code:
    var height = 0f;
                var mapWidth = map.width;
                var mapHeight = map.height;
                var halfMapWidth = mapWidth / 2;
                var halfMapHeight = mapHeight / 2;
    
                var scaledX = x * scale + halfMapWidth;
                var scaledZ = z * scale + halfMapHeight;
    
                var fX = Mathf.FloorToInt(scaledX);
                var fZ = Mathf.FloorToInt(scaledZ);
                var cX = Mathf.CeilToInt(scaledX);
                var cZ = Mathf.CeilToInt(scaledZ);
    
                var rX = scaledX - (int)scaledX;
                var rZ = scaledZ - (int)scaledZ;
    
                var h1 = map.GetPixel(fX, fZ).r;
                var h2 = map.GetPixel(cX, fZ).r;
                var h3 = map.GetPixel(fX, cZ).r;
                var h4 = map.GetPixel(cX, cZ).r;
    
                var b1 = Mathf.Lerp(h1, h2, rX);
                var b2 = Mathf.Lerp(h3, h4, rX);
                height = Mathf.Lerp(b1, b2, rZ);
    
                return height;

    I am using the Resources that Lee linked us, so that shouldn't be it. If the SampleMap is correct, then can anyone think of some other part in the code I might have messed up in? Thanks.

  4. #4
    Join Date
    Sep 2004
    Location
    USA
    Posts
    1,529
    Well, just to be clear here, I am completely stuck at this spot. I do not have the knowledge to work this out on my own. I will need help from others in order to precede with the class videos. I have been working on other things, like the RavenDB lessons while I wait for help. Perhaps I just need someone, that has finished this part already, to look over my code to see what is different in mine. It is kind of depressing being this stuck on something.

  5. #5
    Join Date
    Jan 2010
    Location
    Buenos Aires, Argentina
    Posts
    148
    I don't see anything wrong here. You have to consider that until the next session the uk map they use is different than the one on the resource files.

  6. #6
    Join Date
    Jun 2008
    Posts
    1,088
    It is easy to have a typo or missing something during this process. I had issues for awhile too that looked very similar but just keep going over everything or re-watch the video and you should be able to hunt it down. I definitely know how you feel. When I get home I will take a look and see if there is anything that jumps out.

    -Dane
    You know you want to!

  7. #7
    Join Date
    Sep 2004
    Location
    USA
    Posts
    1,529
    Thank you for responding to my post. It means a lot to me.


    Xavierk,

    It may be a little different but that doesn't explain my next results, surely. The two, what they have at that point and what I have at that point, are as different as night and day.

    Another thing to consider is that my results look just like what they had until the problem showed its self as seen it the first problem picture on the first post of this thread. So they must be pretty close in order to get such a close result.

    See for you self what the next result is. Look at what they have at 15:33 video time compared to what I have at that same point. It is quite clear to me that there is something very wrong with my code somewhere.




    Also, I am not the only one to have used their resource files, so surly everyone that did would have had this same problem.

    To me clear, I used the their altered version of the UK map only when they adjusted theirs in the videos. Before that I used the original version that they where using, that someone else linked us in that thread. So both before the switch and after everything was looking just like how it looked in the video, as far as I could tell, until the before mentioned point in the video.


    DaneCO20,

    I did try to hunt it down, by re-watching the videos, and I know what you mean, as I have definitely been able to do that in other video lessons, but one is a bit different for me. The more I go back, the more the code is different, because of all the changes in the code, there are things that are later removed altogether and others that of completely changed. That makes it near imposable for me to be able to see a small difference in their code from mine, because indeed it is very different. I can't say, “Oh, my code doesn't have that! I must be supposed to put that in my code.” because in a few videos that stuff will be completely removed. What is more, the stuff that seemed to me to be the only code that could be relevant it this issue, all looks correct.


    I am also pretty confused that the code that fatgav corrected for me didn't seem to change anything. Wouldn't you think it would look at least a little bit different after that fix?


    Click image for larger version. 

Name:	LT R&D S2 Pt 17 with problem pt2.jpg 
Views:	118 
Size:	48.6 KB 
ID:	71578

  8. #8
    Join Date
    Jan 2010
    Location
    Buenos Aires, Argentina
    Posts
    148
    I remember having that same result too. I remember that S shaped coastline or whatever that is. So or we both have the same issue or we are doing it right.

    Remember that a little variation on the heightmap then gets multiplied by the crazy high maxHeight value so you can get very different results.

  9. #9
    Join Date
    Sep 2004
    Location
    USA
    Posts
    1,529
    Hmmm. That is very interesting Xavierk. So you got the same results as I did, but instead of freaking out you just kept on going. That is very comforting to know that you got the same results that I did. So you kept going and didn't run into too much trouble with later videos? Did you end up getting yours to look like theirs as they adjusted their map?

    I think I will just make a copy of the current project and then continue from this point and see what happens.

    Thanks Xavierk.


    Yeah, that S shaped really stands out doesn't it. It actually looks pretty cool. It makes me think of a show on the History Channel, that is all about the worlds most dangers roads. It looks like the S could be just such a road.

  10. #10
    Join Date
    Dec 2006
    Posts
    163
    I had a very similar problem. I could find no differences in my code, it happened right after he adjusted the base greyscale of the height map. Even playing with it in photo shop I still got weird results. I just kept going. I lowered the height multiplier so I didnt get too crazy of a terrain, but when we got into the noise (or right before) they will switch some maps around and my terrain looked like Lee's again.

    Edit: I just looked through the videos they start using the new map in video 68 - R&D3-4 Create new world map in photoshop.

    I would just reccomend lowering your height multiplier and keep going because that screen shot looks just like mine did before vid 68.
    Last edited by Kevin2183; 04-21-2011 at 10:32 AM.

Page 1 of 3 123 LastLast

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •