LogoLogo
简体中文
简体中文
  • 主页
  • 联系我们
  • 感谢名单
  • 维基101 - 如何开始?
    • 修改指南
      • 如何备份,解包和重新打包
      • 如何配置修改用一个工作环境
      • 修改工具
        • 如何使用RSPNVPK
        • 资源
          • 游戏目录
          • BSP
            • BSPSource
            • BSP Viewer
            • BSP2MAP
            • BSPZIP
            • EntEd
            • Entspy
            • Map Analyst
            • PackBsp
            • Pakrat
            • VBSP_h4xed
            • VIDE
            • VMEX
            • WinBSPC
            • WinBSPZip
          • Hammer
            • 位移Luxel密度
          • VTF & VMT
            • VTFEdit
            • Vtex
              • Vtex - 编译参数
              • Vtex - 疑难解答
  • 信息
    • 纹理
      • Valve纹理格式-VTF
        • 创建材质
        • 创建动画粒子
        • 修改动画粒子-Wanty的方法
      • Valve材质类型-VMT
      • 纹理和颜色
        • 颜色和纹理信息
      • 着色器
        • $basetexture
        • $color
        • $reflectivity
        • 材质标志
      • 反照率贴图
      • 凹凸贴图
        • $bumpmap
        • $ssbump
      • 立方环境贴图
      • 光照贴图
      • 矢量材质
      • 纹理映射
      • 内容丢失
      • 基础天空盒
        • 2D天空盒
        • 3D天空盒
    • 脚本
      • 关键值
        • Gameinfo.txt
        • 武器配置
      • VScript
    • 文件格式
      • NUT & GNUT-Squirrel游戏语言
      • PSD-Photoshop文档
      • TGA-Truevision图像文件
      • TXT-文本文件
      • VPK-Valve包文件
    • 文件位置
      • VPK
      • 武器
        • 武器模型
        • 武器脚本
        • 武器配置
      • 模型
        • 模型-天空背景
        • 铁驭
          • 模型-铁驭能力
          • 模型-铁驭武器
        • 泰坦
        • 模型-引导标志
        • 模型-容器
        • 模型- Fixtures
        • 模型-IMC基础
        • 模型-工业
        • 模型- 虎大前进基地_live_fire
        • 模型-NPC
        • 模型-边境防御
  • 修改
    • 武器
      • 自定义武器皮肤
        • 使用\应用自定义武器皮肤
          • VTF文件制作
        • 制作武器自定义皮肤
          • 2D图像线框渲染模式(Wireframe mode)
        • 武器自定义皮肤样例
      • 武器效果
      • 准星修改
        • 批量修改准星
        • 准星样例
      • 武器定位
      • 武器视野
      • 一键更换武器视野
      • 特殊/独特武器修改
        • 电能步枪-电弧枪
        • 电能步枪-蓄力颜色
        • LSTAR-蓄力颜色
    • 铁驭
      • 模型-铁驭类
    • 泰坦
      • 泰坦的穹顶护盾
      • 北极星
        • 线缆-钩爪和绊索陷阱
        • 电浆磁轨炮-蓄力特效
        • 北极星-重力特效
        • 北极星-铝热剂特效
      • 浪人
        • 剑封颜色
      • 军团
        • 强大火力-蓄力颜色
      • 离子
        • 镭射炮-蓄力颜色
        • 漩涡防护罩颜色
    • 地图
      • 地图-天空背景
      • 地图-立体地图
      • 战争游戏
        • 全息墙颜色
    • 用户界面
      • 游戏文本修改-r1_language
      • 游戏中
        • 计分板背景
      • 菜单
        • 暂停菜单模糊
        • 主菜单背景
        • 网路-菜单
        • 新闻和聚焦
        • 设置
          • 控制
          • 按键设置
    • 声音
      • 击杀音效
      • 大厅背景音乐
    • 杂项
      • 电缆-滑索
      • 马文机器人-胸部显示屏
      • 脉冲刀范围特效
      • 被声呐探测到的效果
      • 模型-炸蛛
      • 尼斯湖水怪模型
  • 脚本数据
    • 准星
    • 特效(FX)
    • 特效
      • 特效-铁驭
        • 特效-铁驭武器
          • 特效-突击步枪
          • 特效-冲锋枪
          • 特效-轻机枪
          • 特效-狙击步枪
          • 特效-散弹枪
          • 特效-榴弹发射器
          • 特效-副手武器和手枪
          • 特效-反泰坦武器
          • 特效-特殊武器
        • 特效-铁驭投掷物
          • 特效-电弧效果
          • 特效-飞火星
          • 特效-重力星
        • 特效-铁驭能力
      • 特效-泰坦
        • 特效-离子
        • 特效-强力
        • 特效-北极星
          • 特效-电浆轨道炮
          • 特效- Holo Railgun
          • 特效-毒蛇
        • 特效-帝王
          • 特效-Monarch Beam
        • 特效-浪人
        • 特效-烈焰
          • 特效-铝热剂发射器
          • 特效-Meteor First
          • 特效-火墙
        • 特效-军团
      • 特效-NPC和炮台
        • 特效-NPC
          • 特效-无人机
          • FX - Drone Cloak
          • FX - Drone Frag
          • FX - MRVN
          • FX - Mortar
          • FX - Holo Spectre
        • 特效-炮台
      • 特效-杂项和未知项
        • FX - Holo Map
        • FX - Beacon
        • FX - Skybox
          • FX - Skybox 1K
          • FX - Skybox Carrier
          • FX - Skybox Creature
          • FX - Skybox Nuke
          • FX - Skybox Station Traffic
        • FX - Skyway
        • FX - Dev
          • FX - Bug Repro
        • FX - Droppod
        • FX - Scan
      • 特效-原始数据
        • FX - EMP
        • FX - Env
        • FX - Grenade
        • FX - Harvester
          • FX - Coop Harvester FX
        • FX - HUD
          • FX - HUD AR FX
          • FX - HUD AR Impacts
          • FX - HUD AR Lines
          • FX - HUD AR Ordinance
          • FX - HUD AR Pings
          • FX - HUD AR Titandroppoint
        • FX - Impact
          • FX - Impact FX EXP Cutom
        • FX - Light
        • FX - Orbital Strike
        • FX - Projectile Plasma
        • FX - Reload
        • FX - Shell Eject
        • FX - Smoke
        • FX - Tracers
        • FX - Weapon
          • FX - Arc Cannon
          • FX - Dragonbreath
          • FX - Flamethrower
          • FX - Malta Gun
          • FX - Triple Threat
    • 声音
      • 声音-默认语音
      • 声音-铁驭
        • 铁驭武器
          • 突击步枪
          • 冲锋枪
          • 轻机枪
          • 狙击步枪
          • 散弹枪
          • 榴弹枪
          • 副手武器及手枪
          • 反泰坦武器
        • 铁驭投掷物
        • 铁驭能力
      • 声音-泰坦
        • 声音-离子
        • 声音-强力
        • 声音-北极星
        • 声音-帝王
        • 声音-浪人
        • 声音-烈焰
        • 声音-军团
      • 声音-无人机和NPC
        • 声音 -巨型炮塔
      • 声音-杂项和未知项
        • 声音-电弧炮
        • 声音-电弧枪
        • 声音- Flamethrower
        • 声音- Triplethreat
    • 图标和HUD
      • 菜单
        • 私房加载界面
        • 私人比赛
        • 计分板
  • 修改样例
    • 低配模式
    • 无HUD修改
  • 导出资源
    • 导出地图
    • 导出模型
    • 使用Legion的方式导出
  • 资源
    • 纹理库
