CN105976423B - A kind of generation method and device of Lens Flare - Google Patents

A kind of generation method and device of Lens Flare Download PDF

Info

Publication number
CN105976423B
CN105976423B CN201610283282.XA CN201610283282A CN105976423B CN 105976423 B CN105976423 B CN 105976423B CN 201610283282 A CN201610283282 A CN 201610283282A CN 105976423 B CN105976423 B CN 105976423B
Authority
CN
China
Prior art keywords
hot spot
dough sheet
light source
color
texture
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
Application number
CN201610283282.XA
Other languages
Chinese (zh)
Other versions
CN105976423A (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.)
Netease Hangzhou Network Co Ltd
Original Assignee
Netease Hangzhou Network 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 Netease Hangzhou Network Co Ltd filed Critical Netease Hangzhou Network Co Ltd
Priority to CN201610283282.XA priority Critical patent/CN105976423B/en
Publication of CN105976423A publication Critical patent/CN105976423A/en
Application granted granted Critical
Publication of CN105976423B publication Critical patent/CN105976423B/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/04Texture mapping
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06TIMAGE DATA PROCESSING OR GENERATION, IN GENERAL
    • G06T15/003D [Three Dimensional] image rendering
    • G06T15/50Lighting effects
    • G06T15/506Illumination models

Landscapes

  • Engineering & Computer Science (AREA)
  • Computer Graphics (AREA)
  • Physics & Mathematics (AREA)
  • General Physics & Mathematics (AREA)
  • Theoretical Computer Science (AREA)
  • Image Generation (AREA)

Abstract

The invention discloses a kind of generation method of Lens Flare and devices, the described method includes: establishing halation model in three-dimensional scenic, one or more hot spot dough sheets are set on the straight line where scene light source and optical center, so that the light source meets preset ratio to the distance of the hot spot dough sheet and the ratio of distances constant of the light source to the optical center, and according to the position of the light source, the attribute of the hot spot dough sheet in projector space is obtained in real time;According to the attribute of the hot spot dough sheet, the hot spot dough sheet is drawn on the corresponding position of projector space.It can simply and easily be realized using the present invention and real-time dynamicly generate Lens Flare in three-dimensional scenic, calculation amount is smaller, is suitable for the higher scene of requirement of real-time.

Description

