Results 1 to 8 of 8

Thread: hard light ?

  1. #1
    Join Date
    Jan 2009
    Posts
    34

    Default hard light ?

    if a is (<or = too) 5 c=2(a)
    if a is > 5 1-c=2(1-a)(1-b)
    a and b are input textures c is the output.
    I am trying to replicate the hard light mix mode in photoshop using the nodes in mental mill.

    I am encountering problems when trying to connect some of the various nodes, mainly the less than or equal too type nodes. Their output will not connect to pretty much anything.

    Is this mix mode already available, and if not does anyone have suggestions for creating this network.

  2. #2
    Join Date
    Sep 2007
    Location
    San Francisco Bay Area
    Posts
    162

    Default

    Regarding the output of your "Math_color_less_than_or_equal" node, if you hover the mouse over the result box, the text in the application status line will change to show you the data type being output. In this case it will be a bool4.

    I'll try to wire up an example based upon your description.

  3. #3
    Join Date
    Sep 2007
    Location
    San Francisco Bay Area
    Posts
    162

    Default

    Attached is one way of doing this.

    It looks like you made some mistakes in your algorithm. 5 should be 0.5, and 2(a) should be 2(ab):

    if a is (<or = too) 5 c=2(a)
    if a is > 5 1-c=2(1-a)(1-b)
    I've seen it written in this C notation:
    Code:
    a <= 0.5   ?   2 * a * b  :  1 - ( 2 * (1 - a) * (1 - b) )
    In mental mill, I broke each bitmap into component colors to be processed separately. I created a Phenomenon to make the comparison of the float value against 0.5. I use Math_float_conditional to choose one result or another. The formulas are just multiplication, so there are several math_float_multiply nodes. Math_float_invert takes care of the 1-n operations. The two options are wired into the Conditional node.

    This Phenomenon is used once for each Red, Green, and Blue. The results are recombined into a color at the end with a Conversion_floats_to_color node.

    Finally, the whole works is wrapped up as a Phenomenon, so you can add it to your toolbox for future use.

    The shader is attached, along with a screen shot of the entire network. Take a look at the details and let me know if you have any questions.
    Attached Images Attached Images
    Attached Files Attached Files

  4. #4
    Join Date
    Dec 2008
    Posts
    12

    Default

    Of course you could always write it as a .msl file and use it that way rather than having to create it as a node graph. You could use any of the layer_ .msl files as a template.

    -Eric

    Edit: You can find math examples of the photoshop blends on site like here and here.
    Last edited by PiXeL_MoNKeY; April 18th, 2009 at 02:32.

  5. #5
    Join Date
    Sep 2007
    Location
    San Francisco Bay Area
    Posts
    162

    Default

    Hi Eric,

    I agree that custom MetaSL code is probably the quickest way to create math-based shaders.

    This is an option for Standard Edition users, but in the Artist Edition, there really isn't any way to add your own MetaSL code. (Since RBurke started this thread asking how to wire up the effect with nodes in a mill shader graph, that's the approach I took.)

  6. #6
    Join Date
    Jan 2009
    Posts
    34

    Default

    thank you so much, i had been stuck on this one for a few days, and i got a response right away. Mental mill is becoming more and more a part of my daily workflow, and allows me to greatly enhance the capabilities of maya's viewport.
    Thanks again, ill post what im going to be using this for, it has many applications.

  7. #7
    Join Date
    Mar 2009
    Location
    Frankfurt Germany
    Posts
    103

    Default

    re:many applications
    I must also say i am amazed about the dedication of the moderators of this forum! Thx so much!
    AND Mental Mill is absolutely superb! Ok my wishlist is full of suggestions but with what is available i am able to make Shaders! Not only for the viewport but also for rendering and for cgfx and even other plattforms too... WOW!
    And i can learn all this great stuff from the examples and the code you provide....
    It soooo much FUN!


    thx and keep up the good work

    Olaf

  8. #8
    Join Date
    Sep 2007
    Location
    San Francisco Bay Area
    Posts
    162

    Default

    Hah! Silly me.

    You can also just use the predefined node: Layer_hard_light.

    There is actually a "bug" in that this doesn't appear by default in the Layers toolbox folder. To find it, type "layer_h" in the treeview search window.

    It looks like the algorithm is slightly different than what you suggested, but it is a good example of creating the same effect in pure MetaSL code.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •