Jump to content
You must now use your email address to sign in [click for more info] ×

Math for converting float displacement texture to 16bit mid gray


Recommended Posts

Is there mathematical way in procedural texture plugin to convert float displacement out of zbrush to mid gray 16bit, or maybe a workflow in affinity photo?

Im thinking the scale of the object also matters on texture displacement amount from zbrush would that also be a problem.

Thanks 

Mariusz

 

Link to comment
Share on other sites

  • Staff

Hi @Barayase,

I'll try my best to help here.  Would you be referring to floating point displacement maps? As we can convert these to Gray/16 with no issue.  Whats thrown me is the reference to "mid grey".  Do you want to remap values to 0-1? As you could just normalise the RGB values.  Which would mean doing this in procedural texture, create one equation field targeting RGB and use:
norm(vec3(R,G,B))

If that doesn't give the results you are after, if you can give some more information on what you are trying to do, i can see if i can get some further information on this :) 

Link to comment
Share on other sites

Hi 

Yes basically remapping the 0-1 float values is what im after, im including the original displacement textures. I cant get equation to work it may be that the float texture has information in R channel only.

For texture work mid gray (value of .5) is mostly used with bump mapping anything above .5 value raises the surface anything below lowers it. Mid gray maps can also be used as displacement they aren't as accurate. They can be convenient because they can be stacked with overlay blending and just be more useful as a utility map.

Float maps 0-1 there is not much you can do with them except displacement. They are dependent more on the real world scale of your objection in the scene, you have to increase the value a lot sometimes to see anything more than black.

Sometimes i need a mid gray file for whatever texturing work which means baking a new version out in zbrush, big negative is this can take a really long time depending on how many maps there are and the size of them.

Thank you for the help so far. 

Mariusz

 

Disp 1001 16bit .5 mid gray.jpg

disp 1001 float 32bit.jpg

disp_original.zip

Link to comment
Share on other sites

(The 3D vector normalisation function suggested by @stokerg is not applicable to your problem.)

The linear floating point image contains signed values, with 0 representing no displacement. 
The required linear 16-bit integer image will contain unsigned values with 32,768 representing no displacement.

  1. Find the maximum absolute value in the floating point image so that the values can be normalised
  2. For each value: divide by maximum, add 1 and then divide by 2
  3. Convert the modified image to 16-bit integer format without a gamma transform

Regarding step 3: Affinity will apply a gamma transform to R, G and B values when converting from floating point to an integer format, which is not wanted for displacement data. Fortunately, Alpha and Spare Channels are converted linearly, so step 3 can be broken down as:

  1. flatten the floating point document to a single Pixel object
  2. duplicate an R, G or B channel to a Spare Channel
  3. convert the RGB/32 document to Grey/16 (the profile is irrelevant and will be discarded when exporting)
  4. load the Spare Channel into the Intensity channel of the Pixel object
  5. export to Grey/16 TIFF with no embedded profile.

Here is the result of that process applied to your EXR file (I approximated the maximum floating point value with 0.00257): disp 16.tiff

Link to comment
Share on other sites

Brilliant! Thank you this works great, can you tell me how you got maximum floating value whats your procedure.

Small tip ror anyone using maya, you can convert the mid gray map using maya math nodes and move mid gray value of .5 to 0 by using aiAdd node with color management off, set RGB value to -0.5 now you can add displacement and however many bump maps you have together. With this and above procedure this can save lots of bake time!

Thanks

Link to comment
Share on other sites

5 hours ago, Barayase said:

can you tell me how you got maximum floating value whats your procedure.

That was trial and error, unfortunately, so not very helpful for real world use.

The app's auto-levels function could have helped greatly, but it is too aggressive and produces clipping.

Also, I created a macro to do the whole job with the user only needing to manipulate a slider to adjust the white point. A bug in the app's macro system prevented this from being useful, otherwise I'd have posted it, but I have something in mind to try when I find time later today.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
×
×
  • Create New...

Important Information

Terms of Use | Privacy Policy | Guidelines | We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.