Powered by GitBook
On this page
  • 立方环境贴图
  • 历史
  • 优势
  • 缺点
  • 应用
  • 稳定的镜面反射高光
  • 天空盒
  • 天光照明
  • 动态反射
  • 全局照明
  • 投影纹理
  • 存储器寻址
  • 相关

Was this helpful?

  1. 信息
  2. 纹理

立方环境贴图

Previous$ssbumpNext光照贴图

Last updated 3 years ago

Was this helpful?

立方环境贴图

In computer graphics, cube mapping is a method of environment mapping that uses the six faces of a cube as the map shape. The environment is projected onto the sides of a cube and stored as sic square textures, or unfolded into six regions of a single texture. The cube map is generated by first rendering the scene six times from a viewpoint, with the views defined by a 90 degree representing each cube face.

In the majority of cases, cube mapping is preferred over the older method of because it eliminates many of the problems that are inherent in sphere mapping such as image distortion, viewpoint dependency, and computational inefficiency. Also, cube mapping provides a much larger capacity to support of relative to sphere mapping because the combination of inefficiency and viewpoint dependency severely limits the ability of sphere mapping to be applied when there is a consistently changing viewpoint.

历史

Cube mapping was first proposed in 1986 by Ned Greene in his paper "Environment Mapping and Other Applications of World Projections", ten years after environment mapping was first put forward by Jim Blinn and Martin Newell. However, hardware limitations on the ability to access six texture images simultaneously made it infeasible to implement cube mapping without further technological developments. This problem was remedied in 1999 witht he release of the . Nvidia touted cube mapping in hardware as "a breakthrough image quality feature of GeForce 256 that ... will allow developers to create accurate, real-time reflections. Accelerated in hardware, cube environment mapping will free up the creativity of developers to use reflections and specular lighting effect to create interesting, immersive environment." Today, cube mapping is still used in a variety of graphical applications as a favored method of environment mapping.

