Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 12 Next capture
2021 2022 2023
1 capture
12 Jun 22 - 12 Jun 22
sparklines
Close Help
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
  • Asset Store
  • Get Unity

UNITY ACCOUNT

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account
  • Blog
  • Forums
  • Answers
  • Evangelists
  • User Groups
  • Beta Program
  • Advisory Panel

Navigation

  • Home
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
    • Blog
    • Forums
    • Answers
    • Evangelists
    • User Groups
    • Beta Program
    • Advisory Panel

Unity account

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account

Language

  • Chinese
  • Spanish
  • Japanese
  • Korean
  • Portuguese
  • Ask a question
  • Spaces
    • Default
    • Help Room
    • META
    • Moderators
    • Topics
    • Questions
    • Users
    • Badges
  • Home /
  • Help Room /
avatar image
0
Question by Apahdos · May 02, 2020 at 11:49 AM · lightingshadowsprocedural meshperlin noiseterrain generation

Terrain from perlin noise grid pattern in shadows

Hi there!

I want to generate terrain and therefore created a Noise class, which returns me a noise-value based on Perlin-Noise. I've created a class Octave which (sort of) just represent the input for the Noise-Generator: (EDIT: While asking this question I noticed that it should not be the Generation of the noise values but something else. I still appended the code for generation just in case I miss a point)

     using System.Collections;
     using System.Collections.Generic;
     using UnityEngine;
     using WorldGenerator;
     
     public class Octave {
         public Vector2 offset;
         public Vector2 scale;
         public Vector2 frequency;
         public float amplitude;
         public float influence;
         
         public Octave(WorldGenerator.Random random, Vector2 scale, Vector2 frequency, float amplitude, float influence) {
             this.offset = new Vector2(random.nextXInRange(-100000, 100000), random.nextYInRange(-100000, 100000));
             this.scale = scale;
             this.frequency = frequency;
             this.amplitude = amplitude;
             this.influence = influence;
         }
     }
             
     
     public static class Noise
     {
         public static float GenerateNoise(float x, float y, Octave[] octaves) {
             float noiseValue = 0.0f;
             for(int i = 0; i < octaves.Length; i++) {
                 noiseValue += GenerateNoise(x, y, octaves[i]);
             }
             return noiseValue;
         }
         
         public static float GenerateNoise(float x, float y, Octave octave) {
             Vector2 samplePos = new Vector2(x / octave.scale.x * octave.frequency.x, y / octave.scale.y * octave.frequency.y);
             float perlinValue = (Mathf.PerlinNoise(samplePos.x + octave.offset.x, samplePos.y + octave.offset.y) * 2.0f) - 1;
             return (perlinValue * (octave.amplitude * octave.influence));
         }
     }

Now in my world generation script I do The following: In the start function: this.surfaceOctave = new Octave(this.random, new Vector2(this.scale, this.scale), new Vector2(this.noise, this.noise), worldHeight, 1.0f);

and my world has the function:

 public float GetHeightAt(Vector2 pos) {
         
         return Noise.GenerateNoise(pos.x, pos.y, this.surfaceOctave);
 
 }

but when using that function when generating my mesh with the vertices: this.vertices[count] = new Vector3(pos.x, pos.y, World.instance.GetHeightAt(new Vector2(transform.position.x + pos.x, transform.position.y + pos.y)));

I get a strange behaviour...The shadows of my terrain throw in a grid like pattern: terrain

but while making the pictures for this question I noticed that the values of the height should be fine:

terrain-wireframe

As you see there are no jumps in height...I first thought there were when having higher scale values. But that might have happened because of the float precision.

Now my question is. This seems to be due to shadowing...Is there a way to fix this? And if it is not the shadowing. What could it be?

pustekuchen.png (224.0 kB)
eierkuchen.png (272.7 kB)
Comment
Add comment
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users

1 Reply

· Add your reply
  • Sort: 
avatar image
0

Answer by streeetwalker · May 02, 2020 at 01:07 PM

seems more of a shader - shadow bias issue. I doubt you'll even notice this if drop a texture on it. How far zoomed are the images you show?

Comment
Add comment · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users

Your answer

Hint: You can notify a user about this post by typing @username

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this Question

Answers Answers and Comments

242 People are following this question.

avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

Procedural mesh shader problem 0 Answers

Lights and shadows flickering extremely 1 Answer

Realtime shadows pass through gameobjects 2 Answers

What are my shadows doing? 0 Answers

Orthographic camera realtime shadows problem 1 Answer


Enterprise
Social Q&A

Social
Subscribe on YouTube social-youtube Follow on LinkedIn social-linkedin Follow on Twitter social-twitter Follow on Facebook social-facebook Follow on Instagram social-instagram

Footer

  • Purchase
    • Products
    • Subscription
    • Asset Store
    • Unity Gear
    • Resellers
  • Education
    • Students
    • Educators
    • Certification
    • Learn
    • Center of Excellence
  • Download
    • Unity
    • Beta Program
  • Unity Labs
    • Labs
    • Publications
  • Resources
    • Learn platform
    • Community
    • Documentation
    • Unity QA
    • FAQ
    • Services Status
    • Connect
  • About Unity
    • About Us
    • Blog
    • Events
    • Careers
    • Contact
    • Press
    • Partners
    • Affiliates
    • Security
Copyright © 2020 Unity Technologies
  • Legal
  • Privacy Policy
  • Cookies
  • Do Not Sell My Personal Information
  • Cookies Settings
"Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S. and elsewhere (more info here). Other names or brands are trademarks of their respective owners.
  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges