In the olden days, producers knew what visual effects were. Now they’ve gotten into this methodology where they’ll hire a middleman – a visual effects supervisor, and this person works for the producing studio.
They’re middle managers. And when you go into a review with one of them, there’s this weird sort of competition that happens.

It’s a game called ‘Find What’s Wrong With This Shot’. And there’s always going to be something wrong, because everything’s subjective. And you can micromanage it down to a pixel, and that happens all the time. We’re doing it digitally, so there’s no pressure to save on film costs or whatever, so it’s not unusual to go through 500 revisions of the same shot, moving pixels around and scrutinizing this or that.

That’s not how you manage artists. You encourage artists, and then you’ll get – you know – art.

If your idea of managing artists is just pointing out what’s wrong and making them fix it over and over again, you end up with artists who just stand around asking “OK lady, where do you want this sofa? You want it over there? No? Fine. You want it over there? I don’t give a fuck. I’ll put it wherever you want it.” It’s creative mismanagement, it’s part of the whole corporate modality. The fish stinks from the head on down. Back on Star Wars, Robocop, we never thought about what was wrong with a shot.

We just thought about how to make it better.

Phil Tippett

CustomShader3D: Cg shader editing in your comp

Moderator: SecondMan

User avatar
Chad
Fusionista
Posts: 925
Joined: Fri Aug 08, 2014 12:11 pm
Been thanked: 3 times

Re: CustomShader3D: Cg shader editing in your comp

Post #16 by Chad » Thu Jun 02, 2016 12:46 pm

Yeah, wanted to show what I was talking about. I was already doing this, so I had Fusion open.

I THINK you can cap off the face... You'd have to test to see if the fragments were facing away from the camera, using sign(dot(viewvector, normal)) and for all those fragments set their f.Normal to be the normalized eye space rotation of the plane gizmo AND set their f.Position.z to be the projection of their position onto the plane. I am not going to try that now, but I'll make a note to try it later.

Tags:

User avatar
SecondMan
Site Admin
Posts: 1451
Joined: Thu Jul 31, 2014 4:31 pm
Location: Vancouver
Been thanked: 11 times
Contact:

Re: CustomShader3D: Cg shader editing in your comp

Post #17 by SecondMan » Thu Jun 02, 2016 12:52 pm

I was almost waiting for a reference to 3CuS to appear there :D

Oh wow. So I wanted to add "unless you could come up with some clever optical illusion" but that's exactly what you're doing, right?

So fragments have their own ZDepth. Hah, of course. Just getting my head around this.

User avatar
Chad
Fusionista
Posts: 925
Joined: Fri Aug 08, 2014 12:11 pm
Been thanked: 3 times

Re: CustomShader3D: Cg shader editing in your comp

Post #18 by Chad » Thu Jun 02, 2016 12:55 pm

miaz3 wrote:Thanx chad,

So yes, on shadertoy found things well trotured. But i see this multipass, pathracing (estimator monte carlo)
https://www.shadertoy.com/view/4dtGWB

And I ask myself several questions concerning applications are in Fu.


Pathtracing, yes. Multipass, no. In Fusion images are either complete or they aren't. There's no progressive image completion. So you'd have to set a number of iterations and render all at once and just have APrx trigger a lower quality render for interactivity. By default, in Fusion APrx will make smaller textures and smaller 3Rn outputs, but our tools like ReflectionBlur3D change the number of samples they take based on proxy & HiQ.

User avatar
Chad
Fusionista
Posts: 925
Joined: Fri Aug 08, 2014 12:11 pm
Been thanked: 3 times

Re: CustomShader3D: Cg shader editing in your comp

Post #19 by Chad » Thu Jun 02, 2016 12:59 pm

SecondMan wrote:So fragments have their own ZDepth. Hah, of course. Just getting my head around this.


f.Position is in eye space in Fusion. So f.Position.z is basically Z-Depth. In fact, that's how 3Rn makes the Z channel, it's basically float4(f.Position.bbb, 1.0);

Spoiler:
  1. struct FuFragment
  2. {
  3.     float4 VertexColor;    // This is where particles get their per-particle colors.  3Sh and 3Im set this to float4(1,1,1,1)
  4.     float3 TexCoord0;
  5.     float3 TexCoord1;    // For the future!
  6.     float3 TexCoord2;    // For the future!
  7.     float3 EnvCoord;
  8.     float3 Position;    // eye space
  9.     float3 Normal;     // eye space
  10.     float3 TangentU;    // eye space
  11.     float3 TangentV;    // eye space
  12. };
  13.  
  14. struct FuLightData
  15. {
  16.     float4 Color;         // for 3AL, this is float4(0,0,0,0);
  17.     float4 AmbientColor;  // for everything other than 3AL, this is float4(0,0,0,0);
  18.     float3 LightVector;   // eye space
  19. };
Last edited by Chad on Sun Jun 05, 2016 12:22 pm, edited 1 time in total.

User avatar
miaz3
Fusioneer
Posts: 111
Joined: Sat Jan 03, 2015 1:43 am
Location: France
Contact:

Re: CustomShader3D: Cg shader editing in your comp

Post #20 by miaz3 » Fri Jun 03, 2016 4:41 am

OK, thank you Chad.
++

User avatar
Kristof
Fusionista
Posts: 274
Joined: Thu Aug 07, 2014 12:30 pm
Been thanked: 3 times

Re: CustomShader3D: Cg shader editing in your comp

Post #21 by Kristof » Sat Jun 04, 2016 12:23 am

Hey Chad, how am I supposed to load these .cg files that you are sharing? Am a bit confused...

User avatar
Kristof
Fusionista
Posts: 274
Joined: Thu Aug 07, 2014 12:30 pm
Been thanked: 3 times

Re: CustomShader3D: Cg shader editing in your comp

Post #22 by Kristof » Sat Jun 04, 2016 11:51 am

A'ight, baby steps... Cg exposure shader:

  1. float4 Shade(inout FuFragment f)
  2. {
  3.  
  4. float4 inmtl = InputMtl.Shade(f);
  5. float4 outmtl = inmtl;
  6.  
  7. outmtl.rgb *= pow(2, Stop);
  8.  
  9. return outmtl;
  10.  
  11. }


Noticed that if I push it 15 stops and compare it to my macro, the image no longer is the same. Not sure why this is happening right now. Full float operations, maybe not in 3D...

Code: Select all