A kind of generation method and device of Lens Flare
Technical field
The present invention relates to area of computer graphics more particularly to the generation methods and device of a kind of Lens Flare.
Background technique
Lens Flare is the aestheticism dazzle that the interaction between light and lens structure by incident camera lens is formed, due to Its special visual effect is widely used in photography, films and television programs, game or other computer animations.Since works are clapped Light and environment during taking the photograph are limited, and are often difficult to capture suitable Lens Flare when shooting, existing spectators are seen See that the Lens Flare in film and picture usually passes through the special effect making addition in later period, is based primarily upon image processing algorithm, leads to The bright dark areas crossed in analysis image renders hot spot.And in partial 3-D Product Rendering, to realize true fine and smooth light Dizzy effect, then usually pass through the halation of the technical constructions complexity such as ray trace.
Summary of the invention
In the three-dimensional scenics such as game or other computer animations, Lens Flare is to set off one effective hand of sunny weather by contrast Section.However, being generated in real time since the picture of game and animation usually passes through computer, according to aforementioned photography and films and television programs In later period special effect making method, it is clear that be difficult to meet requirement of real-time.And physics renders are carried out by technologies such as ray tracings Although halation result complicated and changeable can be obtained, since Lens Flare is the complicated physical action generation of camera lens and light, Its calculation amount is huge, and existing equipment is difficult to real-time dynamic generation.
The generation method and device for being designed to provide a kind of Lens Flare of the embodiment of the present invention, are simply and easily realized The real-time generation of Lens Flare effect in three-dimensional scenic.
To achieve the above object, the embodiment of the invention provides a kind of generation methods of Lens Flare, comprising:
Halation model is established in three-dimensional scenic, and one or more is arranged on the straight line where scene light source and optical center A hot spot dough sheet so that the light source to the hot spot dough sheet distance at a distance from the light source to the optical center it Than meeting preset ratio, and according to the position of the light source, the hot spot dough sheet in projector space is obtained in real time Attribute;
According to the attribute of the hot spot dough sheet, the hot spot dough sheet is drawn on the corresponding position of projector space.
The generation method of Lens Flare provided by the invention in three-dimensional scenic by establishing halation model, in scene light source With one or more hot spots are set on the straight line where optical center, and according to the position of the light source, obtain the light in real time Spot draws the hot spot on the corresponding position of projector space according to the attribute of the hot spot in the attribute of projector space System, calculation amount is less, and the camera lens light for following light source position dynamic change can be real-time and efficiently generated in preset proportional positions It is dizzy.
Wherein, the attribute of the hot spot dough sheet includes in position, scaling, color, intensity, rotation angle and visibility It is one or more.
It is described that halation model is established in three-dimensional scenic, one is arranged on the straight line where scene light source and optical center Or multiple hot spot dough sheets so that the light source to the hot spot dough sheet distance and the light source to the optical center away from From the ratio between meet preset ratio, and according to the position of the light source, obtain the hot spot face in projector space in real time The attribute of piece, comprising:
The front-rear position relationship of the light source and camera lens is obtained, and according to the front-rear position relationship, judges the hot spot The visibility of dough sheet;
The light source is calculated in the projection coordinate of projector space, and according to the projection coordinate of the light source and the hot spot The location of dough sheet calculates position coordinates of each hot spot dough sheet in projector space;
The light source is obtained at a distance from optical center, and according to the distance, calculates the intensity of each hot spot dough sheet;
The angle that the light source is rotated in projector space around the optical center is obtained, using the angle as the hot spot The rotation angle of dough sheet.
Preferably, three Color Channels of the hot spot dough sheet are on the line direction of the light source and the optical center It is staggered, the distance being staggered is positively correlated at a distance from the hot spot dough sheet to the light source.
Preferably, the hot spot dough sheet is parallel to one of coordinate plane of world coordinates.
The attribute according to the hot spot dough sheet, draws the hot spot dough sheet on the corresponding position of projector space System, comprising:
The hot spot dough sheet is extracted in the two-dimensional coordinate of projector space, according to the hot spot dough sheet by vertex shader The aspect ratio information of attribute and screen, adjustment are output to the apex coordinate of pixel coloring device;
By the pixel coloring device by the texture of the hot spot dough sheet and color addition to the hot spot dough sheet, obtain The color value of each pixel on the hot spot dough sheet.
Preferably, the hot spot dough sheet is extracted in the two-dimensional coordinate of projector space by vertex shader described, according to The attribute of the hot spot dough sheet and the aspect ratio information of screen, adjustment are output to after the apex coordinate of pixel coloring device, also Include:
The third dimension coordinate of the hot spot dough sheet is disposed closest to the value of camera lens.
Further, the attribute according to the hot spot dough sheet, to the hot spot on the corresponding position of projector space Dough sheet is drawn, further includes:
Using the intensity of the hot spot dough sheet, texture index and color index as the third dimension information of the hot spot dough sheet It is input in tinter, all hot spot dough sheets is merged into a batch and are drawn.
Preferably, described using the intensity of the hot spot dough sheet, texture index and color index as the hot spot dough sheet All hot spot dough sheets are merged into a batch and draw into the tinter by third dimension information input, comprising:
Texture used in each hot spot dough sheet is merged into a big texture, and forms corresponding texture index;
The tinter is passed to using color data used in all hot spot dough sheets as specification data;
The texture of hot spot dough sheet index, color index and intensity are packaged into a floating number as the hot spot face The third dimension information of piece, is input in the tinter;
Texture index, color index and intensity are parsed from the third dimension information by the tinter, from institute It states and searches texture corresponding with texture index in large texture, searched from the color data corresponding with the color index Color, all hot spot dough sheets are drawn in a batch.
Data packing is stored in the extra dimension of hot spot dough sheet by the generation method of Lens Flare provided by the invention, is made For hot spot dough sheet third dimension information input into tinter so that hot spot dough sheet can be merged into one by conventional method It is drawn in batch, greatly reduces dough sheet and draw brought performance cost, improve the real-time that Lens Flare generates.
Further, in the attribute according to the hot spot dough sheet, to the light on the corresponding position of projector space After spot dough sheet is drawn, further includes:
The color value product for obtaining background pixel and hot spot pixel carries out the color value product and the background pixel Mixing obtains mixed once result;
The mixed once result is mixed with the hot spot pixel, obtains secondary mixing resultant;
The secondary mixing resultant is output to screen to show.
The generation method of Lens Flare provided by the invention also passes through two different mixed modes, carries out to hot spot dough sheet It mixes twice, facilitates the saturation degree for enhancing Lens Flare, prevent Lens Flare from being covered by light ground.
Correspondingly, the embodiment of the invention provides a kind of generating means of Lens Flare, comprising:
Modeling module, the straight line for establishing halation model in three-dimensional scenic, where scene light source and optical center The one or more hot spot dough sheets of upper setting, so that distance and the light source to the mirror of the light source to the hot spot dough sheet The ratio of distances constant at head center meets preset ratio, and according to the position of the light source, obtains in projector space in real time The attribute of the hot spot dough sheet;
Drafting module, for the attribute according to the hot spot dough sheet, to the hot spot on the corresponding position of projector space Dough sheet is drawn.
Wherein, the attribute of the hot spot dough sheet includes in position, scaling, color, intensity, rotation angle and visibility It is one or more.
Preferably, the modeling module includes:
Visibility judge unit, for obtaining the front-rear position relationship of the light source and camera lens, and according to the anteroposterior position Relationship is set, judges the visibility of the hot spot dough sheet;
Position calculation unit, for calculating the light source in the projection coordinate of projector space, and according to the throwing of the light source The location of shadow coordinate and the hot spot dough sheet calculate position coordinates of each hot spot dough sheet in projector space;
Strength co-mputation unit calculates each for obtaining the light source at a distance from optical center, and according to the distance The intensity of hot spot dough sheet;
Rotate computing unit, the angle rotated in projector space around the optical center for obtaining the light source, by institute State rotation angle of the angle as the hot spot dough sheet.
Preferably, three Color Channels of the hot spot dough sheet are on the line direction of the light source and the optical center It is staggered, the distance being staggered is positively correlated at a distance from the hot spot dough sheet to the light source.
Preferably, the hot spot dough sheet is parallel to one of coordinate plane of world coordinates;The drafting module includes:
Vertex processing unit, for extracting the hot spot dough sheet in the two-dimensional coordinate of projector space by vertex shader, According to the aspect ratio information of the attribute of the hot spot dough sheet and screen, adjustment is output to the apex coordinate of pixel coloring device;
Pixel processing unit, for by the pixel coloring device by the texture of the hot spot dough sheet and color addition to institute It states on hot spot dough sheet, obtains the color value of each pixel on the hot spot dough sheet.
In addition, the vertex processing unit is also used to the third dimension coordinate of the hot spot dough sheet being disposed closest to mirror The value of head.
Further, the drafting module, further includes:
Batch combining unit, for using the intensity of the hot spot dough sheet, texture index and color index as the hot spot All hot spot dough sheets are merged into a batch and draw into tinter by the third dimension information input of dough sheet.
Preferably, the batch combining unit includes:
Texture merges subelement, for texture used in each hot spot dough sheet to be merged into a big texture, and is formed Corresponding texture index;
Color transfer subelement, for passing to institute using color data used in all hot spot dough sheets as specification data State tinter;
Data are packaged subelement, for texture index, color index and the intensity of the hot spot dough sheet to be packaged into one Third dimension information of the floating number as the hot spot dough sheet, is input in the tinter;With,
Batch merges subelement, indexed for parsing texture from the third dimension information by the tinter, Color index and intensity are searched texture corresponding with texture index from the large texture, are looked into from the color data Color corresponding with the color index is looked for, all hot spot dough sheets are drawn in a batch.
Preferably, described device further include:
Mixed once module, for obtaining the color value product of background pixel and hot spot pixel, by the color value product It is mixed with the background pixel, obtains mixed once result;
Secondary mixing module obtains secondary mixed for mixing the mixed once result with the hot spot pixel Close result;
Result display module is shown for the secondary mixing resultant to be output to screen.
Detailed description of the invention
Fig. 1 is the method flow diagram of one embodiment of the generation method of Lens Flare provided by the invention;
Fig. 2 is the method flow diagram for the step S11 that embodiment as shown in Figure 1 provides;
Fig. 3 is the facula position and blanking schematic diagram that embodiment as shown in Figure 2 provides;
Fig. 4 is the spot intensity curve that embodiment as shown in Figure 2 provides;
Fig. 5 is the method flow diagram for the step S12 that embodiment as shown in Figure 1 provides;
Fig. 6 is the spatial position schematic diagram for the hot spot dough sheet that embodiment as shown in Figure 5 provides;
Fig. 7 is the method flow diagram for the step S123 that embodiment as shown in Figure 5 provides;
Fig. 8 is the texture schematic diagram after the merging that embodiment as shown in Figure 7 provides;
Fig. 9 is the method flow diagram of another embodiment of the generation method of Lens Flare provided by the invention;
Figure 10 is the schematic device of one embodiment of the generating means of Lens Flare provided by the invention;
Figure 11 is the schematic device of another embodiment of the generating means of Lens Flare provided by the invention.
Specific embodiment
Following will be combined with the drawings in the embodiments of the present invention, and technical solution in the embodiment of the present invention carries out clear, complete Site preparation description, it is clear that described embodiments are only a part of the embodiments of the present invention, instead of all the embodiments.It is based on Embodiment in the present invention, it is obtained by those of ordinary skill in the art without making creative efforts every other Embodiment shall fall within the protection scope of the present invention.
It is the method flow diagram of one embodiment of the generation method of Lens Flare provided by the invention referring to Fig. 1.
The generation method of the Lens Flare, comprising:
S11 establishes halation model in three-dimensional scenic, and one is arranged on the straight line where scene light source and optical center Or multiple hot spot dough sheets so that the light source to the hot spot dough sheet distance and the light source to the optical center away from From the ratio between meet preset ratio, and according to the position of the light source, obtain the hot spot face in projector space in real time The attribute of piece.
S12 draws the hot spot dough sheet on the corresponding position of projector space according to the attribute of the hot spot dough sheet System.
The generation method of Lens Flare provided by the invention calculates the attribute of hot spot using simplified hot spot model, calculates It measures less, can real-time and efficiently be generated in preset proportional positions and follow the Lens Flare of light source position dynamic change, can answered For having in the scene of requirement of real time but not overcritical physical reality.
Wherein, the attribute of the hot spot dough sheet includes in position, scaling, color, intensity, rotation angle and visibility It is one or more.
As shown in Fig. 2, in specific implementation, the step S11 includes:
S111, obtains the front-rear position relationship of the light source and camera lens, and according to the front-rear position relationship, described in judgement The visibility of hot spot dough sheet.
The light source can be the sun or other illuminators virtual in scene, mainly be with the sun in embodiment hereof Example.The visibility of hot spot is related with the positional relationship of camera lens with light source, and when light source is located at camera lens rear, hot spot is invisible, i.e., Without rendering Lens Flare.Conversely, should then calculate other attributes of hot spot when light source is located in front of camera lens, with to its into Row draws rendering.
S112 calculates the light source in the projection coordinate of projector space, and according to the projection coordinate of the light source and institute The location of hot spot dough sheet is stated, position coordinates of each hot spot dough sheet in projector space are calculated.
In a preferred embodiment, light source the projection coordinate of projector space can be in OpenGL in the following manner Calculate: (sun local coordinate * modelview matrix * is thrown sun_pos*model_view_matrix*projection_matrix Shadow matrix).
Each hot spot is fixed in a proportional positions of the line of light sources project and optical center, thus hot spot will follow The sun is mobile, and when the sun frames out center, hot spot can also frame out center.Conversely, hot spot is gathered to screen center.
S113 obtains the light source at a distance from optical center, and according to the distance, calculates the strong of each hot spot dough sheet Degree.
As shown in Figure 3 and Figure 4, Q1 is application window, and S1 is light source, and O is optical center, and B1 is hot spot dough sheet, J1, J2 is preset blanking boundary, and the blanking boundary is the changed boundary of spot intensity, i.e., when hot spot falls within blanking Spot intensity gradually weakens when except the annulus that boundary J1 and blanking boundary J2 are surrounded.
When specifically, for simulated solar face optical center, incident ray vertical incidence camera lens, halo-reduced effect Fruit, when the sun is fallen within the J1 of blanking boundary, as the sun is close to optical center, the intensity of all hot spots linearly subtracts It is weak.Similarly, when frameing out for simulated solar, angle of incidence of light increases, halo-reduced effect, when the sun falls within blanking side When except boundary J2, as the sun is close to far from optical center, the intensity linear taper of all hot spots.In order to further increase Efficiency does not render halation when the sun falls within especially outer place.
I.e. as shown in figure 4, when the light source is less than corresponding to the blanking boundary J1 radius at a distance from optical center When first threshold, the intensity of all hot spot dough sheets linearly weakens with light source close to optical center.When the light source and optical center Distance be greater than the blanking boundary J2 radius corresponding to second threshold when, the intensity of all hot spot dough sheets is with light source far from mirror Head central linear weakens.When at a distance from the light source with optical center between first threshold and second threshold, institute is kept State the intensity of hot spot dough sheet.
S114 obtains the angle that the light source is rotated in projector space around the optical center, using the angle as institute State the rotation angle of hot spot dough sheet.
Each hot spot dough sheet can be rotated according to the angle of the sun, with relativeness between this analog light source and camera lens Effect caused by changing.
In addition, the size of the scaling of the hot spot dough sheet is at a distance from the hot spot dough sheet to optical center at negative It closes, i.e., closer to optical center, hot spot is bigger, and can carry out different adjustment according to the difference of the hot spot origin cause of formation.The hot spot dough sheet Color can be selected according to user, and can according to the fine day situation of weather carry out intense adjustment, the fine day situation It can be current intensity of illumination.
There are many origin causes of formation of hot spot, and relatively common two kinds are as follows: caused by being scattered as the dust on camera lens, Another kind is as caused by camera lens self space relationship.The former hot spot is usually small and justifies, and position is more random.The shape of the latter Depending on camera lens, usually larger, position is closer to optical center.The present invention ignores the specific origin cause of formation, and directly with can embody The texture mapping of these origin causes of formation.Farther out, thus there may be the case where dispersion apart from screen center for dust hot spot.Institute of the present invention Three Color Channels (RGB channel) for stating hot spot dough sheet are staggered on the line direction of the light source and the optical center, with The chromatic dispersion effects of hot spot are simulated, the distance being staggered is positively correlated at a distance from the hot spot dough sheet to the light source, so that more leaning on Outer hot spot dispersion is more obvious, and is conducive to the authenticity for improving halation.
It is the method flow diagram for the step S12 that embodiment as shown in Figure 1 provides referring to Fig. 5.
In a kind of preferred embodiment, the hot spot dough sheet is parallel to one of coordinate plane of world coordinates (such as xy coordinate plane).As shown in fig. 6, hot spot dough sheet is parallel to the xy coordinate plane of world space, therefore the present invention is on vertex It is not necessary that vertex data is multiplied with world's matrix, camera matrix and projection matrix in tinter, hot spot patch model vertex data Coordinate system and the coordinate system of projector space flush, the hot spot dough sheet of the model space can be mapped directly to by translation and rotation The coordinate plane of projector space.In addition, the hot spot dough sheet is preferably facing to reduce the calculation amount in render process Piece.Though should be noted that in this specification in most of embodiment by taking square dough sheet as an example, those skilled in the art It is appreciated that can also be using the dough sheet of other shapes (such as polygon and circle) as the hot spot in specific implementation Dough sheet, this is not limited by the present invention, and those skilled in the art can select according to actual needs.
Further, since graphics engine can't parse tinter when pre-cut, thus it will be considered that model all It being placed in world space, graphics engine carries out pre-cut to hot spot dough sheet in order to prevent, bounding box can be added for the dough sheet, And the setting of the bounding box of dough sheet such as the bounding box can be arranged bigger than day sylphon enough to big, pass through setting bounding box Skill can be cut to avoid the mistake of graphics engine.
As shown in figure 5, the step S12 includes:
S121 extracts the hot spot dough sheet in the two-dimensional coordinate (for example, xy coordinate) of projector space by vertex shader, According to the aspect ratio information of the attribute of the hot spot dough sheet and screen, adjustment is output to the apex coordinate (example of pixel coloring device Such as, xy value).
In specific implementation, the attribute datas such as position, scaling, color and rotation angle of the hot spot dough sheet, It can be set up directly in patch model.Tinter is adjusted according to the attribute data of hot spot dough sheet and the screen aspect ratio information of input It is output to the xy value of pixel coloring device, it is ensured that when projector space is mapped to screen space, dough sheet is indeformable.
It further, can be by the third dimension coordinate of the hot spot dough sheet in order to guarantee that dough sheet is in screen foremost It is disposed closest to the value of camera lens.For example, in OpenGL (Open Graphics Library, open graphic library), z=-1 For that the z coordinate for being output to pixel coloring device can be appointed as -1 in vertex shader near the value of camera.
S122, by the pixel coloring device by the texture of the hot spot dough sheet and color addition to the hot spot dough sheet On, obtain the color value of each pixel on the hot spot dough sheet.
For common graphics engine, what engine was responsible for is to project to the scene of world space on screen.Engine is not The function of directly drawing on the screen is provided.And draw on the screen dough sheet (such as simple tri patch, Quad Patch or Other more complicated two-dimentional dough sheets) demand be it is existing, and this demand pass through underlying graphics API (Application Programming Interface, application programming interface) complete be it is inconvenient, some graphics engines are not also supported. Using method provided by the invention, it is only necessary to which fine arts personnel carry out the dough sheet of needs, the wash with watercolours provided by existing graphics engine Rendering can be completed in dye channel.The present invention is in vertex shader not by vertex data and world's matrix, camera matrix and projection Matrix multiple, the coordinate system of hot spot patch model vertex data and the coordinate system of projector space flush, and the coordinate of the model space is flat Face maps directly to the coordinate plane of projector space, can simply and easily complete the drafting of dough sheet.
Further, the step S12 further include:
S123, using the intensity of the hot spot dough sheet, texture index and color index as the third dimension of the hot spot dough sheet Information input is spent in tinter (including vertex shader above-mentioned and pixel coloring device), and all hot spot dough sheets are merged into It is drawn in one batch.
It is the method flow diagram for the step S123 that embodiment as shown in Figure 5 provides referring to Fig. 7.
Graphics engine can provide the function that basic batch merges, can be by " model is consistent ", but the sky in the world Between the different model instance such as position, rotation and scaling merge, only submit primary request to GPU, draw all moulds Type example.Here " model is consistent " refers to that uniform (specification) data of model tinter are the same (including texture).Cause This, the present invention merges rendering batch in the following way.
In a kind of preferred embodiment, the step S123 includes:
Texture used in each hot spot dough sheet is merged into a big texture, and forms corresponding texture rope by S1231 Draw.
In a preferred embodiment, the hot spot dough sheet of fine arts personnel production is standard square dough sheet, dough sheet positive direction Towards z-axis positive direction, length and width are all 1, and center is located at origin, and texture coordinate is (0,0)~(1,1).It can be by these facings Texture used in piece is spliced, and a Zhang great Tu is packaged into, and establishes corresponding texture index.As shown in figure 8, for by 4 The big texture maps that texture is spliced into, if the texture index of upper left corner texture is (0,0), then the texture rope of lower right corner texture It is cited as (N-1, M-1), N is the number of the direction x texture grid, and M is the number of the direction y texture grid.The present invention passes through texture Merge so that the data texturing of each hot spot dough sheet is consistent, is criticized so that existing merging method can be used in the next steps Secondary merging, and in render process, specific texture used in each hot spot dough sheet can be searched by texture index.
S1232 transmits color data (rgb value) used in all hot spot dough sheets as specification (uniform) data To the tinter.
In specific implementation, the color data can be split as three arrays according to RGB channel, pass through uniform Interface is sent to the tinter.The color data is the color set that may use of all hot spot dough sheets, when it needs to be determined that When the specific color of some hot spot, it can be searched in the color data according to the color index of the hot spot and the color Index corresponding color.In existing merging rendering batch procedures, it is desirable that the uniform data phase of each rendering batch merged Together, the present invention is by the above method, so that the uniform data of all hot spot dough sheets are identical, it can be in the next steps by existing All hot spots are merged into a batch by some merging rendering batch procedures carries out drafting rendering (as previously mentioned, existing conjunction And render in batch procedures, it is desirable that the uniform data of each rendering batch merged are identical).
The texture of hot spot dough sheet index, color index and intensity are packaged into a floating number as described in by S1233 The third dimension information of hot spot dough sheet, is input in the tinter.
When arriving projector space in view of drawing hot spot dough sheet, having the data of a dimension, there is no uses (such as to work as hot spot When dough sheet is parallel to x/y plane, the data of z-axis are simultaneously not used), the present invention proposes a kind of method, by other attribute datas of hot spot It is packaged in extra third dimension, data is parsed from extra dimension data by tinter in drawing process.
If the texture index that hot spot dough sheet uses is (x_ind, y_ind), color index c_ind, spot intensity are I, it is contemplated that I must be a number less than 1, a kind of preferred packing manner that the present invention uses are as follows: x_ind*100+y_ ind*10+c_ind+I.At most allow 10*10 texture grid in aforesaid way, 10 hot spots can meet most of scene Demand, number of spots can also easily increase.
S1234 parses texture index, color index and strong by the tinter from the third dimension information Degree searches texture corresponding with texture index from the large texture, searches and the color from the color data Corresponding color is indexed, all hot spot dough sheets are drawn in a batch.
According to the mode being packaged, tinter can simply and easily parse texture index, color index and spot intensity, and Texture corresponding with texture index is searched from the large texture, is searched and the color index from the color data Corresponding color, and the information such as rotation angle, scaling and position of the hot spot dough sheet are set up directly on model, figure Engine can be extracted directly, to draw to the hot spot dough sheet.By the above-mentioned means, meeting render process of the invention The requirement of " model is consistent " needed for general merging batch can directly adopt the merging method that existing graphics engine provides, will The drafting of all hot spot dough sheets is merged into a batch and carries out.
The present invention calculates hot spot attribute using a kind of simplified halation model, based on the coloring drawn in projector space The rendering of halation is merged into a batch by device, and calculation amount is smaller, can be applied to requirement of real time but has not been made excessive demands physical reality Field.
It is the flow chart of another embodiment of the generation method of Lens Flare provided by the invention referring to Fig. 9.This implementation Example further comprises on the basis of Fig. 1 embodiment:
S13 obtains the product of both background pixel and hot spot pixel color value (rgb value), by the product of the color value It is mixed with the background pixel, obtains mixed once result.
In specific implementation, mixed mode glBlendFunc (BLEND_DESTCOLOR, GL_ are enabled by OpenGL ONE).Assuming that background pixel is D, hot spot pixel is S, then the result obtained is exactly DS+D.
The mixed once result is mixed with the hot spot pixel, obtains secondary mixing resultant by S14.
In specific implementation, mixed mode glBlendFunc (GL_ONE, GL_ONE) is enabled by OpenGL, in conjunction with Step S13, the then result exported are DS+D+S.
The secondary mixing resultant is output to screen and shown by S15.
By drawing twice, in addition specific hybrid mode, can more preferably keep the saturation degree of halation, reach in bright background In can also see the effect of halation clearly, to embody the color of halation complexity itself.Above-mentioned hybrid mode is only a kind of preferred reality Mode is applied, those skilled in the art can carry out tradeoff selection according to effect and performance, such as when equipment performance deficiency, can only adopt The hybrid mode to be added up with single color.
It is the structural schematic diagram of one embodiment of the generating means of Lens Flare provided by the invention referring to Figure 10.This The basic principle of embodiment is consistent with embodiment illustrated in fig. 1, and place is not described in detail in the present embodiment can be found in embodiment illustrated in fig. 1 Associated description.
The generating means of the Lens Flare include:
Modeling module 11, for establishing halation model in three-dimensional scenic, scene light source with it is straight where optical center One or more hot spot dough sheets are set on line, so that the light source is to the distance of the hot spot dough sheet and the light source described in The ratio of distances constant of optical center meets preset ratio, and according to the position of the light source, obtains in real time in projector space The attribute of the interior hot spot dough sheet.
Drafting module 12, for the attribute according to the hot spot dough sheet, to the light on the corresponding position of projector space Spot dough sheet is drawn.
Wherein, the attribute of the hot spot dough sheet includes in position, scaling, color, intensity, rotation angle and visibility It is one or more.The modeling module 11 includes:
Visibility judge unit 111, for obtaining the front-rear position relationship of the light source and camera lens, and according to the front and back Positional relationship judges the visibility of the hot spot dough sheet.
Position calculation unit 112, for calculating the light source in the projection coordinate of projector space, and according to the light source The location of projection coordinate and the hot spot dough sheet calculate position coordinates of each hot spot dough sheet in projector space.
Strength co-mputation unit 113 is calculated for obtaining the light source at a distance from optical center, and according to the distance The intensity of each hot spot dough sheet.
Computing unit 114 is rotated, the angle rotated in projector space around the optical center for obtaining the light source will Rotation angle of the angle as the hot spot dough sheet.
For the chromatic dispersion effects for simulating hot spot, in a kind of preferred embodiment, three colors of the hot spot dough sheet Channel is staggered on the line direction of the light source and the optical center, the distance being staggered and the hot spot dough sheet to the light The distance in source is positively correlated.
In a kind of preferred embodiment, one of coordinate that the hot spot dough sheet is parallel to world coordinates is flat Face.The drafting module 12 includes:
Vertex processing unit 121 is sat for extracting the hot spot dough sheet by vertex shader in the two dimension of projector space Mark, according to the aspect ratio information of the attribute of the hot spot dough sheet and screen, adjustment is output to the apex coordinate of pixel coloring device.
Pixel processing unit 122, for passing through the pixel coloring device for the texture and color addition of the hot spot dough sheet Onto the hot spot dough sheet, the color value of each pixel on the hot spot dough sheet is obtained.
The drafting module 12 can further include:
Batch combining unit 123, for using the intensity of the hot spot dough sheet, texture index and color index as the light All hot spot dough sheets are merged into a batch and draw into tinter by the third dimension information input of spot dough sheet.
In a kind of preferred embodiment, the pixel processing unit 122 is also used to the of the hot spot dough sheet Three dimensionality coordinate is disposed closest to the value of camera lens.
In specific implementation, the batch combining unit 123 includes:
Texture merges subelement, for texture used in each hot spot dough sheet to be merged into a big texture, and is formed Corresponding texture index;
Color transfer subelement, for passing to institute using color data used in all hot spot dough sheets as specification data State tinter;
Data are packaged subelement, for texture index, color index and the intensity of the hot spot dough sheet to be packaged into one Third dimension information of the floating number as the hot spot dough sheet, is input in the tinter;With,
Batch merges subelement, indexed for parsing texture from the third dimension information by the tinter, Color index and intensity are searched texture corresponding with texture index from the large texture, are looked into from the color data Color corresponding with the color index is looked for, all hot spot dough sheets are drawn in a batch.
It is the structural schematic diagram of another embodiment of the generating means of Lens Flare provided by the invention referring to Figure 11. The basic principle of the present embodiment is consistent with embodiment of the method shown in Fig. 9, and place is not described in detail and can be found in for the present embodiment implements shown in Fig. 9 Associated description in example.
The present embodiment further comprises on the basis of embodiment illustrated in fig. 10:
Mixed once module 13 multiplies the color value for obtaining the color value product of background pixel and hot spot pixel Product is mixed with the background pixel, obtains mixed once result.
Secondary mixing module 14 obtains secondary for mixing the mixed once result with the hot spot pixel Mixing resultant.
Result display module 15 is shown for the secondary mixing resultant to be output to screen.
It should be noted that the apparatus embodiments described above are merely exemplary, wherein described be used as separation unit The unit of explanation may or may not be physically separated, and component shown as a unit can be or can also be with It is not physical unit, it can it is in one place, or may be distributed over multiple network units.It can be according to actual It needs that some or all of the modules therein is selected to achieve the purpose of the solution of this embodiment.In addition, device provided by the invention In embodiment attached drawing, the connection relationship between module indicate between them have communication connection, specifically can be implemented as one or A plurality of communication bus or signal wire.Those of ordinary skill in the art are without creative efforts, it can understand And implement.
Through the above description of the embodiments, it is apparent to those skilled in the art that the present invention can borrow Help software that the mode of required common hardware is added to realize, naturally it is also possible to by specialized hardware include specific integrated circuit, specially It is realized with CPU, private memory, special components and parts etc..Under normal circumstances, all functions of being completed by computer program are ok It is easily realized with corresponding hardware, moreover, being used to realize that the specific hardware structure of same function is also possible to a variety of more Sample, such as analog circuit, digital circuit or special circuit etc..But software program is real in situations more for the purpose of the present invention It is now more preferably embodiment.Based on this understanding, technical solution of the present invention substantially in other words makes the prior art The part of contribution can be embodied in the form of software products, which is stored in the storage medium that can be read In, such as the floppy disk of computer, USB flash disk, mobile hard disk, read-only memory (ROM, Read-Only Memory), random access memory Device (RAM, Random Access Memory), magnetic or disk etc., including some instructions are with so that a computer is set Standby (can be personal computer, server or the network equipment etc.) executes method described in each embodiment of the present invention.
The above description is merely a specific embodiment, but scope of protection of the present invention is not limited thereto, any Those familiar with the art in the technical scope disclosed by the present invention, can easily think of the change or the replacement, and should all contain Lid is within protection scope of the present invention.Therefore, protection scope of the present invention should be based on the protection scope of the described claims.

