keijiro / NoiseBall

Mesh deforming shader example (Unity)
298 stars 42 forks source link

Weird spiky points on the nadir of the Noiseball #1

Open diederikveelo opened 7 years ago

diederikveelo commented 7 years ago

Hi Keijiro,

I was playing around with your Noiseball implementation and am running into an issue with what seems to be an artifact of the noise implementation. It's the pointy spikes at the top and bottom of the sphere. If you have ideas on how to get rid of them, or use a diffetent noise implementation I would love to hear it.

Thanks in advance! By the way, I love the crazy shit you put on here!!

keijiro commented 7 years ago

Hmm. Could you give me an example of that? Screenshots would be helpful.

diederikveelo commented 7 years ago

Hi Keijiro, Screenshots are below, with an animated gif to show you what I mean. I should note that I have subdivided the NoiseBall with 5 levels. I assume the spikes are hardly visible when using a low poly mesh. Would be great if you can point me into a direction how to solve this. It looks like the vertices are rotated around each other or something. Thanks!

noiseball_spikes noiseball_spikes

noiseball_unity_ui
diederikveelo commented 7 years ago

Hi @keijiro, did you had some time to look at the above? I wonder if there is a way to work around the spikes... Thanks!

keijiro commented 7 years ago

Actually I have no idea with it but guess that the tangent equation is not good for making smooth surface.

https://github.com/keijiro/NoiseBall/blob/master/Assets/NoiseBall/Shader/Common.cginc#L10

I designed this function just for hard surfaces so it might not suit for smooth surface. Unfortunately I have no time for redesign it at the moment.

diederikveelo commented 7 years ago

Thanks @keijiro, I'll try to work around it. Thanks for looking into it!

diederikveelo commented 7 years ago

For those that are interested, I managed to flatten out the spikes by adjusting line 10 of NoiseBall/Assets/NoiseBall/Shader/Common.cginc#L10:

from:

    float3 q = normalize(cross(p, float3(0, 1, 0)) + float3(0, 1e-5, 0));

to:

    float3 q = normalize(cross(p, float3(0, 1, 0)) + float3(1e-15, 0, 1e-15));

This makes sure the surface stays more or less flat instead of pointing in- or outwards. For my use case that was enough.