Add functions to NME NodeBlock

Now, how would one add things to the shader outside the main function?

I see something about functions in the nodeMaterialBuildState.ts but am not sure how to leverage it.

Not sure to get the question :frowning:

So if I want to add a function that only get declared once outside the void main() scope if the node is included on the editor.

So for example on my SimplexPerlin3DBlock relies on a function

float SimplexPerlin3D( vec3 P ){
...
}

and the block itself calls that function but the way I am adding it now is through:
state.compilationString += ‘…’

which puts it in the main function scope of the shader.

Basically want the node to compile to:

...
float SimplexPerlin3D( vec3 P ){
     return 1.0;
}
void main(void) {
float output2 = SimplexPerlin3D(v_position);
gl_FragColor = vec4(u_Color, output2);
}

Not:

...

void main(void) {
float SimplexPerlin3D( vec3 P ){
     return 1.0;
}
float output2 = SimplexPerlin3D(v_position);
gl_FragColor = vec4(u_Color, output2);
}

I’ve tried looking at the other examples but some of that code is convoluted.

You have helper for that:

1 Like

Winner winner chicken dinner!

Now to create a gambit of noise nodes for us :slight_smile:

Please keep in mind that out of the box nodes must be general and useful in a lot of scenario

Custom nodes and specific nodes will be supported later with the custom node mechanism

so should noise functions come as a packaged node or should I wait for the custom nodes?

If the custom node will still let you define functions outside of the main scope then I can wait, if not then might as well do the basic Perlin2d-3d and Worley 2d-3d.

@Deltakosh

Should I or should I not do a PR for this block?

1 Like

I think it is a good candidate to be available out of the box
Pinging @PatrickRyan for a second thought

@Pryme8: Please make sure that there is no problem if I had the node multiple times

2 Likes

Looks golden to me, if we decide to make this out the box I will do the 2d version as well and worley.

I think we should leave FBM out for now as loops might be better for Custom Nodes

ooooooOOOOooooo I know how to create nodes now, Im about to go hard on some things that I know we need as I find the time here.

2 Likes

@Deltakosh and @Pryme8 I agree that this looks like a good candidate to be included in v1. I know that @PirateJC will be excited about noise nodes being added. I would definitely like to test this out before launch in case there are any edge cases here.

Ill do a PR right now so you can test what I am doing before I go to far down the road here.

OMG YES! I desperately want this!!!

@Pryme8 you rock!!!

1 Like

What other noise types yall think should be pumped out really quick?

I am looking at making the 2d and 3d ones packaged under the same node, but other types like an Advance Perlin or Worley Im going to do as separate ones.

Worley is also high on my wishlist. +1

On it ^_^.

1 Like

@PirateJC @PatrickRyan


2 Likes

Amazing!