3D NoiseTexture for VisualShader
Asked Answered
L

13

0

Hey all,

I've been learning Godot to create a procedural planet generator. I've been playing around with different approaches including writing GLSL shader code, building an ArrayMesh, etc.

While I've had success with other approaches, the Visual Shader seems like the cleanest and most efficient approach for me. Unfortunately, I've run into a snag since it looks like I can't generate 3D Simplex noise via the Visual Shader interface. Is this a current limitation? Are there plans to add this? 2D Simplex noise doesn't work for the planet since it is causing pinching at the poles.

Thanks in advance!

Ladyship answered 17/7, 2020 at 6:57 Comment(0)
A
0

You are correct that 3D noise is not part of the visual shader by default, but nothing's stopping from either coding the function yourself, or use a function already built in a plugin.

Ahouh answered 17/7, 2020 at 11:50 Comment(0)
A
0

This one includes a variety of noise functions you could use. https://github.com/arkology/ShaderV

Ahouh answered 17/7, 2020 at 12:20 Comment(0)
L
0

Wow! That is very helpful! Played around with it this morning and still getting some pinching issues at the poles but I'm guessing that's just a mapping problem on my part. At any rate this gives me a good idea how to create my own VisualShader nodes. Thanks!

Ladyship answered 17/7, 2020 at 17:7 Comment(0)
S
0

if you construct yourself a base sphere out of a subdivided cube in a 3D DCC such as blender you'll be able to have a better mapping on it. A UV Sphere isn't great for this, yeah.

Stinnett answered 17/7, 2020 at 18:3 Comment(0)
A
0

To sample the 3D noise properly, don't use the UV coordinates, but the model vertex coordinates as sample points. If use world space vertex coordinates, then the noise won't move with the planet (rotating, scaling, translating).

Ahouh answered 17/7, 2020 at 19:43 Comment(0)
S
0

Yeah, that's a bit more complex but also more powerful/flexible way to go.

Stinnett answered 17/7, 2020 at 20:5 Comment(0)
L
0

@Megalomaniak said: if you construct yourself a base sphere out of a subdivided cube in a 3D DCC such as blender you'll be able to have a better mapping on it. A UV Sphere isn't great for this, yeah.

Never would have thought of that. Thanks!

Ladyship answered 17/7, 2020 at 20:21 Comment(0)
L
0

@SIsilicon28 said: To sample the 3D noise properly, don't use the UV coordinates, but the model vertex coordinates as sample points. If use world space vertex coordinates, then the noise won't move with the planet (rotating, scaling, translating).

I tried multiplying the vertex input by the world transform but it was still behaving as if the vertices were defined in model space. (Also I recognize I should be using 3D noise here but this is a minimum example).

FYI I'm using the built-in SphereMesh and not the imported mesh from Blender.

Ladyship answered 18/7, 2020 at 0:41 Comment(0)
A
0

If you try moving the sphere with that setup, you'll see what I mean.

Ahouh answered 18/7, 2020 at 1:32 Comment(0)
L
0

Sorry I wasn't clear. With the above config, the texture is still behaving as if it is relative to the model space, i.e. when I move the camera the same part of the texture is always facing me.

Ladyship answered 18/7, 2020 at 4:57 Comment(0)
L
1

Figured it out! After a bit of reading, vertices in fragment shader are in VIEW space. Camera is VIEW->WORLD matrix. Further multiply by INV(WORLD) got the vertices in MODEL space.

I also needed to do some extra work with the noise shaders in the ShaderV package. I noticed even with correct verts I was getting some strange texture stretching in the Z-axis. After investigation into the shader code, I noticed that even though it states 3D noise, it only uses the .xy coordinates of the input vector. Changing that to .xyz gave the desired effect.

Thanks everyone for the pointers!

Ladyship answered 18/7, 2020 at 6:28 Comment(0)
L
0

Also one more follow-up, just discovered the TextureUniformTriplanar node. Didn't even know what triplanar mapping was but turns out to be exactly what I needed. Using a texture to generate the height map to generate the terrain instead of a 3D noise plugin has the added benefit of using the built-in normal map functionality Godot provides.

Ladyship answered 18/7, 2020 at 7:9 Comment(0)
R
0

Ladyship pls help me, im newbie and i dont know where and how can i change it from .xy coordinates to .xyz?

Reba answered 22/10, 2023 at 13:20 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.