Jump to content
  • Advertisement
Sign in to follow this  
Spa8nky

What environment texture can I use to make a chrome surface with a reflective shader?

This topic is 2720 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

[font=arial, verdana, tahoma, sans-serif][size=2]I've formatted a reflective metal shader for XNA from the NVIDIA Shader Library. The problem is that although the environment texture does give the impression of a chrome material, there is too much going on in the reflection:


Chrome.jpg[/font]

What environment texture can I use to give a smooth silvery chrome effect without all the extra picture information?

Share this post


Link to post
Share on other sites
Advertisement
How about:
- Turning the existing nVidia to Grayscale + blurring it?
- Look for a "chrome reflection" map on the internet?
- Or draw a gray/blueish texture yourself?
- Or let the videocard make one cubeMap each cycle (inside the object, or nearby the camera)
- And use some extra shader tricks: Fresnel / specular highlights?

The green stuff in the nVidia room indeed makes the reflection not really universal. One trick is to update the cubeMap so you always have proper reflection data. However, it will cost. In this simple scene you can easily render hundreds, if not thousands of cubeMaps, but when it gets a little bit more complex... I always render 1 cubeMap nearby the camera and apply it on all reflective objects. Since cubeMaps aren't really accurate, I only use them for glossy reflections. Water or mirrors use a mirrored texture, a different technique.

Making chrome is an old effect though, you don't nessesarely need dynamic cubeMaps and such. Back in the old days, you would draw a simple "sphere map". Which is just a (tiled) 2D texture with gray and blueish streaks. Eventually you can draw the environment slightly into it. For outdoor scenes, make the upper part the sky color, the lower part would be the ground (green or brownish). Keep it saturated for chrome though, only the intense skycolor should be really noticeable. You can use "sphere mapping". Pretty similar to cubeMapping, but useable with a simple 2D texture (or 2 2D textures). It has been million years since I used it, but there should be examples. Otherwise, you can still modify the nVidia cubeMap of course.

Here is an idea to make your cubeMap or sphereMap texture multifunctional:
- Draw a grayscale reflection texture
- Depending on the location or day/night / weather, define a floor, mid and sky color.
- A shader applies these 3 colors, depending on the UV colors. The higher parts mix multiply with the skycolor while the lower parts of the texture mix with the floor.
- Depending on the material, apply contrast and saturation(grayscaling). Chrome has a pretty high saturation value (thus less colored), normal or somewhat low contrast (higher contrast makes the darker parts of the texture invisible)

This way you can use the same reflection texture whole day long, in varying situations, and for multiple types of materials. You can do the saturation/contrast technique also for dynamic cubeMaps by the way.



Last but not least, your scene is only reflecting isn't it? Have a look at some Fresnel shader demo's. You can apply a (simplified) Fresnel term. This basically makes the steeper angles more reflective than the ones that are facing straight towards you. In other words, the edges of a sphere would reflect more than the center when looking at it. You can combine this with a high-frequency (detail) normalMap that is tiled a lot of times. When you are close enough, you could see the "brushed metal" pattern.

Good luck

Share this post


Link to post
Share on other sites
Do you know any tricks to draw reflection of real objects (as opposed to environment map) in scene on a surface? I.e., on the mirror like cube shown by the OP?

Other than ray tracing, the only method I am aware of is to draw the entire scene geometry (after applying reflection transform) again for each side of the cube and use stencil buffer to limit the area. Other than being expensive, it doesn't work on non-planar surfaces.



How about:
- Turning the existing nVidia to Grayscale + blurring it?
- Look for a "chrome reflection" map on the internet?
- Or draw a gray/blueish texture yourself?
- Or let the videocard make one cubeMap each cycle (inside the object, or nearby the camera)
- And use some extra shader tricks: Fresnel / specular highlights?

The green stuff in the nVidia room indeed makes the reflection not really universal. One trick is to update the cubeMap so you always have proper reflection data. However, it will cost. In this simple scene you can easily render hundreds, if not thousands of cubeMaps, but when it gets a little bit more complex... I always render 1 cubeMap nearby the camera and apply it on all reflective objects. Since cubeMaps aren't really accurate, I only use them for glossy reflections. Water or mirrors use a mirrored texture, a different technique.

Making chrome is an old effect though, you don't nessesarely need dynamic cubeMaps and such. Back in the old days, you would draw a simple "sphere map". Which is just a (tiled) 2D texture with gray and blueish streaks. Eventually you can draw the environment slightly into it. For outdoor scenes, make the upper part the sky color, the lower part would be the ground (green or brownish). Keep it saturated for chrome though, only the intense skycolor should be really noticeable. You can use "sphere mapping". Pretty similar to cubeMapping, but useable with a simple 2D texture (or 2 2D textures). It has been million years since I used it, but there should be examples. Otherwise, you can still modify the nVidia cubeMap of course.

Here is an idea to make your cubeMap or sphereMap texture multifunctional:
- Draw a grayscale reflection texture
- Depending on the location or day/night / weather, define a floor, mid and sky color.
- A shader applies these 3 colors, depending on the UV colors. The higher parts mix multiply with the skycolor while the lower parts of the texture mix with the floor.
- Depending on the material, apply contrast and saturation(grayscaling). Chrome has a pretty high saturation value (thus less colored), normal or somewhat low contrast (higher contrast makes the darker parts of the texture invisible)

This way you can use the same reflection texture whole day long, in varying situations, and for multiple types of materials. You can do the saturation/contrast technique also for dynamic cubeMaps by the way.



Last but not least, your scene is only reflecting isn't it? Have a look at some Fresnel shader demo's. You can apply a (simplified) Fresnel term. This basically makes the steeper angles more reflective than the ones that are facing straight towards you. In other words, the edges of a sphere would reflect more than the center when looking at it. You can combine this with a high-frequency (detail) normalMap that is tiled a lot of times. When you are close enough, you could see the "brushed metal" pattern.

Good luck

Share this post


Link to post
Share on other sites
@RumbleWell CubeMaps will never be 100% accurate, but that doesn't really matter as long as you use it for local reflections only, glossy surfaces, or organic shapes where it's hard to tell if the reflection is correct anyway. But when talking about mirrors, mirroring the entire scene or using raycasting are the only real correct solutions, as far as I know.

However.... you can get quite cool results with 3D textures as well. I'm warning you though, this is very advanced stuff, and I didn't try it myself yet. I'm busy with realtime Global Illumination and trying to use 3D textures. Somewhat similar to Crytek's "Light Propagating Volume" technique. The PDF should be out there when you type Crytek and LPV or something. To put it short, this technique approximates G.I. by rendering indirect light (light bounced off by surfaces) into a 3D texture. Then this light is spread all over the 3D texture by moving it to neighbour cells. In the end, given a pixel world position, you can read the incoming light at any point (well, at least in an area around the camera). By default, this is way from accurate though. But with some tricks you can generate a more accurate grid for glossy reflections nearby the camera.

In case you are looking for real mirrors or water, this is probably not the solution you are looking for. But just wanted to show another method. In theory, if the detail is high enough, you could get pretty nice reflections on any object. Performance and memory is (still) limiting this though. Anyway, Youtube for some Crytek "Glossy reflections" and judge for yourself.

Rick

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!