Multiple Image Inputs in Custom Shader

Is there a way to use multiple image inputs for a generative shader? I want to create a shader that uses three image inputs and an input from a camera or kinect to generate a dynamic image.

I have created the shader on interactiveshaderformat.com and it works there but when I try to import into Millumin, I don't know how to make the shader reference my images and kinect data.

Thanks!  


Comments

  • Hello @McDave,

    If your 3 images are static (not changing over time), it should be possible.
    Attach your shader here (zip it if needed), so we could check it.

    Best. Philippe
  • Thank you Philippe,

    I did get it to work by importing the three images, but I would like to use items in my Millumin project as inputs if possible.

    I am new to coding shaders but this does work right now though the depth data from the Kinect is very noisy and unstable.  Is there a way to smooth it out?

     This is my shader so far:


    /*{
    "CREDIT": "by Dave Malcolm",
    "DESCRIPTION": "Shader for AR sandbox using Kinect depth input",
    "CATEGORIES": [
    "generator"
    ],
    "INPUTS": [
    {
    "NAME": "inputImage",
    "TYPE": "image"
    },
        {
          "NAME" : "Beachdepth",
          "TYPE" : "float",
          "MAX" : 1,
          "DEFAULT" : 0.2,
          "MIN" : 0
        },
        {
          "NAME" : "sealevel",
          "TYPE" : "float",
          "MAX" : 1,
          "DEFAULT" : 0.5,
          "MIN" : 0
        },
        {
          "NAME" : "snowline",
          "TYPE" : "float",
          "MAX" : 1,
          "DEFAULT" : 0.7,
          "MIN" : 0
        },
        {
          "NAME" : "snowfade",
          "TYPE" : "float",
          "MAX" : 1,
          "DEFAULT" : 0.1,
          "MIN" : 0
        }
    ],
      "IMPORTED": {
        "Land": {
          "PATH": "
    image
    "
        },
         "Water": {
          "PATH": "
    image
    "
        },
         "Snow": {
          "PATH": "
    image
    "
        }
    }
    }*/

    void main() {

    float depth = ((IMG_THIS_NORM_PIXEL(inputImage).r - sealevel + Beachdepth) / Beachdepth);
    float snowdepth = ((IMG_THIS_NORM_PIXEL(inputImage).r - snowline + snowfade) / snowfade);

    if (IMG_THIS_NORM_PIXEL(inputImage).r > snowline) {
    gl_FragColor= IMG_THIS_NORM_PIXEL(Snow);
    }
    else if ((IMG_THIS_NORM_PIXEL(inputImage).r < snowline)&&(IMG_THIS_NORM_PIXEL(inputImage).r > (snowline - snowfade))) {
    gl_FragColor= (IMG_THIS_NORM_PIXEL(Snow) * snowdepth) + (IMG_THIS_NORM_PIXEL(Land) * (1.0 - snowdepth));
    }
    else if ((IMG_THIS_NORM_PIXEL(inputImage).r < (snowline - snowfade))&&(IMG_THIS_NORM_PIXEL(inputImage).r > sealevel)) {
    gl_FragColor= IMG_THIS_NORM_PIXEL(Land);
    }
    else if ((IMG_THIS_NORM_PIXEL(inputImage).r < sealevel)&&(IMG_THIS_NORM_PIXEL(inputImage).r > (sealevel - Beachdepth))) {
    gl_FragColor= (IMG_THIS_NORM_PIXEL(Land) * depth) + (IMG_THIS_NORM_PIXEL(Water) * (1.0 - depth));
    }
    else {
    gl_FragColor= IMG_THIS_NORM_PIXEL(Water);
    }
    }


  • Hello @MacDave,

    In next beta, Millumin will be able to use inputs (camera, Syphon, images, ...) for image-input in ISF shaders or effects.
    I sent you an intermediate version to test this out.

    Regarding the depth
    data from the Kinect : yes, it's normal it's noisy. You can add a "blur" effect after your shader-effect to smooth things out. Another solution is to use a Kinect V2 that has higher resolution, so diminishing the noise.

    Best. Philippe
Sign In or Register to comment.