Why is Shader Mixer inverting the Displacement Channel?!?

Denki GakaDenki Gaka Posts: 35
edited December 1969 in New Users

Hi,

I thought I was doing pretty good with the whole shader mixer beast, but when I applied a displacement image that had an obvious up and down with my new shader network, I quickly noticed it was inverted. So I spent hours stripping out parts to try and figure out what was happening. After four or five frustrating hours I finally tried just starting a new scene, making a 0.1 M sphere and applying a simple checkerboard displacement. Nothing else. I imported it into shader mixer and then reapplied it to the object without making a single modification and BOOM! -- inverted displacement.

I realize shader mixer can be a bit of a black art, but why is it screwing up its own imported network? Is this a bug? A known "feature"? Or am I really that clueless?!?

When I inverted the image map I was using, that fixed it in the reapplied texture, so obviously I could add some bricks to just invert my displacement maps, but that definitely feels like a band aid, not a real solution. Does this happen to anyone else? would anybody try it and see if it is just the universe picking on me, please? :-S

I am including four pictures that should show what is happening. The first is the original render with the default shader. The second is the imported and reapplied texture on the same sphere. The third is two identical spheres, one with the default shader and one with the shader mixer import applied (you can see they are exact inverses). The last is the shader network that I imported.

Thanks!

Inverted-Displacement-Problem_0002_DaZ-DefaulT-Shader.png
800 x 800 - 73K
Inverted-Displacement-Problem_0000_Overlayed-spheres.png
800 x 800 - 287K
Inverted-Displacement-Problem_0001_ReappLIED-SHADER-MIXER-IMPORT.png
800 x 800 - 290K
Inverted-Displacement-Problem_0003_DaZ-DefaulT-Shader.png
800 x 800 - 286K