Claims (16)

1. a kind of generation method of Lens Flare characterized by comprising
Halation model is established in three-dimensional scenic, and one or more light are set on the straight line where scene light source and optical center Spot dough sheet, so that the light source is accorded with to the distance of the hot spot dough sheet and the ratio of distances constant of the light source to the optical center Preset ratio is closed, and according to the position of the light source, obtains the attribute of the hot spot dough sheet in projector space in real time;
According to the attribute of the hot spot dough sheet, the hot spot dough sheet is drawn on the corresponding position of projector space;
Wherein, the attribute of the hot spot dough sheet includes one in position, scaling, color, intensity, rotation angle and visibility Kind is a variety of;
Wherein, described that halation model is established in three-dimensional scenic, it is arranged one on the straight line where scene light source and optical center A or multiple hot spot dough sheets, so that distance and the light source to the optical center of the light source to the hot spot dough sheet Ratio of distances constant meets preset ratio, and according to the position of the light source, obtains the hot spot in projector space in real time The attribute of dough sheet, comprising:
The front-rear position relationship of the light source and camera lens is obtained, and according to the front-rear position relationship, judges the hot spot dough sheet Visibility;
The light source is calculated in the projection coordinate of projector space, and according to the projection coordinate of the light source and the hot spot dough sheet Location calculates position coordinates of each hot spot dough sheet in projector space;
The light source is obtained at a distance from optical center, and according to the distance, calculates the intensity of each hot spot dough sheet;
The angle that the light source is rotated in projector space around the optical center is obtained, using the angle as the hot spot dough sheet Rotation angle.
2. the generation method of Lens Flare as described in claim 1, which is characterized in that three colors of the hot spot dough sheet are logical Road is staggered on the line direction of the light source and the optical center, the distance being staggered and the hot spot dough sheet to the light source Distance be positively correlated.
3. the generation method of Lens Flare as described in claim 1, which is characterized in that the hot spot dough sheet is parallel to world's seat The one of coordinate plane of target.
4. the generation method of Lens Flare as claimed in claim 3, which is characterized in that the category according to the hot spot dough sheet Property, the hot spot dough sheet is drawn on the corresponding position of projector space, comprising:
The hot spot dough sheet is extracted in the two-dimensional coordinate of projector space, according to the attribute of the hot spot dough sheet by vertex shader And the aspect ratio information of screen, adjustment are output to the apex coordinate of pixel coloring device;
By the pixel coloring device by the texture of the hot spot dough sheet and color addition to the hot spot dough sheet, described in acquisition The color value of each pixel on hot spot dough sheet.
5. the generation method of Lens Flare as claimed in claim 4, which is characterized in that extracted described by vertex shader The hot spot dough sheet projector space two-dimensional coordinate, according to the aspect ratio information of the attribute of the hot spot dough sheet and screen, Adjustment is output to after the apex coordinate of pixel coloring device, further includes:
The third dimension coordinate of the hot spot dough sheet is disposed closest to the value of camera lens.
6. the generation method of Lens Flare as claimed in claim 4, which is characterized in that the category according to the hot spot dough sheet Property, the hot spot dough sheet is drawn on the corresponding position of projector space, further includes:
Using the intensity of the hot spot dough sheet, texture index and color index as the third dimension information input of the hot spot dough sheet Into tinter, all hot spot dough sheets are merged into a batch and are drawn.
7. the generation method of Lens Flare as claimed in claim 6, which is characterized in that described by the strong of the hot spot dough sheet Degree, texture index and color index as the hot spot dough sheet third dimension information input into the tinter, by institute There is hot spot dough sheet to be merged into a batch to be drawn, comprising:
Texture used in each hot spot dough sheet is merged into a big texture, and forms corresponding texture index;
The tinter is passed to using color data used in all hot spot dough sheets as specification data;
The texture of hot spot dough sheet index, color index and intensity are packaged into a floating number as the hot spot dough sheet Third dimension information is input in the tinter;
Texture index, color index and intensity are parsed from the third dimension information by the tinter, from described big Texture corresponding with texture index is searched in texture, and face corresponding with the color index is searched from the color data Color draws all hot spot dough sheets in a batch.
8. the generation method of Lens Flare as described in any one of claims 1 to 7, which is characterized in that described according to The attribute of hot spot dough sheet, after being drawn on the corresponding position of projector space to the hot spot dough sheet, further includes:
The color value product for obtaining background pixel and hot spot pixel, the color value product is mixed with the background pixel It closes, obtains mixed once result;
The mixed once result is mixed with the hot spot pixel, obtains secondary mixing resultant;
The secondary mixing resultant is output to screen to show.
9. a kind of generating means of Lens Flare characterized by comprising
Modeling module is set on scene light source and the straight line where optical center for establishing halation model in three-dimensional scenic One or more hot spot dough sheets are set, so that the light source is to the distance of the hot spot dough sheet and the light source into the camera lens The ratio of distances constant of the heart meets preset ratio, and according to the position of the light source, obtains in real time described in projector space The attribute of hot spot dough sheet;With,
Drafting module, for the attribute according to the hot spot dough sheet, to the hot spot dough sheet on the corresponding position of projector space It is drawn;
Wherein, the attribute of the hot spot dough sheet includes one in position, scaling, color, intensity, rotation angle and visibility Kind is a variety of;
Wherein, the modeling module includes:
Visibility judge unit is closed for obtaining the front-rear position relationship of the light source and camera lens, and according to the front-rear position System, judges the visibility of the hot spot dough sheet;
Position calculation unit is sat for calculating the light source in the projection coordinate of projector space, and according to the projection of the light source It is marked with and the location of the hot spot dough sheet, calculates position coordinates of each hot spot dough sheet in projector space;
Strength co-mputation unit calculates each hot spot for obtaining the light source at a distance from optical center, and according to the distance The intensity of dough sheet;With,
Rotate computing unit, the angle rotated in projector space around the optical center for obtaining the light source, by the angle Spend the rotation angle as the hot spot dough sheet.
10. the generating means of Lens Flare as claimed in claim 9, which is characterized in that three colors of the hot spot dough sheet Channel is staggered on the line direction of the light source and the optical center, the distance being staggered and the hot spot dough sheet to the light The distance in source is positively correlated.
11. the generating means of Lens Flare as claimed in claim 9, which is characterized in that the hot spot dough sheet is parallel to the world One of coordinate plane of coordinate.
12. the generating means of Lens Flare as claimed in claim 11, which is characterized in that the drafting module includes:
Vertex processing unit, for extracting the hot spot dough sheet in the two-dimensional coordinate of projector space by vertex shader, according to The attribute of the hot spot dough sheet and the aspect ratio information of screen, adjustment are output to the apex coordinate of pixel coloring device;With,
Pixel processing unit, for by the pixel coloring device by the texture of the hot spot dough sheet and color addition to the light On spot dough sheet, the color value of each pixel on the hot spot dough sheet is obtained.
13. the generating means of Lens Flare as claimed in claim 12, which is characterized in that the vertex processing unit is also used to The third dimension coordinate of the hot spot dough sheet is disposed closest to the value of camera lens.
14. the generating means of Lens Flare as claimed in claim 12, which is characterized in that the drafting module, further includes:
Batch combining unit, for using the intensity of the hot spot dough sheet, texture index and color index as the hot spot dough sheet Third dimension information input into tinter, all hot spot dough sheets are merged into a batch and are drawn.
15. the generating means of Lens Flare as claimed in claim 14, which is characterized in that the batch combining unit includes:
Texture merges subelement, for texture used in each hot spot dough sheet to be merged into a big texture, and is formed corresponding Texture index;
Color transfer subelement, it is described for being passed to using color data used in all hot spot dough sheets as specification data Color device;
Data are packaged subelement, for texture index, color index and the intensity of the hot spot dough sheet to be packaged into a floating-point Third dimension information of the number as the hot spot dough sheet, is input in the tinter;With,
Batch merges subelement, for parsing texture index, color from the third dimension information by the tinter Index and intensity search corresponding with texture index texture from the large texture, from the color data lookup and The corresponding color of the color index, draws all hot spot dough sheets in a batch.
16. such as the generating means of the described in any item Lens Flares of claim 9~14, which is characterized in that described device is also wrapped It includes:
Mixed once module, for obtaining the color value product of background pixel and hot spot pixel, by the color value product and institute It states background pixel to be mixed, obtains mixed once result;
Secondary mixing module obtains secondary mixing knot for mixing the mixed once result with the hot spot pixel Fruit;With,
Result display module is shown for the secondary mixing resultant to be output to screen.
CN201610283282.XA 2016-04-29 2016-04-29 A kind of generation method and device of Lens Flare Active CN105976423B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN201610283282.XA CN105976423B (en) 2016-04-29 2016-04-29 A kind of generation method and device of Lens Flare

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN201610283282.XA CN105976423B (en) 2016-04-29 2016-04-29 A kind of generation method and device of Lens Flare

