JP7851339B2 - Image processing program, image processing system, image processing method, and image processing apparatus. - Google Patents
Image processing program, image processing system, image processing method, and image processing apparatus.Info
- Publication number
- JP7851339B2 JP7851339B2 JP2024011581A JP2024011581A JP7851339B2 JP 7851339 B2 JP7851339 B2 JP 7851339B2 JP 2024011581 A JP2024011581 A JP 2024011581A JP 2024011581 A JP2024011581 A JP 2024011581A JP 7851339 B2 JP7851339 B2 JP 7851339B2
- Authority
- JP
- Japan
- Prior art keywords
- color
- reflection
- pixel
- ray
- depth
- Prior art date
- Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
- Active
Links
Landscapes
- Image Generation (AREA)
- Processing Or Creating Images (AREA)
Description
本発明は、描画された画像に基づいて反射を表現することが可能な画像処理プログラム、画像処理システム、画像処理方法、および画像処理装置に関する。 This invention relates to an image processing program, an image processing system, an image processing method, and an image processing apparatus capable of representing reflections based on a drawn image.
従来より、描画された画像に対する処理を行うことで反射を表現する方法がある(例えば、非特許文献1)。 Conventionally, there are methods for representing reflection by processing the drawn image (for example, Non-Patent Document 1).
上記従来技術では、オブジェクトの画面奥方向に存在するオブジェクトからの映り込みを生成できない場合がある。 The conventional techniques described above may not be able to generate reflections from objects located in the background of the screen.
それ故、本発明の目的は、オブジェクトの奥方向に存在するオブジェクトからの映り込みを生成することが可能な画像処理プログラム、画像処理システム、画像処理方法、および画像処理装置を提供することである。 Therefore, the object of the present invention is to provide an image processing program, an image processing system, an image processing method, and an image processing apparatus capable of generating reflections from objects located behind an object.
上記の課題を解決すべく、本発明は、以下の構成を採用した。 To solve the above problems, the present invention employs the following configuration.
(第1の構成)
第1の構成の画像処理プログラムは、情報処理装置のコンピュータに、仮想空間内のオブジェクトのうち、第1の種類を除くオブジェクトについて、第1のデプスバッファを用いて第1のデプステストと当該第1のデプスバッファの更新を行わせ、前記第1のデプステストの結果に基づいてフレームバッファに描画を行わせ、前記第1の種類のオブジェクトについて、フレームバッファへの描画を行わずにレンダリングした画像をテクスチャとして設定した平面オブジェクトを前記仮想空間内の前記第1のオブジェクトの位置に配置させる。画像処理プログラムは、前記コンピュータに、描画が行われた前記フレームバッファの画素ごとに、当該画素を着目画素として、前記第1のデプスバッファのデプスに基づいて、仮想カメラから前記着目画素に対応する前記仮想空間内の位置に向かう方向を入射方向、当該位置を反射位置として反射するレイの方向をレイトレース方向として算出させ、当該レイトレース方向に沿って当該レイをトレースさせ、前記第1のデプスバッファに基づいて、前記レイが前記仮想空間内においてオブジェクトに衝突する衝突位置を判定させ、前記レイのトレース距離が第1の距離以内となる範囲内において前記衝突位置が判定された場合に、当該衝突位置に対応する前記フレームバッファ内の画素の色に基づいた色を、前記着目画素の色に加えさせる映り込みの色として決定させ、前記レイが前記平面オブジェクトと交差する場合に、交差位置の前記テクスチャの色に基づいて前記着目画素の色にさらに加えさせる映り込みの色として決定させる。画像処理プログラムは、前記コンピュータに、前記フレームバッファに前記映り込みの色を反映させ、前記映り込みの色を反映させた後に、前記第1の種類のオブジェクトをフレームバッファに描画させる。
(First structure)
The first configuration image processing program causes the computer of the information processing device to perform a first depth test and update the first depth buffer using the first depth buffer for objects in the virtual space, excluding objects of the first type, to draw to the frame buffer based on the results of the first depth test, and for objects of the first type, to place a planar object with the rendered image set as a texture without drawing to the frame buffer at the position of the first object in the virtual space. The image processing program causes the computer to, for each pixel in the frame buffer that has been drawn, to calculate, based on the depth of the first depth buffer, the direction from the virtual camera toward the position in the virtual space corresponding to the pixel of interest, as the incident direction, and the direction of the ray reflected with that position as the reflection position, as the ray trace direction, trace the ray along the ray trace direction, determine the collision position where the ray collides with an object in the virtual space based on the first depth buffer, and if the collision position is determined within a range where the trace distance of the ray is within a first distance, determine a reflection color based on the color of the pixel in the frame buffer corresponding to the collision position, to be added to the color of the pixel of interest, and if the ray intersects with the planar object, determine a reflection color based on the color of the texture at the intersection position, to be added to the color of the pixel of interest. The image processing program causes the computer to reflect the reflection color in the frame buffer, and after reflecting the reflection color, draw the first type of object in the frame buffer.
上記によれば、第1の種類以外のオブジェクトを先にフレームバッファに描画し、レイトレースを行い、レイの衝突位置の画素の色を、着目画素の色に加える映り込みの色として決定する。一方、第1の種類のオブジェクトの画像をテクスチャとして設定した平面オブジェクトがレイと交差する場合に、当該交差位置のテクスチャの色を、着目画素の色にさらに加える映り込みの色として決定する。これにより、第1の種類のオブジェクトの奥方向に、別のオブジェクトが存在する場合でも、第1の種類のオブジェクト及び当該別のオブジェクトの映り込みを生成することができる。 According to the above, objects other than the first type are first drawn to the frame buffer, ray tracing is performed, and the color of the pixel at the ray collision point is determined as the reflection color to be added to the color of the pixel of interest. On the other hand, when a planar object with the image of the first type object set as its texture intersects with the ray, the color of the texture at the intersection point is determined as the reflection color to be added to the color of the pixel of interest. This makes it possible to generate reflections of both the first type object and the other object even when another object exists behind the first type object.
(第2の構成)
第2の構成では、上記第1の構成において、前記第1の種類のオブジェクトは、平たい形状のオブジェクトであってもよい。
(Second structure)
In the second configuration, in the first configuration, the first type of object may be a flat-shaped object.
上記によれば、第1の種類のオブジェクトの画像をテクスチャとして設定した平面オブジェクトを用いて映り込みを生成する場合でも、第1の種類のオブジェクト自体が平たい形状であるため、違和感のない画像とすることができる。 According to the above, even when generating reflections using a planar object with an image of the first type of object set as its texture, the image can be made to look natural because the first type of object itself has a flat shape.
(第3の構成)
第3の構成では、上記第第1又は第2の構成において、前記第1の種類のオブジェクトは、操作入力に基づいて制御されるプレイヤキャラクタオブジェクトであってもよい。
(The third structure)
In the third configuration, in the first or second configuration described above, the first type of object may be a player character object controlled based on an operation input.
上記によれば、第1の種類のオブジェクトが操作入力に基づいて制御される場合であっても、第1の種類のオブジェクト及びその奥方向に存在するオブジェクトの映り込みを生成することができる。 According to the above, even when the first type of object is controlled based on an input, it is possible to generate reflections of the first type of object and objects located behind it.
また、他の実施形態は、上記画像処理を行う画像処理システムであってもよいし、画像処理装置であってもよいし、画像処理方法であってもよい。 Furthermore, other embodiments may include an image processing system, an image processing apparatus, or an image processing method that performs the image processing described above.
本発明によれば、第1の種類のオブジェクトの奥方向に、別のオブジェクトが存在する場合でも、第1の種類のオブジェクト及び当該別のオブジェクトの映り込みを生成することができる。 According to the present invention, even when another object exists behind the first type of object, it is possible to generate reflections of both the first type of object and the other object.
(システム構成)
以下、本実施形態の一例に係るゲームシステムについて説明する。本実施形態におけるゲームシステム1の一例は、本体装置(情報処理装置;本実施形態ではゲーム装置本体として機能する)2と左コントローラ3および右コントローラ4とを含む。本体装置2は、左コントローラ3および右コントローラ4がそれぞれ着脱可能である。つまり、ゲームシステム1は、左コントローラ3および右コントローラ4をそれぞれ本体装置2に装着して一体化された装置として利用できる。また、ゲームシステム1は、本体装置2と左コントローラ3および右コントローラ4とを別体として利用することもできる。以下では、本実施形態のゲームシステム1のハードウェア構成について説明し、その後に本実施形態のゲームシステム1の制御について説明する。
(System configuration)
The following describes a game system according to an example of this embodiment. The example of the game system 1 in this embodiment includes a main unit (information processing device; functioning as the main unit of the game device in this embodiment) 2, a left controller 3, and a right controller 4. The left controller 3 and the right controller 4 are detachable from the main unit 2. In other words, the game system 1 can be used as an integrated device by attaching the left controller 3 and the right controller 4 to the main unit 2. Alternatively, the game system 1 can be used with the main unit 2 and the left controller 3 and right controller 4 as separate units. The following describes the hardware configuration of the game system 1 of this embodiment, followed by a description of the control of the game system 1 of this embodiment.
図1は、本体装置2に左コントローラ3および右コントローラ4を装着した状態の一例を示す図である。図1に示すように、左コントローラ3および右コントローラ4は、それぞれ本体装置2に装着されて一体化されている。本体装置2は、ゲームシステム1における各種の処理(例えば、ゲーム処理)を実行する装置である。本体装置2は、ディスプレイ12を備える。左コントローラ3および右コントローラ4は、ユーザが入力を行うための操作部を備える装置である。 Figure 1 shows an example of the main unit 2 with the left controller 3 and right controller 4 attached. As shown in Figure 1, the left controller 3 and right controller 4 are each attached to the main unit 2 and integrated together. The main unit 2 is a device that executes various processes (e.g., game processing) in the game system 1. The main unit 2 is equipped with a display 12. The left controller 3 and right controller 4 are devices equipped with operation parts for user input.
左コントローラ3および右コントローラ4は、本体装置2に着脱可能である。なお、以下において、左コントローラ3および右コントローラ4の総称として「コントローラ」と記載することがある。 The left controller 3 and the right controller 4 are detachable from the main unit 2. In the following, the left controller 3 and the right controller 4 will be collectively referred to as "controllers."
本体装置2単体または本体装置2に左コントローラ3および右コントローラ4が装着された一体型装置は、携帯型装置となってもよい。また、本体装置2または一体型装置が手持ち型の装置となってもよい。また、本体装置2または一体型装置が可搬型装置となってもよい。 The main unit 2 alone, or the integrated unit with the left controller 3 and right controller 4 attached to the main unit 2, may be a portable device. Furthermore, the main unit 2 or the integrated unit may be a handheld device. Also, the main unit 2 or the integrated unit may be a portable device.
また、本体装置2は、ディスプレイ12の画面上にタッチパネル13を備える。本実施形態においては、タッチパネル13は、マルチタッチ入力が可能な方式(例えば、静電容量方式)のものである。ただし、タッチパネル13は、任意の種類のものであってよく、例えば、シングルタッチ入力が可能な方式(例えば、抵抗膜方式)のものであってもよい。 Furthermore, the main unit 2 includes a touch panel 13 on the screen of the display 12. In this embodiment, the touch panel 13 is of a multi-touch input type (for example, a capacitive touch panel). However, the touch panel 13 may be of any type; for example, it may be of a single-touch input type (for example, a resistive touch panel).
図2は、本体装置2の内部構成の一例を示すブロック図である。 Figure 2 is a block diagram showing an example of the internal configuration of the main unit 2.
本体装置2は、プロセッサ81を備える。プロセッサ81は、本体装置2において実行される各種の情報処理を実行する情報処理部であって、1又は複数のCPU(Central Processing Unit)と、1又は複数のGPU(Graphics Processing Unit)とを含む。プロセッサ81は、CPU機能及びGPU機能等の複数の機能を含むSoC(System-on-a-chip)から構成されてもよい。なお、CPUとGPUとがそれぞれ別々のプロセッサとして構成されてもよい。また、プロセッサ81の内部には、一時的にデータを記憶する1又は複数のメモリが設けられる。プロセッサ81は、記憶部(具体的には、フラッシュメモリ84等の内部記憶媒体、あるいは、スロット23に装着される外部記憶媒体等)に記憶される情報処理プログラム(例えば、ゲームプログラム)を実行することによって、各種の情報処理を実行する。 The main unit 2 includes a processor 81. The processor 81 is an information processing unit that performs various information processing operations in the main unit 2, and includes one or more CPUs (Central Processing Units) and one or more GPUs (Graphics Processing Units). The processor 81 may be composed of a System-on-a-chip (SoC) that includes multiple functions such as CPU and GPU functions. Note that the CPU and GPU may be configured as separate processors. Furthermore, one or more memories for temporarily storing data are provided inside the processor 81. The processor 81 performs various information processing operations by executing information processing programs (e.g., game programs) stored in a storage unit (specifically, an internal storage medium such as flash memory 84, or an external storage medium installed in slot 23).
本体装置2は、自身に内蔵される内部記憶媒体の一例として、フラッシュメモリ84およびDRAM(Dynamic Random Access Memory)85を備える。フラッシュメモリ84およびDRAM85は、プロセッサ81に接続される。フラッシュメモリ84は、主に、本体装置2に保存される各種のデータ(プログラムであってもよい)を記憶するために用いられるメモリである。DRAM85は、情報処理において用いられる各種のデータを一時的に記憶するために用いられるメモリである。 The main unit 2 includes, as an example of an internal storage medium, a flash memory 84 and a DRAM (Dynamic Random Access Memory) 85. The flash memory 84 and DRAM 85 are connected to the processor 81. The flash memory 84 is primarily used to store various types of data (which may include programs) stored in the main unit 2. The DRAM 85 is used to temporarily store various types of data used in information processing.
本体装置2は、スロットインターフェース(以下、「I/F」と略記する。)91を備える。スロットI/F91は、プロセッサ81に接続される。スロットI/F91は、スロット23に接続され、スロット23に装着された所定の種類の記憶媒体(例えば、専用メモリカード)に対するデータの読み出しおよび書き込みを、プロセッサ81の指示に応じて行う。 The main unit 2 is equipped with a slot interface (hereinafter abbreviated as "I/F") 91. The slot I/F 91 is connected to the processor 81. The slot I/F 91 is connected to slot 23 and performs data reading and writing to a predetermined type of storage medium (e.g., a dedicated memory card) installed in slot 23, according to instructions from the processor 81.
プロセッサ81は、フラッシュメモリ84およびDRAM85、ならびに上記各記憶媒体との間でデータを適宜読み出したり書き込んだりして、上記の情報処理を実行する。 The processor 81 performs the above-mentioned information processing by appropriately reading and writing data to and from the flash memory 84 and DRAM 85, as well as to each of the storage media.
本体装置2は、ネットワーク通信部82を備える。ネットワーク通信部82は、プロセッサ81に接続される。ネットワーク通信部82は、ネットワークを介して外部の装置と通信(具体的には、無線通信)を行う。本実施形態においては、ネットワーク通信部82は、第1の通信態様としてWi-Fiの規格に準拠した方式により、無線LANに接続して外部装置と通信を行う。また、ネットワーク通信部82は、第2の通信態様として所定の通信方式(例えば、独自プロトコルによる通信や、赤外線通信)により、同種の他の本体装置2との間で無線通信を行う。 The main unit 2 includes a network communication unit 82. The network communication unit 82 is connected to the processor 81. The network communication unit 82 communicates with external devices via a network (specifically, wirelessly). In this embodiment, the network communication unit 82 communicates with external devices by connecting to a wireless LAN using a method compliant with the Wi-Fi standard as a first communication mode. Furthermore, the network communication unit 82 performs wireless communication with other main units 2 of the same type using a predetermined communication method (for example, communication using a proprietary protocol or infrared communication) as a second communication mode.
本体装置2は、コントローラ通信部83を備える。コントローラ通信部83は、プロセッサ81に接続される。コントローラ通信部83は、左コントローラ3および/または右コントローラ4と無線通信を行う。本体装置2と左コントローラ3および右コントローラ4との通信方式は任意であるが、本実施形態においては、コントローラ通信部83は、左コントローラ3との間および右コントローラ4との間で、Bluetooth(登録商標)の規格に従った通信を行う。 The main unit 2 includes a controller communication unit 83. The controller communication unit 83 is connected to the processor 81. The controller communication unit 83 communicates wirelessly with the left controller 3 and/or the right controller 4. While the communication method between the main unit 2 and the left controller 3 and right controller 4 is arbitrary, in this embodiment, the controller communication unit 83 communicates with the left controller 3 and the right controller 4 in accordance with the Bluetooth® standard.
プロセッサ81は、左側端子17、右側端子21、および下側端子27に接続される。プロセッサ81は、左コントローラ3と有線通信を行う場合、左側端子17を介して左コントローラ3へデータを送信するとともに、左側端子17を介して左コントローラ3から操作データを受信する。また、プロセッサ81は、右コントローラ4と有線通信を行う場合、右側端子21を介して右コントローラ4へデータを送信するとともに、右側端子21を介して右コントローラ4から操作データを受信する。また、プロセッサ81は、クレードルと通信を行う場合、下側端子27を介してクレードルへデータを送信する。このように、本実施形態においては、本体装置2は、左コントローラ3および右コントローラ4との間で、それぞれ有線通信と無線通信との両方を行うことができる。また、左コントローラ3および右コントローラ4が本体装置2に装着された一体型装置または本体装置2単体がクレードルに装着された場合、本体装置2は、クレードルを介してデータ(例えば、画像データや音声データ)を据置型モニタ等に出力することができる。 The processor 81 is connected to the left terminal 17, the right terminal 21, and the lower terminal 27. When the processor 81 communicates with the left controller 3 via a wired connection, it transmits data to the left controller 3 via the left terminal 17 and receives operation data from the left controller 3 via the left terminal 17. Similarly, when the processor 81 communicates with the right controller 4 via a wired connection, it transmits data to the right controller 4 via the right terminal 21 and receives operation data from the right controller 4 via the right terminal 21. Furthermore, when the processor 81 communicates with the cradle, it transmits data to the cradle via the lower terminal 27. Thus, in this embodiment, the main unit 2 can perform both wired and wireless communication with the left controller 3 and the right controller 4, respectively. Also, when the left controller 3 and the right controller 4 are mounted on the main unit 2 as an integrated unit, or when the main unit 2 alone is mounted on the cradle, the main unit 2 can output data (e.g., image data or audio data) to a stationary monitor or the like via the cradle.
本体装置2は、タッチパネル13の制御を行う回路であるタッチパネルコントローラ86を備える。タッチパネルコントローラ86は、タッチパネル13とプロセッサ81との間に接続される。タッチパネルコントローラ86は、タッチパネル13からの信号に基づいて、例えばタッチ入力が行われた位置を示すデータを生成して、プロセッサ81へ出力する。 The main unit 2 includes a touch panel controller 86, which is a circuit for controlling the touch panel 13. The touch panel controller 86 is connected between the touch panel 13 and the processor 81. Based on signals from the touch panel 13, the touch panel controller 86 generates data indicating, for example, the location where a touch input occurred, and outputs it to the processor 81.
本体装置2は、電力制御部97およびバッテリ98を備える。電力制御部97は、バッテリ98およびプロセッサ81に接続される。また、図示しないが、電力制御部97は、本体装置2の各部(具体的には、バッテリ98の電力の給電を受ける各部、左側端子17、および右側端子21)に接続される。電力制御部97は、プロセッサ81からの指令に基づいて、バッテリ98から上記各部への電力供給を制御する。 The main unit 2 comprises a power control unit 97 and a battery 98. The power control unit 97 is connected to the battery 98 and the processor 81. Although not shown, the power control unit 97 is also connected to various parts of the main unit 2 (specifically, the parts that receive power from the battery 98, the left terminal 17, and the right terminal 21). Based on commands from the processor 81, the power control unit 97 controls the power supply from the battery 98 to these parts.
また、バッテリ98は、下側端子27に接続される。外部の充電装置(例えば、クレードル)が下側端子27に接続され、下側端子27を介して本体装置2に電力が供給される場合、供給された電力がバッテリ98に充電される。 Furthermore, the battery 98 is connected to the lower terminal 27. When an external charging device (e.g., a cradle) is connected to the lower terminal 27 and power is supplied to the main unit 2 via the lower terminal 27, the supplied power charges the battery 98.
(画像処理の概要)
次に、本実施形態の画像処理について説明する。本実施形態のゲームシステム1(画像処理システムの一例)では、3次元の仮想空間に複数のオブジェクトが配置され、ゲームが行われる。
(Overview of image processing)
Next, the image processing of this embodiment will be described. In the game system 1 of this embodiment (an example of an image processing system), multiple objects are placed in a three-dimensional virtual space, and the game is played.
図3は、本実施形態のゲームの実行中に仮想空間に配置される複数のオブジェクトの一例を示す図である。本実施形態のゲームが開始されると、xyz直交座標系によって定義される3次元の仮想空間が設定される。例えば、y軸は仮想空間の上方向の軸であり、x軸は、右方向の軸であり、z軸は奥方向の軸である。 Figure 3 shows an example of multiple objects placed in the virtual space during the execution of the game of this embodiment. When the game of this embodiment starts, a three-dimensional virtual space defined by the xyz Cartesian coordinate system is established. For example, the y-axis is the upward axis of the virtual space, the x-axis is the rightward axis, and the z-axis is the backward axis.
図3に示されるように、仮想空間には、複数のオブジェクトとして、地面オブジェクト30が配置される。地面オブジェクト30は、地面を模したオブジェクトであり、例えば、xz平面に平行な平面である。なお、地面オブジェクト30は、凹凸を有してもよいし、斜面を有してもよい。地面オブジェクト30上には、木オブジェクト32と、円柱オブジェクト34とが配置される。また、例えば、仮想空間のz軸方向の所定位置には、山オブジェクト36が配置される。これら地面オブジェクト30、木オブジェクト32、円柱オブジェクト34は、仮想空間に固定される。 As shown in Figure 3, multiple objects, including a ground object 30, are placed in the virtual space. The ground object 30 is an object that mimics the ground, for example, a plane parallel to the xz plane. The ground object 30 may have irregularities or slopes. A tree object 32 and a cylinder object 34 are placed on the ground object 30. Furthermore, for example, a mountain object 36 is placed at a predetermined position in the z-axis direction of the virtual space. These ground objects 30, tree objects 32, and cylinder objects 34 are fixed in the virtual space.
また、仮想空間には、キャラクタオブジェクト41及び43が配置される。キャラクタオブジェクト41及び43は、平たい形状のオブジェクトであり、上下左右方向の長さに比べて厚さ方向の長さが小さい板状のオブジェクトである。例えば、キャラクタオブジェクト41及び43は、それぞれ、前面を構成する平面状のメッシュと背面を構成する平面状のメッシュとを含む3Dオブジェクトである。キャラクタオブジェクト41は、プレイヤによって制御されるプレイヤキャラクタである。キャラクタオブジェクト41は、仮想空間内において、コントローラに対する入力に応じたアクションを行う。例えば、キャラクタオブジェクト41は、アクションとして、地面オブジェクト30上を移動したり、仮想空間内で手足を動かしたり、ジャンプしたり、顔の向きを変化させたりする。キャラクタオブジェクト41が左右方向に移動すると、画面が左右方向にスクロールされる。また、キャラクタオブジェクト43は、キャラクタオブジェクト41の移動に応じて移動するノンプレイヤキャラクタであり、プロセッサ81によって自動制御される。なお、キャラクタオブジェクト43は、プレイヤによって制御されてもよい。 Furthermore, character objects 41 and 43 are placed in the virtual space. Character objects 41 and 43 are flat objects, specifically plate-like objects with a thickness shorter than their length in the vertical, horizontal, and vertical directions. For example, character objects 41 and 43 are 3D objects, each containing a planar mesh forming the front and a planar mesh forming the back. Character object 41 is a player character controlled by the player. Character object 41 performs actions in the virtual space in response to controller input. For example, character object 41 may move on the ground object 30, move its limbs in the virtual space, jump, or change the direction of its face. When character object 41 moves horizontally, the screen scrolls horizontally. Character object 43 is a non-player character that moves in response to the movement of character object 41 and is automatically controlled by processor 81. Character object 43 may also be controlled by the player.
仮想空間には、仮想カメラが配置されており、当該仮想カメラから仮想空間を見たゲーム画像が生成され、生成されたゲーム画像がディスプレイ12又は据置型モニタ(以下、これらを「表示装置」という)に表示される。 A virtual camera is placed within the virtual space, and a game image is generated from the virtual camera's perspective of the virtual space. This generated game image is then displayed on the display 12 or a stationary monitor (hereinafter referred to as the "display device").
図4は、表示装置に表示されるゲーム画像の一例を示す図である。表示装置には、各オブジェクト(30、32、34、36、41、43)の画像が表示される。例えば地面オブジェクト30は反射面であり、地面オブジェクト30上には各オブジェクトが映り込む。本実施形態では、SSR(スクリーンスペースリフレクション)と呼ばれる方法で、各オブジェクトの映り込みが生成される。 Figure 4 shows an example of a game image displayed on a display device. The display device shows images of each object (30, 32, 34, 36, 41, 43). For example, the ground object 30 is a reflective surface, and each object is reflected on the ground object 30. In this embodiment, the reflections of each object are generated using a method called SSR (Screen Space Reflection).
例えば、図4に示されるように、地面オブジェクト30上には、木オブジェクト32の映り込み52と、円柱オブジェクト34の映り込み54とが表示される。また、地面オブジェクト30上には、キャラクタオブジェクト41の映り込み61と、キャラクタオブジェクト43の映り込み63とが表示される。一方、地面オブジェクト30上には、山オブジェクト36の映り込みは表示されない。 For example, as shown in Figure 4, the reflections 52 of the tree object 32 and 54 of the cylinder object 34 are displayed on the ground object 30. Additionally, the reflections 61 of the character object 41 and 63 of the character object 43 are displayed on the ground object 30. However, the reflection of the mountain object 36 is not displayed on the ground object 30.
本実施形態では、木オブジェクト32及び円柱オブジェクト34は、予め特定のオブジェクトとして設定されており、仮想カメラからある程度離れていても地面オブジェクト上に映り込むように設定される。一方、山オブジェクト36は、特定のオブジェクトとして設定されない。 In this embodiment, the tree object 32 and the cylinder object 34 are pre-configured as specific objects and are set to appear on the ground object even when they are a certain distance away from the virtual camera. On the other hand, the mountain object 36 is not configured as a specific object.
特定のオブジェクトは、メッシュ(ポリゴンの集合体)単位で設定される。例えば、木オブジェクト32を構成する複数のメッシュのそれぞれが、特定のオブジェクトとして設定されてもよい。また、木オブジェクト32を構成する複数のメッシュのうちの何れかのメッシュが、特定のオブジェクトとして設定されてもよい。例えば、木オブジェクト32が、幹の部分を構成する第1のメッシュと、葉が茂った部分を構成する第2のメッシュとで構成される場合、第1のメッシュ及び第2のメッシュのうち、第1のメッシュのみが特定のオブジェクトとして設定されてもよい。すなわち、「特定のオブジェクト」は、必ずしも外観上1つに見えるオブジェクトでなくてもよく、外観上1つに見えるオブジェクトのうちの一部を構成するメッシュであってもよい。例えば、xz平面に平行な地面とxz平面に垂直な壁面とが連続的に形成された地形オブジェクトは、外観上、段差を有する1つの地形を形成するように見えるが、地面と壁面とが異なるメッシュにより構成される場合がある。このような地形オブジェクトにおける壁面が、特定のオブジェクトとして設定され、地面は特定のオブジェクトとして設定されなくてもよい。 A specific object is defined at the mesh (a collection of polygons) level. For example, each of the multiple meshes that make up the tree object 32 may be defined as a specific object. Alternatively, any of the multiple meshes that make up the tree object 32 may be defined as a specific object. For example, if the tree object 32 is composed of a first mesh that makes up the trunk and a second mesh that makes up the leafy part, only the first mesh may be defined as a specific object. In other words, a "specific object" does not necessarily have to be an object that appears as a single object visually; it may be a mesh that makes up part of an object that appears as a single object visually. For example, a terrain object in which a ground surface parallel to the xz plane and a wall surface perpendicular to the xz plane are continuously formed may appear to form a single terrain with steps, but the ground surface and the wall surface may be composed of different meshes. In such a terrain object, the wall surface may be defined as a specific object, while the ground surface does not necessarily have to be defined as a specific object.
本実施形態では、特定のオブジェクトとして設定された木オブジェクト32及び円柱オブジェクト34が、地面オブジェクト上に映り込む。以下、これらのオブジェクトの映り込みに関する画像処理について説明する。 In this embodiment, the tree object 32 and the cylindrical object 34, which are set as specific objects, are reflected on the ground object. The image processing related to the reflection of these objects will be described below.
図5は、キャラクタオブジェクト以外のオブジェクトの映り込みに関する画像処理の概要を示す図である。 Figure 5 shows an overview of image processing related to reflections of objects other than character objects.
図5に示されるように、プロセッサ81は、まず、第1デプステストを行う(ステップS1)。ここでは、キャラクタオブジェクト以外の全てのオブジェクト(30、32、34、36)について、画素単位でデプステストが行われ、当該デプステストの結果が第1デプスバッファに記憶される。 As shown in Figure 5, the processor 81 first performs a first depth test (step S1). Here, a depth test is performed on a pixel-by-pixel basis for all objects other than character objects (30, 32, 34, 36), and the results of this depth test are stored in the first depth buffer.
図6は、第1デプスバッファの一例を示す図である。図6に示されるように、第1デプスバッファには、キャラクタオブジェクト以外の全てのオブジェクト(30、32、34、36)について、画素ごとのデプス値が記憶される。なお、図6では、各オブジェクトの画像が表示されているが、これは、第1デプスバッファに記憶された各画素のデプス値を概念的に表したものである。各画素の位置は、スクリーン座標系の座標値で表される。例えば、スクリーン座標系のSx軸は、画像(画面)における右方向の軸であり、Sy軸は、画像における上方向の軸である。スクリーン座標系の原点は、例えば、画像の中心に設定されてもよいし、画像の左下に設定されてもよい。 Figure 6 shows an example of the first depth buffer. As shown in Figure 6, the first depth buffer stores the pixel-by-pixel depth values for all objects other than character objects (30, 32, 34, 36). Note that Figure 6 displays images of each object, which conceptually represent the depth values of each pixel stored in the first depth buffer. The position of each pixel is represented by coordinate values in the screen coordinate system. For example, the Sx axis of the screen coordinate system is the rightward axis in the image (screen), and the Sy axis is the upward axis in the image. The origin of the screen coordinate system may be set, for example, at the center of the image, or at the bottom left of the image.
図5に戻り、ステップS1の後、プロセッサ81は、第1デプステストの結果に基づいて、フレームバッファへのレンダリングを行う(ステップS2)。ステップS2では、第1デプスバッファに記憶されたデプスに基づいて、フレームバッファに画像が描画される。本実施形態では、レンダリングの方法として、ディファードレンダリング(ディファードシェーディングともいう)が用いられる。ステップS2では、画素毎の法線情報を記憶した法線バッファが更新され、フレームバッファに画像が描画される。なお、レンダリングの方法として、ディファードレンダリングではなく、フォワードレンダリングが用いられてもよい。 Returning to Figure 5, after step S1, the processor 81 renders to the frame buffer based on the results of the first depth test (step S2). In step S2, the image is drawn to the frame buffer based on the depth stored in the first depth buffer. In this embodiment, deferred rendering (also called deferred shading) is used as the rendering method. In step S2, the normal buffer, which stores the normal information for each pixel, is updated, and the image is drawn to the frame buffer. Note that forward rendering may be used instead of deferred rendering as the rendering method.
図7は、ステップS2によるレンダリングが行われた後のフレームバッファに描画された画像の一例を示す図である。図7に示されるように、ステップS2では、フレームバッファに、キャラクタオブジェクト以外の全てのオブジェクト(30、32、34、36)の画像が描画される。画素毎に、色情報が記憶される。色情報は、例えば、3つの色を表すRGB値と、透明度(あるいは不透明度)を表すアルファ値とを含む。なお、図7では陰影が省略されているが、ステップS2では、陰影がついた画像が生成される。 Figure 7 shows an example of an image drawn to the frame buffer after rendering in step S2. As shown in Figure 7, in step S2, images of all objects other than character objects (30, 32, 34, 36) are drawn to the frame buffer. Color information is stored for each pixel. The color information includes, for example, RGB values representing three colors and an alpha value representing transparency (or opacity). Note that shading is omitted in Figure 7, but in step S2, an image with shading is generated.
図5に戻り、ステップS2の後、プロセッサ81は、仮想空間に配置された複数のオブジェクトのうち、特定のオブジェクトについて、さらに第2デプステストを行う(ステップS3)。具体的には、複数のオブジェクト(30、32、34、36)のうち、特定のオブジェクトとして設定された木オブジェクト32及び円柱オブジェクト34について、さらに第2デプステストが行われ、当該第2デプステストの結果が第2デプスバッファに記憶される。これにより、第2デプスバッファには、仮想カメラの撮像範囲に含まれる複数のオブジェクト(30、32、34、36)のうち、木オブジェクト32及び円柱オブジェクト34のみの画素毎のデプス値が記憶される。 Returning to Figure 5, after step S2, the processor 81 performs a second depth test on specific objects among the multiple objects placed in the virtual space (step S3). Specifically, the second depth test is performed on the tree object 32 and the cylinder object 34, which are set as specific objects among the multiple objects (30, 32, 34, 36), and the results of this second depth test are stored in the second depth buffer. As a result, the second depth buffer stores the pixel-by-pixel depth values only for the tree object 32 and the cylinder object 34 among the multiple objects (30, 32, 34, 36) included in the imaging range of the virtual camera.
図8は、第2デプスバッファの一例を示す図である。図8に示されるように、第2デプスバッファには、木オブジェクト32及び円柱オブジェクト34の画素毎のデプス値が記憶される。一方、山オブジェクト36のデプス値は、第2デプスバッファに記憶されない。なお、図8は、第2デプスバッファに記憶された各画素のデプス値を概念的に表したものである。 Figure 8 shows an example of a second depth buffer. As shown in Figure 8, the second depth buffer stores the depth values for each pixel of the tree object 32 and the cylinder object 34. On the other hand, the depth value of the mountain object 36 is not stored in the second depth buffer. Note that Figure 8 conceptually represents the depth values of each pixel stored in the second depth buffer.
図5に戻り、ステップS3の後、プロセッサ81は、第1デプスバッファ又は第2デプスバッファを用いて、レイトレースを行う(ステップS4)。ここでは、画素(以下では「着目画素」という)毎に処理が行われる。具体的には、プロセッサ81は、着目画素を設定し、仮想カメラの位置から着目画素に向かう方向にレイ(仮想的な光線)を飛ばしたときのレイの反射位置を計算し、当該反射位置から反射するレイがオブジェクトと衝突するか否かの衝突判定を行う。 Returning to Figure 5, after step S3, the processor 81 performs ray tracing using the first or second depth buffer (step S4). Here, processing is performed for each pixel (hereinafter referred to as the "focus pixel"). Specifically, the processor 81 sets the focus pixel, calculates the reflection position of a ray (a virtual light ray) cast from the virtual camera's position toward the focus pixel, and performs a collision determination to determine whether the ray reflected from that reflection position collides with an object.
次に、プロセッサ81は、レイの衝突位置に対応するフレームバッファ内の画素の色を、着目画素に映り込む色として算出する(ステップS5)。ステップS5の処理も画素毎に行われる。 Next, the processor 81 calculates the color of the pixel in the frame buffer corresponding to the ray collision position as the color reflected on the pixel of interest (step S5). The processing in step S5 is also performed for each pixel.
以下、図7に示される各画素PIXa~PIXcが着目画素として設定された場合のステップS4及びS5の処理について具体的に説明する。 The following describes in detail the processing in steps S4 and S5 when each of the pixels PIXa to PIXc shown in Figure 7 is set as the pixel of interest.
例えば、プロセッサ81は、図7に示される画素PIXaを着目画素として設定する。画素PIXaは、円柱オブジェクト34よりも仮想カメラ側にある画素である。プロセッサ81は、着目画素PIXaのスクリーン座標系における位置と、第1デプスバッファに記憶された当該位置のデプス値とに基づいて、着目画素PIXaの仮想空間における位置を、レイの反射位置RPaとして算出する。 For example, the processor 81 sets pixel PIXa, shown in Figure 7, as the pixel of interest. Pixel PIXa is a pixel located closer to the virtual camera than the cylindrical object 34. Based on the position of the pixel of interest PIXa in the screen coordinate system and the depth value of that position stored in the first depth buffer, the processor 81 calculates the position of the pixel of interest PIXa in virtual space as the ray reflection position RPa.
図9は、レイトレースが行われる様子を示す図であり、反射位置RPaから反射したレイが円柱オブジェクト34に衝突する様子を示した図である。図9の右方向は、仮想カメラVCに基づいて生成されたゲーム画像が画面に表示されたときの画面の奥方向である。 Figure 9 illustrates the ray tracing process, showing how a ray reflected from the reflection point RPa collides with the cylindrical object 34. The rightward direction in Figure 9 represents the depth of the screen when the game image, generated based on the virtual camera VC, is displayed on the screen.
図9に示されるように、プロセッサ81は、仮想カメラVCの位置から反射位置RPaに向かう方向を入射方向とし、当該反射位置RPaから反射するレイの方向をレイトレース方向RTDaとして算出する。具体的には、プロセッサ81は、入射方向と反射位置RPaの法線とに基づいて、レイの反射方向を算出する。入射方向の入射角と、反射方向の反射角とは等しい。そして、プロセッサ81は、当該反射方向、又は、当該反射方向に補正を加えた方向を、レイトレース方向RTDaとして算出する。なお、反射方向の補正については後に説明する。 As shown in Figure 9, the processor 81 defines the direction from the virtual camera VC towards the reflection position RPa as the incident direction, and calculates the direction of the ray reflected from the reflection position RPa as the ray tracing direction RTDa. Specifically, the processor 81 calculates the reflection direction of the ray based on the incident direction and the normal to the reflection position RPa. The angle of incidence in the incident direction and the angle of reflection in the reflection direction are equal. Then, the processor 81 calculates the reflection direction, or a direction corrected from the reflection direction, as the ray tracing direction RTDa. The correction of the reflection direction will be explained later.
プロセッサ81は、反射位置RPaからレイトレース方向RTDaにレイを進行させ、レイがオブジェクトと衝突するか否かの衝突判定を行う。プロセッサ81は、レイのトレース距離がLa未満では、第1デプスバッファを用いて衝突判定を行う。ここで、トレース距離は、反射位置からレイトレース方向に沿った距離である。 The processor 81 propagates a ray from the reflection position RPa in the ray tracing direction RTDa and performs a collision determination to determine whether the ray collides with an object. If the ray's trace distance is less than La, the processor 81 uses the first depth buffer to perform the collision determination. Here, the trace distance is the distance from the reflection position along the ray tracing direction.
図10は、第1デプスバッファを用いて、反射位置RPaから反射するレイの衝突判定が行われる様子を示す図である。プロセッサ81は、まず、仮想空間における反射位置RPaからレイトレース方向RTDaに最大距離Lbだけ進んだ仮想空間における位置を算出し、当該算出した位置をスクリーン座標系に変換することで、スクリーン座標系におけるレイトレース終了位置を算出する。プロセッサ81は、スクリーン座標系において、反射位置RPa(着目画素RPa)をレイトレース開始位置とし、当該レイトレース開始位置からレイトレース終了位置までレイを伸ばし、レイの先端がオブジェクトと衝突するか否かを判定する。具体的には、プロセッサ81は、レイを所定距離進行させ、レイの先端のデプスと、第1デプスバッファに記憶された各位置のデプスとに基づいて、レイがオブジェクトと衝突するか否かを判定する。図9及び図10に示す例では、反射位置RPaで反射したレイが、衝突位置CPaにおいて衝突すると判定される。 Figure 10 shows how collision detection of a ray reflected from the reflection position RPa is performed using the first depth buffer. The processor 81 first calculates the position in the virtual space by traveling a maximum distance Lb in the ray tracing direction RTDa from the reflection position RPa in the virtual space, and then converts this calculated position to the screen coordinate system to calculate the ray tracing end position in the screen coordinate system. In the screen coordinate system, the processor 81 uses the reflection position RPa (the pixel of interest RPa) as the ray tracing start position, extends the ray from the ray tracing start position to the ray tracing end position, and determines whether the tip of the ray collides with an object. Specifically, the processor 81 travels the ray a predetermined distance and determines whether the ray collides with an object based on the depth of the ray tip and the depth of each position stored in the first depth buffer. In the example shown in Figures 9 and 10, it is determined that the ray reflected at the reflection position RPa collides at the collision position CPa.
レイが衝突位置CPaにおいてオブジェクトと衝突すると判定された場合、ステップS5において、当該衝突位置CPaに対応するフレームバッファの画素の色が、着目画素RPaに映り込む色として算出される。 If it is determined that the ray collides with an object at collision position CPa, in step S5, the color of the pixel in the frame buffer corresponding to the collision position CPa is calculated as the color reflected in the pixel of interest RPa.
次に、図7に示される画素PIXbが着目画素として設定される場合と、画素PIXcが着目画素として設定される場合とについて説明する。画素PIXbは、木オブジェクト32よりも仮想カメラ側にある画素である。また、画素PIXcは、山オブジェクト36よりも仮想カメラ側にある画素である。 Next, we will explain the cases where pixel PIXb, shown in Figure 7, is set as the pixel of interest, and where pixel PIXc is set as the pixel of interest. Pixel PIXb is a pixel located closer to the virtual camera than the tree object 32. Similarly, pixel PIXc is a pixel located closer to the virtual camera than the mountain object 36.
図11は、レイトレースが行われる様子を示す図であり、反射位置RPbから反射したレイが木オブジェクト32に衝突する様子を示した図である。図12は、レイトレースが行われる様子を示す図であり、反射位置RPcから反射したレイがオブジェクトに衝突しない様子を示した図である。図13は、第2デプスバッファを用いて、レイの衝突判定が行われる様子を示す図である。 Figure 11 shows how ray tracing is performed, illustrating how a ray reflected from reflection position RPb collides with the tree object 32. Figure 12 shows how ray tracing is performed, illustrating how a ray reflected from reflection position RPc does not collide with the object. Figure 13 shows how ray collision detection is performed using the second depth buffer.
図11に示されるように、プロセッサ81は、画素PIXbを着目画素として設定した場合、上記と同様に、着目画素PIXbに対応する反射位置RPbを算出し、反射位置RPbから反射するレイの方向を、レイトレース方向RTDbとして算出する。プロセッサ81は、レイトレース方向RTDbにレイを進行させ、レイがオブジェクトと衝突するか否かの衝突判定を行う。プロセッサ81は、トレース距離がLa未満のときは、第1デプスバッファを用いてレイの衝突判定を行うが、トレース距離がLa未満のときは、レイはオブジェクトと衝突しない。このため、プロセッサ81は、さらにレイを進行させ、第2デプスバッファを用いて、レイの衝突判定を行う(図13)。図11及び図13に示されるように、トレース距離がLa以上であり、かつ、最大距離Lb以下であるときに、レイは衝突位置CPbにおいて木オブジェクト32と衝突すると判定される。 As shown in Figure 11, when the processor 81 sets pixel PIXb as the pixel of interest, it calculates the reflection position RPb corresponding to the pixel of interest PIXb, as described above, and calculates the direction of the ray reflected from the reflection position RPb as the ray tracing direction RTDb. The processor 81 propagates the ray in the ray tracing direction RTDb and performs a collision determination to determine whether the ray collides with an object. When the trace distance is less than La, the processor 81 performs the ray collision determination using the first depth buffer. However, when the trace distance is less than La, the ray does not collide with an object. Therefore, the processor 81 propagates the ray further and performs the ray collision determination using the second depth buffer (Figure 13). As shown in Figures 11 and 13, when the trace distance is greater than or equal to La and less than or equal to the maximum distance Lb, it is determined that the ray collides with the tree object 32 at the collision position CPb.
一方、図12に示されるように、プロセッサ81は、画素PIXcを着目画素として設定した場合、上記と同様に、着目画素PIXcに対応する反射位置RPcを算出し、反射位置RPcから反射するレイの方向をレイトレース方向RTDcとして算出し、当該レイトレース方向RTDbにレイを進行させる。プロセッサ81は、トレース距離がLa未満のときは、第1デプスバッファを用いてレイの衝突判定を行い、トレース距離がLa以上であり、かつ、最大距離Lb以下であるときは、第2デプスバッファを用いてレイの衝突判定を行う。ここで、図13に示されるように、第2デプスバッファには山オブジェクト36のデプスは記憶されていない。このため、図12及び図13に示されるように、プロセッサ81は、レイを最大距離Lbまで進行させても、レイはオブジェクトと衝突しないと判定する。 On the other hand, as shown in Figure 12, when the processor 81 sets pixel PIXc as the pixel of interest, it calculates the reflection position RPc corresponding to the pixel of interest PIXc, calculates the direction of the ray reflected from the reflection position RPc as the ray tracing direction RTDc, and propagates the ray in the ray tracing direction RTDb. When the trace distance is less than La, the processor 81 performs ray collision detection using the first depth buffer. When the trace distance is La or greater and less than or equal to the maximum distance Lb, it performs ray collision detection using the second depth buffer. Here, as shown in Figure 13, the depth of the mountain object 36 is not stored in the second depth buffer. Therefore, as shown in Figures 12 and 13, the processor 81 determines that the ray will not collide with the object even when propagated to the maximum distance Lb.
なお、第1デプスバッファに基づいてレイの衝突位置が算出された場合と、第2デプスバッファに基づいてレイの衝突位置が算出された場合とで、衝突位置の画素の色を着目画素の色に加える際のパラメータを異ならせてもよい。例えば、第2デプスバッファに基づいて衝突位置が算出された場合は、第1デプスバッファに基づいて衝突位置が算出された場合よりも、映り込みの色が濃くなるようにパラメータが変更されてもよい。 Furthermore, the parameters used to add the color of the pixel at the collision point to the color of the pixel of interest may differ depending on whether the ray collision point is calculated based on the first depth buffer or the second depth buffer. For example, when the collision point is calculated based on the second depth buffer, the parameters may be changed so that the reflected color becomes darker than when the collision point is calculated based on the first depth buffer.
各着目画素について上述したステップS4及びS5の処理が行われることにより、各着目画素に映り込む色が決定される。そして、各着目画素の色に、決定された映り込む色を加えることで、各オブジェクトの映り込みがフレームバッファに描画されることになる。 The processing described in steps S4 and S5 above is performed for each pixel of interest, thereby determining the color reflected in each pixel. Then, by adding the determined reflected color to the color of each pixel of interest, the reflection of each object is drawn to the frame buffer.
図14は、各画素に映り込む色が加えられたときのフレームバッファに描画される画像の一例を示す図である。 Figure 14 shows an example of an image drawn to the frame buffer when the color reflected in each pixel is added.
図14に示されるように、画素RPaに対して、上述のように算出された衝突位置CPaの画素の色が加えられる。円柱オブジェクト34の手前側の領域(仮想カメラ側の領域)に含まれる各画素に対して同様の処理が行われることで、円柱オブジェクト34の映り込み54がフレームバッファに描画される。また、画素RPbに対して、衝突位置CPbの画素の色が加えられる。木オブジェクト32の手前側の領域に含まれる各画素に対して同様の処理が行われることで、木オブジェクト32の映り込み52がフレームバッファに描画される。一方、画素RPcについては、衝突位置は算出されない。山オブジェクト36の手前側の領域に含まれる各画素に対して処理が行われる場合も同様である。このため、山オブジェクト36の映り込みはフレームバッファには描画されない。 As shown in Figure 14, the color of the pixel at the collision position CPa calculated as described above is added to the pixel RPa. The same process is performed on each pixel in the area in front of the cylinder object 34 (the area on the virtual camera side), so that the reflection 54 of the cylinder object 34 is drawn to the frame buffer. Similarly, the color of the pixel at the collision position CPb is added to the pixel RPb. The same process is performed on each pixel in the area in front of the tree object 32, so that the reflection 52 of the tree object 32 is drawn to the frame buffer. On the other hand, the collision position is not calculated for the pixel RPc. The same applies when processing is performed on each pixel in the area in front of the mountain object 36. Therefore, the reflection of the mountain object 36 is not drawn to the frame buffer.
このように、本実施形態では、複数のオブジェクトについて第1デプステストを行った結果を第1デプスバッファに記憶し、複数のオブジェクトのうちの特定のオブジェクトについて第2デプステストを行った結果を第2デプスバッファに記憶する。トレース距離がLa未満のときは、第1デプスバッファに基づいてレイの衝突判定を行い、トレース距離がLa以上、かつ、最大距離Lb以下のときは、第2デプスバッファに基づいてレイの衝突判定を行う。これにより、SSRを用いて、複数のオブジェクトのうちの特定のオブジェクトについては、仮想カメラから離れている場合でも、映り込みを表示させ、特定のオブジェクト以外のオブジェクトについては、映り込みを表示させないようにすることができる。映り込ませたいオブジェクトを特定のオブジェクトに指定することで、所望のオブジェクトを例えば地面に映り込ませることができる。逆に、映り込ませたくないオブジェクトを特定のオブジェクトに指定しないことで、所望のオブジェクトを、映り込ませないようにすることができる。 In this embodiment, the results of a first depth test performed on multiple objects are stored in a first depth buffer, and the results of a second depth test performed on a specific object among the multiple objects are stored in a second depth buffer. When the trace distance is less than La, ray collision detection is performed based on the first depth buffer. When the trace distance is La or greater and less than or equal to the maximum distance Lb, ray collision detection is performed based on the second depth buffer. This allows SSR to display reflections of a specific object among multiple objects, even when it is far from the virtual camera, while preventing reflections from being displayed for other objects. By designating the object to be reflected as a specific object, the desired object can be reflected, for example, on the ground. Conversely, by not designating an object that should not be reflected as a specific object, the desired object can be prevented from being reflected.
また、第1デプスバッファに基づいてレイの衝突位置が算出された場合と、第2デプスバッファに基づいてレイの衝突位置が算出された場合とで、衝突位置の画素の色を着目画素に映り込ませる際のパラメータを異ならせる。これにより、例えば、特定のオブジェクトをより濃く、はっきりと映り込ませることができる。 Furthermore, the parameters used to reflect the color of the pixel at the collision point onto the target pixel differ depending on whether the ray collision point is calculated based on the first depth buffer or the second depth buffer. This allows, for example, a specific object to be reflected more intensely and clearly.
(反射方向の補正)
次に、反射方向の補正について説明する。上述のように、仮想カメラVCから反射位置に向かう方向が入射方向として算出され、当該入射方向と反射位置の法線方向とに基づいて、反射方向が算出される。本実施形態では、補正条件が満たされる場合に、反射方向を補正した方向が、レイトレース方向として設定される。補正条件が満たされない場合、反射方向が、レイトレース方向として設定される。以下、反射方向が補正される補正条件、及び、補正の方法について具体的に説明する。
(Correction of reflection direction)
Next, the correction of the reflection direction will be explained. As described above, the direction from the virtual camera VC towards the reflection position is calculated as the incident direction, and the reflection direction is calculated based on this incident direction and the normal direction of the reflection position. In this embodiment, if the correction conditions are met, the direction in which the reflection direction has been corrected is set as the ray tracing direction. If the correction conditions are not met, the reflection direction is set as the ray tracing direction. The correction conditions for correcting the reflection direction and the method of correction will be explained in detail below.
図15は、反射方向を補正したレイトレース方向の一例を示す図である。図15に示されるように、例えば、画面の左端に近い着目画素(反射位置RP1)についてレイトレースが行われる場合、入射方向と法線方向とに基づいて算出される反射方向RD1が補正され、補正後の方向が、レイトレース方向RTD1として設定される。また、反射位置RP1よりも画面の右側にある着目画素(反射位置RP2)についてレイトレースが行われる場合も、反射方向RD2が補正され、補正後の方向が、レイトレース方向RTD2として設定される。 Figure 15 shows an example of a ray tracing direction after correction of the reflection direction. As shown in Figure 15, for example, when ray tracing is performed on a pixel of interest near the left edge of the screen (reflection position RP1), the reflection direction RD1, calculated based on the incident direction and normal direction, is corrected, and the corrected direction is set as the ray tracing direction RTD1. Similarly, when ray tracing is performed on a pixel of interest located to the right of reflection position RP1 (reflection position RP2), the reflection direction RD2 is corrected, and the corrected direction is set as the ray tracing direction RTD2.
補正条件は、反射位置に関する条件と、反射方向に関する条件の両方が成立する場合に、満たされる。反射位置に関する条件は、反射位置が画面の端から所定範囲にあることである。また、反射方向に関する条件は、反射方向が画面の外側を向いていることである。反射位置に関する条件、及び、反射方向に関する条件のうち一方が成立しない場合、補正条件は満たされず、反射方向は補正されない。例えば、反射位置が画面の左端から画面の左右方向の長さの1/4までの範囲にあり、かつ、反射方向が画面の左方向を向いている場合、補正条件が満たされる。また、反射位置が画面の右端から1/4までの範囲にあり、かつ、反射方向が画面の右方向を向いている場合、補正条件が満たされる。 The correction conditions are met when both the conditions regarding the reflection position and the reflection direction are satisfied. The condition regarding the reflection position is that the reflection position is within a predetermined range from the edge of the screen. The condition regarding the reflection direction is that the reflection direction is directed outwards from the screen. If either the reflection position condition or the reflection direction condition is not met, the correction conditions are not satisfied, and the reflection direction is not corrected. For example, if the reflection position is within a range from the left edge of the screen to 1/4 of the screen's horizontal length, and the reflection direction is directed to the left of the screen, the correction conditions are satisfied. Similarly, if the reflection position is within a range from the right edge of the screen to 1/4 of the screen's length, and the reflection direction is directed to the right of the screen, the correction conditions are satisfied.
画面の左端に近い反射位置RP1の方が、反射位置RP2よりも補正の度合いが大きい。具体的には、反射位置のスクリーン座標系のSx軸方向における位置に基づいて、補正の度合いCRが決定される。反射位置のSx軸方向における位置が、画面の左端又は右端に近いほど、補正の度合いCRが大きくなる。また、スクリーン座標系における反射方向とSy軸方向との角度が大きいほど、補正の度合いCRは小さくなる。 The degree of correction is greater at reflection position RP1, which is closer to the left edge of the screen, than at reflection position RP2. Specifically, the degree of correction CR is determined based on the position of the reflection position in the Sx-axis direction of the screen coordinate system. The closer the reflection position is to the left or right edge of the screen in the Sx-axis direction, the greater the degree of correction CR. Also, the larger the angle between the reflection direction and the Sy-axis direction in the screen coordinate system, the smaller the degree of correction CR.
図16は、反射方向に対する補正の詳細を説明するための図である。図16に示されるように、例えば、反射方向RDと画面の上方向(Sy軸方向)との角度が45度以下である場合、補正の度合いCRは、反射位置RPのSx座標値に応じた値CR(Sx)に設定される。CR(Sx)は、例えば、0~1の範囲で設定され、反射位置が画面の左端又は右端に近いほど大きくなる。反射方向RDと画面の上方向との角度が45度を超える場合、その超えた角度に応じて、反射位置RPのSx座標値に応じた値CR(Sx)が小さくなる。反射方向RDと画面の上方向との角度が閾値(例えば、60度~65度)を超える場合、補正の度合いCRは、「0」に設定される。 Figure 16 illustrates the details of the correction for the reflection direction. As shown in Figure 16, for example, if the angle between the reflection direction RD and the upward direction of the screen (Sy axis direction) is 45 degrees or less, the correction degree CR is set to a value CR(Sx) corresponding to the Sx coordinate value of the reflection position RP. CR(Sx) is set, for example, in the range of 0 to 1, and increases as the reflection position approaches the left or right edge of the screen. If the angle between the reflection direction RD and the upward direction of the screen exceeds 45 degrees, the value CR(Sx) corresponding to the Sx coordinate value of the reflection position RP decreases according to the angle exceeding 45 degrees. If the angle between the reflection direction RD and the upward direction of the screen exceeds a threshold (for example, 60 to 65 degrees), the correction degree CR is set to "0".
補正の度合いCRに応じて、反射方向に、画面内側向きの補正が加えられる。具体的には、仮想空間における反射位置RPから反射方向RDに最大距離Lbだけ進んだ位置をスクリーン座標系に変換した位置が、レイトレース終了位置EPとして算出される。このレイトレース終了位置EPのSx座標値が、補正の度合いCRに応じて、画面の内側方向に移動するように補正される。例えば、線形補完により、レイトレース終了位置EPのSx座標値が、反射位置RPのSx座標値に近づくように補正される。例えば、反射位置RPが画面の左端から所定範囲に位置している場合、レイトレース終了位置EPは、補正の度合いCRに応じて、右方向(Sx軸正方向)に移動される。レイトレース終了位置EPのSx座標値は、反射位置RPのSx座標値を超えて移動されない。また、レイトレース終了位置EPのSy座標値については、補正前後で変化しない。そして、反射位置EPから、移動後のレイトレース終了位置EP‘に向かう方向が、レイトレース方向RTDとして算出される。 Depending on the degree of correction CR, a correction is applied in the direction of reflection, towards the inside of the screen. Specifically, the position obtained by converting the position obtained by moving the maximum distance Lb from the reflection position RP in the reflection direction RD in the virtual space to the screen coordinate system is calculated as the ray tracing end position EP. The Sx coordinate value of this ray tracing end position EP is corrected to move inward towards the screen, depending on the degree of correction CR. For example, linear interpolation is used to correct the Sx coordinate value of the ray tracing end position EP to approach the Sx coordinate value of the reflection position RP. For example, if the reflection position RP is located within a predetermined range from the left edge of the screen, the ray tracing end position EP is moved to the right (positive Sx axis direction) depending on the degree of correction CR. The Sx coordinate value of the ray tracing end position EP is not moved beyond the Sx coordinate value of the reflection position RP. Also, the Sy coordinate value of the ray tracing end position EP does not change before and after the correction. Then, the direction from the reflection position EP to the ray tracing end position EP' after movement is calculated as the ray tracing direction RTD.
このように、画面の端に近い領域においては、反射方向を補正した方向がレイトレース方向として算出される。これにより、画面の端において、SSRによる映り込みを生成することができる。例えば、図15に示されるように、画面の左端にある位置RP1の画素について、反射方向RD1にレイトレースが行われる場合、レイの衝突位置が画面の外側になる場合があり、衝突位置の画素の色を、位置RP1の画素に加えることができない。このため、反射方向に対して補正が行われない場合は、画面の端の部分が、他の部分と異なる色になってしまい、違和感のある画像になってしまう場合がある。 Thus, in areas near the edges of the screen, the direction corrected for the reflection direction is calculated as the ray tracing direction. This allows for the generation of SSR reflections at the edges of the screen. For example, as shown in Figure 15, when ray tracing is performed in the reflection direction RD1 for a pixel at position RP1 on the left edge of the screen, the ray collision point may be outside the screen, and the color of the pixel at the collision point cannot be added to the pixel at position RP1. Therefore, if no correction is performed for the reflection direction, the edges of the screen may have a different color than other parts, resulting in an unnatural-looking image.
本実施形態では、入射方向と法線方向とに基づく反射方向が補正され、補正後の方向がレイトレース方向として設定されるため、レイの衝突位置を画面内に収め易くすることができ、レンダリングした画像に基づいて映り込みを生成することができる。レイトレース終了位置EPのSx座標値は、反射位置RPのSx座標値に近づくように移動される。このため、画面の外側を向く反射方向が、最大の補正が行われても、画面の内側を向く方向とはならず、画面の上方向となる。したがって、例えば、画面の左端の位置の画素に、それよりも右側の画素の色が映り込まない。これにより、不自然にオブジェクトが歪められて地面に映り込むことを防止することができる。 In this embodiment, the reflection direction is corrected based on the incident direction and the normal direction, and the corrected direction is set as the ray tracing direction. This makes it easier to keep the ray collision position within the screen, and allows for the generation of reflections based on the rendered image. The Sx coordinate value of the ray tracing end position EP is moved to approach the Sx coordinate value of the reflection position RP. Therefore, even with maximum correction, the reflection direction pointing outwards from the screen will not point inwards from the screen, but rather upwards. Consequently, for example, the color of pixels to the right of the left edge of the screen will not be reflected in pixels at that position. This prevents unnatural distortion of objects when reflected on the ground.
また、本実施形態では、反射位置が画面の端に近いほど補正の度合いが大きくなる。このため、画面の端の近傍でも、画面内の画素に基づいて映り込みを生成することができる。 Furthermore, in this embodiment, the degree of correction increases as the reflection position approaches the edge of the screen. Therefore, even near the edge of the screen, reflections can be generated based on pixels within the screen.
また、例えば、反射方向が画面の内側を向いている場合において、反射方向が補正された場合、実際の映り込みとはかけ離れた映り込みになることがある。本実施形態では、反射方向が画面の外側を向いていない場合、反射方向の補正は行われないため、実際の映り込みとかけ離れた映り込みが生成されることを防止することができる。 Furthermore, for example, if the reflection direction is directed inward, correcting the reflection direction can result in a reflection that is far removed from the actual reflection. In this embodiment, since no correction is performed when the reflection direction is not directed outward, it is possible to prevent the generation of reflections that are far removed from the actual reflection.
また、反射方向と画面の上方向との角度が比較的大きい場合(例えば45度を超える場合)、補正の度合いCRは小さくなる。反射方向と画面の上方向との角度が閾値を超えると、補正の度合いが0になる。これにより、例えば、地面が斜面になっている場合に、補正の度合いが大きすぎて不自然な映り込みが生成されることを防止することができる。また、反射方向が横方向となる壁面への映り込みに対する補正を抑制することができる。 Furthermore, when the angle between the reflection direction and the top of the screen is relatively large (for example, exceeding 45 degrees), the degree of correction (CR) decreases. When the angle between the reflection direction and the top of the screen exceeds a threshold, the degree of correction becomes 0. This prevents unnatural reflections from being generated due to excessive correction, for example, when the ground is sloped. It also suppresses correction for reflections on walls where the reflection direction is horizontal.
また、本実施形態では、反射方向の補正は、スクリーン座標系における左右方向の成分についてのみ行われる。このため、例えば、画面の左右方向に仮想空間が広がり、横方向にスクロールされるゲームに適している。 Furthermore, in this embodiment, the correction of the reflection direction is performed only for the left-right component in the screen coordinate system. Therefore, it is suitable, for example, for games where the virtual space expands horizontally and is scrolled horizontally.
(キャラクタオブジェクトの映り込みの生成)
次に、キャラクタオブジェクト41及び43の映り込みを生成する方法について説明する。図17は、円柱オブジェクト34の手前側にキャラクタオブジェクト41が存在しないときのゲーム画像の一例を示す図である。図18は、キャラクタオブジェクト41が移動し、円柱オブジェクト34の手前側にキャラクタオブジェクト41が存在するときのゲーム画像の一例を示す図である。
(Generating reflections of character objects)
Next, we will explain how to generate reflections of character objects 41 and 43. Figure 17 shows an example of a game image when character object 41 is not in front of cylindrical object 34. Figure 18 shows an example of a game image when character object 41 has moved and is in front of cylindrical object 34.
図17に示されるように、円柱オブジェクト34の手前側にキャラクタオブジェクト41が存在しない場合、例えば、手前側の反射位置RPdからレイトレースが行われ、衝突位置CPdが算出され、当該衝突位置CPdの色が、反射位置RPdの色に加えられる。各画素に対して同様の処理が行われることで、円柱オブジェクト34の映り込み54が表示される。 As shown in Figure 17, if there is no character object 41 in front of the cylindrical object 34, for example, ray tracing is performed from the reflection position RPd on the front side, the collision position CPd is calculated, and the color of the collision position CPd is added to the color of the reflection position RPd. By performing the same process for each pixel, the reflection 54 of the cylindrical object 34 is displayed.
一方、図18では、円柱オブジェクト34の手前側にキャラクタオブジェクト41が存在し、図17と同じ位置CPdにキャラクタオブジェクト41の頭部が存在する。この場合、反射位置RPdの画素には、図17に示す円柱オブジェクト34の衝突位置CPdの画素の色を加えることができず、反射位置RPdには円柱オブジェクト34の一部が映り込まない。このように、例えば、キャラクタオブジェクト41が円柱オブジェクト34の手前に位置するときは、本来の各オブジェクトの位置関係に応じた自然な映り込みを表現することができない場合がある。 On the other hand, in Figure 18, the character object 41 is located in front of the cylindrical object 34, and the head of the character object 41 is at the same position CPd as in Figure 17. In this case, the pixel at the reflection position RPd cannot have the color of the pixel at the collision position CPd of the cylindrical object 34 shown in Figure 17, and part of the cylindrical object 34 is not reflected at the reflection position RPd. Thus, for example, when the character object 41 is located in front of the cylindrical object 34, it may not be possible to represent a natural reflection that corresponds to the actual positional relationship of each object.
本実施形態では、キャラクタオブジェクト及びその奥側にあるオブジェクトの映り込みを表示するために、図19に示す方法で画像処理が行われる。図19は、キャラクタオブジェクト及びその奥側にあるオブジェクトの映り込みを生成するための画像処理の概要を示す図である。 In this embodiment, image processing is performed using the method shown in Figure 19 to display the reflections of the character object and the object behind it. Figure 19 is a diagram illustrating the overview of the image processing for generating the reflections of the character object and the object behind it.
図19に示されるように、プロセッサ81は、まず、キャラクタオブジェクト以外のオブジェクトのレンダリングを行う(ステップS10)。ここでは、仮想空間に配置された複数のオブジェクト30、32、34、36をフレームバッファに描画する処理が行われる。ステップS10の処理は、図5のステップS1~S2の処理である。 As shown in Figure 19, the processor 81 first renders objects other than character objects (step S10). Here, the process of drawing multiple objects 30, 32, 34, and 36 placed in the virtual space to the frame buffer is performed. The process in step S10 corresponds to the processes in steps S1 and S2 of Figure 5.
次に、プロセッサ81は、キャラクタオブジェクトを別バッファにレンダリングして、当該レンダリングした画像をテクスチャとして設定したキャラクタ平面を作成する(ステップS11)。 Next, the processor 81 renders the character object into a separate buffer and creates a character plane with the rendered image set as a texture (step S11).
図20は、ステップS11で作成されるキャラクタ平面の一例を示す図である。図20に示されるように、キャラクタオブジェクト41が別バッファにレンダリングされ、当該キャラクタオブジェクト41をレンダリングした画像が、2次元の平面オブジェクトにテクスチャとして設定されることにより、キャラクタ平面65が作成される。同様に、キャラクタオブジェクト43をレンダリングした画像をテクスチャとして設定したキャラクタ平面66が作成される。本実施形態では、各キャラクタオブジェクトをレンダリングした画像が、毎フレーム生成される。なお、各キャラクタオブジェクトをレンダリングした画像は、予め用意されてもよい。例えば、キャラクタオブジェクト41の各アクションに応じた画像が予め記憶媒体に記憶され、当該予め記憶された画像をテクスチャとして設定したキャラクタ平面65が作成されてもよい。 Figure 20 shows an example of a character plane created in step S11. As shown in Figure 20, the character object 41 is rendered to a separate buffer, and the rendered image of the character object 41 is set as a texture on a two-dimensional plane object to create the character plane 65. Similarly, a character plane 66 is created by setting the rendered image of the character object 43 as a texture. In this embodiment, an image of each character object is generated every frame. Note that the rendered images of each character object may be prepared in advance. For example, images corresponding to each action of the character object 41 may be stored in advance on a storage medium, and the character plane 65 may be created by setting these pre-stored images as textures.
次に、プロセッサ81は、キャラクタオブジェクト以外のオブジェクトの映り込みの色を算出する(ステップS12)。ここでは、仮想空間に配置された複数のオブジェクト30、32、34、36について、映り込みの色が算出される。具体的には、プロセッサ81は、上述した図5のステップS3~S5の処理を行う。この時点では、キャラクタオブジェクトはフレームバッファに描画されていないため、仮想空間において仮想カメラVCから見てオブジェクトの手前側にキャラクタオブジェクトが存在する場合であっても、当該オブジェクトの映り込みの色を算出することができる。算出されたキャラクタオブジェクト以外のオブジェクトの映り込みの色(以下では、「第1の映り込みの色」という)は、映り込みバッファに記憶される。例えば、映り込みバッファには、第1の映り込みの色を示す色情報として、RGB値とアルファ値とが記憶される。 Next, the processor 81 calculates the reflection colors of objects other than character objects (step S12). Here, the reflection colors are calculated for multiple objects 30, 32, 34, and 36 placed in the virtual space. Specifically, the processor 81 performs the processing shown in steps S3 to S5 of Figure 5 above. At this point, since the character object has not yet been drawn to the frame buffer, the reflection color of that object can be calculated even if the character object is located in front of the virtual camera VC in the virtual space. The calculated reflection colors of objects other than character objects (hereinafter referred to as "first reflection colors") are stored in the reflection buffer. For example, the reflection buffer stores RGB values and alpha values as color information indicating the first reflection color.
次に、プロセッサ81は、キャラクタの映り込みの色を算出する(ステップS13)。ここでは、プロセッサ81は、ステップS11で作成されたキャラクタ平面を仮想空間に配置したときのキャラクタオブジェクトの映り込みの色を算出する。 Next, the processor 81 calculates the color of the character's reflection (step S13). Here, the processor 81 calculates the color of the character object's reflection when the character plane created in step S11 is placed in the virtual space.
図21は、ステップS13におけるキャラクタの映り込みの色の算出について説明するための図である。図21に示されるように、プロセッサ81は、仮想空間におけるキャラクタオブジェクト41の位置及び姿勢に応じてキャラクタ平面65を仮想空間に配置したときの当該キャラクタ平面65とレイとの交差位置を算出する。具体的には、プロセッサ81は、キャラクタ平面65を仮想空間に配置したときのデプスを計算し、反射位置RPeからレイトレース方向RTDeに向かうレイとキャラクタ平面65との交差位置CRPeを算出する。交差位置CRPeにおける画素の色が、キャラクタの映り込みの色(以下では、「第2の映り込みの色」という)として算出される。ここで、キャラクタ平面65のうち、キャラクタオブジェクト41の画像以外の部分については透明に設定され、レイと交差しない。例えば、反射位置RPfからレイトレース方向RTDfに向かうレイは、キャラクタ平面65のうちのキャラクタオブジェクト41の画像とは交差しない。この場合、交差位置は算出されない。算出された第2の映り込みの色は、映り込みバッファに記憶される。例えば、映り込みバッファには、第2の映り込みの色を示す色情報として、RGB値とアルファ値とが記憶される。 Figure 21 is a diagram illustrating the calculation of the color of the character reflection in step S13. As shown in Figure 21, the processor 81 calculates the intersection position of the character plane 65 and the ray when the character plane 65 is placed in the virtual space according to the position and orientation of the character object 41 in the virtual space. Specifically, the processor 81 calculates the depth when the character plane 65 is placed in the virtual space and calculates the intersection position CRPe of the ray traveling from the reflection position RPe toward the ray tracing direction RTDe and the character plane 65. The color of the pixel at the intersection position CRPe is calculated as the color of the character reflection (hereinafter referred to as the "second reflection color"). Here, the part of the character plane 65 other than the image of the character object 41 is set to transparent and does not intersect with the ray. For example, a ray traveling from the reflection position RPf toward the ray tracing direction RTDf does not intersect with the image of the character object 41 in the character plane 65. In this case, the intersection position is not calculated. The calculated second reflection color is stored in the reflection buffer. For example, the reflection buffer stores RGB values and alpha values as color information indicating the color of the second reflection.
図19に戻り、プロセッサ81は、次に、ステップS12の結果とステップS13の結果とに基づいて、着目画素に映り込む色を算出する(ステップS14)。例えば、第1の映り込みの色に、第2の映り込みの色が加えられることにより、着目画素に映り込む色が算出される。ここで、「第1の色に第2の色を加える」とは、2つの色を混合することであってもよい。例えば、「第1の色に第2の色を加える」とは、第1の色を背景色とし、第2の色を前景色とするアルファブレンドを行うことであってもよい。また、「第1の色に第2の色を加える」とは、第2の色を背景色とし、第1の色を前景色とするアルファブレンドを行うことであってもよい。また、「第1の色に第2の色を加える」とは、第1の色と第2の色とをそれぞれのアルファ値に基づいて混合することであってもよい。また、「第1の色に第2の色を加える」とは、第2の色が第1の色よりも優先され、第1の色に第2の色を上塗りすることであってもよい。 Returning to Figure 19, the processor 81 then calculates the color reflected in the pixel of interest based on the results of steps S12 and S13 (step S14). For example, the color reflected in the pixel of interest is calculated by adding the second reflected color to the first reflected color. Here, "adding the second color to the first color" may also mean mixing the two colors. For example, "adding the second color to the first color" may mean performing alpha blending with the first color as the background color and the second color as the foreground color. Alternatively, "adding the second color to the first color" may mean performing alpha blending with the second color as the background color and the first color as the foreground color. Furthermore, "adding the second color to the first color" may mean mixing the first and second colors based on their respective alpha values. Also, "adding the second color to the first color" may mean that the second color takes precedence over the first color, and the second color is overpainted onto the first color.
次に、プロセッサ81は、ステップS14で算出した結果をフレームバッファにレンダリングする(ステップS15)。ここでは、プロセッサ81は、フレームバッファに記憶された着目画素の色に、ステップS14で算出した映り込む色を加える。例えば、プロセッサ81は、着目画素の色を背景色とし、ステップS14で算出した映り込む色を前景色としたアルファブレンドを行う。これにより、フレームバッファに、キャラクタオブジェクト及びキャラクタオブジェクト以外のオブジェクトの映り込みが描画される。 Next, the processor 81 renders the result calculated in step S14 into the frame buffer (step S15). Here, the processor 81 adds the reflected color calculated in step S14 to the color of the pixel of interest stored in the frame buffer. For example, the processor 81 performs alpha blending using the color of the pixel of interest as the background color and the reflected color calculated in step S14 as the foreground color. As a result, the reflections of the character object and other objects are drawn into the frame buffer.
ステップS15の処理が行われた後、プロセッサ81は、キャラクタオブジェクト41及び43をフレームバッファにレンダリングする(ステップS16)。これにより、図22に示されるようなゲーム画像が生成されて表示装置に表示される。 After step S15 is completed, the processor 81 renders the character objects 41 and 43 into the frame buffer (step S16). This generates a game image, as shown in Figure 22, which is then displayed on the display device.
図22は、図19の画像処理が行われた場合に表示されるゲーム画像の一例を示す図である。図22に示されるように、木オブジェクト32及びその映り込み52が表示される。また、キャラクタオブジェクト43及びその映り込み63も表示される。また、円柱オブジェクト34及びその映り込み54が表示される。円柱オブジェクト34の手前側にはキャラクタオブジェクト41が存在し、キャラクタオブジェクト41及びその映り込み61が表示される。円柱オブジェクト34の映り込み54と、キャラクタオブジェクト41の映り込み61とは一部が重なるが、これらは何れも実際の形状および位置関係に応じた形状となり、自然な映り込みを表現することができる。 Figure 22 shows an example of a game image displayed after the image processing shown in Figure 19 has been performed. As shown in Figure 22, a tree object 32 and its reflection 52 are displayed. A character object 43 and its reflection 63 are also displayed. Furthermore, a cylinder object 34 and its reflection 54 are displayed. A character object 41 is located in front of the cylinder object 34, and the character object 41 and its reflection 61 are displayed. While the reflection 54 of the cylinder object 34 and the reflection 61 of the character object 41 partially overlap, their shapes correspond to their actual shapes and relative positions, resulting in a natural-looking reflection.
本実施形態では、キャラクタオブジェクトは平たい形状のオブジェクトである。上述のように、キャラクタオブジェクトの画像をテクスチャとして設定したキャラクタ平面に基づいて、キャラクタオブジェクトの映り込みを生成する場合、キャラクタオブジェクトの映り込みが平面的に見えてしまう。キャラクタオブジェクト自体がある程度の厚さを有する立体的なオブジェクトである場合、その映り込みが平面的に見えると違和感のある画像になる可能性があるが、本実施形態では、キャラクタオブジェクト自体が平たい形状のオブジェクトであるため、違和感のない画像とすることができる。 In this embodiment, the character object is a flat object. As described above, when generating a reflection of the character object based on a character plane where the character object's image is set as a texture, the reflection of the character object appears flat. If the character object itself is a three-dimensional object with a certain thickness, its reflection appearing flat may result in an unnatural image. However, in this embodiment, since the character object itself is a flat object, an image without unnaturalness can be achieved.
(画像処理の詳細)
次に、上述した画像処理の詳細について説明する。まず、本体装置2のメモリ(プロセッサ81内のメモリ、DRAM85、フラッシュメモリ84、又は外部記憶媒体等)に記憶されるデータについて説明する。図23は、本体装置2のメモリに記憶されるデータの一例を示す図である。
(Details of image processing)
Next, we will explain the details of the image processing described above. First, we will explain the data stored in the memory of the main unit 2 (memory in the processor 81, DRAM 85, flash memory 84, or external storage medium, etc.). Figure 23 is a diagram showing an example of the data stored in the memory of the main unit 2.
図23に示されるように、本体装置2のメモリには、プログラムと、操作データと、オブジェクトデータと、キャラクタデータと、キャラクタ平面データとが記憶される。また、本体装置2のメモリには、第1デプスバッファと、第2デプスバッファと、法線バッファと、映り込みバッファと、フレームバッファとが記憶される。 As shown in Figure 23, the memory of the main unit 2 stores the program, operation data, object data, character data, and character plane data. The memory of the main unit 2 also stores the first depth buffer, the second depth buffer, the normal buffer, the reflection buffer, and the frame buffer.
プログラムは、後述するメイン処理を実行するためのプログラムであり、上述した映り込みに関する画像処理を行う画像処理プログラムを含む。プログラムは、スロット23に装着される外部記憶媒体又はフラッシュメモリ84に予め記憶されており、ゲームの実行時にDRAM85に読み込まれる。なお、プログラムは、ネットワーク(例えばインターネット)を介して他の装置から取得されてもよい。 The program is for executing the main processing described later, and includes an image processing program for performing the image processing related to reflections mentioned above. The program is pre-stored in an external storage medium or flash memory 84 installed in slot 23 and is loaded into DRAM 85 when the game is executed. The program may also be obtained from other devices via a network (e.g., the Internet).
操作データは、左コントローラ3及び右コントローラ4から取得された操作に関するデータである。例えば、操作データは、左コントローラ3及び右コントローラ4から所定の時間間隔(例えば、1/200秒間隔)で本体装置2に送信され、メモリに記憶される。 The operation data consists of data related to operations acquired from the left controller 3 and the right controller 4. For example, the operation data is transmitted from the left controller 3 and the right controller 4 to the main unit 2 at predetermined time intervals (e.g., 1/200 second intervals) and stored in memory.
オブジェクトデータは、仮想空間に配置されたキャラクタオブジェクト以外の各オブジェクト(30、32、34、36)に関するデータである。オブジェクトデータは、各オブジェクトの仮想空間における位置や姿勢に関するデータと、形状に関するデータと、テクスチャに関するデータとを含む。また、オブジェクトデータは、各オブジェクトが特定のオブジェクトとして設定されているか否かに関する情報を含む。例えば、木オブジェクト32及び円柱オブジェクト34は、特定のオブジェクトとして設定される。一方、山オブジェクト36は、特定のオブジェクトとして設定されない。 Object data pertains to each object (30, 32, 34, 36) placed in the virtual space, excluding character objects. Object data includes data on each object's position and orientation in the virtual space, as well as data on its shape and texture. Furthermore, object data includes information on whether each object is designated as a specific object. For example, tree object 32 and cylinder object 34 are designated as specific objects. On the other hand, mountain object 36 is not designated as a specific object.
キャラクタデータは、キャラクタオブジェクト41,43に関するデータである。キャラクタデータは、各キャラクタの仮想空間における位置や姿勢に関するデータと、形状に関するデータと、テクスチャに関するデータとを含む。本実施形態では、各キャラクタオブジェクトは、3Dモデルとして形成されているが、上下左右方向に比べて厚さ方向が薄い平面的なオブジェクトとして形成されている。 The character data pertains to character objects 41 and 43. The character data includes data relating to the position and orientation of each character in virtual space, data relating to its shape, and data relating to its texture. In this embodiment, each character object is formed as a 3D model, but it is formed as a planar object with a thickness that is thinner in the thickness direction compared to the up, down, left, and right directions.
キャラクタ平面データは、2次元のオブジェクトであり、キャラクタオブジェクトをレンダリングした画像をテクスチャとして設定した平面オブジェクトに関するデータである。キャラクタ平面データは、キャラクタオブジェクト41の画像をテクスチャとして設定したキャラクタ平面65に関するデータと、キャラクタオブジェクト43の画像をテクスチャとして設定したキャラクタ平面66に関するデータとを含む。 Character plane data is a two-dimensional object, and it is data relating to a plane object for which the rendered image of a character object has been set as a texture. The character plane data includes data relating to character plane 65, for which the image of character object 41 has been set as a texture, and data relating to character plane 66, for which the image of character object 43 has been set as a texture.
第1デプスバッファは、第1デプステストの結果に基づいて生成・更新される画素毎のデプス値を記憶したバッファである。第1デプスバッファには、仮想カメラVCの撮像範囲に含まれるキャラクタオブジェクト以外の全てのオブジェクトのデプス値が記憶される。 The first depth buffer is a buffer that stores the depth values for each pixel, which are generated and updated based on the results of the first depth test. The first depth buffer stores the depth values of all objects except character objects that are included in the imaging range of the virtual camera VC.
第2デプスバッファは、第2デプステストの結果に基づいて生成・更新される画素毎のデプス値を記憶したバッファである。第2デプスバッファには、仮想カメラVCの撮像範囲に含まれる特定のオブジェクトのデプス値が記憶される。 The second depth buffer is a buffer that stores the depth values for each pixel, which are generated and updated based on the results of the second depth test. The second depth buffer stores the depth values of specific objects included within the imaging range of the virtual camera VC.
法線バッファは、各画素の法線情報を記憶したバッファである。 A normal buffer is a buffer that stores the normal information of each pixel.
映り込みバッファは、上記第1の映り込みの色(キャラクタオブジェクト以外のオブジェクトの映り込みの色)及び上記第2の映り込みの色(キャラクタオブジェクトの映り込みの色)を記憶するためのバッファである。映り込みバッファには、後述するレイトレース処理において、レイがキャラクタオブジェクト以外のオブジェクトと衝突した場合に、第1の映り込みの色が記憶され、レイとキャラクタ平面とが交差する場合に、第2の映り込みの色が記憶される。詳細は後述するが、映り込みバッファには、複数の映り込みの色が記憶される場合がある。 The reflection buffer is a buffer for storing the first reflection color (the reflection color of objects other than character objects) and the second reflection color (the reflection color of character objects). In the ray tracing process described later, the reflection buffer stores the first reflection color when a ray collides with an object other than a character object, and the second reflection color when the ray intersects with the character plane. As will be explained in detail later, the reflection buffer may store multiple reflection colors.
フレームバッファは、表示されるゲーム画像を格納するバッファである。フレームバッファに記憶された画像が、所定のタイミングで表示装置に出力され、表示装置において表示される。 The frame buffer is a buffer that stores the game images to be displayed. The images stored in the frame buffer are output to the display device at predetermined timings and displayed on the display device.
(本体装置2におけるゲーム処理の詳細)
次に、図24から図27を参照して、本体装置2において行われる処理の詳細について説明する。図24は、本体装置2のプロセッサ81によって実行されるメイン処理の一例を示すフローチャートである。図24から図27に示す処理は、プロセッサ81のCPU又はGPUによって行われる。
(Details of game processing in main unit 2)
Next, with reference to Figures 24 to 27, the details of the processing performed in the main unit 2 will be described. Figure 24 is a flowchart showing an example of the main processing performed by the processor 81 of the main unit 2. The processing shown in Figures 24 to 27 is performed by the CPU or GPU of the processor 81.
図24に示されるように、プロセッサ81は、まず、初期処理を実行する(ステップS100)。具体的には、プロセッサ81は、3次元の仮想空間を設定し、仮想空間に各オブジェクト(30、32、34、36)、各キャラクタオブジェクト(41,43)、仮想カメラVC、光源、その他のゲームに用いられる各種オブジェクトを配置する。プロセッサ81は、初期処理を実行した後、次のステップS101~ステップS108の処理を所定のフレーム時間間隔(例えば、1/60秒間隔)で繰り返し実行する。 As shown in Figure 24, the processor 81 first performs initial processing (step S100). Specifically, the processor 81 sets up a three-dimensional virtual space and places various objects used in the game, such as objects (30, 32, 34, 36), character objects (41, 43), a virtual camera VC, a light source, and other objects, into the virtual space. After performing the initial processing, the processor 81 repeatedly executes the following steps S101 to S108 at predetermined frame time intervals (for example, 1/60 second intervals).
ステップS101において、プロセッサ81は、コントローラからの操作データを取得する。 In step S101, the processor 81 acquires operation data from the controller.
次に、プロセッサ81は、取得した操作データに基づいて、ゲーム処理を行う(ステップS102)。例えば、プロセッサ81は、操作データに基づいて、キャラクタオブジェクト41を仮想空間内で移動させたり、キャラクタオブジェクト41に所定のアクション(例えば、ジャンプアクション、攻撃アクション等)を行わせたりする。また、プロセッサ81は、所定のアルゴリズムに従ってキャラクタオブジェクト43を仮想空間内で移動させたり、キャラクタオブジェクト43に所定のアクションを行わせたりする。また、プロセッサ81は、キャラクタオブジェクト以外の敵オブジェクトを仮想空間内で制御したり、キャラクタオブジェクトの障害となる障害オブジェクトを仮想空間内で移動させたりする。 Next, the processor 81 performs game processing based on the acquired operation data (step S102). For example, the processor 81 moves the character object 41 in the virtual space or causes the character object 41 to perform a predetermined action (e.g., a jump action, an attack action, etc.) based on the operation data. The processor 81 also moves the character object 43 in the virtual space or causes the character object 43 to perform a predetermined action according to a predetermined algorithm. Furthermore, the processor 81 controls enemy objects other than character objects in the virtual space and moves obstacle objects that hinder character objects in the virtual space.
次に、プロセッサ81は、キャラクタオブジェクト以外のオブジェクトのレンダリング処理を行う(ステップS103)。具体的には、プロセッサ81は、仮想カメラVCの撮像範囲に含まれるキャラクタオブジェクト41、43以外の各オブジェクトについて、第1デプステストを行い、第1デプスバッファを更新する。また、プロセッサ81は、第1デプスバッファに記憶されたデプスに基づいて、各オブジェクトをフレームバッファに描画する。本実施形態では、レンダリングの方法としてディファードレンダリングが用いられる。ステップS103では、法線バッファの更新も行われる。なお、レンダリングの方法としてフォワードレンダリングが用いられてもよい。 Next, the processor 81 performs rendering processing on objects other than character objects (step S103). Specifically, the processor 81 performs a first depth test on each object other than character objects 41 and 43 that are included in the imaging range of the virtual camera VC, and updates the first depth buffer. The processor 81 then draws each object to the frame buffer based on the depth stored in the first depth buffer. In this embodiment, deferred rendering is used as the rendering method. The normal buffer is also updated in step S103. Note that forward rendering may also be used as the rendering method.
次に、プロセッサ81は、キャラクタオブジェクトを別バッファにレンダリングして、キャラクタ平面を作成する(ステップS104)。具体的には、プロセッサ81は、キャラクタオブジェクト41を別バッファにレンダリングし、当該別バッファにレンダリングされたキャラクタオブジェクト41の画像をテクスチャとして平面オブジェクトに設定することにより、キャラクタ平面65を作成する。また、プロセッサ81は、同様に、キャラクタオブジェクト43の画像をテクスチャとして平面オブジェクトに設定したキャラクタ平面66を作成する。 Next, the processor 81 renders the character object into a separate buffer to create a character plane (step S104). Specifically, the processor 81 renders the character object 41 into a separate buffer and creates a character plane 65 by setting the image of the rendered character object 41 as a texture to a plane object. Similarly, the processor 81 creates a character plane 66 by setting the image of the character object 43 as a texture to a plane object.
ステップS104の後、プロセッサ81は、SSR処理を行う(ステップS105)。SSR処理は、キャラクタオブジェクトを含む全てのオブジェクトの映り込みをフレームバッファに描画するための処理である。以下、SSR処理の詳細について説明する。 After step S104, the processor 81 performs SSR processing (step S105). SSR processing is the process of rendering reflections of all objects, including character objects, to the frame buffer. The details of SSR processing are described below.
(SSR処理)
図25は、ステップS105のSSR処理の一例を示すフローチャートである。
(SSR processing)
Figure 25 is a flowchart showing an example of the SSR process in step S105.
図25に示されるように、プロセッサ81は、特定のオブジェクトに対して第2デプステストを行い、第2デプスバッファを更新する(ステップS121)。例えば、プロセッサ81は、予め特定のオブジェクトとして設定された木オブジェクト32及び円柱オブジェクト34に対して、デプステストを行い、第2デプスバッファを更新する。なお、特定のオブジェクトの設定は、メッシュ単位で行われる。 As shown in Figure 25, the processor 81 performs a second depth test on a specific object and updates the second depth buffer (step S121). For example, the processor 81 performs a depth test on the tree object 32 and the cylinder object 34, which have been pre-configured as specific objects, and updates the second depth buffer. Note that the configuration of specific objects is done on a mesh-by-mesh basis.
次に、プロセッサ81は、レイトレース処理を行う(ステップS122)。レイトレース処理は、各着目画素に対して行われる。ここでは、各着目画素への映り込みの色が算出される。なお、レイトレース処理は、全ての画素について行われてもよいし、特定の範囲の画素についてのみ行われてもよい。たとえば、モデルが描画されていない部分、モデルやメッシュ単位でSSRが無効に設定されている部分、法線方向が特定の範囲外の部分等を除外することで負荷を軽減するようにしてもよい。以下、レイトレース処理の詳細について説明する。 Next, processor 81 performs ray tracing (step S122). Ray tracing is performed for each pixel of interest. Here, the color of the reflection on each pixel of interest is calculated. Note that ray tracing may be performed for all pixels, or only for a specific range of pixels. For example, the load may be reduced by excluding areas where the model is not rendered, areas where SSR is disabled at the model or mesh level, or areas where the normal direction is outside a specific range. The details of ray tracing are described below.
(レイトレース処理)
図26は、ステップS122のレイトレース処理の一例を示すフローチャートである。
(Ray tracing)
Figure 26 is a flowchart showing an example of the ray tracing process in step S122.
図26に示されるように、プロセッサ81は、着目画素の仮想空間における位置を反射位置として算出し、反射方向を算出する(ステップS131)。具体的には、プロセッサ81は、着目画素のスクリーン座標系における位置と、第1デプスバッファに記憶された着目画素のデプスとに基づいて、着目画素の仮想空間における位置を、反射位置として算出する。また、プロセッサ81は、仮想カメラVCの位置から反射位置に向かう方向を入射方向とし、当該入射方向と反射位置の法線方向とに基づいて、反射方向を算出する。 As shown in Figure 26, the processor 81 calculates the position of the pixel of interest in virtual space as the reflection position and calculates the reflection direction (step S131). Specifically, the processor 81 calculates the position of the pixel of interest in virtual space as the reflection position based on the position of the pixel of interest in the screen coordinate system and the depth of the pixel of interest stored in the first depth buffer. Furthermore, the processor 81 defines the direction from the position of the virtual camera VC toward the reflection position as the incident direction, and calculates the reflection direction based on this incident direction and the normal direction of the reflection position.
次に、プロセッサ81は、算出した反射方向、又は、反射方向を補正した方向をレイトレース方向として設定する(ステップS132)。ここでは、補正条件が満たされる場合は、反射方向を補正した方向がレイトレース方向として設定され、補正条件が満たされない場合は、反射方向がレイトレース方向として設定される。また、レイトレース終了位置が設定される。補正条件および補正の方法については、上述した通りである。 Next, the processor 81 sets the calculated reflection direction, or the direction corrected from the reflection direction, as the ray tracing direction (step S132). Here, if the correction conditions are met, the direction corrected from the reflection direction is set as the ray tracing direction; if the correction conditions are not met, the reflection direction is set as the ray tracing direction. The ray tracing end position is also set. The correction conditions and correction method are as described above.
ステップS132の後、プロセッサ81は、判定用デプスバッファとして第1デプスバッファを設定し、着目画素からレイトレースを開始する(ステップS133)。レイトレースはスクリーン座標系で行われる。次に、プロセッサ81は、レイを所定距離進める(ステップS134)。 After step S132, the processor 81 sets a first depth buffer as a depth buffer for determination and starts ray tracing from the pixel of interest (step S133). Ray tracing is performed in the screen coordinate system. Next, the processor 81 advances the ray a predetermined distance (step S134).
続いて、プロセッサ81は、トレース距離が最大距離Lbを超えたか否かを判定する(ステップS135)。具体的には、プロセッサ81は、スクリーン座標系におけるレイの先端がレイトレース終了位置に到達したか否かを判定する。 Next, the processor 81 determines whether the trace distance has exceeded the maximum distance Lb (step S135). Specifically, the processor 81 determines whether the leading edge of the ray in the screen coordinate system has reached the ray trace end position.
トレース距離がLbを超えたと判定した場合(ステップS135:YES)、プロセッサ81は、次にステップS141の処理を行う。 If it is determined that the trace distance exceeds Lb (step S135: YES), the processor 81 then performs the process in step S141.
一方、トレース距離がLb以下である場合(ステップS135:NO)、プロセッサ81は、レイがオブジェクトと衝突したか否かを判定する(ステップS136)。具体的には、プロセッサ81は、判定用デプスバッファを用いて、レイの先端がオブジェクトと衝突したか否かを判定する。 On the other hand, if the trace distance is less than or equal to Lb (step S135: NO), the processor 81 determines whether or not the ray has collided with an object (step S136). Specifically, the processor 81 uses a depth buffer for determination to determine whether or not the leading edge of the ray has collided with an object.
レイがオブジェクトと衝突していないと判定した場合(ステップS136:NO)、プロセッサ81は、トレース距離がLa以上か否かを判定する(ステップS137)。 If it is determined that the ray has not collided with an object (step S136: NO), the processor 81 determines whether the trace distance is greater than or equal to La (step S137).
トレース距離がLa以上である場合(ステップS137:YES)、プロセッサ81は、判定用デプスバッファを第2デプスバッファに変更し(ステップS138)、再びステップS134の処理を実行する。一方、トレース距離がLa未満である場合(ステップS137:NO)、プロセッサ81は、判定用デプスバッファを維持したまま、ステップS134の処理を再び実行する。 If the trace distance is greater than or equal to La (step S137: YES), the processor 81 changes the determination depth buffer to the second depth buffer (step S138) and executes the process in step S134 again. On the other hand, if the trace distance is less than La (step S137: NO), the processor 81 maintains the determination depth buffer and executes the process in step S134 again.
一方、レイがオブジェクトと衝突したと判定した場合(ステップS136:YES)、プロセッサ81は、レイの衝突位置の色から第1の映り込みの色を算出する(ステップS139)。例えば、プロセッサ81は、フレームバッファに記憶された衝突位置の画素の色を第1の映り込みの色として算出してもよいし、衝突位置の画素の色に所定の処理を加えた色を第1の映り込みの色として算出してもよい。第1デプスバッファに基づいて衝突したと判定された場合と第2デプスバッファに基づいて衝突したと判定された場合とで、第1の映り込みの色が異なる。例えば、判定用デプスバッファとして第1デプスバッファが設定されている場合、トレース距離に応じて、衝突位置の画素の色を薄く変化させ(アルファ値を小さくし)、当該変化させた色を第1の映り込みの色として算出してもよい。また、判定用デプスバッファとして第2デプスバッファが設定されている場合、トレース距離に関わらず、衝突位置の画素の色を、第1の映り込みの色として算出してもよい。また、判定用デプスバッファとして第2デプスバッファが設定されている場合、トレース距離に応じて衝突位置の画素の色を薄く変化させるが、判定用デプスバッファとして第1デプスバッファが設定されている場合よりは濃くなるように変化させ、当該変化させた色を、第1の映り込みの色として算出してもよい。そして、プロセッサ81は、算出した第1の映り込みの色を映り込みバッファに記憶する。ここで、第1デプスバッファに基づいてレイが衝突したと判定された場合に映り込みバッファに記憶される第1の映り込みの色を、「第1の映り込みの色(第1デプスバッファ)」と表記する。また、第2デプスバッファに基づいてレイが衝突したと判定された場合に映り込みバッファに記憶される第1の映り込みの色を、「第1の映り込みの色(第2デプスバッファ)」と表記する。 On the other hand, if it is determined that the ray has collided with an object (step S136: YES), the processor 81 calculates the color of the first reflection from the color of the ray's collision location (step S139). For example, the processor 81 may calculate the color of the pixel at the collision location stored in the frame buffer as the color of the first reflection, or it may calculate the color of the pixel at the collision location after applying a predetermined process as the color of the first reflection. The color of the first reflection differs depending on whether the collision is determined based on the first depth buffer or the second depth buffer. For example, if the first depth buffer is set as the depth buffer for determination, the color of the pixel at the collision location may be lightened (alpha value reduced) according to the trace distance, and the changed color may be calculated as the color of the first reflection. Also, if the second depth buffer is set as the depth buffer for determination, the color of the pixel at the collision location may be calculated as the color of the first reflection regardless of the trace distance. Furthermore, if a second depth buffer is set as the depth buffer for determination, the color of the pixel at the collision position is lightened according to the trace distance, but it is changed to be darker than when the first depth buffer is set as the depth buffer for determination, and this changed color may be calculated as the color of the first reflection. The processor 81 then stores the calculated color of the first reflection in the reflection buffer. Here, the color of the first reflection stored in the reflection buffer when a ray collision is determined based on the first depth buffer is denoted as "color of the first reflection (first depth buffer)". Similarly, the color of the first reflection stored in the reflection buffer when a ray collision is determined based on the second depth buffer is denoted as "color of the first reflection (second depth buffer)".
次に、プロセッサ81は、判定用デプスバッファが第1デプスバッファであり、かつ、ステップS139で算出した第1の映り込みの色が半透明か否かを判定する(ステップS140)。例えば、トレース距離がLa以下であり、かつ、第1の映り込みの色が半透明である場合は、さらに奥側にレイトレースが行われる。半透明であるということは、映り込みのアルファ値が1.0未満であるということであるが、アルファ値は距離La、衝突位置、その他各種パラメータに基づいて独自に算出される。 Next, the processor 81 determines whether the depth buffer for determination is the first depth buffer and whether the color of the first reflection calculated in step S139 is semi-transparent (step S140). For example, if the trace distance is less than or equal to La and the color of the first reflection is semi-transparent, ray tracing is performed further into the background. Semi-transparent means that the alpha value of the reflection is less than 1.0, but the alpha value is calculated independently based on the distance La, collision position, and various other parameters.
ステップS140でNOと判定した場合、プロセッサ81は、ステップS141に処理を進める。ステップS140でYESと判定した場合、プロセッサ81は、ステップS138に処理を進める。 If the result in step S140 is NO, the processor 81 proceeds to step S141. If the result in step S140 is YES, the processor 81 proceeds to step S138.
ステップS141において、プロセッサ81は、キャラクタオブジェクトの映り込みの色(第2の映り込みの色)を算出する。以下、ステップS141の処理の詳細について説明する。 In step S141, the processor 81 calculates the color of the reflection of the character object (the color of the second reflection). The details of the process in step S141 are described below.
図27は、ステップS141におけるキャラクタの映り込みの色の算出処理の一例を示すフローチャートである。 Figure 27 is a flowchart showing an example of the color calculation process for character reflections in step S141.
図27に示されるように、プロセッサ81は、レイとキャラクタ平面との交差位置を算出する(ステップS151)。具体的には、プロセッサ81は、キャラクタ平面をキャラクタオブジェクトの仮想空間における位置及び姿勢に応じて配置したときのデプスを算出し、上記レイトレースに用いられたレイと、キャラクタ平面とが交差するか否かを判定する。レイがキャラクタ平面と交差する場合、プロセッサ81は、その交差位置を算出する。 As shown in Figure 27, the processor 81 calculates the intersection position of the ray and the character plane (step S151). Specifically, the processor 81 calculates the depth when the character plane is positioned according to the position and orientation of the character object in virtual space, and determines whether the ray used in the ray tracing intersects with the character plane. If the ray intersects with the character plane, the processor 81 calculates the intersection position.
次に、プロセッサ81は、交差位置の色を第2の映り込みの色として映り込みバッファに記憶する(ステップS152)。具体的には、プロセッサ81は、交差位置に対応するキャラクタオブジェクトのテクスチャ画像の画素の色に基づく色を、第2の映り込みの色として記憶する。なお、第2の映り込みの色は、キャラクタオブジェクトのテクスチャ画像の画素の色であってもよいし、当該画素の色に所定の処理を加えて算出した色であってもよい。プロセッサ81は、ステップS152の処理を行った場合、図27に示す処理を終了し、処理を図26に戻す。なお、レイが複数のキャラクタ平面と交差する場合、複数の第2の映り込みの色が映り込みバッファに記憶される。この場合、複数の第2の映り込みの色は、交差位置が仮想カメラに近い順に、映り込みバッファに記憶されてもよい。 Next, the processor 81 stores the color of the intersection point as the color of the second reflection in the reflection buffer (step S152). Specifically, the processor 81 stores the color based on the pixel color of the character object's texture image corresponding to the intersection point as the color of the second reflection. The color of the second reflection may be the pixel color of the character object's texture image, or it may be a color calculated by applying a predetermined process to the pixel color. After performing the process in step S152, the processor 81 terminates the process shown in Figure 27 and returns to the process shown in Figure 26. If the ray intersects with multiple character planes, multiple second reflection colors are stored in the reflection buffer. In this case, the multiple second reflection colors may be stored in the reflection buffer in order of proximity of the intersection point to the virtual camera.
ステップS139及びステップS152の処理が行われることにより、映り込みバッファには、0から複数の映り込みの色が記憶される。例えば、映り込みバッファには、レイの衝突位置又は交差位置に応じた映り込みの色が、仮想カメラに近い順に、記憶されてもよい。例えば、トレース距離がLa未満である第1の位置でレイが衝突したと判定され、かつ、トレース距離がLa以上Lb未満である第2の位置でレイが衝突したと判定された場合において、第1の位置と第2の位置との間でレイがキャラクタ平面と交差する場合、映り込みバッファには、仮想カメラから近い順に、第1の映り込みの色(第1デプスバッファ)、第2の映り込みの色、第1の映り込みの色(第2デプスバッファ)が記憶される(図23参照)。なお、レイが何れのオブジェクトとも衝突せず、キャラクタ平面とも交差しない場合、映り込みバッファには、映り込みの色は記憶されない。 As a result of the processing in steps S139 and S152, the reflection buffer stores zero to multiple reflection colors. For example, the reflection buffer may store reflection colors corresponding to the ray's collision or intersection positions, in order of proximity to the virtual camera. For example, if it is determined that a ray has collided at a first position where the trace distance is less than La, and also determined that a ray has collided at a second position where the trace distance is between La and Lb, and the ray intersects the character plane between the first and second positions, the reflection buffer stores the first reflection color (first depth buffer), the second reflection color, and the first reflection color (second depth buffer) in order of proximity to the virtual camera (see Figure 23). If the ray does not collide with any object and does not intersect the character plane, no reflection color is stored in the reflection buffer.
図26に戻り、プロセッサ81は、ステップS141の処理の後、映り込みバッファに記憶された映り込みの色に基づいて、着目画素に映り込む色を算出する(ステップS142)。映り込みバッファに複数の映り込みの色が記憶されている場合、プロセッサ81は、仮想カメラから遠い順に複数の映り込みの色をアルファブレンドすることで、着目画素に映り込む色を算出してもよい。例えば、図23に示されるように、映り込みバッファに、仮想カメラから近い順に、第1の映り込みの色(第1デプスバッファ)、第2の映り込みの色、第1の映り込みの色(第2デプスバッファ)が記憶されている場合、プロセッサ81は、第1の映り込みの色(第2デプスバッファ)に第2の映り込みの色をアルファブレンドした色を算出し、さらにその算出した色に第1の映り込みの色(第1デプスバッファ)をアルファブレンドすることにより、着目画素に映り込む色を算出してもよい。また、例えば、映り込みバッファにおいて、仮想カメラに近い順に、第2の映り込みの色、第1の映り込みの色が記憶されている場合(すなわち、仮想カメラから見てキャラクタの手前側にオブジェクトが存在せず、かつ、キャラクタの奥側にオブジェクトが存在する場合)、プロセッサ81は、第1の映り込みの色に第2の映り込みの色をアルファブレンドすることで、着目画素に映り込む色を算出してもよい。例えば、手前側の第2の映り込みの色が不透明である場合、着目画素に映り込む色として、第2の映り込みの色が設定される。また、手前側の第2の映り込みの色が半透明である場合、着目画素に映り込む色として、第1の映り込みの色と第2の映り込みの色とをブレンドした色が算出される。プロセッサ81は、算出した映り込む色をメモリに記憶する。 Returning to Figure 26, after processing in step S141, the processor 81 calculates the color reflected in the pixel of interest based on the reflected colors stored in the reflection buffer (step S142). If multiple reflected colors are stored in the reflection buffer, the processor 81 may calculate the color reflected in the pixel of interest by alpha blending the multiple reflected colors in order of distance from the virtual camera. For example, as shown in Figure 23, if the reflection buffer stores the first reflected color (first depth buffer), the second reflected color, and the first reflected color (second depth buffer) in order of proximity to the virtual camera, the processor 81 may calculate a color by alpha blending the second reflected color with the first reflected color (second depth buffer), and then alpha blend the first reflected color (first depth buffer) with the calculated color to calculate the color reflected in the pixel of interest. Furthermore, for example, if the reflection buffer stores the colors of the second reflection and the first reflection in order of proximity to the virtual camera (i.e., when there are no objects in front of the character from the virtual camera's perspective, and there are objects behind the character), the processor 81 may calculate the color reflected in the pixel of interest by alpha blending the color of the second reflection with the color of the first reflection. For example, if the color of the second reflection on the foreground is opaque, the color of the second reflection is set as the color reflected in the pixel of interest. Also, if the color of the second reflection on the foreground is semi-transparent, a color is calculated by blending the colors of the first and second reflections as the color reflected in the pixel of interest. The processor 81 stores the calculated reflection color in memory.
ステップS142の処理を行った場合、プロセッサ81は、図26の処理を終了し、処理を図25に戻す。 If the process in step S142 is completed, the processor 81 terminates the process shown in Figure 26 and returns to the process shown in Figure 25.
図25に戻り、ステップS122の後、プロセッサ81は、レイトレース処理の結果に基づいて、フレームバッファへのレンダリングを行う(ステップS123)。例えば、プロセッサ81は、フレームバッファに記憶された着目画素の色に、ステップS142で算出された映り込む色を加える。これにより、着目画素の色に、ステップS142で算出された映り込む色が反映される。 Returning to Figure 25, after step S122, the processor 81 renders to the frame buffer based on the ray tracing results (step S123). For example, the processor 81 adds the reflected color calculated in step S142 to the color of the pixel of interest stored in the frame buffer. This ensures that the reflected color calculated in step S142 is reflected in the color of the pixel of interest.
次に、プロセッサ81は、全画素についてステップS122及びS123の処理を行ったか否かを判定する(ステップS124)。プロセッサ81は、ステップS124でNOと判定した場合、ステップS122の処理を再び実行する。全画素についてステップS122及びS123の処理が行われることにより、仮想空間に配置されたキャラクタオブジェクト以外のオブジェクトの映り込み(52、54)と、キャラクタオブジェクトの映り込み(61、63)とがフレームバッファに描画される。プロセッサ81は、ステップS124でYESと判定した場合、図25の処理を終了し、処理を図24に戻す。 Next, the processor 81 determines whether or not the processes in steps S122 and S123 have been performed for all pixels (step S124). If the processor 81 determines NO in step S124, it repeats the process in step S122. By performing the processes in steps S122 and S123 for all pixels, reflections of objects other than character objects placed in the virtual space (52, 54) and reflections of character objects (61, 63) are drawn to the frame buffer. If the processor 81 determines YES in step S124, it terminates the process in Figure 25 and returns to the process in Figure 24.
図24に戻り、ステップS105の後、プロセッサ81は、キャラクタオブジェクト41及び43をフレームバッファにさらにレンダリングする(ステップS106)。 Returning to Figure 24, after step S105, the processor 81 further renders the character objects 41 and 43 into the frame buffer (step S106).
次に、プロセッサ81は、フレームバッファに記憶された画像を表示装置に出力する(ステップS107)。これにより、ゲーム画像が表示される。 Next, the processor 81 outputs the image stored in the frame buffer to the display device (step S107). This displays the game image.
次に、プロセッサ81は、ゲームを終了するか否かを判定する(ステップS108)。例えば、プレイヤによってゲームの終了が指示された場合、プロセッサ81は、図24に示すゲーム処理を終了する。プロセッサ81は、ゲームを終了しないと判定した場合(ステップS108:NO)、ステップS101の処理を再び実行する。以上で、図24に示すメイン処理の説明を終了する。 Next, the processor 81 determines whether or not to terminate the game (step S108). For example, if the player instructs the game to end, the processor 81 terminates the game processing shown in Figure 24. If the processor 81 determines that the game should not be terminated (step S108: NO), it executes the process in step S101 again. This concludes the explanation of the main processing shown in Figure 24.
なお、上記フローチャートにおける処理の順番、内容、判定に用いられた値等は単なる一例であり、これらは適宜変更されてもよい。 The order of processes, content, and values used for determination in the flowchart above are merely examples and may be modified as appropriate.
以上のように、本実施形態では、トレース距離がLa未満である場合は、第1デプスバッファに基づいてレイの衝突判定が行われ、トレース距離がLa以上である場合は、第2デプスバッファに基づいてレイの衝突判定が行われる(ステップS135~ステップS140)。これにより、特定のオブジェクトについてトレース距離が長い場合であっても映り込みを表示させることができる。また、特定のオブジェクト以外のオブジェクトについては、映り込みを表示させないようにすることができ、所望のオブジェクトを映り込ませたり、映り込ませないようにしたりすることができる。また、第1デプスバッファ及び第2デプスバッファに基づいて映り込みを生成し、第1デプスバッファに基づく場合はトレース距離に応じて映り込みの色の薄くすることにより、特定のオブジェクトについては大きくはっきりと映り込ませ、それ以外のオブジェクトについては、小さく映り込ませることができる。 As described above, in this embodiment, if the trace distance is less than La, ray collision detection is performed based on the first depth buffer, and if the trace distance is La or greater, ray collision detection is performed based on the second depth buffer (steps S135 to S140). This allows reflections to be displayed even when the trace distance is long for a specific object. Furthermore, reflections can be hidden from objects other than the specific object, allowing for the display or exclusion of desired objects. Additionally, by generating reflections based on the first and second depth buffers, and by lightening the color of the reflection according to the trace distance when based on the first depth buffer, specific objects can be reflected large and clearly, while other objects can be reflected small.
また、本実施形態では、着目画素(反射位置)が画面の端に近い場合、入射方向と反射位置における法線方向とに基づく反射方向を補正した方向が、レイトレース方向として設定される(ステップS132)。これにより、フレームバッファに描画された画素に基づいて映り込みの色を算出することができ、画面の端であっても映り込みを生成することができる。 Furthermore, in this embodiment, when the pixel of interest (reflection position) is near the edge of the screen, the direction obtained by correcting the reflection direction based on the incident direction and the normal direction at the reflection position is set as the ray tracing direction (step S132). This allows the color of the reflection to be calculated based on the pixels drawn in the frame buffer, enabling the generation of reflections even at the edge of the screen.
また、本実施形態では、キャラクタオブジェクト以外のオブジェクトを先にフレームバッファに描画し、当該オブジェクトの映り込みを描画し、さらにキャラクタオブジェクトの映り込みを描画し、最後にキャラクタオブジェクトを描画する。これにより、仮想カメラから見てキャラクタオブジェクトの奥側にあるオブジェクトの映り込みを表示するとともに、キャラクタオブジェクトの映り込みも表示することができる。 Furthermore, in this embodiment, objects other than character objects are first drawn to the frame buffer, their reflections are drawn, then the reflections of character objects are drawn, and finally the character objects are drawn. This allows for the display of reflections of objects behind the character object from the virtual camera's perspective, as well as the reflection of the character object itself.
また、本実施形態では、第1デプスバッファに基づいて算出された衝突位置の色と、第2デプスバッファに基づいて算出された衝突位置の色と、キャラクタ平面との交差位置の色とを算出し、奥から順にこれらの色をアルファブレンドする。これにより、仮想カメラから見て各オブジェクトが重なる場合でも、各オブジェクトの映り込みを表示することができる。 Furthermore, in this embodiment, the color of the collision position calculated based on the first depth buffer, the color of the collision position calculated based on the second depth buffer, and the color of the intersection position with the character plane are calculated, and these colors are alpha-blended in order from the back. This allows the reflection of each object to be displayed even when the objects overlap as viewed from the virtual camera.
(変形例)
以上、本実施形態の画像処理について説明したが、上記実施形態は単なる一例であり、例えば以下のような変形が加えられてもよい。
(Variant)
The image processing of this embodiment has been described above, but the above embodiment is merely an example, and modifications such as the following may be made.
例えば、上記実施形態では、レンダリングの方法としてディファードレンダリングが用いられたが、他の実施形態では、フォワードレンダリングが用いられてもよい。フォワードレンダリングが用いられる場合、上記SSR処理において、例えば、着目画素の周囲の複数の画素のデプスに基づいて着目画素に対応する反射位置の法線方向を推定し、入射方向と当該法線方向とに基づいて、反射方向が算出されてもよい。あるいは、仮想空間におけるメッシュの姿勢を算出し、着目画素に対応する反射位置の法線方向を算出し、当該法線方向に基づいて、反射方向が算出されてもよい。 For example, in the above embodiment, deferred rendering was used as the rendering method, but in other embodiments, forward rendering may be used. When forward rendering is used, in the SSR processing described above, for example, the normal direction of the reflection position corresponding to the pixel of interest may be estimated based on the depth of multiple pixels surrounding the pixel of interest, and the reflection direction may be calculated based on the incident direction and the said normal direction. Alternatively, the pose of the mesh in virtual space may be calculated, the normal direction of the reflection position corresponding to the pixel of interest may be calculated, and the reflection direction may be calculated based on the said normal direction.
また、上記実施形態では、画面の左端又は右端から所定範囲の領域の画素について反射方向を補正したが、他の実施形態では、画面の上端又は下端から所定範囲の領域の画素についても反射方向を補正してもよい。上記実施形態では、反射方向の補正において、スクリーン座標系におけるレイトレース終了位置のSx軸方向における位置を、反射位置のSx軸方向における位置に近づけた。他の実施形態では、レイトレース終了位置のSy軸方向における位置についても、Sy軸正方向又は負方向に移動させることにより、反射方向の補正が行われてもよい。レイトレース終了位置を横方向及び/又は縦方向に移動させることで、レイの衝突位置が画面内に収まるように、反射方向が補正されてもよい。 Furthermore, in the above embodiment, the reflection direction was corrected for pixels in a predetermined range from the left or right edge of the screen. However, in other embodiments, the reflection direction may also be corrected for pixels in a predetermined range from the top or bottom edge of the screen. In the above embodiment, in correcting the reflection direction, the position of the ray tracing end position in the Sx axis direction in the screen coordinate system was brought closer to the position of the reflection position in the Sx axis direction. In other embodiments, the reflection direction may also be corrected by moving the position of the ray tracing end position in the Sy axis direction in the positive or negative direction of the Sy axis. The reflection direction may also be corrected by moving the ray tracing end position horizontally and/or vertically so that the ray collision position fits within the screen.
また、上記実施形態では、レイトレースをスクリーン座標系で行ったが、他の実施形態では、レイトレースを仮想空間のxyz座標系で行ってもよい。すなわち、仮想空間のxyz座標系においてレイを伸ばしていき、レイの衝突位置を計算し、衝突位置に対応する位置の画素の色を、映り込みの色として算出してもよい。 Furthermore, while ray tracing was performed in the screen coordinate system in the above embodiment, in other embodiments, ray tracing may be performed in the xyz coordinate system of a virtual space. That is, rays may be extended in the xyz coordinate system of a virtual space, the collision positions of the rays may be calculated, and the color of the pixel at the position corresponding to the collision position may be calculated as the reflected color.
また、上記実施形態では、キャラクタオブジェクトの画像をテクスチャとして平面オブジェクトに設定したキャラクタ平面を作成し、当該キャラクタ平面を用いてキャラクタオブジェクトの映り込みの色を算出した。他の実施形態では、キャラクタオブジェクトの画像をテクスチャとして3次元のオブジェクトに設定し、当該3次元のオブジェクトを用いてキャラクタオブジェクトの映り込みの色を算出してもよい。また、上記実施形態では、キャラクタオブジェクトは平たい形状のオブジェクトであるとしたが、他の実施形態では、キャラクタオブジェクトは厚さを有する立体的な形状のオブジェクトであってもよい。 Furthermore, in the above embodiment, a character plane was created by setting the image of the character object as a texture on a planar object, and the color of the reflection of the character object was calculated using this character plane. In other embodiments, the image of the character object may be set as a texture on a three-dimensional object, and the color of the reflection of the character object may be calculated using this three-dimensional object. Also, in the above embodiment, the character object was assumed to be a flat object, but in other embodiments, the character object may be a three-dimensional object with thickness.
また、上記実施形態では、地面を反射面として、地面にオブジェクトが映り込む場合について説明したが、地面以外の面(例えば、壁面や天井面)を反射面として、上述した処理によりオブジェクトを映り込ませてもよい。 Furthermore, while the above embodiment described the case where the ground is used as a reflective surface and an object is reflected on the ground, it is also possible to use a surface other than the ground (for example, a wall or ceiling) as a reflective surface and reflect the object using the process described above.
また、上記実施形態では、ゲーム画像を生成するものとしたが、上述した画像処理は、ゲーム画像に限らず任意の画像を生成する際に用いられてもよい。 Furthermore, while the above embodiment was used to generate game images, the image processing described above may be used to generate any image, not just game images.
また、上記ハードウェア構成は単なる一例であり、他の任意のハードウェアにおいて上記画像処理が行われてもよい。例えば、パーソナルコンピュータ、タブレット端末、スマートフォン、インターネット上のサーバ等、任意の情報処理装置において上記処理が実行されてもよい。また、上記画像処理は、複数の装置を含む情報処理システムにおいて実行されてもよい。複数の装置が上記画像処理を分散実行してもよい。また、上記画像処理を行う装置と、画像を表示する装置とが異なってもよい。例えば、第1の装置(例えばサーバ)が、上記画像処理の一部又は全部を実行することにより画像を生成し、生成した画像をネットワーク(例えば、インターネットやLAN)を介して第2の装置に送信し、第2の装置が当該画像を表示してもよい。 Furthermore, the above hardware configuration is merely an example, and the image processing may be performed on any other hardware. For example, the processing may be executed on any information processing device, such as a personal computer, tablet terminal, smartphone, or server on the internet. Also, the image processing may be performed in an information processing system including multiple devices. Multiple devices may perform the image processing in a distributed manner. Furthermore, the device performing the image processing and the device displaying the image may be different. For example, a first device (e.g., a server) may generate an image by performing part or all of the image processing, transmit the generated image to a second device via a network (e.g., the internet or a LAN), and the second device may display the image.
また上記実施形態及びその変形例に係る構成は、互いに矛盾しない限り、任意に組み合わせることが可能である。また、上記は本発明の例示に過ぎず、上記以外にも種々の改良や変形が加えられてもよい。 Furthermore, the configurations of the above embodiments and their modified forms can be combined in any way, as long as they do not contradict each other. Also, the above are merely illustrative examples of the present invention, and various other improvements and modifications may be made.
1 ゲームシステム
2 本体装置
81 プロセッサ
32 木オブジェクト
34 円柱オブジェクト
36 山オブジェクト
41、43 キャラクタオブジェクト
1. Game System 2. Main Unit 81. Processor 32. Tree Object 34. Cylinder Object 36. Mountain Object 41, 43. Character Object
Claims (12)
仮想空間内のオブジェクトのうち、第1の種類のオブジェクトを除くオブジェクトについて、
第1のデプスバッファを用いて第1のデプステストと当該第1のデプスバッファの更新を行わせ、
前記第1のデプステストの結果に基づいてフレームバッファに描画を行わせ、
前記第1の種類のオブジェクトについて、フレームバッファへの描画を行わずにレンダリングした画像をテクスチャとして設定した平面オブジェクトを前記仮想空間内の前記第1の種類のオブジェクトの位置に配置させ、
描画が行われた前記フレームバッファの画素ごとに、当該画素を着目画素として、
前記第1のデプスバッファのデプスに基づいて、仮想カメラから前記着目画素に対応する前記仮想空間内の位置に向かう方向を入射方向、当該位置を反射位置として反射するレイの方向をレイトレース方向として算出させ、
当該レイトレース方向に沿って当該レイをトレースさせ、前記第1のデプスバッファに基づいて、前記レイが前記仮想空間内においてオブジェクトに衝突する衝突位置を判定させ、
前記レイのトレース距離が第1の距離以内となる範囲内において前記衝突位置が判定された場合に、当該衝突位置に対応する前記フレームバッファ内の画素の色に基づいた色を、前記着目画素の色に加えさせる映り込みの色として決定させ、
前記レイが前記平面オブジェクトと交差する場合に、交差位置の前記テクスチャの色に基づいて前記着目画素の色にさらに加えさせる映り込みの色として決定させ、
前記フレームバッファに前記映り込みの色を反映させ、
前記映り込みの色を反映させた後に、前記第1の種類のオブジェクトをフレームバッファに描画させる、画像処理プログラム。 In the computer of the information processing device,
Of the objects in the virtual space, all objects except for the first type of object ,
The first depth buffer is used to perform a first depth test and update the first depth buffer.
Based on the results of the first depth test, the frame buffer is used to draw.
For the first type of object, a planar object with a rendered image set as a texture without drawing to the frame buffer is placed at the position of the first type of object in the virtual space.
For each pixel of the frame buffer on which drawing has been performed, the pixel in question is designated as the pixel of interest.
Based on the depth of the first depth buffer, the direction from the virtual camera toward the position in the virtual space corresponding to the pixel of interest is calculated as the incident direction, and the direction of the ray reflected with that position as the reflection position is calculated as the ray tracing direction.
The ray is traced along the ray tracing direction, and the collision position where the ray collides with an object in the virtual space is determined based on the first depth buffer.
When the collision position is determined within a range where the tracing distance of the ray is within a first distance, a color based on the color of the pixel in the frame buffer corresponding to the collision position is determined as the reflection color to be added to the color of the pixel of interest.
When the ray intersects the planar object, the color of the texture at the intersection point is determined as the reflected color to be added to the color of the pixel of interest.
The frame buffer is then configured to reflect the color of the reflection.
An image processing program that, after reflecting the colors of the reflections, draws the first type of object to the frame buffer.
仮想空間内のオブジェクトのうち、第1の種類のオブジェクトを除くオブジェクトについて、
第1のデプスバッファを用いて第1のデプステストと当該第1のデプスバッファの更新を行い、
前記第1のデプステストの結果に基づいてフレームバッファに描画を行い、
前記第1の種類のオブジェクトについて、フレームバッファへの描画を行わずにレンダリングした画像をテクスチャとして設定した平面オブジェクトを前記仮想空間内の前記第1の種類のオブジェクトの位置に配置し、
描画が行われた前記フレームバッファの画素ごとに、当該画素を着目画素として、
前記第1のデプスバッファのデプスに基づいて、仮想カメラから前記着目画素に対応する前記仮想空間内の位置に向かう方向を入射方向、当該位置を反射位置として反射するレイの方向をレイトレース方向として算出し、
当該レイトレース方向に沿って当該レイをトレースさせ、前記第1のデプスバッファに基づいて、前記レイが前記仮想空間内においてオブジェクトに衝突する衝突位置を判定し、
前記レイのトレース距離が第1の距離以内となる範囲内において前記衝突位置が判定された場合に、当該衝突位置に対応する前記フレームバッファ内の画素の色に基づいた色を、前記着目画素の色に加える映り込みの色として決定し、
前記レイが前記平面オブジェクトと交差する場合に、交差位置の前記テクスチャの色に基づいて前記着目画素の色にさらに加える映り込みの色として決定し、
前記フレームバッファに前記映り込みの色を反映し、
前記映り込みの色を反映した後に、前記第1の種類のオブジェクトをフレームバッファに描画する、画像処理システム。 An image processing system comprising a processor, wherein the processor is
Of the objects in the virtual space, all objects except for the first type of object ,
A first depth test and an update of the first depth buffer are performed using the first depth buffer.
Based on the results of the first depth test, the data is drawn to the frame buffer.
For the first type of object, a planar object with a rendered image (without drawing to the frame buffer) set as its texture is placed at the position of the first type of object in the virtual space.
For each pixel of the frame buffer on which drawing has been performed, the pixel in question is designated as the pixel of interest.
Based on the depth of the first depth buffer, the direction from the virtual camera toward the position in the virtual space corresponding to the pixel of interest is calculated as the incident direction, and the direction of the ray reflected with that position as the reflection position is calculated as the ray tracing direction.
The ray is traced along the ray tracing direction, and the collision position where the ray collides with an object in the virtual space is determined based on the first depth buffer.
When the collision position is determined within a range where the tracing distance of the ray is within a first distance, a color based on the color of the pixel in the frame buffer corresponding to the collision position is determined as the reflection color to be added to the color of the pixel of interest.
When the ray intersects the planar object, the color of the texture at the intersection point is determined as the reflection color to be added to the color of the pixel of interest.
The frame buffer reflects the color of the reflection,
An image processing system that, after reflecting the colors of the reflections, draws the first type of object to a frame buffer.
仮想空間内のオブジェクトのうち、第1の種類のオブジェクトを除くオブジェクトについて、
第1のデプスバッファを用いて第1のデプステストと当該第1のデプスバッファの更新を行うこと、
前記第1のデプステストの結果に基づいてフレームバッファに描画を行うこと、
前記第1の種類のオブジェクトについて、フレームバッファへの描画を行わずにレンダリングした画像をテクスチャとして設定した平面オブジェクトを前記仮想空間内の前記第1の種類のオブジェクトの位置に配置すること、
描画が行われた前記フレームバッファの画素ごとに、当該画素を着目画素として、
前記第1のデプスバッファのデプスに基づいて、仮想カメラから前記着目画素に対応する前記仮想空間内の位置に向かう方向を入射方向、当該位置を反射位置として反射するレイの方向をレイトレース方向として算出すること、
当該レイトレース方向に沿って当該レイをトレースさせ、前記第1のデプスバッファに基づいて、前記レイが前記仮想空間内においてオブジェクトに衝突する衝突位置を判定すること、
前記レイのトレース距離が第1の距離以内となる範囲内において前記衝突位置が判定された場合に、当該衝突位置に対応する前記フレームバッファ内の画素の色に基づいた色を、前記着目画素の色に加える映り込みの色として決定すること、
前記レイが前記平面オブジェクトと交差する場合に、交差位置の前記テクスチャの色に基づいて前記着目画素の色にさらに加える映り込みの色として決定すること、
前記フレームバッファに前記映り込みの色を反映すること、
前記映り込みの色を反映した後に、前記第1の種類のオブジェクトをフレームバッファに描画すること、を備える、画像処理方法。 An image processing method,
Of the objects in the virtual space, all objects except for the first type of object ,
Perform a first depth test and update the first depth buffer using the first depth buffer.
Based on the results of the first depth test, draw to the frame buffer.
With respect to the first type of object, a planar object with a rendered image set as a texture without drawing to the frame buffer is placed at the position of the first type of object in the virtual space.
For each pixel of the frame buffer on which drawing has been performed, the pixel in question is designated as the pixel of interest.
Based on the depth of the first depth buffer, the direction from the virtual camera toward the position in the virtual space corresponding to the pixel of interest is calculated as the incident direction, and the direction of the ray reflected with that position as the reflection position is calculated as the ray tracing direction.
The ray is traced along the ray tracing direction, and the collision position where the ray collides with an object in the virtual space is determined based on the first depth buffer.
When the collision position is determined within a range where the tracing distance of the ray is within a first distance, a color based on the color of the pixel in the frame buffer corresponding to the collision position is determined as the reflection color to be added to the color of the pixel of interest.
When the ray intersects the planar object, the color of the texture at the intersection point is determined as the reflection color to be added to the color of the pixel of interest.
The frame buffer reflects the color of the reflection.
An image processing method comprising: reflecting the color of the reflection, and then drawing the first type of object to the frame buffer.
仮想空間内のオブジェクトのうち、第1の種類のオブジェクトを除くオブジェクトについて、
第1のデプスバッファを用いて第1のデプステストと当該第1のデプスバッファの更新を行い、
前記第1のデプステストの結果に基づいてフレームバッファに描画を行い、
前記第1の種類のオブジェクトについて、フレームバッファへの描画を行わずにレンダリングした画像をテクスチャとして設定した平面オブジェクトを前記仮想空間内の前記第1の種類のオブジェクトの位置に配置し、
描画が行われた前記フレームバッファの画素ごとに、当該画素を着目画素として、
前記第1のデプスバッファのデプスに基づいて、仮想カメラから前記着目画素に対応する前記仮想空間内の位置に向かう方向を入射方向、当該位置を反射位置として反射するレイの方向をレイトレース方向として算出し、
当該レイトレース方向に沿って当該レイをトレースさせ、前記第1のデプスバッファに基づいて、前記レイが前記仮想空間内においてオブジェクトに衝突する衝突位置を判定し、
前記レイのトレース距離が第1の距離以内となる範囲内において前記衝突位置が判定された場合に、当該衝突位置に対応する前記フレームバッファ内の画素の色に基づいた色を、前記着目画素の色に加える映り込みの色として決定し、
前記レイが前記平面オブジェクトと交差する場合に、交差位置の前記テクスチャの色に基づいて前記着目画素の色にさらに加える映り込みの色として決定し、
前記フレームバッファに前記映り込みの色を反映し、
前記映り込みの色を反映した後に、前記第1の種類のオブジェクトをフレームバッファに描画する、画像処理装置。 An image processing apparatus comprising a processor, wherein the processor is
Of the objects in the virtual space, all objects except for the first type of object ,
A first depth test and an update of the first depth buffer are performed using the first depth buffer.
Based on the results of the first depth test, the data is drawn to the frame buffer.
For the first type of object, a planar object with a rendered image (without drawing to the frame buffer) set as its texture is placed at the position of the first type of object in the virtual space.
For each pixel of the frame buffer on which drawing has been performed, the pixel in question is designated as the pixel of interest.
Based on the depth of the first depth buffer, the direction from the virtual camera toward the position in the virtual space corresponding to the pixel of interest is calculated as the incident direction, and the direction of the ray reflected with that position as the reflection position is calculated as the ray tracing direction.
The ray is traced along the ray tracing direction, and the collision position where the ray collides with an object in the virtual space is determined based on the first depth buffer.
When the collision position is determined within a range where the tracing distance of the ray is within a first distance, a color based on the color of the pixel in the frame buffer corresponding to the collision position is determined as the reflection color to be added to the color of the pixel of interest.
When the ray intersects the planar object, the color of the texture at the intersection point is determined as the reflection color to be added to the color of the pixel of interest.
The frame buffer reflects the color of the reflection,
An image processing device that, after reflecting the color of the reflection, draws the first type of object to the frame buffer.
Priority Applications (4)
| Application Number | Priority Date | Filing Date | Title |
|---|---|---|---|
| JP2024011581A JP7851339B2 (en) | 2024-01-30 | 2024-01-30 | Image processing program, image processing system, image processing method, and image processing apparatus. |
| US18/883,392 US20250245907A1 (en) | 2024-01-30 | 2024-09-12 | Non-transitory computer-readable medium, image processing system, image processing method, and image processing apparatus |
| US18/883,274 US20250245909A1 (en) | 2024-01-30 | 2024-09-12 | Non-transitory computer-readable medium, image processing system, image processing method, and image processing apparatus |
| US18/883,406 US20250242255A1 (en) | 2024-01-30 | 2024-09-12 | Non-transitory computer-readable medium, image processing system, image processing method, and image processing apparatus |
Applications Claiming Priority (1)
| Application Number | Priority Date | Filing Date | Title |
|---|---|---|---|
| JP2024011581A JP7851339B2 (en) | 2024-01-30 | 2024-01-30 | Image processing program, image processing system, image processing method, and image processing apparatus. |
Publications (2)
| Publication Number | Publication Date |
|---|---|
| JP2025116987A JP2025116987A (en) | 2025-08-12 |
| JP7851339B2 true JP7851339B2 (en) | 2026-04-24 |
Family
ID=96697774
Family Applications (1)
| Application Number | Title | Priority Date | Filing Date |
|---|---|---|---|
| JP2024011581A Active JP7851339B2 (en) | 2024-01-30 | 2024-01-30 | Image processing program, image processing system, image processing method, and image processing apparatus. |
Country Status (1)
| Country | Link |
|---|---|
| JP (1) | JP7851339B2 (en) |
Citations (2)
| Publication number | Priority date | Publication date | Assignee | Title |
|---|---|---|---|---|
| WO2019123547A1 (en) | 2017-12-19 | 2019-06-27 | 株式会社ソニー・インタラクティブエンタテインメント | Image generator, reference image data generator, image generation method, and reference image data generation method |
| US20200051313A1 (en) | 2018-08-10 | 2020-02-13 | Electronic Arts Inc. | Systems and methods for rendering reflections |
-
2024
- 2024-01-30 JP JP2024011581A patent/JP7851339B2/en active Active
Patent Citations (2)
| Publication number | Priority date | Publication date | Assignee | Title |
|---|---|---|---|---|
| WO2019123547A1 (en) | 2017-12-19 | 2019-06-27 | 株式会社ソニー・インタラクティブエンタテインメント | Image generator, reference image data generator, image generation method, and reference image data generation method |
| US20200051313A1 (en) | 2018-08-10 | 2020-02-13 | Electronic Arts Inc. | Systems and methods for rendering reflections |
Non-Patent Citations (6)
| Title |
|---|
| Chalmers University of Technology,"Screen-space Reflections",Wayback Machine [online],2020年05月08日,https://web.archive.org/web/20200508174836/https://www.cse.chalmers.se/edu/year/2018/course/TDA361/Advanced%20Computer%20Graphics/Screen-space%20reflections.pdf [取得日 2025年11月17日] |
| Dominic. BW,"Exclude Objects from SSR Reflection",Unreal Engine フォーラム [online],2019年08月,https://forums.unrealengine.com/t/exclude-objects-from-ssr-reflection/127053/10 [取得日 2025年11月17日] |
| Morgan MCGUIRE et al.,"Efficient GPU Screen-Space Ray Tracing",the Journal of Computer Graphics Techniques [online],2014年,pp.73-85,https://jcgt.org/published/0003/04/04/paper.pdf [取得日 2025年11月17日] |
| Morgan MCGUIRE,"Screen Space Ray Tracing",casual effects [online],2014年08月09日,https://casual-effects.blogspot.com/2014/08/screen-space-ray-tracing.html [取得日 2025年11月17日] |
| unity,"Screen Space Reflection",Unity Manual-Graphics-Graphics Overview-Post-processing overview-Post-processing stack-Ambient Occlusion [online],2017年05月24日,https://docs.unity3d.com/560/Documentation/Manual/PostProcessing-ScreenSpaceReflection.html [取得日 2025年11月17日] |
| Voicu POPESCU et al.,"Reflected‐Scene Impostors for Realistic Reflections at Interactive Rates",Computer Graphics Forum,2006年09月,Vol. 25, No. 3,pp.313-322,DOI: 10.1111/j.1467-8659.2006.00950.x |
Also Published As
| Publication number | Publication date |
|---|---|
| JP2025116987A (en) | 2025-08-12 |
Similar Documents
| Publication | Publication Date | Title |
|---|---|---|
| CN101911129B (en) | Image processing device and image processing method | |
| US20120154311A1 (en) | Information storage medium, terminal, and input determination method | |
| US8797360B2 (en) | Image display device, method for controlling image display device, and information storage medium | |
| US20030193496A1 (en) | Image processing system, image processing method, semiconductor device, computer program, and recording medium | |
| JP4125251B2 (en) | Information processing method and apparatus | |
| JP6616072B2 (en) | Input processing apparatus and program | |
| JP6449647B2 (en) | Input processing apparatus and program | |
| JP3352982B2 (en) | Rendering method and device, game device, and computer-readable recording medium for storing program for rendering three-dimensional model | |
| US20250245909A1 (en) | Non-transitory computer-readable medium, image processing system, image processing method, and image processing apparatus | |
| JP7851339B2 (en) | Image processing program, image processing system, image processing method, and image processing apparatus. | |
| GB2389501A (en) | Displaying shadows of 3D objects | |
| AU2004201817B2 (en) | Game software and game machine | |
| US6980214B2 (en) | Methods and apparatus for shading object drawings in video games | |
| JP7698754B1 (en) | IMAGE PROCESSING PROGRAM, IMAGE PROCESSING SYSTEM, IMAGE PROCESSING METHOD, AND IMAGE PROCESSING APPARATUS | |
| JP7698755B1 (en) | IMAGE PROCESSING PROGRAM, IMAGE PROCESSING SYSTEM, IMAGE PROCESSING METHOD, AND IMAGE PROCESSING APPARATUS | |
| JP5088972B2 (en) | Image processing apparatus, image processing method, computer program, recording medium, and semiconductor device | |
| JP6385272B2 (en) | Input processing apparatus and program | |
| JP2011065396A (en) | Program, information storage medium, and object generation system | |
| JP4343207B2 (en) | Game device and image processing program | |
| CN114882162B (en) | Texture image mapping method, device, electronic device and readable storage medium | |
| JP3748451B1 (en) | Program, information storage medium, and image generation system | |
| US7485041B2 (en) | Program for projecting an image onto a character in a game, game machine incorporating the program, and storage medium having the program stored thereon | |
| CN115690365A (en) | Method, apparatus, device and medium for managing three-dimensional model | |
| JP7417218B1 (en) | Image processing program, image processing system, image processing device, and image processing method | |
| JP7849537B2 (en) | Game program, game system, game processing method, and game device |
Legal Events
| Date | Code | Title | Description |
|---|---|---|---|
| A621 | Written request for application examination |
Free format text: JAPANESE INTERMEDIATE CODE: A621 Effective date: 20241029 |
|
| A131 | Notification of reasons for refusal |
Free format text: JAPANESE INTERMEDIATE CODE: A131 Effective date: 20251126 |
|
| A521 | Request for written amendment filed |
Free format text: JAPANESE INTERMEDIATE CODE: A523 Effective date: 20260116 |
|
| TRDD | Decision of grant or rejection written | ||
| A01 | Written decision to grant a patent or to grant a registration (utility model) |
Free format text: JAPANESE INTERMEDIATE CODE: A01 Effective date: 20260324 |
|
| A61 | First payment of annual fees (during grant procedure) |
Free format text: JAPANESE INTERMEDIATE CODE: A61 Effective date: 20260414 |
|
| R150 | Certificate of patent or registration of utility model |
Ref document number: 7851339 Country of ref document: JP Free format text: JAPANESE INTERMEDIATE CODE: R150 |