In the past I've usually just made the specular colour a really strong colour that's fairly opposite the diffuse colour of the material. So for a red material, I'd use a strong bright green highlight. Also using very saturated colours seems to help.
Beyond that you could try using bright, multi-coloured environment reflection maps.
Also helps to read up on "why" this effect occurs, so you can better simulate it when you have an understanding of what's happening with the light in the real world.
This looked like a fun exercise, so I did up a quick HLSL thing. It's not perfect, but it does the main job of hue shifting by view incidence:
float3 k = normalize(float3(1,1,1));
float t = dot(N, V) * 3.142 * 2;
float3 v = C.xyz;
C.xyz = v * cos(t) + cross(k, v) * sin(t) + k * dot(k, v) * (1 - cos(t)); //Rodrigues' Rotation Formula ftw
//credit to Vailias for turning me onto the Formula a couple months back :D
I'll try and do up a UDK node network when I'm back from lunch
the reason I used fresnel nodes instead of a colored specular was because the fresnel nodes react to camera angle the way real iridescence works rather than a static color regardless of viewing angle. The fresnel is computationally heavy and I really just did this to see if it could be done accurately rather than making something that could be used heavily in a game. If I was going to make an army of japanese beetles for a game I would probably just use a colored specular map - they do work, but like most specular maps in udk, you have to multiply them for them to be strong enough.
Thanks for the feedback all, and I look forward to learning about HLSL when I have more time.
OH btw LoTekk and others, here Have some Material Functions.
I'm building a library of these things, and will eventually be providing documentation. I have a few more things in the works to add.
However a material function version of Rodriques' rotation function is in there as "Vailias_Vector_Rotation" (everything is prefixed with my name and in a Vailias_Utils section of the function library. Included in the pack are a controllable fresnel, a minnaert shading model, a normalized gaussian function.. which I need to double check as being accurate, a per pixel reflection vector generator.. since UDK's reflection vector is per vertex, a SelfShadowing bump offset function.. and a vector reflector.. ie it takes two vectors, and reflects one about the other. Anyway dig in. It will get its own thread later.
also:
lol here's another version.. this one is a bit math heavy due to how I made the banding. It would likely be lighter just to do a gradient ramping thing like that one thread from a while back, but I like the control and effect I get with this one.
All images here are either different angles of the same setting or a tweak to a parameter or two in the Material instance.
The banding could be done differently, frankly using a ramp texture sampled with the dot product would likely be one of the cheapest options. The key to the look, In my opinion, is the color-shifted environment map which is simple to do really. Just a cubemap lookup, plugged into a desaturation node, with the specular color map as the percentage, then overlay the desaturated cube on the spec color map. 2 node setup now that we have material functions.
Ok, I think I've come up with a more finalized result. I ended up borrowing from both of your material setups and put it together as a modified phong.
Here's what I came up with:
Replies
http://www.pestcontrolcanada.com/Questions/iridescent%20beetle.jpg
In the past I've usually just made the specular colour a really strong colour that's fairly opposite the diffuse colour of the material. So for a red material, I'd use a strong bright green highlight. Also using very saturated colours seems to help.
Beyond that you could try using bright, multi-coloured environment reflection maps.
http://en.wikipedia.org/wiki/Iridescence
Also helps to read up on "why" this effect occurs, so you can better simulate it when you have an understanding of what's happening with the light in the real world.
First off, I tried to emulate the kind of iridescence of this beetle:
I think I've been able to recreate the general behavior of the specular color based on viewer angle with a fair bit of accuracy.
Screenshot:
Material Editor:
Specular Network:
All in all this was a pretty fun project.
I hope this helps.
I'll try and do up a UDK node network when I'm back from lunch
^I don't think so. I never got any results with colored gloss.
Thanks for the feedback all, and I look forward to learning about HLSL when I have more time.
Kept getting hung up on the sin/cos input. Docs say it takes radians, but it doesn't actually. 1 = 360 degrees = 6.2~~~ radians. -_-
Anyway, that's a node translation of Rodrigues' Rotation Formula.
[edit]
I forgot to take the multiply node out before, so I've swapped it out for a power node (to control hue shift falloff).
[/edit]
Thanks a ton, this looks way lighter on overhead too.
I'm building a library of these things, and will eventually be providing documentation. I have a few more things in the works to add.
However a material function version of Rodriques' rotation function is in there as "Vailias_Vector_Rotation" (everything is prefixed with my name and in a Vailias_Utils section of the function library. Included in the pack are a controllable fresnel, a minnaert shading model, a normalized gaussian function.. which I need to double check as being accurate, a per pixel reflection vector generator.. since UDK's reflection vector is per vertex, a SelfShadowing bump offset function.. and a vector reflector.. ie it takes two vectors, and reflects one about the other. Anyway dig in. It will get its own thread later.
also:
lol here's another version.. this one is a bit math heavy due to how I made the banding. It would likely be lighter just to do a gradient ramping thing like that one thread from a while back, but I like the control and effect I get with this one.
All images here are either different angles of the same setting or a tweak to a parameter or two in the Material instance.
The banding could be done differently, frankly using a ramp texture sampled with the dot product would likely be one of the cheapest options. The key to the look, In my opinion, is the color-shifted environment map which is simple to do really. Just a cubemap lookup, plugged into a desaturation node, with the specular color map as the percentage, then overlay the desaturated cube on the spec color map. 2 node setup now that we have material functions.
(where's that 3D math video series?! )
Here's what I came up with:
http://dl.dropbox.com/u/22781761/3dviewer/flyinginsect/WebPlayer.html
This is not a realistic effect but in a limited mobile game may be a solution.
Yes, but you can get the same result by Multiplying the the two together and then multiplying it all by 2.
The difference is extremely minor, I still haven't come across anything that makes those extra 10-12 instructions worth it.
Haha, no way! I have exactly the same setup in my material :P