NME Port Types - Sampler2D

So I am still trying to understand all of the things here with blocks.

How would I make a input/ouput be a sampler2d instead of a color value? I see we dont have that capability yet:

Is that coming in the next version, or is that something that needs to start being looked into?

Not sure why you would need it?

If we are talking about doing Custom Nodes and other things then it is needed. There are definitely times you want to reference the sampler and not just a color or a value when doing procedural stuff.

Plus as I am doing a Black and White to Normal Map Node. It takes sampling the texture 4 times which means I will need access to the Sampler2D or I would have to make 4 inputs for offset samples which is not ideal.

I was looking at what it would take to add it and my first impression is it would not be that hard.

I’m not convince this should be a block…

1 Like

The Black and White to Normal map is just a example.

Cause Im talking about Port input/output types not a node really with this post, I guess the title is misleading.

What about making on the Texture Node a output port that is Sampler2D and then just exposing Sampler2D as a valid port type is more what I am talking about.

Yes this is far better. I do not want to bloat the nme with 1000 blocks that are really niche

1 Like

So how would I go about adding a Sampler2D port type?

Do I just add it to the BlockConnectionTypes and then make sure the editor has all the css rules to display the port type?


 /** Float */
    Float = 1,
    /** Int */
    Int = 2,
    /** Vector2 */
    Vector2 = 4,
    /** Vector3 */
    Vector3 = 8,
    /** Vector4 */
    Vector4 = 16,
    /** Color3 */
    Color3 = 32,
    /** Color4 */
    Color4 = 64,
    /** Matrix */
    Matrix = 128,
    /** Detect type based on connection */
    AutoDetect = 1024,
    /** Output type that will be defined by input type */
    BasedOnInput = 2048

Where would Sampler2D fit in and its value? Do those have to keep scaling by 2?

Ill read up on this:

And see if I can figure it out.

Well This is going to be not easy as this is not a value type. Again why do you need a sampler? I’m not convince at all you need more than what the texture block will return.
What else can you do besides reading a color from the sampler?

I promise people will request the holy crap out of it as soon as we release customNodes, unless I miss understand how they are going to work. But for example, right now if I wanted to make a normalMap procedurally generated from a Black and White image, given the current setup I would need to make 4 texture nodes offset the uv on each of them, and then pass those 4 colors to input instead of just passing the texture sampler itself. It is also needed for when we want to do textureBased sampled noise, incase people don’t want to use procedural.

The Node editor is just another means to construct shaders, if we do not have access to a sampler2d variable our ability to build cool stuff is going to be hindered.

I understand where you are coming from though, as it’s not a output that you can just hook up to something and see a value.

Yes but sampler2d is not enough. You will need the texture matrix, and the uv. So having 4 texture blocks seems reasonable.

In your case you will have to either ignore texture matrix, or re-invent the wheel and rebuild the texture matrix etc…Or ignore texture matrix, but then people will complaint about their uOffset/vOffset etc not being supported…

For noise, or stuff like that maybe hosting the sampler would work? Exposing the sampler is too complicated for the purpose of the NME. By complicated I mean from the user standpoint

What do you mean by hosting the sampler?

I mean just create them inside your block. If your block needs to read data multiple time with a specific behavior I see no problem to create a sampler inside your block (like what the textureBlock does)

I can see the use in that ok.

So what about dynamic inputs like in this use case. Lets say a user wants to make a FBN node, but in it they want to be able to drag into an input a noise function of some kind? Is this going to be solved with Custom Nodes, I don’t see how unless a custom node can output a reference to a function.

Well not sure how this works with other node editor but I had no plan for dynamic input. In this case I would say that the FBN can take a float value as input and you can plug in that input either a float or the output of another node (which could be a noise block)

I guess that would work, but how would you get the iterated new sample values from the prior nodes?

FBN relies on the the sample position being modified as it loops.

And the sample position can rely on a noise func
I understand…Not something we support so far

Blocks are providing values, not functions so this may end up having to do everything inside the FBN node

I’m also thinking about code node where you can write glsl directly

If we have code nodes then we will need like ‘Static Function Blocks’ Where its a node that has no input or output but includes some code that creates the namespace for a function that can be accessed by any Custom Node or Custom Code node.

So that way you would just replace the Static Function Blocks name to whatever is referenced in the Custom Node block so like in the Custom Code block you have a function ‘globalNoise’ that you are using, it would point directly to whatever function was in the Static Function Block with that name.

Yep that sounds like a good idea

1 Like

i found myself needing a sampler2d block too :smile: