Subversion Repository Public Repository

Divide-Framework

This repository has no backups
This repository's network speed is throttled to 100KB/sec

Diff Revisions 330 vs 331 for /trunk/Source Code/Rendering/Lighting/Headers/LightGrid.h

Diff revisions: vs.
  @@ -26,8 +26,10 @@
26 26 #include "Light.h"
27 27
28 28 /**
29 - * This class contains the representation, and construction of the light grid used for tiled deferred shading.
30 - * The grid is stored in statically sized arrays, the size is determined by LIGHT_GRID_MAX_DIM_X and LIGHT_GRID_MAX_DIM_Y
29 + * This class contains the representation, and construction of the light grid used for
30 + * tiled deferred shading.
31 + * The grid is stored in statically sized arrays, the size is determined by
32 + * LIGHT_GRID_MAX_DIM_X and LIGHT_GRID_MAX_DIM_Y
31 33 * (see Config.h).
32 34 */
33 35
  @@ -45,15 +47,20 @@
45 47 };
46 48
47 49
48 - inline static LightInternal make_light(const vec3<F32>& position, const vec3<F32>& color, F32 range)
49 - {
50 - LightInternal l = { position, color, range };
50 + inline static LightInternal makeLight(const vec3<F32>& position,
51 + const vec3<F32>& color,
52 + F32 range) {
53 + LightInternal l = {position,
54 + color,
55 + range };
51 56 return l;
52 57 }
53 58
54 - inline static LightInternal make_light(const vec3<F32>& position, const LightInternal &l)
55 - {
56 - return make_light(position, l.color, l.range);
59 + inline static LightInternal makeLight(const vec3<F32>& position,
60 + const LightInternal &l) {
61 + return makeLight(position,
62 + l.color,
63 + l.range);
57 64 }
58 65
59 66
  @@ -66,7 +73,10 @@
66 73
67 74 typedef vectorImpl<ScreenRect> ScreenRects;
68 75
69 - LightGrid() {};
76 + LightGrid()
77 + {
78 + }
79 +
70 80 /**
71 81 * Call to build the grid structure.
72 82 * The tile size and (screen) resolution must combine to be less than the maximum defined byt
  @@ -76,61 +86,107 @@
76 86 * The values are expected to be in view space.
77 87 * It must have the dimensions LIGHT_GRID_MAX_DIM_X x LIGHT_GRID_MAX_DIM_Y.
78 88 */
79 - void build(const vec2<U16>& tileSize, const vec2<U16>& resolution, const Lights& light,
80 - const mat4<F32>& modelView, const mat4<F32>& projection, F32 near, const vectorImpl<vec2<F32> >& gridMinMaxZ);
89 + void build(const vec2<U16>& tileSize,
90 + const vec2<U16>& resolution,
91 + const Lights& light,
92 + const mat4<F32>& modelView,
93 + const mat4<F32>& projection,
94 + F32 near,
95 + const vectorImpl<vec2<F32> >& gridMinMaxZ);
81 96
82 97 void prune(const vectorImpl<vec2<F32> >& gridMinMaxZ);
98 +
83 99 void pruneFarOnly(F32 aNear, const vectorImpl<vec2<F32> >& aGridMinMaxZ);
84 100
85 101 /**
86 102 * Access to grid wide properties, set at last call to 'build'.
87 103 */
88 - const vec2<U16>& getTileSize() const { return m_tileSize; }
89 - const vec2<U16>& getGridDim() const { return m_gridDim; }
90 - U32 getMaxTileLightCount() const { return m_maxTileLightCount; }
91 - U32 getTotalTileLightIndexListLength() const { return U32(m_tileLightIndexLists.size()); }
104 + const vec2<U16>& getTileSize() const {
105 + return m_tileSize;
106 + }
107 +
108 + const vec2<U16>& getGridDim() const {
109 + return m_gridDim;
110 + }
111 +
112 + U32 getMaxTileLightCount() const {
113 + return m_maxTileLightCount;
114 + }
115 +
116 + U32 getTotalTileLightIndexListLength() const {
117 + return U32(m_tileLightIndexLists.size());
118 + }
92 119
93 120 /**
94 121 * tile accessor functions, returns data for an individual tile.
95 122 */
96 - I32 tileLightCount(U32 x, U32 y) const { return m_gridCounts[x + y * Config::Lighting::LIGHT_GRID_MAX_DIM_X]; }
97 - const I32 *tileLightIndexList(U32 x, U32 y) const { return &m_tileLightIndexLists[m_gridOffsets[x + y * Config::Lighting::LIGHT_GRID_MAX_DIM_X]]; }
98 - const vec2<F32> getTileMinMax(U32 x, U32 y) const { return m_minMaxGridValid ? m_gridMinMaxZ[x + y * m_gridDim.x] : vec2<F32>(0.0f, 0.0f); }
123 + I32 tileLightCount(U32 x, U32 y) const {
124 + return m_gridCounts[x + y * Config::Lighting::LIGHT_GRID_MAX_DIM_X];
125 + }
126 +
127 + const I32 *tileLightIndexList(U32 x, U32 y) const {
128 + return &m_tileLightIndexLists[m_gridOffsets[x + y * Config::Lighting::LIGHT_GRID_MAX_DIM_X]];
129 + }
99 130
131 + const vec2<F32> getTileMinMax(U32 x, U32 y) const {
132 + return m_minMaxGridValid ? m_gridMinMaxZ[x + y * m_gridDim.x] : vec2<F32>(0.0f, 0.0f);
133 + }
100 134
101 135 /**
102 136 * Grid data pointer accessors, used for uploading to GPU.
103 137 */
104 - const I32 *tileDataPtr() const { return m_gridOffsets; }
105 - const I32 *tileCountsDataPtr() const { return m_gridCounts; }
106 - const I32 *tileLightIndexListsPtr() const { return &m_tileLightIndexLists[0]; }
138 + const I32 *tileDataPtr() const {
139 + return m_gridOffsets;
140 + }
141 +
142 + const I32 *tileCountsDataPtr() const {
143 + return m_gridCounts;
144 + }
107 145
146 + const I32 *tileLightIndexListsPtr() const {
147 + return &m_tileLightIndexLists[0];
148 + }
108 149 /**
109 150 * Returns the list of lights, transformed to view space, that are present in the grid,
110 151 * i.e. produces an on screen rectangle. The light indices in the tile light lists index
111 152 * into this list.
112 153 */
113 - const Lights& getViewSpaceLights() const { return m_viewSpaceLights; }
114 -
154 + const Lights& getViewSpaceLights() const {
155 + return m_viewSpaceLights;
156 + }
115 157 /**
116 158 * Indicated whether there are any lights visible, i.e. with on-screen rects.
117 159 */
118 - bool empty() const { return m_screenRects.empty(); }
160 + bool empty() const {
161 + return m_screenRects.empty();
162 + }
119 163 /**
120 164 * if true, then the contents of the min/max grid is valid,
121 165 * i.e. the pointer was not 0 last time build was called.
122 166 */
123 - bool minMaxGridValid() const { return m_minMaxGridValid; }
167 + bool minMaxGridValid() const {
168 + return m_minMaxGridValid;
169 + }
124 170
125 - static ScreenRect findScreenSpaceBounds(const mat4<F32>& projection, const vec3<F32>& pt, F32 rad, I32 width, I32 height, F32 nearPlane);
171 + static ScreenRect findScreenSpaceBounds(const mat4<F32>& projection,
172 + const vec3<F32>& pt,
173 + F32 rad,
174 + I32 width,
175 + I32 height,
176 + F32 nearPlane);
126 177
127 178 protected:
128 179
129 180 /**
130 181 * Builds rects list (m_screenRects) and view space lights list (m_viewSpaceLights).
131 182 */
132 - void buildRects(const vec2<U16>& resolution, const Lights& lights, const mat4<F32>& modelView, const mat4<F32>& projection, F32 nearPlane);
183 + void buildRects(const vec2<U16>& resolution,
184 + const Lights& lights,
185 + const mat4<F32>& modelView,
186 + const mat4<F32>& projection,
187 + F32 nearPlane);
133 188
189 + protected:
134 190 vec2<U16> m_tileSize;
135 191 vec2<U16> m_gridDim;
136 192