Jump to content

How to use ATTR_shiny_rat?


krogerfoot

Recommended Posts

Hi all,

 

I'm baffled again with a texture problem. When exporting from Blender, I often noticed that my objects were gleaming in the sun. Opening up the OBJ files with a text editor, I found that they were always exported with ATTR_diffuse_rgb, ATTR_emission_rgb, some other ATTRs (namely no_hard, no_cull, depth, blend, draw_enable, no_solid_camera, and shade_smooth), and always ATTR_shiny_rat 0.500.

 

I figured out that I could set the shiny_rat to 0, which took away the shininess, obviously (only recently did I realize I could just delete most of these ATTRs). 

 

My problem now is, I want to make parts of my scenery shiny, but now nothing I do with the shiny_rat seems to work. I've taken care to insert ATTR_shiny_rat immediately before the TRIS command, and have deleted every other ATTR that might seem to cancel out or affect the shiny_rat level, but nothing changes. Setting the shiny_rat to almost any number seems to have no effect.

 

I'm wondering if I've done something with my texture files that I shouldn't have. I understand shiny_rat gets its effect by using alpha channels in the png texture file. Is there some way to confirm that there is a usable alpha channel in my texture files?

 

 

Link to comment
Share on other sites

Actually, ATTR_shiny_rat, though it still works, it is a deprecated feature.  The modern method of making shiny parts of a model is by adding the text directive to the OBJ text file:

 

GLOBAL_specular 1.0

 

The line above can be added to the header of the object file, just below the TEXTURE entries.

 

What this line does though, is tell x-plane that the object also has either a normal map texture or a grayscale specular texture.   So when using the above directive, you should also have in the object file header a directive like so:

 

TEXTURE_NORMAL   SomeTextureName_NML.png

 

That directive will work for both RGB normal maps and grayscale specular maps.  X-Plane will simply look at the image and if its grayscale only, then it will only affect shininess.  If there is RGB information in the image, then that will affect the bump and the alpha channel will be used for the shininess/specular.  A "grayscale image" is a very specific image type in Photoshop/GIMP...not just an image that is gray or has been desaturated so you have to explicitly set your image type to grayscale if you want to control shininess only. (and not bump also)

 

Note that if you use a grayscale only image to control shininess, then that image should contain no alpha channel.  This trips up lots of folks and leads to weird things. Once you have those two lines in the header of the object file, then you simply use the grayscale UV image to control shininess.  white is fully shiny, black if fully dull and gray is "in the middle".

 

Below is an example of a grayscale specular image used on the F4 phantom.  You'll note the brightest color is essentailly a dark gray.  Basically this means there is no shiny parts at all on the F4.  The whiter the texture, the shinier the part.

 

TomK

post-5-0-11579500-1408296416_thumb.jpg

Edited by tkyler
  • Upvote 1
Link to comment
Share on other sites

Aha, thank you very much. If I understand correctly, then, adding the global specularity directive will result in X-plane reading the normal map textures for specularity information?

I've been advised that alpha channels in normal maps can cause problems in HDR, but obviously there needs to be an alpha channel for the directive to take effect, correct?

With regard to making only certain parts of the scenery shiny, this needs to be controlled with normal map then, I guess. Or does the modeler need to choose whether to have an RGB normal map or a grayscale specular map?

Thanks again for your help.

Link to comment
Share on other sites

Well we should be very careful about our terminology.   The term "normal map" inherently implies a "bump like" map, which is achieved using the RGB channels of the texture.  If you say "normal", then you automatically mean "bump".  Here is where things get interesting.  If x-plane uses the RGB channels of an image for bump effects, then that leaves the alpha channel of that same image (if it has one) free.  The alpha channel is simply a grayscale component of what is called a "RGBA" image and you can use the alpha channel of a "normal map" to control shininess if you choose.  What you get here then is "two for one".  You get both specular AND normal information in one image, saving some VRAM.  Most other programs might use a separate grayscale image for the specular and then yet another image for the normal map....thereby having to load up two images.  Why not use the same image for both???...well that is what x-plane does.   BUT.....lets say you didn't care about the "bump stuff"...you only want the "shininess" part. ...well, let me back up..... The real reason x-plane has two ways of affecting shininess is typically bump/normal maps only use a small percentage of their pixel area for actual bump effects....which wastes VRAM for the other pixels.  9 out of 10 times, what you really want is just the specular effect.  So Laminar said,  "OK, you can choose to use a "grayscale" image if you are only concerned about shininess only.

 

As far as the "alpha channel" funnies go....it only causes funnies if you have an alpha channel in the grayscale image.  If you have an alpha channel in an RGB image, then indeed that alpha channel will be used by x-plane for specular effects.  If the RGB image has NO alpha channel, then all you get is bump effects.  So as a artist you have 3 choices:

 

  1. Use a grayscale only image (never any alpha channel in grayscale).....this controls specular effects in combination with GLOBAL_specular 1.0
  2. Use a RGB image (no alpha channel) for bump effects only.  (no specular effects with this option...and therefore GLOBAL_specular 1.0 directive not needed)
  3. Use a RGBA image where the RGB part of the image controls bump effects...and the alpha channel is used to control specular effects.  Use this option when you want BOTH bump and specular effects on an object.  With this option you DO need the GLOBAL_specular 1.0 directive.

 

Note that the alpha channel of a RGBA image is just a grayscale image....so its possible to do a specular map as a grayscale image, and then later, if you want to add bump effects, simply paste the grayscale image into the alpha channel of your RGBA image...and then do your bump effects in the RGB channels.

 

TomK

 

Oh...and FWIW, the '1.0' part of GLOBAL_specular 1.0 simply means, "white pixels are as shiny as x-plane can make it".  You can lower this value to 0.8, or 0.3 or whatever in order to lower the overall effect on the object globally.  A value of zero will make the object wholly dull with no specular highlights at all.

Edited by tkyler
  • Upvote 1
Link to comment
Share on other sites

Okay, this is hugely useful, and the answers are pretty much what I hoped/expected they would be. Thanks very much. I do indeed want to preserve the bump-mapping aspect of the RGB normal map images I've been using.

post-8747-0-88838000-1408329777_thumb.pn

 

Being able to add specularity data on the alpha channel is going to open up some new opportunities. Thanks again for your patient and thorough explanations.

 

 

  • Upvote 1
Link to comment
Share on other sites

I followed the explanation here , helps alot.

But I have a couple questions:

 

1. can one implement it with .pol files and not just OBJ's ? (i.e. ground textures)

2. I tried to do it with LIT textures so HDR lights will also shine the building , didn't work ( in daytime it works ok)

I tried somthing like TEXTURE_NORMAL_LIT ... any ideas ?

 

That's how it looks with the sun:

 

14986537316_d342774276_o.pngCarenado_C172_1 by mtaxpfan, on Flickr

 

 

 

But when it's night it seems like HDR lights don't make this "shine" effect .

Edited by mtaxp
Link to comment
Share on other sites

LITs are not part of the specular pipeline no.  Just the "daytime" light source.  

 

Consult the file format specifications for which entities can accept what....however, I'm not sure how up-to-date it is.  It if were me, I'd certainly try the normal map effect on some items anyhow.

 

http://wiki.x-plane.com/Category:Scenery_File_Formats

Edited by tkyler
Link to comment
Share on other sites

  • 1 month later...

Hi Tom,

 

Sorry to resurrect an old thread but I am having trouble with the specular map.  You can see in the images below, that I am trying to have the brick be bumpy but not shiny at all.  The normal map is correct in the brick area in RGB channels, and I thought if I had all black in the alpha channel for that area i should get no shine at all, but what i do get is.... shinyness!  Pictures explain it better.  What am I doing wrong??  Thanks!

 

-Chris

 

fWMBef6.png

 

KbQd6bN.png

 

33H8yax.png

Edited by czoog
Link to comment
Share on other sites

  • 2 weeks later...

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
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...
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...