{
   Tools = ordered() {
      exposure = MacroOperator {
         NameSet = true,
         Inputs = ordered() {
            Comments = Input { Value = "exposure v1.00\r\nKristof Indeherberge\r\n2015", },
            MainInput1 = InstanceInput {
               SourceOp = "BrightnessContrast1",
               Source = "Input",
            },
            Input1 = InstanceInput {
               SourceOp = "BrightnessContrast1",
               Source = "stop",
               Name = "Stop",
               Default = 0,
            },
         },
         Outputs = {
            MainOutput1 = InstanceOutput {
               SourceOp = "BrightnessContrast1",
               Source = "Output",
            },
         },
         ViewInfo = GroupInfo { Pos = { 440, 181.5, }, },
         Tools = ordered() {
            BrightnessContrast1 = BrightnessContrast {
               CtrlWZoom = false,
               CtrlWShown = false,
               Inputs = {
                  Gain = Input {
                     Value = 2,
                     Expression = "2^stop",
                  },
                  Input = Input {
                     SourceOp = "Plasma1",
                     Source = "Output",
                  },
                  stop = Input { Value = 1, },
               },
               ViewInfo = OperatorInfo { Pos = { 0, 10.15, }, },
               UserControls = ordered() {
                  stop = {
                     INP_Integer = true,
                     INP_MinAllowed = -10000,
                     LINKID_DataType = "Number",
                     INPID_InputControl = "SliderControl",
                     IC_ControlPage = 0,
                     INP_MaxScale = 20,
                     INP_MinScale = -20,
                  },
               },
            },
         },
      },
      Plasma1 = Plasma {
         Inputs = {
            Width = Input { Value = 2048, },
            Height = Input { Value = 1556, },
            ["Gamut.SLogVersion"] = Input { Value = FuID { "SLog2", }, },
         },
         ViewInfo = OperatorInfo { Pos = { 275, 214.5, }, },
      },
      Renderer3D1 = Renderer3D {
         Inputs = {
            Width = Input { Value = 2048, },
            Height = Input { Value = 1556, },
            Depth = Input { Value = 4, },
            ["Gamut.SLogVersion"] = Input { Value = FuID { "SLog2", }, },
            SceneInput = Input {
               SourceOp = "Shape3D1",
               Source = "Output",
            },
            RendererType = Input { Value = FuID { "RendererOpenGLUV", }, },
         },
         ViewInfo = OperatorInfo { Pos = { 660, 247.5, }, },
      },
      Shape3D1 = Shape3D {
         Inputs = {
            MaterialInput = Input {
               SourceOp = "CustomShader3D1",
               Source = "MaterialOutput",
            },
            ["MtlStdInputs.MaterialID"] = Input { Value = 1, },
            ["SurfacePlaneInputs.ObjectID.ObjectID"] = Input { Value = 1, },
         },
         ViewInfo = OperatorInfo { Pos = { 550, 247.5, }, },
      },
      CustomShader3D1 = Indicated.CustomShaderOperator3D {
         CtrlWZoom = false,
         Inputs = {
            ShaderTextInputs = Input { Value = "FuFloat4 InputMtl;\nfloat Stop;\n\n", },
            ShaderTextBody = Input { Value = "float4 Shade(inout FuFragment f)\r\n{\r\n\r\nfloat4 inmtl = InputMtl.Shade(f);\r\nfloat4 outmtl = inmtl;\r\n\r\noutmtl.rgb *= pow(2, Stop);\r\n\r\nreturn outmtl;\r\n\r\n}", },
            MaterialGroup = Input { Value = 1, },
            FloatGroup = Input { Value = 1, },
            MaterialID = Input { Value = 1, },
            InputMtl = Input {
               SourceOp = "Plasma1",
               Source = "Output",
               CustomData = {
                  Metadata = {
                     Set = "InputMtl",
                     Type = "Material",
                  },
               },
            },
            Stop = Input {
               Value = 1,
               CustomData = {
                  Metadata = {
                     Set = "Stop",
                     Type = "Float",
                  },
               },
               Expression = "exposure.Input1",
            },
         },
         ViewInfo = OperatorInfo { Pos = { 440, 247.5, }, },
         UserControls = ordered() {
            InputMtl = {
               {
                  LINKID_DataType = "MtlGraph3D",
               },
               {
                  LINKID_DataType = "Image",
               },
               {
                  LINKID_AllowedDataType = "Image",
               },
               {
                  LINKID_AllowedDataType = "Mask",
               },
               LINK_Main = 2,
               INP_AcceptsGLImages = true,
               INP_Required = false,
               IC_ControlPage = 0,
               INP_AcceptsMasks = true,
               INPID_InputControl = "ImageControl",
            },
            Stop = {
               IC_ControlPage = 0,
               INPID_InputControl = "SliderControl",
               LINKID_DataType = "Number",
            },
         },
      },
   },
}

User avatar
Chad
Fusionista
Posts: 925
Joined: Fri Aug 08, 2014 12:11 pm
Been thanked: 3 times

Re: CustomShader3D: Cg shader editing in your comp

Post #23 by Chad » Sun Jun 05, 2016 12:21 pm

You have the 3Rn set to int8 textures. The render itself is float32, so you get unclamped output, but it's all muliples of just 256 values. Change the texturing to float32 and you'll get a good match.

There's a possibility for some float rounding errors with bilinear texture filtering. It's very small for low contrast images (as opposed to a quincunx pattern of -10000 and 10000 pixels). Setting the texture filtering to nearest takes care of that.

Of course, this all breaks down at 20 stops, but that's because BC clamps the Gain to 1M. You didn't limit your 3CuS to the same amount. So here's the "fixed" version:

