• Advertisement
Sign in to follow this  

Specular Cube Maps

This topic is 4911 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

I've heard that Cube Maps can be used not only for environment mapping, but also to implement specular lighting in objects. How exactly this works? I've searched in google, but the resources I found say you use the reflection vector to index the cube map, but they don't explain how to build the cube map. Can anyone explain this technique or better give some links about this subject? This is about specular mapping ONLY, I'm not asking about environment mapping. Thanks in advance.

Share this post


Link to post
Share on other sites
Advertisement
I´m not sure, but i think you could paint your specular maps in photoshop, just like a gloss map. more white areas correspond to a higher amount of specularity, and dark areas are less specular.

Share this post


Link to post
Share on other sites
I think you can just build a cube map of the surrounding scene and then use the reflection vector of your view vector (i.e. a unit vector pointing from the eye point to the point your shadind) to lookup into the cubemap. You can then modulate this cube map value using a specular/gloss map. Another way to do it would be just to render the lights as blurred spheres into a cubemap.

Share this post


Link to post
Share on other sites
@Gammastrahler: What you're saying is gloss map, using a 2D texture to define the "shininess" of the surface. I'm not talking about that.

@Monder: Rendering the surrounding scene is used for environment mapping. Yes, rendering the lights as spheres is closer to what I'm looking for. I've already done that and it looks like specular lighting, I'm just not sure if this is the standard approach.

Does anyone else has more info about this?

Share this post


Link to post
Share on other sites
Well if you look at the HL2 shading paper here it appears they're doing they specular pretty much the same way as I said (look at pages 34-37 for images of how they build up the specular component and 52 for the shader code they actually use to calculate it). They only thing they do different is they also modulate the looked up cube-map value by a fresnel value.

Share this post


Link to post
Share on other sites
Ok thanks, actually I used that very same paper to implement diffuse lighting, but I missed the part where they talker about speculars. If I understand correctly, the level designers select some key points for the engine to build cubemaps(by rendering the lights as spheres or stars or something), and then at rendering time, the engine selects the most appropriate cubemap for every surface, correct?

Share this post


Link to post
Share on other sites
Yeah that's pretty much it, the cube maps are built by the engine at some point (by typing buildcubemaps into the console actually) and saved into the map file.

As for how they distribute the cube map sample points around the HL2 SDK docs basically say you need to put them distributed evenly over and near any surfaces that have specular reflection I think.

The cube maps themselves aren't just renderings of the lights but of the entire scene surrounding the sample point, note how they cube map sampler in the pixel shader is refered to as an environment map.

Share this post


Link to post
Share on other sites
Thanks for all the help. I would just need one more tiny thing clarified:

Quote:

The cube maps themselves aren't just renderings of the lights but of the entire scene surrounding the sample point, note how they cube map sampler in the pixel shader is refered to as an environment map.


If they rendered in the cubemaps only the scene geometry,as you do normally when you render from eye's POV, they would have only environment mapping, not speculars. Do they render both the scene and the lights as glowing spheres or something?

Share this post


Link to post
Share on other sites
Nope they render the scene normally (Well I'm pretty sure they do).

If you think about specular highlights are just reflections of the surrounding scene. The thing that stops all your specular stuff looking like mirrors is the fresnel part which alters how much is reflected depending on the angle between the surface normal and the indcident ray (i.e. the view vector).

Share this post


Link to post
Share on other sites
Well, if you had just a sphere and a point light, with no geometry around them, the sphere wouldn't have any reflections on it, but it would have specular highlights, so they're not exactly the same thing. Anyway, thanks for the help, I will play around with those ideas and see what I can do with them.

Share this post


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

  • Advertisement