Some Function definition questions

Started by PG, May 06, 2009, 04:47:36 PM

Previous topic - Next topic

PG

I have some questions on certain function nodes that aren't made too clear (from my standpoint) in the node reference.


  • What is meant by "component-wise"?
  • How are colours represented in functions? (e.g. how does the abscolour function node find the absolute value of a colour?)
  • Do you absolutely have to create a constant scalar value for every condition in a function (e.g. min/max values of clamp scalar), or is there a way I can just type the required values in?
  • How do you determine the position that the "get" functions work from? For example, if I want to get the normal for a wave in a power fractal ocean.

That's all I have for now but I'll doubtless have more as I plod along.
Figured out how to do clicky signatures

jo

    Hi PG,

    First off I apologise for using links to the old reference in the following, I'm on dialup right now and I know where stuff is there so I'm taking the easy way out :-).

Quote from: PG on May 06, 2009, 04:47:36 PM
  • What is meant by "component-wise"?

The components of a colour are the red, green and blue values. The components of a vector are the x, y and z values. A componentwise operation works on the same components of the input values ( i.e. input 1.red + input 2.red ). An example:

http://forums.planetside.co.uk/index.php?topic=2070

Quote
  • How are colours represented in functions? (e.g. how does the abscolour function node find the absolute value of a colour?)

It depends. The documentation will say. The page for abs colour says it does it componentwise ( see above :-) and gives an example using a vector:

http://forums.planetside.co.uk/index.php?topic=3081

There is a page here about how TG2 handles conversions between different types, for example what happens if you connect a colour to a scalar input:

http://forums.planetside.co.uk/index.php?topic=2089

Quote
  • Do you absolutely have to create a constant scalar value for every condition in a function (e.g. min/max values of clamp scalar), or is there a way I can just type the required values in?

If you want to use a value other than the default values for the inputs then yes you do need to create constant scalars. Some functions will use default values for inputs if nothing is connected there and that should be mentioned in the docs, although this is sometimes mentioned in the error section, for example:

http://forums.planetside.co.uk/index.php?topic=3174

Quote
  • How do you determine the position that the "get" functions work from? For example, if I want to get the normal for a wave in a power fractal ocean.

I'm not sure about this myself, sad to say, I'm waiting for the docs ;-). I believe the "get" functions work on the particular piece of the scene being rendered, for example "get normal" gets the normal from the current render state/micropolygon being evaluated.

Regards,

Jo

Oshyan

It's my understanding, like Jo, that "get" works on the piece of the scene currently being rendered. I'm not sure if you can get the position of a specific point or area, but if you have that I suppose you could just use constants or something...

Sad to say function nodes aren't my area of expertise. Some of this complexity is precisely the reason I am needing input from the development side for the docs.

- Oshyan

PG