Spoiler:
  1. {
  2.     Tools = ordered() {
  3.         exposure = MacroOperator {
  4.             CtrlWZoom = false,
  5.             NameSet = true,
  6.             Inputs = ordered() {
  7.                 Comments = Input { Value = "exposure v1.00\r\nKristof Indeherberge\r\n2015", },
  8.                 MainInput1 = InstanceInput {
  9.                     SourceOp = "BrightnessContrast1",
  10.                     Source = "Input",
  11.                 },
  12.                 Input1 = InstanceInput {
  13.                     SourceOp = "BrightnessContrast1",
  14.                     Source = "stop",
  15.                     Name = "Stop",
  16.                     Default = 0,
  17.                 },
  18.             },
  19.             Outputs = {
  20.                 MainOutput1 = InstanceOutput {
  21.                     SourceOp = "BrightnessContrast1",
  22.                     Source = "Output",
  23.                 },
  24.             },
  25.             ViewInfo = GroupInfo { Pos = { 990, 313.5, }, },
  26.             Tools = ordered() {
  27.                 BrightnessContrast1 = BrightnessContrast {
  28.                     CtrlWZoom = false,
  29.                     CtrlWShown = false,
  30.                     Inputs = {
  31.                         Gain = Input {
  32.                             Value = 1000000,
  33.                             Expression = "2^stop",
  34.                         },
  35.                         Input = Input {
  36.                             SourceOp = "PipeRouter1",
  37.                             Source = "Output",
  38.                         },
  39.                         stop = Input { Value = 20, },
  40.                     },
  41.                     ViewInfo = OperatorInfo { Pos = { 0, 10.15, }, },
  42.                     UserControls = ordered() {
  43.                         stop = {
  44.                             INP_Integer = true,
  45.                             INP_MinAllowed = -10000,
  46.                             LINKID_DataType = "Number",
  47.                             INP_MinScale = -20,
  48.                             IC_ControlPage = 0,
  49.                             INP_MaxScale = 20,
  50.                             INPID_InputControl = "SliderControl",
  51.                         },
  52.                     },
  53.                 },
  54.             },
  55.         },
  56.         Plasma1 = Plasma {
  57.             Inputs = {
  58.                 Width = Input { Value = 2048, },
  59.                 Height = Input { Value = 1556, },
  60.                 Depth = Input { Value = 4, },
  61.                 ["Gamut.SLogVersion"] = Input { Value = FuID { "SLog2", }, },
  62.             },
  63.             ViewInfo = OperatorInfo { Pos = { 550, 313.5, }, },
  64.         },
  65.         PipeRouter1 = PipeRouter {
  66.             Inputs = {
  67.                 Input = Input {
  68.                     SourceOp = "Plasma1",
  69.                     Source = "Output",
  70.                 },
  71.             },
  72.             ViewInfo = PipeRouterInfo { Pos = { 770, 313.5, }, },
  73.         },
  74.         CustomShader3D1 = Indicated.CustomShaderOperator3D {
  75.             Inputs = {
  76.                 ShaderTextInputs = Input { Value = "FuFloat4 InputMtl;\nfloat Stop;\n\n", },
  77.                 ShaderTextBody = Input { Value = "float4 Shade(inout FuFragment f)\r\n{\r\n\r\nfloat4 inmtl = InputMtl.Shade(f);\r\nfloat4 outmtl = inmtl;\r\n\r\noutmtl.rgb *= min(pow(2, Stop), 1000000);\r\n\r\nreturn outmtl;\r\n\r\n}", },
  78.                 MaterialGroup = Input { Value = 1, },
  79.                 FloatGroup = Input { Value = 1, },
  80.                 MaterialID = Input { Value = 1, },
  81.                 InputMtl = Input {
  82.                     SourceOp = "Texture2D",
  83.                     Source = "MaterialOutput",
  84.                     CustomData = {
  85.                         Metadata = {
  86.                             Type = "Material",
  87.                             Set = "InputMtl",
  88.                         },
  89.                     },
  90.                 },
  91.                 Stop = Input {
  92.                     Value = 20,
  93.                     CustomData = {
  94.                         Metadata = {
  95.                             Type = "Float",
  96.                             Set = "Stop",
  97.                         },
  98.                     },
  99.                     Expression = "exposure.Input1",
  100.                 },
  101.             },
  102.             ViewInfo = OperatorInfo { Pos = { 990, 379.5, }, },
  103.             UserControls = ordered() {
  104.                 InputMtl = {
  105.                     {
  106.                         LINKID_DataType = "MtlGraph3D",
  107.                     },
  108.                     {
  109.                         LINKID_DataType = "Image",
  110.                     },
  111.                     {
  112.                         LINKID_AllowedDataType = "Image",
  113.                     },
  114.                     {
  115.                         LINKID_AllowedDataType = "Mask",
  116.                     },
  117.                     LINK_Main = 2,
  118.                     INP_AcceptsGLImages = true,
  119.                     INPID_InputControl = "ImageControl",
  120.                     IC_ControlPage = 0,
  121.                     INP_Required = false,
  122.                     INP_AcceptsMasks = true,
  123.                 },
  124.                 Stop = {
  125.                     IC_ControlPage = 0,
  126.                     LINKID_DataType = "Number",
  127.                     INPID_InputControl = "SliderControl",
  128.                 },
  129.             },
  130.         },
  131.         ChannelBooleans1 = ChannelBoolean {
  132.             Inputs = {
  133.                 Operation = Input { Value = 13, },
  134.                 Background = Input {
  135.                     SourceOp = "Renderer3D1",
  136.                     Source = "Output",
  137.                 },
  138.                 Foreground = Input {
  139.                     SourceOp = "BrightnessContrast1",
  140.                     Source = "Output",
  141.                 },
  142.             },
  143.             ViewInfo = OperatorInfo { Pos = { 1320, 379.5, }, },
  144.         },
  145.         Renderer3D1 = Renderer3D {
  146.             Inputs = {
  147.                 Width = Input { Value = 2048, },
  148.                 Height = Input { Value = 1556, },
  149.                 Depth = Input { Value = 4, },
  150.                 ["Gamut.SLogVersion"] = Input { Value = FuID { "SLog2", }, },
  151.                 SceneInput = Input {
  152.                     SourceOp = "ImagePlane3D1",
  153.                     Source = "Output",
  154.                 },
  155.                 RendererType = Input { Value = FuID { "RendererOpenGLUV", }, },
  156.                 ["RendererOpenGLUV.UVGutterSize"] = Input { Value = 0, },
  157.                 ["RendererOpenGLUV.Texturing"] = Input { Value = 1, },
  158.                 ["RendererOpenGLUV.TextureDepth"] = Input { Value = 4, },
  159.             },
  160.             ViewInfo = OperatorInfo { Pos = { 1210, 379.5, }, },
  161.         },
  162.         Texture2D = Texture2DOperator {
  163.             Inputs = {
  164.                 Input = Input {
  165.                     SourceOp = "PipeRouter1",
  166.                     Source = "Output",
  167.                 },
  168.                 ["FilterMode.Nest"] = Input { Value = 1, },
  169.                 ["FilterMode.GL.LowQ"] = Input { Value = FuID { "Nearest", }, },
  170.                 ["FilterMode.GL.HiQ"] = Input { Value = FuID { "Nearest", }, },
  171.                 MaterialID = Input { Value = 2, },
  172.                 LimitToHalfMaxTextureSize = Input { Value = 1, },
  173.             },
  174.             ViewInfo = OperatorInfo { Pos = { 880, 379.5, }, },
  175.             UserControls = ordered() {
  176.                 LimitToHalfMaxTextureSize = {
  177.                     LINKID_DataType = "Number",
  178.                     LINKS_Name = "Limit To Half Max Texture Size (OpenGL)",
  179.                     IC_ControlPage = 0,
  180.                     INPID_InputControl = "CheckboxControl",
  181.                     INP_Default = 0,
  182.                 },
  183.             },
  184.         },
  185.         ImagePlane3D1 = ImagePlane3D {
  186.             Inputs = {
  187.                 ["SurfacePlaneInputs.BlendMode.Nest"] = Input { Value = 1, },
  188.                 ["SurfacePlaneInputs.ObjectID.ObjectID"] = Input { Value = 2, },
  189.                 MaterialInput = Input {
  190.                     SourceOp = "CustomShader3D1",
  191.                     Source = "MaterialOutput",
  192.                 },
  193.                 ["MtlStdInputs.MaterialID"] = Input { Value = 3, },
  194.             },
  195.             ViewInfo = OperatorInfo { Pos = { 1100, 379.5, }, },
  196.         },
  197.     },
  198. }

