Material for Gems, transparency? Custom Specular Highlight map?

I am aware of the technical difficulty of translucent material right now, and that’s why I’m here to ask if there would be a good way to fake the specularity, refraction and translucency of those gorgeous gems?

Would something like 2 meshes, one with translucency and refraction, one with transparency and specularity work?

And, is it possible to map a custom made texture for specular high light on an object? I don’t quite know how to describe it, but I think Bungie’s Destiny GDC presentation actually mentioned and showed the sample of their custom materials, which each one of them have a different kind of specular high light.

You can simulate your own lighting response entirely within the gem material, but it will not receive shadows from the environment or other gem objects. If that is not necessary then this should work well. There should also be no need to break the material up into refraction/specularity shaders.

For the refraction, you should be able to use the built in refraction. You just set the translucent material to use refraction with a number over 1.0. 1.0 would be no refraction, less than 1 would bend the refraction backwards and greater than 1 would give you the results you want.

If you want custom specularity, you just need to take the DotProduct of a Vector3 (aka, your user specified or BP-obtained lightvector) and ReflectionVectorWS node. Then do a Power with a ScalarParameter as the exponent. That will be your specular power. Probably need to clamp to 0-1 before the power so it doesn’t create another highlight on the opposite side of the mesh (negative times negative makes positive).

Alternatively, if you want to use a texture to define the specular, this is fairly easy to do. Make your texture. As a start, I suggest trying something with a few soft white spots near the center of the texture and the rest black. Then you need to take your fake light vector (use 0,0,-1 as a test top down light), subtract VertexNormalWS (or your normalmaptransformed into worldspace if you need to use one). Then Multiply 0.5 and then add 0.5, mask to RG, and use that as texture coordinates and you will have texture defined specular.

This will place a highlight on the back side of the mesh too, so you may need to mask that back-facing highlight using a direct lighting dot product. For that, you just do dotproduct of LightVector and Normal, clamp 0-1 and use that to mask the highlight.

That is beautiful, thanks a lot!

You are welcome. Out of curiosity, are your gems so large and protruding that it is important they refract the dynamically changing game scene? If not, I think you might get superior results instead making an opaque gem material and layering in the fake refraction of the scene using a locally captured static cubemap. You would fake the refraction by sampling the cubemap with reflection vector and doing your own refraction using the vertex normals or normal map. If that sounds like something you want to try also I can help but it will be a few steps.

I’m really just trying to mimic the visual of a gem, not necessarily to reflect the entire dynamic scene. What I try to do is making the gem look as valuable and real as possible so when it comes to chance for player to pick some up, they should know it’s worth it. Gems in Skyrim is nearly the visual quality I’m trying to mimic.

And yea I really like to know about using a cube map to fake refraction, may it cause you a bit time but I’ll consider myself owe you some. :smiley:

  1. place a SceneCaptureCube actor in your level near your gems. you may want to hide one gem, and then place the capture actor close(ish) to that gem and capture a bit of its neighbors if you want it to look like a dense cluster.

  2. In the content browser create a new Cube Render Target

  3. Go back to your SceneCaptureCube actor, and assign the target to the texturetarget slot.

4)Go back to the ContentBrowser, right click your render target and select “Create Static Texture”. Save the resulting asset.

  1. Now place this cubemap texture as a texturecube in your material. Place a CameraVectorWS node and hook that up the the UVs. You should now have a simple camera based cubemap projection (you may have to multiply it by 1,1,-1 if its flipped on Z).

  2. I am not entirely sure on the Fake refraction (been a while since I tried it), but try this:

a) take your normalmap, add a transform node set to transform from tangent to view.

b) multiply that by a small number, maybe make it a scalarparameter for better tweak iteration

c) add that small offset of the screenspace normalmap into the cameravector that goes into the cubemap UVs and you will have simulated refraction (maybe). 0 will be none, and positive or negative will flip the direction of refraction. I am not sure what will look right so just mess around with it. Let me know if it’s not working well. Maybe first try changing the normal transform to tangent->world since I am unsure about whether it should be view or worldspace there.

It’s partially working except the refraction part, it gives me that wavy feeling from the normal map, but it doesn’t necessarily refracts the cubemap.

Though, if the scalar value is big enough it definitely look like something is being refracted. VISUAL FIDELITY! YIEEEEE, :smiley:

Thank you for spending time help me, I really learnt a lot of useful stuff here!

Can you share a pic with results? I am just thinking about texutre for refraction too