Comments

  • ZarconDeeGrissomZarconDeeGrissom Posts: 5,412
    edited June 2014

    min/max? should min be (-) and max be (+)?

    At-least with the default surface tab in DS4.6 for both Bump and Displacement it is that way.
    (edit)
    "Preview" thing in the center of that schematic. Bottom two sliders.

    Inverted-Displacement-Problem_0002_DaZ-DefaulT-Shader_fix1.PNG
    800 x 800 - 67K
    Post edited by ZarconDeeGrissom on
  • kitakoredazkitakoredaz Posts: 3,526
    edited December 1969

    I beleive, it seems bug,,:roll:

    when I add new ds Default displacement,, it usually set min and max
    Min = min -0.1 , Max = max 0.1 as default.

    but when I import shader blick from the scene with displacement map,

    it seems Auto reverse as same as your pic,
    Min = max 0.1, Max = min -0.1
    when check default value, it seems change labell and apply inverse value,,

    after that, I apply the import shader blicks to current obj in the scene,
    it seems turn labell name again, and set value as same as before,,
    but, the effect seems reverse.

    and even though I inverse min, max value,
    the displacement strenghth seems work strange way.
    everry time, my obj strech hard,,

    (I set default camera, and do not touch anything, just export shader ,to shader mixer,
    and re-apply it again,with displacement map,
    the pic seems perfectly change siplacement strength too.)

    displacementstrength2.JPG
    970 x 643 - 81K
    mixerbug1.JPG
    1069 x 574 - 90K
  • kitakoredazkitakoredaz Posts: 3,526
    edited December 1969

    And,, even though I remove the ds default displacement blick (imported)
    and add new one, then apply property values (min, max, and image displacement strength)
    as same as default mat value (of the scene),
    then, re-apply it to the obj material in the scene,

    it seems perfectly wrong. I do not know, how to re-make same effect ^^;

    the mat preset is really simple one for daz default shader, I believe.
    I checked float or percent etc,, but I could not find where is problem,,

  • ZarconDeeGrissomZarconDeeGrissom Posts: 5,412
    edited June 2014

    wow. I figured I'd give it a guess. I don't know how many times I put in a Displacement map, and forget to move the slider from 0% up to 100% (In the simple tab-thing in Studio).

    I figured it may have been something like that. If the thing is swapping the (Sign-bit) all on it's own to give you a negative max and a positive min, then I would say It's more then just a bug. Someone else might spot something simple tho. That jumper-wire-mess-thing is way over my head.


    Or to quote John Sheppard from SGA,
    Oh, that's what you call a glitch, huh?
    McKay: Yes, well, you should know that, uh, I'll be giving Zelenka a stern talking to.

    Post edited by ZarconDeeGrissom on
  • BejaymacBejaymac Posts: 1,897
    edited June 2014

    The ShaderMixer algorithm that is used to mimic the default surface shader has a few bugs in it, which is why it's not advisable to use the "import from scene" function, only time I use it is to look at another ShaderMixer shader. Displacement min/max have been switched and relabeled so instead of negative disp you get positive and vice versa, reflections are also screwed in that any map is roughly 160 degrees off and doesn't have the correct "distortions".

    The bugs have been there since the SM first appeared in DS3, so don't go expecting them to be fixed, if you intend to use the SM then you need to learn to build from scratch.

    Post edited by Bejaymac on
  • kitakoredazkitakoredaz Posts: 3,526
    edited December 1969

    OK, I could find,,
    why it seems change displacement strongneth.and how to correct it,
    when simply import from the scene.

    when I import shader blicks from scene with displacement map, it set image Map blick, strength .
    as displacement strength value.

    I think it need to work,, but even though I delete the image Map blick then, set same value as displacement strength
    it can not work when apply the mix shader to the obj.

    (at least, even though I set same value of original, it can not work . about my case,
    original displacement strength= 3% (0.03) , then it stored as image Map blick "strength"
    which connected to DS Default Displacmenent blick.

    I can not find any problem about the blick, the 0.03 value should be multipled with the image color,
    then it need to work,, as displacement strenght, but it could not.

    then my solution is, just fix the value of image Map blick, to 100% or change type to color, and keep white.
    then use hidden strength value of "DS default Displacement."

    after that, exchange mix and max property name, and set value corectly.
    then apply it original obj.

    it keep same effect. as same as before.
    it seems correct way, to set displacment image and strength value?
    or is their more simple way?

    beforeandafter.JPG
    1149 x 556 - 58K
    after.JPG
    915 x 682 - 104K
    before.JPG
    957 x 810 - 128K
  • Richard HaseltineRichard Haseltine Posts: 102,718
    edited December 1969

    Please report these as bugs, by opening a Zendesk ticket for Technical Support.

  • Richard HaseltineRichard Haseltine Posts: 102,718
    edited June 2014

    OK, I could find,,
    why it seems change displacement strongneth.and how to correct it,
    when simply import from the scene.

    when I import shader blicks from scene with displacement map, it set image Map blick, strength .
    as displacement strength value.

    I think it need to work,, but even though I delete the image Map blick then, set same value as displacement strength
    it can not work when apply the mix shader to the obj.

    (at least, even though I set same value of original, it can not work . about my case,
    original displacement strength= 3% (0.03) , then it stored as image Map blick "strength"
    which connected to DS Default Displacmenent blick.

    I can not find any problem about the blick, the 0.03 value should be multipled with the image color,
    then it need to work,, as displacement strenght, but it could not.

    then my solution is, just fix the value of image Map blick, to 100% or change type to color, and keep white.
    then use hidden strength value of "DS default Displacement."

    after that, exchange mix and max property name, and set value corectly.
    then apply it original obj.

    it keep same effect. as same as before.
    it seems correct way, to set displacment image and strength value?
    or is their more simple way?

    Yes, I found this a problem with some store shaders made with SM. I fixed it, as I recall, in a more long-winded but flexible way by working out the neutral value (mid-grey only if min and max are opposite) and mixing the map with that colour using displacement strength as the alpha value.

    Post edited by Richard Haseltine on
  • kitakoredazkitakoredaz Posts: 3,526
    edited December 1969

    I fixed it, as I recall, in a more long-winded but flexible way by working out the neutral value (mid-grey only if min and max are opposite) and mixing the map with that colour using displacement strength as the alpha value.

    Ah,,displacement map color as zero (newtral)
    need to be newtral grey,, 128 128 128?

    so that just mulitple not work? I supposed so,,
    then understand it seems better,, to set more long winded but correct way,,

    usually in daz studio default shader, displacment strength controll with the displacement image map.
    but your suggestion way seems beyond my head scale even thoug I understand basic ^^;

    then sorry,, :coolmad:
    I refuse your suggestion to send bug report,(I hope OP or other guys send bug report,,)

    I have no skill to send good bug report with Correct English.
    I understand , my report often puzzle bug support mens I believe.:sick:

  • Richard HaseltineRichard Haseltine Posts: 102,718
    edited December 1969

    Ah,,displacement map color as zero (newtral)
    need to be newtral grey,, 128 128 128?

    No, neutral is mid grey only if Min = -Max. What I did, as i recall, was take Max-Min to get the extent of displacement, then divide -Min by that (with a check to make sure the extent wasn't zero, of course):

    neutral = - Min/(Max-Min)

  • kitakoredazkitakoredaz Posts: 3,526
    edited December 1969

    thank you, I got it now. ^^

  • Denki GakaDenki Gaka Posts: 35
    edited December 1969

    Wow! I shouldn't have been off reading the thread on the PC+ stuff.

    So if I am understanding correctly, I have two options:

    1. I can rebuild my entire tree from scratch so that I don't get the messed up code from the imported shader code. (I guess deleting the displacement blocks and reinserting them won't do it, right?)

    or

    2. I can process my displacement maps through a min max routine to make sure that they get output with the correct middle value of 128?

    The first one is obviously something I can do. It is only time. However, the second one confuses me a bit because the user can change the min and max values. That shouldn't change where the mid gray in the image would be...

    Ok. So I went and played after your helpful hints and here is what you led me to discover. It is simply a matter of bad labels in the control. It imports the values from the scene properly, but because the labels in the shader mixer brick are reversed, they go to the wrong places and act to invert the displacement. The solution was as simple as opening the properties for those controls and changing the names back to their correct names and then inputting the right values. Bingo! fixed.

    Thanks to everyone for helping!:cheese:

    Is there a way to change the title of the thread to show it is resolved?

    I am including a picture with the labels that need changed circled. I will post a bug report tomorrow in the hopes that someone will fix it eventually.

    Now if someone can just help me figure out what is going on with my hue shift code over in the nuts N Bolts forum. Maybe I posted it in the wrong place. it is called "Shader Mixer Hue Shift Parameter only works when you drag the slider" if anyone wants to see if they can solve that for me, too! ;-)

    Inverted-Displacement-Problem-Fixed.png
    800 x 800 - 88K
  • ZarconDeeGrissomZarconDeeGrissom Posts: 5,412
    edited June 2014

    Ah,,displacement map color as zero (newtral)
    need to be newtral grey,, 128 128 128?

    No, neutral is mid grey only if Min = -Max. What I did, as i recall, was take Max-Min to get the extent of displacement, then divide -Min by that (with a check to make sure the extent wasn't zero, of course):

    neutral = - Min/(Max-Min)


    "O" and from "Zero" to 255, the midle is 127 not 128, lol.
    Binary numbers not starting from, one.

    Post edited by ZarconDeeGrissom on
  • Richard HaseltineRichard Haseltine Posts: 102,718
    edited December 1969

    Ah,,displacement map color as zero (newtral)
    need to be newtral grey,, 128 128 128?

    No, neutral is mid grey only if Min = -Max. What I did, as i recall, was take Max-Min to get the extent of displacement, then divide -Min by that (with a check to make sure the extent wasn't zero, of course):

    neutral = - Min/(Max-Min)


    "O" and from "Zero" to 255, the midle is 127 not 128, lol.
    Binary numbers not starting from, one.

    Actually the mid value is [127.5,127.5,127.5] so both 127 and 128 are as close as possible - and 127.5 would usually round to 128. In any event, the displacement values floats from [0,1].

  • JaderailJaderail Posts: 0
    edited December 1969

    Ah,,displacement map color as zero (newtral)
    need to be newtral grey,, 128 128 128?

    No, neutral is mid grey only if Min = -Max. What I did, as i recall, was take Max-Min to get the extent of displacement, then divide -Min by that (with a check to make sure the extent wasn't zero, of course):

    neutral = - Min/(Max-Min)


    "O" and from "Zero" to 255, the midle is 127 not 128, lol.
    Binary numbers not starting from, one.

    Actually the mid value is [127.5,127.5,127.5] so both 127 and 128 are as close as possible - and 127.5 would usually round to 128. In any event, the displacement values floats from [0,1].For DAZ Studio 128,128,128 is default mid, I have tested this many times. It auto rounds up to 128 in all the versions from DS2 on up that I have tried.

  • ZarconDeeGrissomZarconDeeGrissom Posts: 5,412
    edited December 1969

    good point. 127.5 as mid point between the top 128 possibilities, and the lower 128 possibilities, of the 8bit variable.

    "O" that is interesting Jaderail, so the 8bit gray-scale is rounded out to a smaller scale-range. Out of curiosity, what is the finest resolution a bump/displacement map can have for increments (That I should waste my time working with for mu maps)? Increments of 4, 8, 16, other?

    the attached scale was done by subtracting 16s from 255 months ago. Is that scale to fine for a bump map?

    _ClrScl_sRGBfull004.png
    400 x 200 - 3K
  • JaderailJaderail Posts: 0
    edited December 1969

    Believe it or not but DAZ Studio and 3Delight does read each point from 0 to 255 very well. It will allow a very good Bump for example if your scale (gradient) is fine enough. Very smooth curves are possible.

  • ZarconDeeGrissomZarconDeeGrissom Posts: 5,412
    edited December 1969

    coolness. I was just thinking about malty-level cloth weaves this morning, Like them cool shirts that change color depending on how there flexed or the angle you look at the cloth. Good stuff to know, thanks.

  • Denki GakaDenki Gaka Posts: 35
    edited December 1969

    Since the incoming image range of values is converted to floating point values between 0-1, it can handle virtually any bit depth gradient. I have used it with 16-bit per pixel images (0-65535).

  • JaderailJaderail Posts: 0
    edited December 1969

    mccarlp said:
    Since the incoming image range of values is converted to floating point values between 0-1, it can handle virtually any bit depth gradient. I have used it with 16-bit per pixel images (0-65535).
    Oh yes it will handle high bit depths but hitting mid grey is a PITA then. Well not easy anyway.
  • jestmartjestmart Posts: 4,449
    edited December 1969

    Bump maps look okay at 8 bit grey scale but displacement maps are better at 16 bit. You can cheat when making a displacement by doing it at 8 bit then convert to 16 bit and apply averaging with a very low setting, most image programs should be able to do this.

  • ZarconDeeGrissomZarconDeeGrissom Posts: 5,412
    edited December 1969

    16 bit, now this is new. Last I checked BMP was only up to 24 bit (8red, 8green, 8blue) color depth.

    I was unaware of a 48bit (no compression) file format anywhere? or for that matter, a computer display, graphics card, etc.

    Where do I find such stuff, and a version of Ms Paint that can do that color depth, so I can make the maps pixel by pixel?

    Or are you talking about internal 3D-engine stuff?

  • jestmartjestmart Posts: 4,449
    edited December 1969

    BMP is 8 bit as it is 8 bits per red, green and blue. 16 bit TIFF files are what I use, the only thing is there are several variants of the TIFF format and not all of them work with Studio. I use Paint Shop Pros default TIFF variant. I believe GIMP is capable of creating 16 bit grey scale and it is free.

    http://www.gimp.org/

  • ZarconDeeGrissomZarconDeeGrissom Posts: 5,412
    edited June 2014

    gimp. I'll need to look at that again, only fussed with it for around a month (not decades).

    As for Tiff, lol. "O" that was back in the 80s, when computer graphics wasn't much to, well, green and black were the common colors. and sixteen color (not bit, colors) EGA, was something to brag about. Hay man, I have two shades of red, Starflight is really going to look good now! lol.

    looks like Tiff has finally got some of that "Thousands of Incompatible File Formats", fires contained, tho not quite under control or out.

    (edit)
    I had avoided TIFF, as only the program that saved the file was 100% guaranteed to be able to read it, on the very computer it was made on.

    Post edited by ZarconDeeGrissom on
  • jestmartjestmart Posts: 4,449
    edited December 1969

    OOPS! I got BMP and GIF confused, BMP is 24 bit COLOR depth and GIF is 8 bit.

Sign In or Register to comment.