User avatar
Chad
Fusionista
Posts: 925
Joined: Fri Aug 08, 2014 12:11 pm
Been thanked: 3 times

Re: CustomShader3D: Cg shader editing in your comp

Post #24 by Chad » Sun Jun 05, 2016 1:59 pm

Image
So that's the effective translation for the UV space hatching.


Image
And in eye space with perspective.


Image
And in screen space without perspective.


Image
And with an arbitrary screen space rotation of the hatching.


Image
Bonus: Squigly lines based on an input material, in this case, 3FN.


Image
Last edited by Chad on Mon Jun 06, 2016 12:52 pm, edited 1 time in total.

User avatar
Kristof
Fusionista
Posts: 274
Joined: Thu Aug 07, 2014 12:30 pm
Been thanked: 3 times

Re: CustomShader3D: Cg shader editing in your comp

Post #25 by Kristof » Mon Jun 06, 2016 5:52 am

Waaah, chad! Looks really interesting. Thanks for the feedback and example code. Going to push this at work and hopefully they will see the potential of this plugin and buy it too.

User avatar
Chad
Fusionista
Posts: 925
Joined: Fri Aug 08, 2014 12:11 pm
Been thanked: 3 times

Re: CustomShader3D: Cg shader editing in your comp

Post #26 by Chad » Mon Jun 06, 2016 7:37 am

Kristof wrote:Hey Chad, how am I supposed to load these .cg files that you are sharing? Am a bit confused...


You're not. Just copy paste into 3CuS's .ShaderTextBody.

You CAN use .cg files for includes, though. So if you have some commonly used functions you want to reuse across many tools, of you just want to move them to external files for easy of management and updating, you can put something like
  1. #include "Path\\To\\YourFiles\\CommonlyUsedFunctions.cg"

User avatar
Chad
Fusionista
Posts: 925
Joined: Fri Aug 08, 2014 12:11 pm
Been thanked: 3 times

Re: CustomShader3D: Cg shader editing in your comp

Post #27 by Chad » Mon Jun 06, 2016 7:07 pm

Image
Thin film specular reflection

User avatar
SecondMan
Site Admin
Posts: 1451
Joined: Thu Jul 31, 2014 4:31 pm
Location: Vancouver
Been thanked: 11 times
Contact:

Re: CustomShader3D: Cg shader editing in your comp

Post #28 by SecondMan » Tue Jun 07, 2016 7:01 am

This topic just keeps getting better and better...

User avatar
Kristof
Fusionista
Posts: 274
Joined: Thu Aug 07, 2014 12:30 pm
Been thanked: 3 times

Re: CustomShader3D: Cg shader editing in your comp

Post #29 by Kristof » Tue Jun 07, 2016 8:38 am

And another one: POM (parallax occlusion mapping)!

Work in progress though. Made by Thomas Van Riel based on this code:

http://sunandblackcat.com/tipFullView.php?l=eng&topicid=28&topic=Parallax-Occlusion-Mapping

  1. {
  2.     Tools = ordered() {
  3.         CustomShader3D1_1_1_1 = Indicated.CustomShaderOperator3D {
  4.             CtrlWZoom = false,
  5.             Inputs = {
  6.                 ShaderTextInputs = Input { Value = "FuFloat4 Normal;\nFuFloat4 Diffuse;\nFuFloat4 Height;\nfloat ParallaxScale;\nfloat MaxLayers;\nfloat MinLayers;\nFuLight Lights[];\nfloat4x4 ProjectionI;\nfloat3x3 ModelToEyeIT;\nfloat3x3 EyeToModelIT;\nfloat3x3 WorldToEyeIT;\nfloat3x3 EyeToWorldIT;\n\n", },
  7.                 ShaderTextBody = Input { Value = "float2 standard_parallaxMapping(FuFragment f, float3 V, float2 T)\r\n{\r\n    // get depth for this fragment\r\n  FuFragment newf = f;\r\n    newf.TexCoord0 = float3(T, 1.0);\r\n    float initialHeight = Height.Shade(newf).x;\r\n\r\n // calculate amount of offset for Parallax Mapping\r\n  float2 texCoordOffset = ParallaxScale * V.xy / V.z * initialHeight;\r\n\r\n // calculate amount of offset for Parallax Mapping With Offset Limiting\r\n texCoordOffset = ParallaxScale * V.xy * initialHeight;\r\n\r\n  // retunr modified texture coordinates\r\n  return T - texCoordOffset;\r\n}\r\n\r\nfloat2 steep_parallaxMapping(FuFragment f, float3 V, float2 T, out float parallaxHeight)\r\n{\r\n    // determine number of layers from angle between V and N\r\n    float minLayers = 5;\r\n    float maxLayers = 15;\r\n   float numLayers = lerp(MaxLayers, MinLayers, abs(dot(float3(0, 0, 1), V)));\r\n\r\n // height of each layer\r\n float layerHeight = 1.0 / numLayers;\r\n    // depth of current layer\r\n   float currentLayerHeight = 0;\r\n   // shift of texture coordinates for each iteration\r\n  float2 dtex = ParallaxScale * V.xy / V.z / numLayers;\r\n\r\n   // current texture coordinates\r\n  float2 currentTextureCoords = T;\r\n\r\n    // get first depth from heightmap\r\n   FuFragment newf = f;\r\n    newf.TexCoord0 = float3(currentTextureCoords, 1.0);\r\n float heightFromTexture = Height.Shade(newf).x;\r\n\r\n // while point is above surface\r\n while(heightFromTexture > currentLayerHeight)\r\n   {\r\n       // to the next layer\r\n        currentLayerHeight += layerHeight;\r\n      // shift texture coordinates along vector V\r\n     currentTextureCoords -= dtex;\r\n       // get new depth from heightmap\r\n     newf.TexCoord0 = float3(currentTextureCoords, 1.0);\r\n     heightFromTexture = Height.Shade(newf).x;\r\n   }\r\n\r\n   // return results\r\n   parallaxHeight = currentLayerHeight;\r\n    return currentTextureCoords;\r\n} \r\n\r\nfloat2 relief_parallaxMapping(FuFragment f, float3 V, float2 T, out float parallaxHeight)\r\n{\r\n   // determine required number of layers\r\n   const float minLayers = 10;\r\n   const float maxLayers = 15;\r\n   float numLayers = mix(MaxLayers, MinLayers, abs(dot(float3(0, 0, 1), V)));\r\n\r\n   // height of each layer\r\n   float layerHeight = 1.0 / numLayers;\r\n   // depth of current layer\r\n   float currentLayerHeight = 0;\r\n   // shift of texture coordinates for each iteration\r\n   float2 dtex = ParallaxScale * V.xy / V.z / numLayers;\r\n\r\n   // current texture coordinates\r\n   float2 currentTextureCoords = T;\r\n\r\n   // depth from heightmap\r\n  FuFragment newf = f;\r\n    newf.TexCoord0 = float3(currentTextureCoords, 1.0);\r\n float heightFromTexture = Height.Shade(newf).x;\r\n\r\n   // while point is above surface\r\n   while(heightFromTexture > currentLayerHeight)\r\n   {\r\n     // go to the next layer\r\n     currentLayerHeight += layerHeight;\r\n      // shift texture coordinates along V\r\n    currentTextureCoords -= dtex;\r\n   currentTextureCoords = frac(currentTextureCoords);\r\n      // new depth from heightmap\r\n       newf.TexCoord0 = float3(currentTextureCoords, 1.0);\r\n     heightFromTexture = Height.Shade(newf).x;\r\n   }\r\n\r\n   ///////////////////////////////////////////////////////////\r\n   // Start of Relief Parallax Mapping\r\n\r\n   // decrease shift and height of layer by half\r\n   float2 deltaTexCoord = dtex / 2;\r\n   float deltaHeight = layerHeight / 2;\r\n\r\n   // return to the mid point of previous layer\r\n   currentTextureCoords += deltaTexCoord;\r\n   currentLayerHeight -= deltaHeight;\r\n\r\n   // binary search to increase precision of Steep Paralax Mapping\r\n   const int numSearches = 5;\r\n   for(int i=0; i<numSearches; i++)\r\n   {\r\n    // decrease shift and height of layer by half\r\n   deltaTexCoord /= 2;\r\n     deltaHeight /= 2;\r\n\r\n   // new depth from heightmap\r\n       newf.TexCoord0 = float3(currentTextureCoords, 1.0);\r\n     heightFromTexture = Height.Shade(newf).x;\r\n\r\n     // shift along or agains vector V\r\n   if(heightFromTexture > currentLayerHeight) // below the surface\r\n     {\r\n      currentTextureCoords -= deltaTexCoord;\r\n      currentLayerHeight += deltaHeight;\r\n   }\r\n   else // above the surface\r\n   {\r\n      currentTextureCoords += deltaTexCoord;\r\n      currentLayerHeight -= deltaHeight;\r\n   }\r\n   }\r\n\r\n   // return results\r\n   parallaxHeight = currentLayerHeight;    \r\n   return currentTextureCoords;\r\n} \r\n\r\nfloat parallaxSoftShadowMultiplier(FuFragment f, float3 L, float2 initialTexCoord, float initialHeight)\r\n{\r\n float shadowMultiplier = 1;\r\n\r\n // calculate lighting only for surface oriented to the light source\r\n if(dot(float3(0, 0, 1), L) > 0)\r\n {\r\n       // calculate initial parameters\r\n     float numSamplesUnderSurface =0;\r\n        shadowMultiplier = 0;\r\n       float numLayers = lerp(MaxLayers, MinLayers, abs(dot(float3(0, 0, 1), L)));\r\n     float layerHeight = initialHeight / numLayers;\r\n      float2 texStep = ParallaxScale * L.xy / L.z / numLayers;\r\n\r\n        // current parameters\r\n       float currentLayerHeight = initialHeight - layerHeight;\r\n     float2 currentTextureCoords = initialTexCoord + texStep;\r\n\r\n        currentTextureCoords = frac(currentTextureCoords + 64.0);\r\n\r\n       FuFragment newf = f;\r\n        newf.TexCoord0 = float3(currentTextureCoords, 1.0);\r\n     float heightFromTexture = Height.Shade(newf).x;\r\n\r\n     int stepIndex = 1;\r\n  \r\n        // while point is below depth 0.0 )\r\n     while(currentLayerHeight > 0)\r\n       {\r\n           // if point is under the surface\r\n            if(heightFromTexture < currentLayerHeight)\r\n          {\r\n              // calculate partial shadowing factor\r\n               numSamplesUnderSurface += 1;\r\n            float newShadowMultiplier = (currentLayerHeight - heightFromTexture) * (1.0 - stepIndex / numLayers);\r\n               shadowMultiplier = max(shadowMultiplier, newShadowMultiplier);\r\n           }\r\n\r\n           // offset to the next layer\r\n         stepIndex += 1;\r\n         currentLayerHeight -= layerHeight;\r\n          currentTextureCoords += texStep;\r\n            currentTextureCoords = frac(currentTextureCoords + 4.0);\r\n            newf.TexCoord0 = float3(currentTextureCoords, 1.0);\r\n         heightFromTexture = Height.Shade(newf).x;\r\n       }\r\n\r\n       // Shadowing factor should be 1 if there were no points under the surface\r\n       if(numSamplesUnderSurface < 1)\r\n      {\r\n          shadowMultiplier =1;\r\n     }\r\n       else\r\n        {\r\n          shadowMultiplier =1-shadowMultiplier;\r\n        }\r\n   }\r\n   return shadowMultiplier;\r\n} \r\n\r\nfloat4 normalMappingLighting(FuFragment f, float3 L, float3 V, float shadowMultiplier)\r\n{\r\n   // restore normal from normal map\r\n   float3 N = normalize(Normal.Shade(f).xyz * 2.0 - 1.0);\r\n  N = N.x * normalize(f.TangentU) + N.y * normalize(f.TangentV) + N.z * normalize(f.Normal);\r\n  float3 D = Diffuse.Shade(f).xyz;\r\n\r\n    // diffuse lighting\r\n float idiff = clamp(dot(N, L), 0.0, 1.0);\r\n\r\n   float4 resColor;\r\n    resColor = float4(D * ((idiff) * pow(shadowMultiplier, 4)), 1.0);\r\n\r\n   return resColor;\r\n}\r\n\r\nfloat4 Shade(inout FuFragment f){\r\n\r\n  float4 Kd = Diffuse.Shade(f);\r\n   float4 normalMap = Normal.Shade(f) * 2.0 - 1.0;   \r\n\r\n  normalMap.xyz = normalMap.x * normalize(f.TangentU) + normalMap.y * normalize(f.TangentV) + normalMap.z * normalize(f.Normal); \r\n\r\n float3 n = normalMap.xyz;\r\n    float3x3 mWorldToTangent = float3x3( f.TangentU, f.TangentV, f.Normal ) ;\r\n    float3 vNormalWorld = normalize(mul(mWorldToTangent, normalize(-f.Position)));\r\n    float3 v = vNormalWorld;\r\n    \r\n    float3 aAccum = 0;\r\n  float3 dAccum = 0;\r\n  float3 Lambert; \r\n    float3 l;  \r\n\r\n float parallaxHeight;\r\n   float2 T = relief_parallaxMapping(f, v, f.TexCoord0.xy, parallaxHeight);\r\n    FuFragment newf = f;\r\n    newf.TexCoord0 = float3(T, 1.0);\r\n                \r\n    float3 d = Diffuse.Shade(newf).xyz;\r\n\r\n for (int i = 0; i < Lights.length; i++) \r\n    {\r\n       FuLightData data = Lights[i].Illuminate(newf);\r\n      aAccum += data.AmbientColor.rgb;\r\n        l = normalize(data.LightVector);\r\nl = normalize(mul(mWorldToTangent, normalize(data.LightVector)));\r\n       // get self-shadowing factor for elements of parallax\r\n       float shadowMultiplier = parallaxSoftShadowMultiplier(newf, l, newf.TexCoord0.xy, parallaxHeight);\r\n\r\n      dAccum += normalMappingLighting(newf, l, v, shadowMultiplier).xyz * data.Color.rgb;\r\n }\r\n\r\n   float4 ret = float4(d * (dAccum + aAccum), Kd.a);\r\n   return ret; \r\n}", },
  8.                 RCGroup = Input { Value = 1, },
  9.                 UseLights = Input { Value = 1, },
  10.                 RCMatrices = Input { Value = 682, },
  11.                 MaterialGroup = Input { Value = 1, },
  12.                 FloatGroup = Input { Value = 1, },
  13.                 MaterialID = Input { Value = 1, },
  14.                 Normal = Input {
  15.                     CustomData = {
  16.                         Metadata = {
  17.                             Set = "Normal",
  18.                             Type = "Material",
  19.                         },
  20.                     },
  21.                 },
  22.                 Diffuse = Input {
  23.                     CustomData = {
  24.                         Metadata = {
  25.                             Set = "Diffuse",
  26.                             Type = "Material",
  27.                         },
  28.                     },
  29.                 },
  30.                 Height = Input {
  31.                     CustomData = {
  32.                         Metadata = {
  33.                             Set = "Height",
  34.                             Type = "Material",
  35.                         },
  36.                     },
  37.                 },
  38.                 ParallaxScale = Input {
  39.                     Value = 0.1,
  40.                     CustomData = {
  41.                         Metadata = {
  42.                             Set = "ParallaxScale",
  43.                             Type = "Float",
  44.                         },
  45.                     },
  46.                 },
  47.                 MaxLayers = Input {
  48.                     Value = 30,
  49.                     CustomData = {
  50.                         Metadata = {
  51.                             Set = "MaxLayers",
  52.                             Type = "Float",
  53.                         },
  54.                     },
  55.                 },
  56.                 MinLayers = Input {
  57.                     Value = 15,
  58.                     CustomData = {
  59.                         Metadata = {
  60.                             Set = "MinLayers",
  61.                             Type = "Float",
  62.                         },
  63.                     },
  64.                 },
  65.             },
  66.             ViewInfo = OperatorInfo { Pos = { 330, -1006.5, }, },
  67.             UserControls = ordered() {
  68.                 Normal = {
  69.                     {
  70.                         LINKID_DataType = "MtlGraph3D",
  71.                     },
  72.                     {
  73.                         LINKID_DataType = "Image",
  74.                     },
  75.                     {
  76.                         LINKID_AllowedDataType = "Image",
  77.                     },
  78.                     {
  79.                         LINKID_AllowedDataType = "Mask",
  80.                     },
  81.                     LINK_Main = 2,
  82.                     INP_AcceptsGLImages = true,
  83.                     INP_AcceptsMasks = true,
  84.                     IC_ControlPage = 0,
  85.                     INP_Required = false,
  86.                     INPID_InputControl = "ImageControl",
  87.                 },
  88.                 Diffuse = {
  89.                     {
  90.                         LINKID_DataType = "MtlGraph3D",
  91.                     },
  92.                     {
  93.                         LINKID_DataType = "Image",
  94.                     },
  95.                     {
  96.                         LINKID_AllowedDataType = "Image",
  97.                     },
  98.                     {
  99.                         LINKID_AllowedDataType = "Mask",
  100.                     },
  101.                     LINK_Main = 2,
  102.                     INP_AcceptsGLImages = true,
  103.                     INP_AcceptsMasks = true,
  104.                     IC_ControlPage = 0,
  105.                     INP_Required = false,
  106.                     INPID_InputControl = "ImageControl",
  107.                 },
  108.                 Height = {
  109.                     {
  110.                         LINKID_DataType = "MtlGraph3D",
  111.                     },
  112.                     {
  113.                         LINKID_DataType = "Image",
  114.                     },
  115.                     {
  116.                         LINKID_AllowedDataType = "Image",
  117.                     },
  118.                     {
  119.                         LINKID_AllowedDataType = "Mask",
  120.                     },
  121.                     LINK_Main = 3,
  122.                     INP_AcceptsGLImages = true,
  123.                     INP_AcceptsMasks = true,
  124.                     IC_ControlPage = 0,
  125.                     INP_Required = false,
  126.                     INPID_InputControl = "ImageControl",
  127.                 },
  128.                 ParallaxScale = {
  129.                     IC_ControlPage = 0,
  130.                     LINKID_DataType = "Number",
  131.                     INPID_InputControl = "SliderControl",
  132.                 },
  133.                 MaxLayers = {
  134.                     IC_ControlPage = 0,
  135.                     INPID_InputControl = "SliderControl",
  136.                     LINKID_DataType = "Number",
  137.                 },
  138.                 MinLayers = {
  139.                     IC_ControlPage = 0,
  140.                     INPID_InputControl = "SliderControl",
  141.                     LINKID_DataType = "Number",
  142.                 },
  143.             },
  144.         },
  145.     },
  146.     ActiveTool = "CustomShader3D1_1_1_1",
  147. }

