Created attachment 3363[details]
cubemap support for opengl2
Here's a patch that adds simple cubemap support for opengl2.
It still needs a lot of work, though. The patch is currently very ugly, and doesn't support things that it should.
Specifying cubemaps is currently very simplified. You create a text file in maps/<level name>/cubemaps.txt, and in that file is a line with a number indicating the number of cubemaps, then lines giving the coordinates of each. An example should be in the attachments.
The renderer then takes those, assigns a closest cubemap to each world surface, and renders those cubemaps.
Using the cubemaps while drawing world surfaces has been integrated into the specular lighting. If no specular texture has been specified for a surface, the shader assumes a specular reflectance at normal incidence of 0.04, and a gloss of 0.5. The gloss is set high so the effects are noticeable, but will probably be toned down in the final version.
Here's the current, non-exhaustive list of problems:
- Entities do not use cubemaps.
- Sunlight is not rendered within cubemaps.
- Cubemaps are not blended, resulting in visible seams when surface edges switch between cubemaps.
- Cubemaps cannot be turned off.
- External cubemaps are not supported.
Created attachment 3374[details]
cubemap support and more for opengl2, v2
So I should probably post something, or I'm never going to stop tweaking this thing.
So here's a v2 of the cubemap patch, only I've done a lot more than just cubemaps. I've been reading up on the presentations at SIGGRAPH, and implemented a bunch of things.
- Implemented more specular types. Here are the r_specularMapping settings:
1 - Blinn-Phong.
2 - Blinn-Phong with Fresnel.
3 - Cook-Torrance as done by Stephen McAuley - http://blog.selfshadow.com/publications/s2012-shading-course/mcauley/s2012_pbs_farcry3_notes_v2.pdf
4 - Neumann-Neumann as done by Yoshiharu Gotanda - http://research.tri-ace.com/Data/s2012_beyond_CourseNotes.pdf
5 - Cook-Torrance as done by Dimitar Lazarov - http://blog.selfshadow.com/publications/s2013-shading-course/lazarov/s2013_pbs_black_ops_2_notes.pdf
- Added EnvironmentBRDF() from http://blog.selfshadow.com/publications/s2013-shading-course/lazarov/s2013_pbs_black_ops_2_notes.pdf for modifying cube map reflections by glossiness.
- Sped up the lightall render path by making the fragment program work in tangent space instead of world space.
- Reduced number of GLSL shaders compiled by assuming that a normal map and specular map are always given. As a result, all surfaces have specular now, except in fast light mode.
- Tweaked default specular.
- Removed code to read cubemaps.txt, and instead parse the BSP's map entities. If a misc_cubemap is found, it'll use those, and if not, info_player_deathmatch locations will be used instead.
- Removed r_normalAmbient, and replaced with r_deluxeSpecular. I've noticed that specular using deluxemaps looks bad in a lot of circumstances, so r_deluxeSpecular allows you to adjust the specular hardness [0-1], or eliminate the specular altogether [0]. Defaults to 0.5.
- Slight speedup by simplifying the deluxemapping code. The previous code was too complex and did not noticeably improve the look.
- Added r_cubeMapping to turn cubemaps on and off.
- Some other things I've probably forgotten by now.
Created attachment 3384[details]
cubemap support and more for opengl2, v3
This will probably be the version I push to github, barring any serious problems.
New features:
-r_baseGloss and r_baseSpecular. These two cvars control the gloss and specular of surfaces that don't specify otherwise. They default to 0.3 and 0.04, respectively.
-r_specularIsMetallic. This cvar controls whether the specular texture is the specular reflectance at normal incidence (0), or if the red channel indicates metallicness (1). If r_specularIsMetallic is 1 and the red channel is 1, then the diffuse texture is used as specular reflectance at normal incidence, and the diffuse reflectance is set to 0.
-set the fragment program to use world space again, because lighting calculations weren't correct when the tangent space was non-orthogonal.
-added a simple occlusion hack for deluxe specular and cubemaps, to avoid odd brightness in dark areas of textures. This should probably be removed and replaced with a combination of the ssao and texture ao.
-all lit surfaces use cubemaps now, including models.
-some cleanup
Created attachment 3363 [details] cubemap support for opengl2 Here's a patch that adds simple cubemap support for opengl2. It still needs a lot of work, though. The patch is currently very ugly, and doesn't support things that it should. Specifying cubemaps is currently very simplified. You create a text file in maps/<level name>/cubemaps.txt, and in that file is a line with a number indicating the number of cubemaps, then lines giving the coordinates of each. An example should be in the attachments. The renderer then takes those, assigns a closest cubemap to each world surface, and renders those cubemaps. Using the cubemaps while drawing world surfaces has been integrated into the specular lighting. If no specular texture has been specified for a surface, the shader assumes a specular reflectance at normal incidence of 0.04, and a gloss of 0.5. The gloss is set high so the effects are noticeable, but will probably be toned down in the final version. Here's the current, non-exhaustive list of problems: - Entities do not use cubemaps. - Sunlight is not rendered within cubemaps. - Cubemaps are not blended, resulting in visible seams when surface edges switch between cubemaps. - Cubemaps cannot be turned off. - External cubemaps are not supported.
Created attachment 3364 [details] Example cubemaps for q3dm1
Created attachment 3384 [details] cubemap support and more for opengl2, v3 This will probably be the version I push to github, barring any serious problems. New features: -r_baseGloss and r_baseSpecular. These two cvars control the gloss and specular of surfaces that don't specify otherwise. They default to 0.3 and 0.04, respectively. -r_specularIsMetallic. This cvar controls whether the specular texture is the specular reflectance at normal incidence (0), or if the red channel indicates metallicness (1). If r_specularIsMetallic is 1 and the red channel is 1, then the diffuse texture is used as specular reflectance at normal incidence, and the diffuse reflectance is set to 0. -set the fragment program to use world space again, because lighting calculations weren't correct when the tangent space was non-orthogonal. -added a simple occlusion hack for deluxe specular and cubemaps, to avoid odd brightness in dark areas of textures. This should probably be removed and replaced with a combination of the ssao and texture ao. -all lit surfaces use cubemaps now, including models. -some cleanup