#3
Quote from: jo on May 06, 2009, 08:44:58 PM
    Quote from: PG on May 06, 2009, 04:47:36 PM
    • What is meant by "component-wise"?

    The components of a colour are the red, green and blue values. The components of a vector are the x, y and z values. A componentwise operation works on the same components of the input values ( i.e. input 1.red + input 2.red ). An example:

    http://forums.planetside.co.uk/index.php?topic=2070

    Quote
    • How are colours represented in functions? (e.g. how does the abscolour function node find the absolute value of a colour?)

    It depends. The documentation will say. The page for abs colour says it does it componentwise ( see above :-) and gives an example using a vector:

    Still a little shaky on this. So is colour bitwise? (input.red gives 1 if red, 0 if not), or is it a value up to 255?
    On an unrelated, the reply box keeps jumping all over the place. keeps wanting to scroll up one line. aggghh[/list]
    Figured out how to do clicky signatures

    jo

    Hi PG,

    Ok, so we have two colours, colour1 and colour2. Each colour has three components - red, green and blue. Normally when you're talking about a colour you really mean something described by the three separate components. A componentwise add operation looks like this:

    finalColour.red = colour1.red + colour2.red
    finalColour.green = colour1. green + colour2. green
    finalColour.blue = colour1. blue + colour2. blue

    A componentwise multiply operation looks like this:

    finalColour.red = colour1.red x colour2.red
    finalColour.green = colour1. green x colour2. green
    finalColour.blue = colour1. blue x colour2. blue

    To put this into context, using an Add colour node, colour1 would be the value connected to the Input node input, colour2 would be the value connected to the Input 2 input and finalColour would be the value coming out of the output.

    A colour isn't bitwise ( that doesn't really make in this context ). Each component of the colour is a decimal value ( floating point in computer speak ). The "normal" maximum value of a colour component is 1.0 ( i.e. red = 1.0, green = 1.0, blue = 1.0 is white and red = 0.5, green = 0.5, blue = 0.5 is mid grey ). 1.0 is equivalent to 255 if you are used to using 255 for maximum colour values.

    However, because TG2 uses high dynamic range colour throughout you can use colour values greater than 1.0, or even less than 0.0 ( the normal minimum value ) if you have a reason to. Normally you'd probably want to keep them between 0.0 and 1.0 though. The clamp functions help you to do this.

    Regards,

    Jo



    Hetzen

    Hi Jo, could you explain the get function's input connection to me please. I'd like to use say a "get position" then split that vector into four offsets with +/-1 in x and z to read the altitude at those offsets, then make an average value for those four points and apply it to the point being calculated. So in this case, is it possible to offset the "Get Altitude" by feeding it a modified vector into it's input?

    The application in this instance, is trying to flatten out terrain under a painted mask to represent a road, which still conforms to the general terrain.

    cyphyr

    I may be on the wrong track here... :)
    The "get" function seems as said to get its colour, scalar or vector from what ever bit of geometry is being rendered.
    This was confusing to me until I realised that this do not matter practically in most situations. I thought, "What use is this, I want to specify on the terrain where my effect is controlled". I now realise it doesn't work that way. I use the "get" function in the normal way and then use a "transform" shader to place the effect where I want.
    Hope this helps :)
    Richard
    www.richardfraservfx.com
    https://www.facebook.com/RichardFraserVFX/
    /|\

    Ryzen 9 5950X OC@4Ghz, 64Gb (TG4 benchmark 4:13)

    Hetzen

    Sure, so why does the get function have an input? Usually you would use it at the top of a node branch.

    I just thought something like the attached might work, where I add +/- 10 meters in x or z, get the altitude in those positional offsets, add them together, then divide by four to return an average height.

    PG

    That, I'm pretty sure (not sure at all), is if you have multiple, stacked heightfields. I think it's just for heirarchy rather than data input.
    Figured out how to do clicky signatures

    Hetzen

    #9
    Well, that would be ok. If I had two heightfields the same, one to get average height, the second to distort by the result of the first.

    The wording in the node reference states:

    "Provides the Altitude of the input node as its output."

    So it would suggest, if I redirected the input with a vector constant, it would shift where it looks for the altitude.

    I've usually used this set of nodes without connecting the input, just the output. I just wondered why it does have an input at all, and how it's intended to be used.

    Maybe I don't need the get position at the start of the chain, maybe I can just connect a heightfield into the four splits, to affect a second duplicate. It would be extremely usefull if I could get various readings offset from the calculated micro triangle to drive conditions, like collision detection of water on land

    PG

    #10
    Isn't the heightfield a 4D matrix? If you added a heightfield to, what I assume is, a constant vector then the Add function wouldn't know which vector to use from the heightfield. Surely you'd need to split them up first. Mathematically you can add a vector to a matrix but it may not give you the result you want. Particularly if you only want to affect certain sides of the heightfield.
    Figured out how to do clicky signatures

    Hetzen

    Quote from: PG on June 14, 2009, 12:58:30 PM
    If you added a heightfield to, what I assume is, a constant vector then the Add function wouldn't know which vector to use from the heightfield.

    Not sure about the 4D matrix, that's a little beyond me. To my limited logic, I'd have thought the input of a Get function would indicate what you wanted to look at.

    Matt

    The "Get ..." functions give you values that have already been calculated for the current microtriangle, microvertex or whatever shading state is being calculated, before the function network is calculated. For example, if you are using a function network as a blendshader for some Surface Layer, the "Get Altitude" function will give you the altitude of the micropolygon being shaded by the Surface Layer. You can think of it as if the Surface Layer already knows the altitude before it asks the blend shader network to do anything.

    The "Get..." functions currently do not take any inputs. The fact that they are displayed with input plugs is a limitation of the node system, which gives all nodes an input connection even if it is not used.

    It's not possible to use these functions to calculate values from surrounding parts of a landscape. I have considered giving these function the ability to query some input shader network, but I think it may be more appropriate to handle that using a separate set of functions. Having these functions operate in different ways depending on their input would lead to more confusion and ambiguity over exactly what they do.

    It looks like the documentation for these functions is wrong in that respect.
    Just because milk is white doesn't mean that clouds are made of milk.

    Hetzen