User avatar
Chad
Fusionista
Posts: 925
Joined: Fri Aug 08, 2014 12:11 pm
Been thanked: 3 times

Re: CustomShader3D: Cg shader editing in your comp

Post #30 by Chad » Tue Jun 07, 2016 8:46 am

miaz3 wrote:Exemple, we can copy/paste some GLSL test from www.shadertoy.com.
And rocks on ?!


It works better than I thought it would. It never occurred to me to use GLSL code in 3CuS. At least on Nvidia cards it compiles just fine. :D This is actually news to me, I'm going to explore this more...

Spoiler:
Code: [Select all] [Expand/Collapse] [Download] (GLSL_and_HLSL.setting)
  1. {
  2.     Tools = ordered() {
  3.         CustomShader3D1_3 = Indicated.CustomShaderOperator3D {
  4.             CtrlWZoom = false,
  5.             Inputs = {
  6.                 ShaderTextInputs = Input { Value = "float blend;\n\n", },
  7.                 ShaderTextBody = Input { Value = "float4 Shade(inout FuFragment f)\r\n{\r\n\r\nfloat4 A = vec4(.2, .3, .4, 1);\r\n\r\nvec4 B = float4(.8, .0, .9, 1);\r\n\r\nreturn lerp(A, B, blend);\r\n\r\n}", },
  8.                 FloatGroup = Input { Value = 1, },
  9.                 MaterialID = Input { Value = 1, },
  10.                 blend = Input {
  11.                     CustomData = {
  12.                         Metadata = {
  13.                             Type = "Float",
  14.                             Set = "blend",
  15.                         },
  16.                     },
  17.                 },
  18.             },
  19.             ViewInfo = OperatorInfo { Pos = { 2310, 148.5, }, },
  20.             UserControls = ordered() {
  21.                 blend = {
  22.                     LINKID_DataType = "Number",
  23.                     INPID_InputControl = "SliderControl",
  24.                     IC_ControlPage = 0,
  25.                 },
  26.             },
  27.         },
  28.     },
  29.     ActiveTool = "CustomShader3D1_3",
  30. }




