CN106447761A - Shadow rendering method - Google Patents

Shadow rendering method Download PDF

Info

Publication number
CN106447761A
CN106447761A CN201610795401.XA CN201610795401A CN106447761A CN 106447761 A CN106447761 A CN 106447761A CN 201610795401 A CN201610795401 A CN 201610795401A CN 106447761 A CN106447761 A CN 106447761A
Authority
CN
China
Prior art keywords
light source
source direction
texture
shadow
depth information
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.)
Granted
Application number
CN201610795401.XA
Other languages
Chinese (zh)
Other versions
CN106447761B (en
Inventor
辛双江
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Beijing Pixel Software Technology Co Ltd
Original Assignee
Beijing Pixel Software Technology Co Ltd
Priority date (The priority date 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 date listed.)
Filing date
Publication date
Application filed by Beijing Pixel Software Technology Co Ltd filed Critical Beijing Pixel Software Technology Co Ltd
Priority to CN201610795401.XA priority Critical patent/CN106447761B/en
Publication of CN106447761A publication Critical patent/CN106447761A/en
Application granted granted Critical
Publication of CN106447761B publication Critical patent/CN106447761B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06TIMAGE DATA PROCESSING OR GENERATION, IN GENERAL
    • G06T15/003D [Three Dimensional] image rendering
    • G06T15/50Lighting effects
    • G06T15/60Shadow generation
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06TIMAGE DATA PROCESSING OR GENERATION, IN GENERAL
    • G06T2215/00Indexing scheme for image rendering
    • G06T2215/12Shadow map, environment map

Landscapes

  • Engineering & Computer Science (AREA)
  • Computer Graphics (AREA)
  • Physics & Mathematics (AREA)
  • General Physics & Mathematics (AREA)
  • Theoretical Computer Science (AREA)
  • Image Generation (AREA)
  • Processing Or Creating Images (AREA)

Abstract

The invention discloses a shadow rendering method. The method comprises the steps of dividing six light source directions into N groups, and respectively rendering depth information of the N groups of light source directions into N shadow textures, wherein the six light source directions are the same as six directions of a three-dimensional space coordinate axis, and N is greater than and equal to 1, but less than or equal to 3; for each pixel of an object to be rendered, determining a shadow texture of depth information of the pixel and the position of the pixel in the shadow texture according to a light source direction corresponding to the position of the pixel; sampling from the determined shadow texture according to the position, and obtaining the depth information of the pixel; and determining a shadow of the object to be rendered and performing corresponding rendering according to the depth information of the pixel. By adopting the shadow rendering method provided by the invention, the rendering efficiency of shadows of indoor point light sources can be improved.

Description

A kind of Shading Rendering method
Technical field
The present invention relates to three-dimensional scenic Rendering, more particularly to a kind of Shading Rendering method.
Background technology
At present, render in application in three-dimensional scenic, in order to increase the vivid effect of scene rendering, generally all can be using correlation Real-time shadow technology to render shade for the rendering objects in scene.For example, in the rendering of scene of game, in order to strengthen game Display effect, generally all can render shade using related real-time shadow technology for the game object of motion in scene.
In existing Shading Rendering scheme, first render the depth map of a scene typically at light source position, then At camera, whole scene is rendered again, and be compared with the depth map rendering before, obtain the hatching effect of scene. But for indoor spot light, due to shade projection need towards all directions around light source, so need by All depth informations around light source all project in depth texture.For this scene, general way is to create one cube Volume textures (CubeMap), then at spot light, 6 directions towards spot light build 6 projection matrixes, by each direction Scene be all rendered in the depth texture of correspondence direction in CubeMap, render use for next passage.
Above-mentioned traditional Shading Rendering method, for the render scenes of indoor spot light shade, by the depth around light source Information is rendered on a CubeMap to be needed, using 6 shadow-textures, so, to take larger video memory space, impact renders Efficiency, especially can produce a lot of efficiency on low side machine.
Content of the invention
In view of this, present invention is primarily targeted at providing a kind of Shading Rendering method, the method can improve interior The rendering efficiency of spot light shade.
In order to achieve the above object, technical scheme proposed by the present invention is:
A kind of Shading Rendering method, including:
Six light source direction are divided into N group, the depth information of described N group light source direction are rendered into N respectively and open shade line In reason;Described six light source direction are identical with the six direction of three dimensional space coordinate axle;1≤N≤3;
For each pixel of object to be rendered, according to this corresponding light source direction in pixel position, determine this pixel Depth information be located shadow-texture and the position in shadow-texture;According to described position from the shade line determined Reason up-sampling, obtains the depth information of this pixel;
According to the depth information of described pixel, determine the shade of described object to be rendered and rendered accordingly.
In sum, Shading Rendering method proposed by the present invention, same by being rendered into the depth information of multiple directions Open the mode of shadow-texture, reduce the usage quantity of depth texture, such that it is able to the occupancy in video memory space is greatly reduced, thus The rendering efficiency of indoor spot light shade on the premise of ensureing rendering effect, can be improved.
Brief description
Fig. 1 is the schematic flow sheet of the embodiment of the present invention.
Specific embodiment
For making the object, technical solutions and advantages of the present invention clearer, right below in conjunction with the accompanying drawings and the specific embodiments The present invention is described in further detail.
The core concept of the present invention is:By the depth information of multiple directions being rendered into the side of same shadow-texture Formula, reduces the usage quantity of depth texture, and on the premise of ensureing rendering effect, that improves indoor spot light shade renders effect Rate.
Fig. 1 is the schematic flow sheet of the embodiment of the present invention, as shown in figure 1, the Shading Rendering method master that this embodiment is realized Including:
Step 101, six light source direction are divided into N group, the depth information of described N group light source direction is rendered into N respectively Open in shadow-texture;Described six light source direction are identical with the six direction of three dimensional space coordinate axle;1≤N≤3.
In this step, need to be grouped six light source direction, then by the depth information of N group light source direction wash with watercolours respectively Contaminate N to open in shadow-texture, that is, the depth information of same group of light source direction is rendered in a shadow-texture, different groups The depth information of light source direction is rendered in different shadow-textures.So, by by the depth information wash with watercolours in multiple light sources direction Contaminate in a shadow-texture, it is possible to reduce the quantity of the shadow-texture being used, opening of video memory space can be reduced accordingly Pin, such that it is able to increase substantially indoor spot light Shading Rendering efficiency, it is to avoid need each light source direction each in traditional scheme Using the low problem of the rendering efficiency existing for a shadow-texture.
In actual applications, those skilled in the art can determine packet count N of light source direction according to actual needs Value.It is preferred that light source direction can be divided into 2 groups, i.e. N=2.
It is preferred that as N=2, one group can be formed using four light source direction, another two light source direction composition another Six light source direction are divided into two groups by the mode of group, select four light source direction from six light source direction, will be selected Four light source direction going out are divided into one group, and non-selected two light source direction are divided into another group.Further, it is based on Six light source direction can be divided into two groups using following methods by this packet mode:
Light source direction is stated for each, the sequence number of this light source direction is divided by with 4, after division result is rounded plus 1 as The sequence number of this light source direction place group.
Said method is only one to be used for determining the specific example of group belonging to each light source direction, the method is easily achieved, in reality Border application in however it is not limited to this.
It is preferred that N can be rendered into the depth information of described N group light source direction respectively using following methods to open shade line In reason:
Step x1, for every group of light source direction, the sequence number according to shadow-texture is identical with the group sequence number of this group light source direction Principle, determine the depth information shadow-texture that renders to of needs of this group light source direction.
Step x1 is used for determining that the depth information of each light source direction needs to be rendered into which shadow-texture, using this step Suddenly, the sequence number of shadow-texture is determined it can be ensured that the depth of same group of light source direction is believed according to the sequence number of light source direction place group Breath is rendered in a shadow-texture, and the depth information of different group light source direction is rendered in different shadow-textures.
Step x2, for every group of light source direction, according to default texture height TexHeight and texture width TexWidth, according to Pi=OffsetArray [i] * (TexHeight, TexWidth), calculates the depth of wherein each light source direction Position P in the shadow-texture needing to render to for the degree informationi, and according to the position P being calculatediBy corresponding light source direction Depth information renders in corresponding shadow-texture.
Wherein, OffsetArray [i] is light source direction corresponding texture coordinate side-play amount, i=in shadow-texture Index%k, % represent complementation computing, and Index is the sequence number of light source direction, and k is light source direction quantity in one group of light source direction Maximum.
Need exist for illustrating, due to being to believe the depth that the depth information in one group of light source direction is multiple light sources direction Breath is rendered in a shadow-texture, therefore, if shade need to be divided into one group in light source direction quantity identical cadre Point, each light source direction will correspond to a part therein, for rendering the depth information of this light source direction.Above-mentioned OffsetArray [i] is light source direction corresponding texture coordinate side-play amount in shadow-texture, and that is, light source direction is in shadow-texture The coordinate offset amount of middle corresponding part, based on this, you can calculate the shade that the depth information of light source direction renders in needs Position P in texturei, such that it is able to the depth information of light source direction be rendered in the shadow-texture of corresponding part.
It is preferred that work as, using above-mentioned, six light source direction are divided into 2 groups, and it is divided by according to the sequence number and 4 of light source direction Round Jia 1 as light source direction place group sequence number when, can be using following methods by the depth information of described N group light source direction It is rendered into N respectively to open in shadow-texture:
Step b1, according to textureIndex=int (Index/4)+1, determine the depth letter of each described light source direction Breath needs the shadow-texture rendering to, and wherein, Index is the sequence number of light source direction, and textureIndex is the moon determined The sequence number of shadow texture, int () is bracket function.
Step b2, according to Pi=OffsetArray [i] * (TexHeight, TexWidth), calculates wherein each light source side To depth information needing the position P in the shadow-texture that renders toi, and according to the position P being calculatediBy corresponding light source The depth information in direction renders in corresponding shadow-texture.
Wherein, OffsetArray [i] is light source direction corresponding texture coordinate side-play amount, i=in shadow-texture Index%4, % are complementation computing, and Index is the sequence number of light source direction, OffsetArray [0]=(0,0), OffsetArray [1]=(0.5,0), OffsetArray [2]=(0,0.5), OffsetArray [3]=(0.5,0.5).
Step 102, each pixel for object to be rendered, according to this corresponding light source direction in pixel position, really Shadow-texture and the position in shadow-texture that the depth information of this pixel fixed is located;According to described position from being determined Shadow-texture up-sampling, obtain the depth information of this pixel.
In this step, by the shadow-texture obtaining from step 101, each pixel that sampling obtains object to be rendered is worked as The depth information in front position corresponding light source direction, to be realized using the depth information of each pixel being obtained in step 103 Treat the rendering of shade of rendering objects.
Here, when the depth information of each pixel being sampled, need according to the corresponding light source side in pixel position To the shadow-texture and position wherein that determine that depth information is located, so that therefrom sampling obtains the depth information of pixel.
It is preferred that can using following methods determine each pixel depth information be located shadow-texture and in shade Position in texture:
According to t=int (r/4)+1, determine the shadow-texture that the depth information of pixel is located, wherein, r is in place for pixel institute Put the sequence number of corresponding light source direction, t is the sequence number of the shadow-texture at depth information place of pixel, and int () is to round letter Number.
According to Qs=OffsetArray [s]+0.5* (u, v), calculates the position in shadow-texture for the depth information of pixel Qs, wherein, (u, v) is the original texture coordinate of pixel, and OffsetArray [s] is that light source direction r is corresponding in shadow-texture Texture coordinate side-play amount, s=r%4, % represent complementation computing.
Step 103, the depth information according to described pixel, determine the shade of described object to be rendered and carry out corresponding wash with watercolours Dye.
In sum, these are only presently preferred embodiments of the present invention, be not intended to limit protection scope of the present invention. All any modification, equivalent substitution and improvement within the spirit and principles in the present invention, made etc., should be included in the present invention's Within protection domain.

Claims (6)

1. a kind of Shading Rendering method is it is characterised in that include:
Six light source direction are divided into N group, the depth information of described N group light source direction are rendered into N respectively and open in shadow-texture; Described six light source direction are identical with the six direction of three dimensional space coordinate axle;1≤N≤3;
For each pixel of object to be rendered, according to this corresponding light source direction in pixel position, determine the depth of this pixel Shadow-texture and the position in shadow-texture that degree information is located;According to described position from the shadow-texture determined Sampling, obtains the depth information of this pixel;
According to the depth information of described pixel, determine the shade of described object to be rendered and rendered accordingly.
2. method according to claim 1 is it is characterised in that as N=2, described six light source direction is divided into N group bag Include:
Select four light source direction from six light source direction, by selected go out four light source direction be divided into one group, will Non-selected two light source direction are divided into another group.
3. method according to claim 2 is it is characterised in that described be divided into the inclusion of N group by six light source direction:
Light source direction is stated for each, the sequence number of this light source direction is divided by with 4, Jia 1 after division result is rounded as this light The sequence number of source direction place group.
4. method according to claim 1 is it is characterised in that render the depth information of described N group light source direction respectively Open shadow-texture to N to include:
For every group of light source direction, the sequence number according to shadow-texture and the group sequence number identical principle of this group light source direction, determine The shadow-texture that the depth information needs of this group light source direction render to;
For every group of light source direction, according to default texture height TexHeight and texture width TexWidth, according to Pi= OffsetArray [i] * (TexHeight, TexWidth), the depth information calculating wherein each light source direction is needing to render Position P in shadow-texture extremelyi, and according to the position P being calculatediIt is right that the depth information in corresponding light source direction is rendered to In the shadow-texture answered, wherein, OffsetArray [i] is light source direction corresponding texture coordinate side-play amount in shadow-texture, I=Index%k, % represent complementation computing, and Index is the sequence number of light source direction, and k is light source direction number in one group of light source direction The maximum of amount.
5. method according to claim 3 is it is characterised in that the described depth information by described N group light source direction is distinguished It is rendered into N and opens shadow-texture and include:
According to textureIndex=int (Index/4)+1, determine that the depth information of each described light source direction needs to render to Shadow-texture, wherein, Index be light source direction sequence number, the sequence number of the shadow-texture by being determined for the textureIndex, Int () is bracket function;
According to Pi=OffsetArray [i] * (TexHeight, TexWidth), calculates the depth information of wherein each light source direction Position P in the shadow-texture needing to render toi, and according to the position P being calculatediDepth letter by corresponding light source direction Breath renders in corresponding shadow-texture;Wherein, OffsetArray [i] is light source direction corresponding texture in shadow-texture Coordinate offset amount, i=Index%4, % are complementation computing, and Index is the sequence number of light source direction, OffsetArray [0]=(0, 0), OffsetArray [1]=(0.5,0), OffsetArray [2]=(0,0.5), OffsetArray [3]=(0.5,0.5).
6. method according to claim 5 it is characterised in that described this pixel of determination depth information be located shade line Reason and the position in shadow-texture include:
According to t=int (r/4)+1, determine the shadow-texture that the depth information of pixel is located, wherein, r is pixel position pair The sequence number of the light source direction answered, t is the sequence number of the shadow-texture at depth information place of pixel, and int () is bracket function;
According to Qs=OffsetArray [s]+0.5* (u, v), calculates the position Q in shadow-texture for the depth information of pixels, its In, (u, v) is the original texture coordinate of pixel, and OffsetArray [s] is light source direction r corresponding texture in shadow-texture Coordinate offset amount, s=r%4, % represent complementation computing.
CN201610795401.XA 2016-08-31 2016-08-31 A kind of Shading Rendering method Active CN106447761B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN201610795401.XA CN106447761B (en) 2016-08-31 2016-08-31 A kind of Shading Rendering method

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN201610795401.XA CN106447761B (en) 2016-08-31 2016-08-31 A kind of Shading Rendering method

Publications (2)

Publication Number Publication Date
CN106447761A true CN106447761A (en) 2017-02-22
CN106447761B CN106447761B (en) 2019-03-08

Family

ID=58164951

Family Applications (1)

Application Number Title Priority Date Filing Date
CN201610795401.XA Active CN106447761B (en) 2016-08-31 2016-08-31 A kind of Shading Rendering method

Country Status (1)

Country Link
CN (1) CN106447761B (en)

Cited By (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN107808410A (en) * 2017-10-27 2018-03-16 网易(杭州)网络有限公司 The processing method and processing device of shade depth skew
CN110211218A (en) * 2019-05-17 2019-09-06 腾讯科技(深圳)有限公司 Picture rendering method and device, storage medium and electronic device
CN111311723A (en) * 2020-01-22 2020-06-19 腾讯科技(深圳)有限公司 Pixel point identification and illumination rendering method and device, electronic equipment and storage medium
CN114742934A (en) * 2022-04-07 2022-07-12 北京字跳网络技术有限公司 Image rendering method and device, readable medium and electronic equipment

Citations (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN101882323A (en) * 2010-05-19 2010-11-10 北京航空航天大学 Microstructure surface global illumination real-time rendering method based on height map
US20110032256A1 (en) * 2009-08-06 2011-02-10 Samsung Electronics Co., Ltd. Image processing apparatus and method
CN102436673A (en) * 2011-10-24 2012-05-02 克拉玛依红有软件有限责任公司 Shadow drafting method of large-scale outdoor scene
CN102768765A (en) * 2012-06-25 2012-11-07 南京安讯网络服务有限公司 Real-time soft shadow rendering method for point light sources
CN103903296A (en) * 2014-04-23 2014-07-02 东南大学 Method for shadow rendering in virtual home decoration indoor scene design

Patent Citations (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20110032256A1 (en) * 2009-08-06 2011-02-10 Samsung Electronics Co., Ltd. Image processing apparatus and method
CN101882323A (en) * 2010-05-19 2010-11-10 北京航空航天大学 Microstructure surface global illumination real-time rendering method based on height map
CN102436673A (en) * 2011-10-24 2012-05-02 克拉玛依红有软件有限责任公司 Shadow drafting method of large-scale outdoor scene
CN102768765A (en) * 2012-06-25 2012-11-07 南京安讯网络服务有限公司 Real-time soft shadow rendering method for point light sources
CN103903296A (en) * 2014-04-23 2014-07-02 东南大学 Method for shadow rendering in virtual home decoration indoor scene design

Cited By (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN107808410A (en) * 2017-10-27 2018-03-16 网易(杭州)网络有限公司 The processing method and processing device of shade depth skew
CN107808410B (en) * 2017-10-27 2021-04-27 网易(杭州)网络有限公司 Shadow depth migration processing method and device
CN110211218A (en) * 2019-05-17 2019-09-06 腾讯科技(深圳)有限公司 Picture rendering method and device, storage medium and electronic device
CN111311723A (en) * 2020-01-22 2020-06-19 腾讯科技(深圳)有限公司 Pixel point identification and illumination rendering method and device, electronic equipment and storage medium
CN114742934A (en) * 2022-04-07 2022-07-12 北京字跳网络技术有限公司 Image rendering method and device, readable medium and electronic equipment

Also Published As

Publication number Publication date
CN106447761B (en) 2019-03-08

Similar Documents

Publication Publication Date Title
CN102768765B (en) Real-time soft shadow rendering method for point light sources
CN109035383B (en) Volume cloud drawing method and device and computer readable storage medium
CN106447761A (en) Shadow rendering method
CN102163337B (en) For using the system and method for at least one translucent surface rendered pixel
CN102708585A (en) Method for rendering contour edges of models
CN104392479A (en) Method of carrying out illumination coloring on pixel by using light index number
CN102243768B (en) Method for drawing stereo picture of three-dimensional virtual scene
WO1999052079A1 (en) Object-based anti-aliasing
CN104574496B (en) A kind of method and device of the static shade for calculating illumination pattern and dynamic shadow fusion
Widmer et al. An adaptive acceleration structure for screen-space ray tracing
CN104318605B (en) Parallel lamination rendering method of vector solid line and three-dimensional terrain
JPH11514118A (en) 3D image generation
CN106600665A (en) Camera animation path generating method and device
CN108305228A (en) Image processing method, device, storage medium and processor
CN109671158A (en) A kind of optimization method of game picture
KR20210088588A (en) street field color palette
CN104157005A (en) Image-based HDR (high-dynamic range) illumination rendering method
CN108055477A (en) A kind of method and apparatus for realizing smear special efficacy
CN101930367A (en) Implementation method of switching images and mobile terminal
CN104822059A (en) Virtual viewpoint synthesis method based on GPU acceleration
CN103745448A (en) Rapid generating method for ultrahigh-resolution composite image in raster 3D displaying
CN106780704B (en) The direct lighting effect proximity rendering method of three-dimensional scenic reused based on visibility
CN104661013A (en) Virtual view point drawing method based on spatial weighting
CN106204418A (en) Image warping method based on matrix inversion operation in a kind of virtual reality mobile terminal
JP7460641B2 (en) Apparatus and method for generating a light intensity image - Patents.com

Legal Events

Date Code Title Description
C06 Publication
PB01 Publication
C10 Entry into substantive examination
SE01 Entry into force of request for substantive examination
GR01 Patent grant
GR01 Patent grant