Page 1 of 2 12 LastLast
Results 1 to 10 of 20
  1. #1
    Join Date
    Feb 2004
    Location
    United Kingdom (South)
    Posts
    991

    Can Terrain work with Diamond shaped patches?

    I was trying to find a way to get more involved in coding a version of the Terrain R&D so that it wasn't just a carbon copy. I thought it would be nice if the hexagonal grid wasn't disrupted by having a square patch. I also liked the simplicity of having the same number of vertices in each row offered by the simple squares with diagonals through the middle.

    Stretching the positioning of the squares with diagonals gives you a grid of equilateral triangles which forms a diamond shape (think Repton diamonds). So I set about adapting the code after each section of the video to use diamond shaped patches.

    If anything putting the code in for this was simpler than for the approach that Lee took as you don't have to cater for rows with different numbers of vertices. This approach will probably lead to some unforeseen issues as I get into the second set of R&D videos but I'm going to work with it for as long as I can keep it working.

    I've reached the end of the first part of the R&D now and have groups of patches working which gives the result shown in the image.

    Click image for larger version. 

Name:	Diamonds2.png 
Views:	163 
Size:	1,006.0 KB 
ID:	71461

    Ok I need to stop work on this now as I need the TPController done before I can continue Still no problems up to that point and having a character to run around in the scene will be useful.
    Last edited by Avace; 03-12-2011 at 08:29 PM. Reason: update post rather than double post / bump :)

  2. #2
    Join Date
    Dec 2002
    Location
    Virginia Beach, VA
    Posts
    861
    Nice work on getting your version up to this point. There is no right or wrong way of approaching your patch layout just what is best for your needs. The only issue that I see with the approach you are taking won't be readily obvious until you start displacing your mesh. It not something that is impossible to overcome but you will have to be careful how much of an elevation change you allow along a line of vertices. What you'll find is that if you push it too far you will get a very noticable saw tooth pattern along the bottom and tops of a cliff faces. It isn't impossible to over come but I wanted you to be aware of it. That was the deciding factor for going with the hexagon pattern in the terrain R&D. While hexagons do not completely eliminate the problem it does allow for a much greater displacement before it becomes noticeable.

    Definitely looking forward to seeing more screenshots once you get height displacement working to see how the slanted patches look. They look like they will help with the saw tooth problem but I'm curious to see how much.

  3. #3
    Join Date
    Jan 2010
    Location
    Buenos Aires, Argentina
    Posts
    148
    maybe it's easier for you to build hexagonal patches... and build a beehive structure...

  4. #4
    Join Date
    Feb 2004
    Location
    United Kingdom (South)
    Posts
    991
    xavierk..... First reaction - no. It seems more complicated for little tangible gain but it has got me thinking about the similarities between generating hexagons and my approach. That lead me to a better way to deal with texture mapping in my approach which I'll have to address now. I read your post just as I was waking up and thinking I wanted to go back to sleep! My brain jumped into thinking about hexagons versus diamonds and took me off on lots of tangents which I'll cover in a new post here. I was forced to get up and get them all on paper while they were fresh in my mind.

    Having seen in my mind how similar my approach and hexagons could be I'll continue on with the diamond approach after putting up that initial exploration for everyone. I don't want to get sidetracked too much from progressing with the diamond shaped patches and not see an idea through to it's conclusion as a result.

    On balance any negativity expressed above has been offset by positive thoughts brought about by you causing me to actually think then do rather than do for a change. The uv mapping side of things is an especially nice bonus as I wasn't happy with the texture stretching caused by the mapping I already had in place.

    Quote Originally Posted by chronos78 View Post
    What you'll find is that if you push it too far you will get a very noticable saw tooth pattern along the bottom and tops of a cliff faces. It isn't impossible to over come but I wanted you to be aware of it. That was the deciding factor for going with the hexagon pattern in the terrain R&D. While hexagons do not completely eliminate the problem it does allow for a much greater displacement before it becomes noticeable.

    Definitely looking forward to seeing more screenshots once you get height displacement working to see how the slanted patches look. They look like they will help with the saw tooth problem but I'm curious to see how much.
    With the approach as it stands so far the mesh is slightly closer to the true shape of a hexagon than in your implementation but you have the advantage of consistent units in x and z. I'm scaling the z component by 0.866025 to approximate equal triangle side length for equilateral triangles. It remains to be seen if something slightly closer to a hexagon in shape provides any visual benefit but I'm excited to see how it turns out.

    You've made me realise another problem with my approach. I'm actually squeezing the texture in z with my current mapping. I'll have to come up with a solution to that as well at some point. That willl mean that different patches may have to have different offsets in UV space. Without attacking that issue I can't tell whether Unity will have any issues in that respect as it really depends on how it will handle the wrapping.

    I'm thinking vertical displacement by sine waves in x and z might help me to get an idea of exactly how well each approach holds up under various levels of height displacement. Testing on a large patch created with each method should provide enough geometry to see the effect.
    Last edited by Avace; 03-13-2011 at 05:48 AM. Reason: Extra note about uv mapping and response.

  5. #5
    Join Date
    Feb 2004
    Location
    United Kingdom (South)
    Posts
    991
    Ok so I've got a couple of drawings to show how I plan the texture to work and how a hexagonal layout would be somewhat similar to what I'm already doing.


    The image above shows how I plan to have the UVs laid out across uv space. It also shows a problem I have which is that the triangles I am creating are 0.866025 units in z and 1 unit in x. If I can offset to values greater than 1 in UV space and have the texture wrapped then this approach will work.

    The image below shows that if you arranged three of the patches above together you would have a hexagon shape. You might have to have six methods for patch creation rather than four - top, top left, top right, bottom left, bottom right and bottom. Then you'd need to make sure you're offsetting correctly in each direction and decide how to handle tiling. You should be able to see that by tiling both of these you end up with an identical pattern in the mesh. So assuming it was coded correctly adding height to either of these should give the same results.


    I'm off to take a quick break after which I'll begin working through the Third Party Camera system videos so that I can continue working on the diamond approach.
    Attached Thumbnails Attached Thumbnails Click image for larger version. 

Name:	Layout_Illustration_2.png 
Views:	149 
Size:	113.2 KB 
ID:	71492   Click image for larger version. 

Name:	Layout_Illustration2_2.png 
Views:	151 
Size:	122.1 KB 
ID:	71493  
    Last edited by Avace; 03-21-2011 at 03:40 PM. Reason: shrink images to reduce thread length

  6. #6
    Join Date
    Sep 2010
    Location
    New York
    Posts
    57
    I'm glad this trail pop up. How about this pattern ? Get rid of those giant seams. Though I cannot say if the idea will work

    Last edited by tomo; 03-18-2011 at 04:33 PM. Reason: gave anchor instead of showing image

  7. #7
    Join Date
    Feb 2004
    Location
    United Kingdom (South)
    Posts
    991
    I can't say whether that will work either but I'll have more of an idea when I get back to watching the R&D videos. Time to go through some more 3rd party controller content for the moment As for the giant seams.. I think the seams on the suggestion above have exactly the same length as the seams in the diamond patch style. It should be possible to create this style of patch with a few changes to the diamond code by replacing the iteration counter that determines the offset of each row of vertices with an offset that alternates between 0 and 0.5. Hmm.. in fact the center of each patch will not coincide with a vertex position. That's not necessarily a problem as it can certainly be calculated as:

    (SpacingX * (Number of Vertices in Width - 0.5) / 2) in x and
    (SpacingZ * (Number of Vertices in Height -1) / 2) in z

    Thinking about it the above is not that much different to calculation of the center for a diamond shaped patch.

    The loop to generate the triangles would also need to change from the one I'm using for the diamond. The number of vertices in each row is the same but the offset will mean that the triangles in every 2nd strip will have to be drawn between different vertices. The image below illustrates what you'd end up with if you altered the offset in my code without changing the triangle drawing.

    Attached Thumbnails Attached Thumbnails Click image for larger version. 

Name:	Example_Existing_Order.jpg 
Views:	163 
Size:	623.8 KB 
ID:	71489  
    Last edited by Avace; 03-18-2011 at 09:53 PM. Reason: I think this just timed out before posting and marked it as edited!

  8. #8
    Join Date
    Sep 2010
    Location
    New York
    Posts
    57
    Just to clarify for anyone else reading - In my idea I just shifted the half triangles from one side to combine as full triangles on the other. I believe the seam is shown because there is a giant line cutting all triangles down the middle where any two patches are put together side by side. I no longer have time to revisit this.

  9. #9
    Join Date
    Oct 2009
    Posts
    123
    Tomo: That jagged-edged patch is exactly my implementation so far, I'm going through the earlier videos a second time and experimenting a bit. I haven't yet encountered any problems, but I haven't started any terrain sculpting so I have a little concern that the UV wrapping in the u (left to right) direction might end up with sculpting across patch edges wrapping inappropriately but I'll look into that when I get there. If this course has taught me anything, it is that nothing is impossible. It might not be worth the time to implement, but it isn't impossible!
    ( ! ) Assets/_Scripts/TP_Camera.cs(50,35): BCE0000: WTF?

  10. #10
    Join Date
    Sep 2010
    Location
    New York
    Posts
    57
    Quote Originally Posted by D.M.J. View Post
    Tomo: That jagged-edged patch is exactly my implementation so far, I'm going through the earlier videos a second time and experimenting a bit. I haven't yet encountered any problems, but I haven't started any terrain sculpting so I have a little concern that the UV wrapping in the u (left to right) direction might end up with sculpting across patch edges wrapping inappropriately but I'll look into that when I get there. If this course has taught me anything, it is that nothing is impossible. It might not be worth the time to implement, but it isn't impossible!
    Nice ! So it's working. You should post a screen shot of the terrain in your scene with 'tex-wire' ticked. I don't think the UV wrapping will be much of problem as whatever the next set of videos cover "sculpting wise" must address stitching I would imagine.

Page 1 of 2 12 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
  •