优势

Cube mapping is preferred over other methods of environment mapping because of its relative simplicity. Also, cube mapping produces results that are similar to those obtained by , but is much more computationally efficient - the moderate reduction in quality is compensated for by large gains in efficiency.

Predating cube mapping, sphere mapping has many inherent flaws that made it impractical for most applications. Sphere mapping is view dependent meaning that a different texture is necessary for each viewpoint. Therefore, in applications where the viewpoint is mobile, it would be necessary to dynamically generate a new sphere mapping for each new viewpoint (or, to pre-generate a mapping for every viewpoint). Also, a texture mapped onto a sphere's surface must be stretched and compressed, and warping and distortion (particularly along the edge of the sphere) are direct consequence of this. Although these image flows can be reduced using certain tricks and technique like 'pre-stretching", this just adds another layer of complexity to sphere mapping.

Paraboloid mapping provides some improvement on the limitations of sphere mapping, however it requires two rendering passes in addition to special image warping operations and more involved computation.

Conversely, cube mapping requires only a single render pass, and due to its simple nature, is very easy for developers to comprehend and generate. Also, cube mapping uses the entire resolution of the texture image, compared to sphere and paraboloid mappings, which also allows it to use lower resolution images to achieve the same quality. Although handling the seams of the cube map is a problem, algorithms have been developed to handle seam behavior and result in a seamless reflection.

缺点

If a new object or new lighting is introduced into scene or if some object that is reflected in it is moving or changing some manner, then the reflection changed and the cube map must be re-rendered. When the cube map is affixed to an object that moves through the scene then the cube map must also be re-rendered from that new position.

应用

稳定的镜面反射高光

天光照明

Cube maps can be useful for modelling outdoor illumination accurately. Simply modelling sunlight as a single infinite light oversimplifies outdoor illumination and results in unrealistic lighting. Although plenty of light does come from the sun, the scattering of rays in the atmosphere causes the whole sky to act as a light source (often referred to as skylight illumination). However, by using a cube map the diffuse contribution from skylight illumination can be captured. Unlike environment maps where the reflection vector is used, this method accesses the cube map based on the surface normal vector to provide a fast approximation of the diffuse illumination from the skylight. The one downside to this method is that computing cube maps to properly represent a skylight is very complex; one recent process is computing the spherical harmonic basis that best represents the low frequency diffuse illumination fro the cube map. However, a considerable amount of research has been done to effectively model skylight illumination.

动态反射

Basic environment mapping uses a static cube map - although the object can be moved and distorted, the reflected environment stays consistent. However, a cube maps texture can be consistently updated to represent a dynamically changing environment (for example, trees swaying in the wind). A simple yet costly way to generate dynamic reflections, involves building the cube maps at runtime for every frame. Although this is far less efficient than static mapping because of additional rendering steps, it can still be performed at interactive rates.

Unfortunately, this technique does not scale well when multiple reflective objects are present. A unique dynamic environment map is usually required for each reflective object. Also, further complications are added if reflective objects can reflect each other - dynamic cube maps can be recursively generated approximating the effects normally generated using raytracing.

全局照明

投影纹理

存储器寻址

A cube texture indexes six textures maps from 0 to 5 in order Positive X, Negative X, Positive Y, Negative Y, Positive Z, Negative Z. The images are stored with the origin at the lower left of the image. The Positive X and Y faces must reverse the Z coordinate and the Negative Z face must negate the X coordinate. If given the face, and texture coordinates (u,v)(u, v)(u,v), the non-normalized vector (x,y,z)( x, y, z)(x,y,z) can be computed by the function:

void convert_cube_uv_to_xyz(int index, float u, float v, float *x, float *y, float *z)
{
  // convert range 0 to 1 to -1 to 1
  float uc = 2.0f * u - 1.0f;
  float vc = 2.0f * v - 1.0f;
  switch (index)
  {
    case 0: *x =  1.0f; *y =    vc; *z =   -uc; break;	// POSITIVE X
    case 1: *x = -1.0f; *y =    vc; *z =    uc; break;	// NEGATIVE X
    case 2: *x =    uc; *y =  1.0f; *z =   -vc; break;	// POSITIVE Y
    case 3: *x =    uc; *y = -1.0f; *z =    vc; break;	// NEGATIVE Y
    case 4: *x =    uc; *y =    vc; *z =  1.0f; break;	// POSITIVE Z
    case 5: *x =   -uc; *y =    vc; *z = -1.0f; break;	// NEGATIVE Z
  }
}

Likewise, a vector (x,y,z)( x, y, z)(x,y,z)can be converted to the face index and texture coordinates (u,v)(u, v)(u,v)with the function:

void convert_xyz_to_cube_uv(float x, float y, float z, int *index, float *u, float *v)
{
  float absX = fabs(x);
  float absY = fabs(y);
  float absZ = fabs(z);
  
  int isXPositive = x > 0 ? 1 : 0;
  int isYPositive = y > 0 ? 1 : 0;
  int isZPositive = z > 0 ? 1 : 0;
  
  float maxAxis, uc, vc;
  
  // POSITIVE X
  if (isXPositive && absX >= absY && absX >= absZ) {
    // u (0 to 1) goes from +z to -z
    // v (0 to 1) goes from -y to +y
    maxAxis = absX;
    uc = -z;
    vc = y;
    *index = 0;
  }
  // NEGATIVE X
  if (!isXPositive && absX >= absY && absX >= absZ) {
    // u (0 to 1) goes from -z to +z
    // v (0 to 1) goes from -y to +y
    maxAxis = absX;
    uc = z;
    vc = y;
    *index = 1;
  }
  // POSITIVE Y
  if (isYPositive && absY >= absX && absY >= absZ) {
    // u (0 to 1) goes from -x to +x
    // v (0 to 1) goes from +z to -z
    maxAxis = absY;
    uc = x;
    vc = -z;
    *index = 2;
  }
  // NEGATIVE Y
  if (!isYPositive && absY >= absX && absY >= absZ) {
    // u (0 to 1) goes from -x to +x
    // v (0 to 1) goes from -z to +z
    maxAxis = absY;
    uc = x;
    vc = z;
    *index = 3;
  }
  // POSITIVE Z
  if (isZPositive && absZ >= absX && absZ >= absY) {
    // u (0 to 1) goes from -x to +x
    // v (0 to 1) goes from -y to +y
    maxAxis = absZ;
    uc = x;
    vc = y;
    *index = 4;
  }
  // NEGATIVE Z
  if (!isZPositive && absZ >= absX && absZ >= absY) {
    // u (0 to 1) goes from +x to -x
    // v (0 to 1) goes from -y to +y
    maxAxis = absZ;
    uc = -x;
    vc = y;
    *index = 5;
  }

  // Convert range from -1 to 1 to 0 to 1
  *u = 0.5f * (uc / maxAxis + 1.0f);
  *v = 0.5f * (vc / maxAxis + 1.0f);
}

相关

(CAD) programs use specular highlights as visual cues to convey a sense of surface curvature when rendering 3D objects. However, many CAD programs exhibit problems in sampling specular highlights because the specular lighting computations are only performed at the vertices of the mesh used to represent the object, and interpolation is used to estimate lighting across the surface of the object. Problems occur when the mesh vertices are not dense enough, resulting in insufficient sampling of the specular lighting. This in turn results in highlights with brightness proportionate to the distance from mesh vertices, ultimately compromising the visual cues that indicate curvature. Unfortunately, this problem cannot be solved simply by creating a denser mesh, as this can greatly reduce the efficiency of object rendering.

Cube maps provide a fairly straightforward and efficient solution to rendering stable specular highlights. Multiple specular highlights can be encoded into a cube map texture, which can be accesses by across the surface's to supply coordinates. Relative to computing lighting at individual vertices, this method provides cleaner results that more accurately represent curvature. Another advantage to this method is that it scales well, as additional specular highlights can be encoded into the texture at no increase in the cost of rendering. However, this approach is limited in that the light sources must be either distant or infinite lights, although fortunately this is usually the case in CAD programs.

Perhaps the most advanced application of cube mapping is to create pre-rendered panoramic which are then rendered by the graphical engine as faces of a cube at practically infinite distance with the view point located in the center of the cube. The perspective projection of the cube faces done by the graphics engine undoes the effects of projecting the environment to create a cube map, so that the observer experiences an illusion of being surrounded by the scene which was used to generate the . This technique has found a widespread use in video games since it allows designers to add complex (albeit not explorable) environments to a game at almost no performance cost.

An algorithm for computation at interactive rates using a cube-map data structure, was presented at 2002.

Another application which found widespread use in video games is. It relies on cube maps to project images of an environment onto the surrounding scene; for example, a point light source is tied to a cube map which is a panoramic image shot from inside a lantern cage or a window frame through which the light is filtering. This enables a game developer to achieve realistic lighting without having to complicate the scene geometry or resort to expensive real-time computations.

A large set of free cube maps for experimentation:

Mark VandeWettering took famous self-portrait and reversed the mapping to obtain these cube map images: , , , , , []. Here is a demo using these images (best viewed in wide browser window, and may need to refresh page to view demo):

You can also convert other environmental projections into a cube map (e.g. )

Source: Reference:

Fernando, R. & Kilgard M. J. (2003). The CG Tutorial: The Definitive Guide to Programmable Real-Time Graphics. (1st ed.). Addison-Wesley Longman Publishing Co., Inc. Boston, MA, USA. Chapter 7: Environment Mapping Techniques

Greene, N (1986). "Environment mapping and other applications of world projections". IEEE Comput. Graph. Appl. 6 (11): 21–29. :.

Nvidia, Jan 2000. Technical Brief: 2008-10-04 at the

view frustum
sphere mapping
real-time rendering
reflections
Nvidia GeForce 256
ray tracing
Computer-aided design
interpolating
reflection vector
天空盒
sky images
skybox
global illumination
ICCVG
projective texture mapping
shadow volume
http://www.humus.name/index.php?page=Textures
M. C. Escher's
Hand with Reflecting Sphere
left
right
up
down
back
front
permanent dead link
three.js
https://web.archive.org/web/20140519021736/http://threejs.org/examples/webgl_materials_cubemap_escher.html
from equirectangular projection to cube map
https://en.wikipedia.org/wiki/Cube_mapping
^
doi
10.1109/MCG.1986.276658
^
Perfect Reflections and Specular Lighting Effects With Cube Environment Mapping
Archived
Wayback Machine
^
https://msdn.microsoft.com/en-us/library/windows/desktop/ff476906(v=vs.85).aspx
^
http://www.nvidia.com/object/cube_map_ogl_tutorial.html
^
Example of a texture that can be mapped to the faces of a cubic skybox, with faces labelled
Cube-mapped reflections in action
This illustration shows how a cube map is indexed and addressed.