- Home /
My script height function doesn't show the same height as the shader
Hello there,
After I asked my previous question I started to figure out how a perlin function worked and was able to implement this into a shader, however I now have a problem, because my script that should display the same height as the terrain seems... shifted. So I converted my function from the shader to c# again, but despite having precisely the same function it's still wrong. I also checked if the vertex changed by the unity_ObjectToWorld matrix and transform.position are both world coordinates and they seem to be the same.
Can anyone of you help me?
If you need to see the shader and the c# script you can find them on this github repository:
My scripts on github
If you want to test the shader you first do need either just a plane (for a 10 x 10 resolution) or a 3d model plane width any other resolution (and make sure every face is 1 x 1 in unity units) If if you've done so then you can move the plane around and view the terrain
Answer by Koen124 · Jan 21 at 04:33 PM
Oké, I found the problem!
I used a sine function for a random value at a coordinate, but aparently this isn't very precise with large numbers (wich I used)
So I'm know writing a new randomise function where I use a sort of sine wave (but linear) instead of the actual sine function and it now mostly works.
Only the randomness in the texture shows some repeating, but that's not so hard to fix
Your answer
Follow this Question
Related Questions
Perlin Noise not working properly when using offset 0 Answers
Displace y position with image 0 Answers
Perlin Noise to Texture in Shader 0 Answers
Setting unitys new shader graphs properties via C# 2 Answers
How to force the compilation of a shader in Unity? 5 Answers