Publications (2)

Publication Number Publication Date
CN105976423A CN105976423A (en) 2016-09-28
CN105976423B true CN105976423B (en) 2019-07-30

Family

ID=56993861

Family Applications (1)

Application Number Title Priority Date Filing Date
CN201610283282.XA Active CN105976423B (en) 2016-04-29 2016-04-29 A kind of generation method and device of Lens Flare

Country Status (1)

Country Link
CN (1) CN105976423B (en)

Families Citing this family (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN106846454A (en) * 2017-01-17 2017-06-13 网易(杭州)网络有限公司 Lens Flare method for drafting and device
CN109529333A (en) * 2018-11-21 2019-03-29 北京像素软件科技股份有限公司 Lens Flare analogy method, Lens Flare simulator and terminal device
CN109885464B (en) * 2019-01-24 2021-07-16 腾讯科技(深圳)有限公司 Data processing method and system based on open graphic library
CN112435323B (en) * 2020-11-26 2023-08-22 网易(杭州)网络有限公司 Light effect processing method, device, terminal and medium in virtual model

Citations (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
JP2003102990A (en) * 2001-09-30 2003-04-08 Sankyo Kk Game machine
CN1870055A (en) * 2006-06-27 2006-11-29 北京航空航天大学 High dynamic range material color applying drawing method
CN104930464A (en) * 2015-06-11 2015-09-23 横店集团得邦照明股份有限公司 Method for forming annular halo

Family Cites Families (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US9595132B2 (en) * 2013-09-10 2017-03-14 Research & Business Foundation Sungkyunkwan University Methods and apparatuses of lens flare rendering using linear paraxial approximation, and methods and apparatuses of lens flare rendering based on blending

Patent Citations (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
JP2003102990A (en) * 2001-09-30 2003-04-08 Sankyo Kk Game machine
CN1870055A (en) * 2006-06-27 2006-11-29 北京航空航天大学 High dynamic range material color applying drawing method
CN104930464A (en) * 2015-06-11 2015-09-23 横店集团得邦照明股份有限公司 Method for forming annular halo

Non-Patent Citations (1)

* Cited by examiner, † Cited by third party
Title
模拟器视景***中太阳及镜头光晕的绘制;任鸿翔 等;《大连海事大学学报》;20070515;第33卷(第2期);第125页右栏第2-3段,第126页左栏第3段,第126页右栏第2段,图2-3

Also Published As

Publication number Publication date
CN105976423A (en) 2016-09-28

Similar Documents

Publication Publication Date Title
CN107452048B (en) The calculation method and device of global illumination
CN107341853B (en) Virtual-real fusion method and system for super-large virtual scene and dynamic screen shooting
JP5531093B2 (en) How to add shadows to objects in computer graphics
CN111508052B (en) Rendering method and device of three-dimensional grid body
CN105976423B (en) A kind of generation method and device of Lens Flare
US20070057940A1 (en) 2D editing metaphor for 3D graphics
CN104103092A (en) Real-time dynamic shadowing realization method based on projector lamp
US20230230311A1 (en) Rendering Method and Apparatus, and Device
CN110908510A (en) Application method of oblique photography modeling data in immersive display equipment
Sheng et al. A spatially augmented reality sketching interface for architectural daylighting design
CN113648652B (en) Object rendering method and device, storage medium and electronic equipment
CN113034660A (en) Laser radar simulation method based on PBR reflection model
Knecht et al. A framework for perceptual studies in photorealistic augmented reality
JP2003168130A (en) System for previewing photorealistic rendering of synthetic scene in real-time
Noh et al. Soft shadow rendering based on real light source estimation in augmented reality
Yoshida On-The-Fly Simulator of Tabletop Light-Field 3-D Displays Powered by a Game Engine
KR20210052005A (en) Method for augmenting video content in a 3-dimensional environment
Kolivand et al. Shadow mapping or shadow volume?
US20220012941A1 (en) Method and system for digital processing
US20230090732A1 (en) System and method for real-time ray tracing in a 3d environment
Ward et al. VRVision: A new tool for the display of 3-D images in behavioral research
Chochlík Scalable multi-GPU cloud raytracing with OpenGL
Hagen et al. Computer graphics and visual perception: The state of the art
Peschel et al. Plausible visualization of the dynamic digital factory with massive amounts of lights
CN114419215A (en) Processing method and device of volume cloud and electronic equipment

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