That means you can just copy/paste and have it run...

Shadertoy sample: https://www.shadertoy.com/view/ltfSzr

Verbatim copy/paste to 3CuS:
Spoiler:
Code: [Select all] [Expand/Collapse] [Download] (3CuS_Voronoise.setting)
  1. {
  2.     Tools = ordered() {
  3.         ChannelBoolean2 = MtlChanBool {
  4.             Inputs = {
  5.                 OperandAR = Input { Value = 28, },
  6.                 OperandBR = Input { Value = 30, },
  7.                 OperandAG = Input { Value = 4, },
  8.                 OperandAB = Input { Value = 5, },
  9.                 MaterialID = Input { Value = 4, },
  10.             },
  11.             ViewInfo = OperatorInfo { Pos = { 1485, 247.5, }, },
  12.         },
  13.         ChannelBoolean3 = MtlChanBool {
  14.             Inputs = {
  15.                 OperationR = Input { Value = 6, },
  16.                 OperandBR = Input { Value = 10, },
  17.                 BackgroundMaterial = Input {
  18.                     SourceOp = "ChannelBoolean2",
  19.                     Source = "MaterialOutput",
  20.                 },
  21.                 MaterialID = Input { Value = 5, },
  22.             },
  23.             ViewInfo = OperatorInfo { Pos = { 1485, 280.5, }, },
  24.         },
  25.         ChannelBoolean3_1 = MtlChanBool {
  26.             Inputs = {
  27.                 OperationR = Input { Value = 4, },
  28.                 OperandBR = Input { Value = 10, },
  29.                 BackgroundMaterial = Input {
  30.                     SourceOp = "ChannelBoolean3",
  31.                     Source = "MaterialOutput",
  32.                 },
  33.                 MaterialID = Input { Value = 5, },
  34.             },
  35.             ViewInfo = OperatorInfo { Pos = { 1485, 313.5, }, },
  36.         },
  37.         CustomShader3D_Voronoise = Indicated.CustomShaderOperator3D {
  38.             CtrlWZoom = false,
  39.             NameSet = true,
  40.             Inputs = {
  41.                 ShaderTextInputs = Input { Value = "FuFloat4 SmoothnessMtl;\nFuFloat4 IrregularityMtl;\nfloat irregular;\nfloat smoothness;\nfloat scale;\nfloat4x4 EyeToModel;\n\n", },
  42.                 ShaderTextBody = Input { Value = "vec2 rand2(vec2 p)\r\n{\r\n   vec2 q = vec2(dot(p,vec2(127.1,311.7)), \r\n        dot(p,vec2(269.5,183.3)));\r\n  return fract(sin(q)*43758.5453);\r\n}\r\n\r\nfloat rand(vec2 p)\r\n{\r\n    return fract(sin(dot(p,vec2(419.2,371.9))) * 833458.57832);\r\n}\r\n\r\nfloat iqnoise(in vec2 pos, float irregular, float smoothness)\r\n{\r\n  vec2 cell = floor(pos);\r\n vec2 cellOffset = fract(pos);\r\n\r\n   float sharpness = 1.0 + 63.0 * pow(1.0-smoothness, 4.0);\r\n    \r\n    float value = 0.0;\r\n  float accum = 0.0;\r\n  // Sample the surrounding cells, from -2 to +2\r\n  // This is necessary for the smoothing as well as the irregular grid.\r\n   for(int x=-2; x<=2; x++ )\r\n   for(int y=-2; y<=2; y++ )\r\n   {\r\n       vec2 samplePos = vec2(float(y), float(x));\r\n\r\n          // Center of the cell is not at the center of the block for irregular noise.\r\n        // Note that all the coordinates are in \"block\"-space, 0 is the current block, 1 is one block further, etc\r\n        vec2 center = rand2(cell + samplePos) * irregular;\r\n      float centerDistance = length(samplePos - cellOffset + center);\r\n\r\n     // High sharpness = Only extreme values = Hard borders = 64\r\n     // Low sharpness = No extreme values = Soft borders = 1\r\n     float sample =pow(1.0 - smoothstep(0.0, 1.414, centerDistance), sharpness);\r\n\r\n     // A different \"color\" (shade of gray) for each cell\r\n      float color = rand(cell + samplePos);\r\n       value += color * sample;\r\n        accum += sample;\r\n    }\r\n\r\n   return value/accum;\r\n}\r\n\r\n\r\n// Everything above this line is copied verbatim from https://www.shadertoy.com/view/ltfSzr\r\n\r\nfloat4 Shade(inout FuFragment f)\r\n{\r\n\r\nfloat4 ret = 1;\r\n\r\nfloat2 pos = f.TexCoord0.xy;\r\n\r\nret.rgb = iqnoise(pos*scale, irregular*IrregularityMtl.Shade(f), smoothness*SmoothnessMtl.Shade(f));  // .Shade(f) in this case returns a float4, but the .r is what's actually used.\r\n\r\nreturn ret;\r\n\r\n}", },
  43.                 RCGroup = Input { Value = 1, },
  44.                 RCMatrices = Input { Value = 16, },
  45.                 MaterialGroup = Input { Value = 1, },
  46.                 FloatGroup = Input { Value = 1, },
  47.                 MaterialID = Input { Value = 1, },
  48.                 irregular = Input {
  49.                     Value = 1,
  50.                     CustomData = {
  51.                         Metadata = {
  52.                             Type = "Float",
  53.                             Set = "irregular",
  54.                         },
  55.                     },
  56.                 },
  57.                 smoothness = Input {
  58.                     Value = 1,
  59.                     CustomData = {
  60.                         Metadata = {
  61.                             Type = "Float",
  62.                             Set = "smoothness",
  63.                         },
  64.                     },
  65.                 },
  66.                 SmoothnessMtl = Input {
  67.                     SourceOp = "ChannelBoolean3_1",
  68.                     Source = "MaterialOutput",
  69.                     CustomData = {
  70.                         Metadata = {
  71.                             Type = "Material",
  72.                             Set = "SmoothnessMtl",
  73.                         },
  74.                     },
  75.                 },
  76.                 IrregularityMtl = Input {
  77.                     SourceOp = "ChannelBoolean3_3",
  78.                     Source = "MaterialOutput",
  79.                     CustomData = {
  80.                         Metadata = {
  81.                             Type = "Material",
  82.                             Set = "IrregularityMtl",
  83.                         },
  84.                     },
  85.                 },
  86.                 scale = Input {
  87.                     Value = 64,
  88.                     CustomData = {
  89.                         Metadata = {
  90.                             Type = "Float",
  91.                             Set = "scale",
  92.                         },
  93.                     },
  94.                 },
  95.             },
  96.             ViewInfo = OperatorInfo {
  97.                 Pos = { 1485, 379.5, },
  98.                 Flags = {
  99.                     ShowPic = true,
  100.                 },
  101.             },
  102.             UserControls = ordered() {
  103.                 irregular = {
  104.                     LINKID_DataType = "Number",
  105.                     INPID_InputControl = "SliderControl",
  106.                     IC_ControlPage = 0,
  107.                 },
  108.                 smoothness = {
  109.                     LINKID_DataType = "Number",
  110.                     INPID_InputControl = "SliderControl",
  111.                     IC_ControlPage = 0,
  112.                 },
  113.                 SmoothnessMtl = {
  114.                     {
  115.                         LINKID_DataType = "MtlGraph3D",
  116.                     },
  117.                     {
  118.                         LINKID_DataType = "Image",
  119.                     },
  120.                     {
  121.                         LINKID_AllowedDataType = "Image",
  122.                     },
  123.                     {
  124.                         LINKID_AllowedDataType = "Mask",
  125.                     },
  126.                     INP_AcceptsGLImages = true,
  127.                     LINK_Main = 2,
  128.                     INP_AcceptsMasks = true,
  129.                     INPID_InputControl = "ImageControl",
  130.                     INP_Required = false,
  131.                     IC_ControlPage = 0,
  132.                 },
  133.                 IrregularityMtl = {
  134.                     {
  135.                         LINKID_DataType = "MtlGraph3D",
  136.                     },
  137.                     {
  138.                         LINKID_DataType = "Image",
  139.                     },
  140.                     {
  141.                         LINKID_AllowedDataType = "Image",
  142.                     },
  143.                     {
  144.                         LINKID_AllowedDataType = "Mask",
  145.                     },
  146.                     INP_AcceptsGLImages = true,
  147.                     LINK_Main = 3,
  148.                     INP_AcceptsMasks = true,
  149.                     INPID_InputControl = "ImageControl",
  150.                     INP_Required = false,
  151.                     IC_ControlPage = 0,
  152.                 },
  153.                 scale = {
  154.                     LINKID_DataType = "Number",
  155.                     INPID_InputControl = "SliderControl",
  156.                     IC_ControlPage = 0,
  157.                 },
  158.             },
  159.         },
  160.         ChannelBoolean3_3 = MtlChanBool {
  161.             Inputs = {
  162.                 OperationR = Input { Value = 4, },
  163.                 OperandBR = Input { Value = 10, },
  164.                 BackgroundMaterial = Input {
  165.                     SourceOp = "ChannelBoolean3_2",
  166.                     Source = "MaterialOutput",
  167.                 },
  168.                 MaterialID = Input { Value = 5, },
  169.             },
  170.             ViewInfo = OperatorInfo { Pos = { 1320, 379.5, }, },
  171.         },
  172.         ChannelBoolean3_2 = MtlChanBool {
  173.             Inputs = {
  174.                 OperationR = Input { Value = 6, },
  175.                 OperandBR = Input { Value = 10, },
  176.                 BackgroundMaterial = Input {
  177.                     SourceOp = "ChannelBoolean2_1",
  178.                     Source = "MaterialOutput",
  179.                 },
  180.                 MaterialID = Input { Value = 5, },
  181.             },
  182.             ViewInfo = OperatorInfo { Pos = { 1320, 346.5, }, },
  183.         },
  184.         ChannelBoolean2_1 = MtlChanBool {
  185.             Inputs = {
  186.                 OperandAR = Input { Value = 29, },
  187.                 OperandBR = Input { Value = 30, },
  188.                 OperandAG = Input { Value = 4, },
  189.                 OperandAB = Input { Value = 5, },
  190.                 MaterialID = Input { Value = 4, },
  191.             },
  192.             ViewInfo = OperatorInfo { Pos = { 1320, 313.5, }, },
  193.         },
  194.     },
  195. }


With some animated inputs and additional shader processing of the output:

Image
Last edited by Chad on Tue Jun 07, 2016 10:52 am, edited 1 time in total.

Who is online

Users browsing this forum: No registered users and 1 guest