Merge lp:~unity-team/nux/nux.pixel-to-texture-mapping into lp:nux/2.0
- nux.pixel-to-texture-mapping
- Merge into 2.0
Status: | Merged |
---|---|
Approved by: | Jay Taoko |
Approved revision: | 542 |
Merged at revision: | 542 |
Proposed branch: | lp:~unity-team/nux/nux.pixel-to-texture-mapping |
Merge into: | lp:nux/2.0 |
Diff against target: |
956 lines (+416/-334) 14 files modified
Nux/WindowCompositor.cpp (+1/-1) NuxGraphics/GraphicsEngine.cpp (+1/-1) NuxGraphics/IOpenGLBaseTexture.cpp (+4/-2) NuxGraphics/IOpenGLBaseTexture.h (+14/-6) NuxGraphics/IOpenGLRectangleTexture.cpp (+19/-16) NuxGraphics/IOpenGLRectangleTexture.h (+13/-2) NuxGraphics/IOpenGLSurface.cpp (+37/-17) NuxGraphics/IOpenGLSurface.h (+9/-2) NuxGraphics/IOpenGLTexture2D.cpp (+19/-16) NuxGraphics/IOpenGLTexture2D.h (+13/-2) NuxGraphics/RenderingPipe.cpp (+15/-8) NuxGraphics/RenderingPipe.h (+3/-3) NuxGraphics/RenderingPipeTextureBlend.cpp (+267/-257) configure.ac (+1/-1) |
To merge this branch: | bzr merge lp:~unity-team/nux/nux.pixel-to-texture-mapping |
Related bugs: |
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
Mirco Müller (community) | Approve | ||
Review via email: mp+88803@code.launchpad.net |
Commit message
Description of the change
* Dump a texture mip level RGBA data: IOpenGLBaseText
* Added layer blendind shader code.
* Corrected texel to pixel coordinate mapping. Ensure 1 to 1 correspondance when texture and quad are the same size.
* Removed 0.375 offset in model view translation matrix, meant to match quad and line rendering at the pixel level.
- 536. By Andrea Azzarone
-
This branch is a partial fix for the bug #893670. It requires also:
- https://code.launchpad .net/~andyrock/ compiz- core/scale- left-padding/ +merge/ 88622
- https://code.launchpad .net/~andyrock/ unity/scale- left-padding/ +merge/ 88625 But you can test it setting the spacing option in the scale ccsm panel to 100.. Fixes: https:/
/bugs.launchpad .net/bugs/ 893670. Appoved by Mirco Müller. - 537. By Andrea Azzarone
-
Add support for the _COMPIZ_
NET_OVERLAY_ STRUTS property.. Fixes: . Appoved by Sam Spilsbury. - 538. By Andrea Azzarone
-
Changes the cursor when the mouse pointer is over the text entry area.. Fixes: https:/
/bugs.launchpad .net/bugs/ 737719, https:/ /bugs.launchpad .net/bugs/ 849175. Appoved by Jay Taoko.
- 539. By Jay Taoko
-
* Exposes a BaseWindow textures. Fixes: . Appoved by Jason Smith.
- 540. By Jay Taoko
-
* Reset projection matrix when restoring framebuffer.. Fixes: . Appoved by Mirco Müller.
- 541. By Jay Taoko
-
* Merged with Nux trunk
- 542. By Jay Taoko
-
* Resolved conflict
* merged with Nux trunk
* Upgraded nx_abi_version
Preview Diff
1 | === modified file 'Nux/WindowCompositor.cpp' |
2 | --- Nux/WindowCompositor.cpp 2012-01-16 03:35:13 +0000 |
3 | +++ Nux/WindowCompositor.cpp 2012-01-20 20:42:24 +0000 |
4 | @@ -1217,7 +1217,7 @@ |
5 | window_thread_->GetGraphicsEngine().ResetProjectionMatrix(); |
6 | |
7 | window_thread_->GetGraphicsEngine().ResetModelViewMatrixStack(); |
8 | - window_thread_->GetGraphicsEngine().Push2DTranslationModelViewMatrix(0.375f, 0.375f, 0.0f); |
9 | + window_thread_->GetGraphicsEngine().Push2DTranslationModelViewMatrix(0.0f, 0.0f, 0.0f); |
10 | |
11 | |
12 | if (force_draw || SizeConfigurationEvent) |
13 | |
14 | === modified file 'NuxGraphics/GraphicsEngine.cpp' |
15 | --- NuxGraphics/GraphicsEngine.cpp 2011-10-22 06:17:42 +0000 |
16 | +++ NuxGraphics/GraphicsEngine.cpp 2012-01-20 20:42:24 +0000 |
17 | @@ -808,7 +808,7 @@ |
18 | // glTranslatef(0.375, 0.375, 0.0); |
19 | /* render all primitives at integer positions */ |
20 | |
21 | - const float RASTERIZATION_OFFSET = 0.375f; |
22 | + const float RASTERIZATION_OFFSET = 0.0f; |
23 | void GraphicsEngine::Push2DWindow(int w, int h) |
24 | { |
25 | #ifndef NUX_OPENGLES_20 |
26 | |
27 | === modified file 'NuxGraphics/IOpenGLBaseTexture.cpp' |
28 | --- NuxGraphics/IOpenGLBaseTexture.cpp 2011-10-21 22:06:35 +0000 |
29 | +++ NuxGraphics/IOpenGLBaseTexture.cpp 2012-01-20 20:42:24 +0000 |
30 | @@ -254,11 +254,13 @@ |
31 | return 0; |
32 | } |
33 | |
34 | - void* IOpenGLBaseTexture::GetSurfaceData(int level, int &width, int &height, int &format) |
35 | + unsigned char* IOpenGLBaseTexture::GetSurfaceData(int level, int &width, int &height, int &stride) |
36 | { |
37 | + // Make this call a pure virtual once it has been implemented for IOpenGLCubeTexture, |
38 | + // IOpenGLVolumeTexture and IOpenGLAnimatedTexture. |
39 | width = 0; |
40 | height = 0; |
41 | - format = BITFMT_UNKNOWN; |
42 | + stride = 0; |
43 | return 0; |
44 | } |
45 | |
46 | |
47 | === modified file 'NuxGraphics/IOpenGLBaseTexture.h' |
48 | --- NuxGraphics/IOpenGLBaseTexture.h 2011-10-21 22:06:35 +0000 |
49 | +++ NuxGraphics/IOpenGLBaseTexture.h 2012-01-20 20:42:24 +0000 |
50 | @@ -136,12 +136,20 @@ |
51 | SURFACE_LOCKED_RECT *pLockedRect, |
52 | const SURFACE_RECT *pRect); |
53 | |
54 | - virtual int UnlockRect( |
55 | - int Level |
56 | - ); |
57 | - |
58 | - //! Return the a pointer to the texture mip level data. |
59 | - virtual void* GetSurfaceData(int level, int &width, int &height, int &format); |
60 | + virtual int UnlockRect(int Level); |
61 | + |
62 | + //! Return a pointer to a mipmap level data. |
63 | + /*! |
64 | + Return a pointer to a mipmap level data. The data is in the RGBA format.\n |
65 | + |
66 | + @param level The requested texture mipmap level data. |
67 | + @param width Returns the width in pixel of the image data. |
68 | + @param height Returns the height in pixel of the image data. |
69 | + @param stride Returns the row stride of the image data. |
70 | + |
71 | + @return A pointer to RGBA data. The caller must delete the data by calling delete []. |
72 | + */ |
73 | + virtual unsigned char* GetSurfaceData(int level, int &width, int &height, int &stride); |
74 | |
75 | protected: |
76 | GLTextureStates _TextureStates; |
77 | |
78 | === modified file 'NuxGraphics/IOpenGLRectangleTexture.cpp' |
79 | --- NuxGraphics/IOpenGLRectangleTexture.cpp 2011-10-22 06:17:42 +0000 |
80 | +++ NuxGraphics/IOpenGLRectangleTexture.cpp 2012-01-20 20:42:24 +0000 |
81 | @@ -143,23 +143,26 @@ |
82 | return OGL_OK; |
83 | } |
84 | |
85 | - void* IOpenGLRectangleTexture::GetSurfaceData(int level, int &width, int &height, int &format) |
86 | + unsigned char* IOpenGLRectangleTexture::GetSurfaceData(int level, int &width, int &height, int &stride) |
87 | { |
88 | - nuxAssertMsg(level >= 0, "[IOpenGLRectangleTexture::LockRect] Invalid mipmap level."); |
89 | - nuxAssertMsg(level < _NumMipLevel, "[IOpenGLRectangleTexture::LockRect] Invalid mipmap level."); |
90 | - |
91 | - if (level < _NumMipLevel) |
92 | - { |
93 | - ObjectPtr<IOpenGLSurface> pSurfaceLevel = _SurfaceArray [level]; |
94 | - return pSurfaceLevel->GetSurfaceData(width, height, format); |
95 | - } |
96 | - else |
97 | - { |
98 | - width = 0; |
99 | - height = 0; |
100 | - format = BITFMT_UNKNOWN; |
101 | - return 0; |
102 | - } |
103 | + width = 0; |
104 | + height = 0; |
105 | + stride = 0; |
106 | + |
107 | + if (level < 0) |
108 | + { |
109 | + nuxAssertMsg(level >= 0, "[IOpenGLRectangleTexture::GetSurfaceData] Invalid mipmap level."); |
110 | + return NULL; |
111 | + } |
112 | + |
113 | + if (level >= _NumMipLevel) |
114 | + { |
115 | + nuxAssertMsg(level < _NumMipLevel, "[IOpenGLRectangleTexture::GetSurfaceData] Invalid mipmap level."); |
116 | + return NULL; |
117 | + } |
118 | + |
119 | + ObjectPtr<IOpenGLSurface> pSurfaceLevel = _SurfaceArray[level]; |
120 | + return pSurfaceLevel->GetSurfaceData(width, height, stride); |
121 | } |
122 | } |
123 | |
124 | |
125 | === modified file 'NuxGraphics/IOpenGLRectangleTexture.h' |
126 | --- NuxGraphics/IOpenGLRectangleTexture.h 2011-10-19 20:32:38 +0000 |
127 | +++ NuxGraphics/IOpenGLRectangleTexture.h 2012-01-20 20:42:24 +0000 |
128 | @@ -73,8 +73,19 @@ |
129 | return OGL_OK;; |
130 | } |
131 | |
132 | - //! Return the a pointer to the texture mip level data. |
133 | - virtual void* GetSurfaceData(int level, int &width, int &height, int &format); |
134 | + //! Return a pointer to a mipmap level data. |
135 | + /*! |
136 | + Return a pointer to a mipmap level data. The data is in the RGBA format.\n |
137 | + Inherited from IOpenGLBaseTexture. |
138 | + |
139 | + @param level The requested texture mipmap level data. |
140 | + @param width Returns the width in pixel of the image data. |
141 | + @param height Returns the height in pixel of the image data. |
142 | + @param stride Returns the row stride of the image data. |
143 | + |
144 | + @return A pointer to RGBA data. The caller must dlete the data by calling delete []. |
145 | + */ |
146 | + unsigned char* GetSurfaceData(int level, int &width, int &height, int &stride); |
147 | |
148 | private: |
149 | |
150 | |
151 | === modified file 'NuxGraphics/IOpenGLSurface.cpp' |
152 | --- NuxGraphics/IOpenGLSurface.cpp 2011-10-22 06:17:42 +0000 |
153 | +++ NuxGraphics/IOpenGLSurface.cpp 2012-01-20 20:42:24 +0000 |
154 | @@ -679,37 +679,57 @@ |
155 | } |
156 | } |
157 | |
158 | - void* IOpenGLSurface::GetSurfaceData(int &width, int &height, int &format) |
159 | + unsigned char* IOpenGLSurface::GetSurfaceData(int &width, int &height, int &stride) |
160 | { |
161 | width = 0; |
162 | height = 0; |
163 | - format = BITFMT_UNKNOWN; |
164 | + stride = 0; |
165 | + |
166 | + if (_BaseTexture->_OpenGLID == 0) |
167 | + { |
168 | + return NULL; |
169 | + } |
170 | |
171 | #ifndef NUX_OPENGLES_20 |
172 | - // Because we use SubImage when unlocking surfaces, we must first get some dummy data in the surface before we can make a lock. |
173 | - int texwidth = ImageSurface::GetLevelWidth(_BaseTexture->_PixelFormat, _BaseTexture->_Width, _SMipLevel); |
174 | - int texheight = ImageSurface::GetLevelHeight(_BaseTexture->_PixelFormat, _BaseTexture->_Height, _SMipLevel); |
175 | - |
176 | - nuxAssert(texwidth > 0); // Should never happen |
177 | - nuxAssert(texheight > 0); // Should never happen |
178 | - |
179 | CHECKGL(glBindTexture(_STextureTarget, _BaseTexture->_OpenGLID)); |
180 | |
181 | + // Despite a 1 byte pack alignment not being the most optimum, do it for simplicity. |
182 | CHECKGL(glPixelStorei(GL_PACK_ALIGNMENT, 1)); |
183 | - int size = texwidth * texheight * 4; // assume a memory alignment of 1 |
184 | - |
185 | - unsigned char *img = new unsigned char [size]; |
186 | + |
187 | + // We want RGBA data |
188 | + int mip_level_size = GetWidth() * GetHeight() * 4; |
189 | + unsigned char* img = new unsigned char[mip_level_size]; |
190 | + |
191 | + // Internal OpenGL textures are in the RGBA format. |
192 | + // If the selected texture image does not contain four components, the following mappings are applied: |
193 | + // - Single-component textures are treated as RGBA buffers with red set to the single-component value, green set to 0, blue set to 0, and alpha set to 1. |
194 | + // - red set to component zero |
195 | + // - green set to 0 |
196 | + // - blue set to 0 |
197 | + // - alpha set to 1.0 |
198 | + // - Two-component textures are treated as RGBA buffers with: |
199 | + // - red set to component zero |
200 | + // - green set to 0 |
201 | + // - blue set to 0 |
202 | + // - alpha set to component one |
203 | + // |
204 | + // - Three-component textures are treated as RGBA buffers with: |
205 | + // - red set to component zero |
206 | + // - green set to component one |
207 | + // - blue set to component two |
208 | + // - alpha set to 1.0 |
209 | |
210 | CHECKGL(glGetTexImage(_STextureTarget, _SMipLevel, GL_RGBA, GL_UNSIGNED_BYTE, img)); |
211 | |
212 | - width = _BaseTexture->_Width; |
213 | - height = _BaseTexture->_Height; |
214 | - format = BITFMT_R8G8B8A8; |
215 | + width = GetWidth(); |
216 | + height = GetHeight(); |
217 | + stride = width * 4; |
218 | + |
219 | return img; |
220 | #else |
221 | -//FIXME: need to render to framebuffer and use glReadPixels |
222 | + //FIXME: need to render to framebuffer and use glReadPixels |
223 | return NULL; |
224 | #endif |
225 | } |
226 | - |
227 | } |
228 | + |
229 | |
230 | === modified file 'NuxGraphics/IOpenGLSurface.h' |
231 | --- NuxGraphics/IOpenGLSurface.h 2011-10-22 06:17:42 +0000 |
232 | +++ NuxGraphics/IOpenGLSurface.h 2012-01-20 20:42:24 +0000 |
233 | @@ -48,8 +48,15 @@ |
234 | //! Copy the render target into the texture mip level. |
235 | void CopyRenderTarget(int x, int y, int width, int height); |
236 | |
237 | - //! Return the a pointer to the texture mip level data. |
238 | - void* GetSurfaceData(int &width, int &height, int &format); |
239 | + //! Return the mipmap data. |
240 | + /*! |
241 | + Return the mipmap data. |
242 | + |
243 | + @param width Returns the width in pixel of the image data. |
244 | + @param height Returns the height in pixel of the image data. |
245 | + @param stride Returns the row stride of the image data. |
246 | + */ |
247 | + unsigned char* GetSurfaceData(int &width, int &height, int &stride); |
248 | |
249 | private: |
250 | virtual ~IOpenGLSurface(); |
251 | |
252 | === modified file 'NuxGraphics/IOpenGLTexture2D.cpp' |
253 | --- NuxGraphics/IOpenGLTexture2D.cpp 2011-10-22 06:17:42 +0000 |
254 | +++ NuxGraphics/IOpenGLTexture2D.cpp 2012-01-20 20:42:24 +0000 |
255 | @@ -154,22 +154,25 @@ |
256 | return OGL_OK; |
257 | } |
258 | |
259 | - void* IOpenGLTexture2D::GetSurfaceData(int level, int &width, int &height, int &format) |
260 | + unsigned char* IOpenGLTexture2D::GetSurfaceData(int level, int &width, int &height, int &stride) |
261 | { |
262 | - nuxAssertMsg(level >= 0, "[IOpenGLTexture2D::LockRect] Invalid mipmap level."); |
263 | - nuxAssertMsg(level < _NumMipLevel, "[IOpenGLTexture2D::LockRect] Invalid mipmap level."); |
264 | - |
265 | - if (level < _NumMipLevel) |
266 | - { |
267 | - ObjectPtr<IOpenGLSurface> pSurfaceLevel = _SurfaceArray [level]; |
268 | - return pSurfaceLevel->GetSurfaceData(width, height, format); |
269 | - } |
270 | - else |
271 | - { |
272 | - width = 0; |
273 | - height = 0; |
274 | - format = BITFMT_UNKNOWN; |
275 | - return 0; |
276 | - } |
277 | + width = 0; |
278 | + height = 0; |
279 | + stride = 0; |
280 | + |
281 | + if (level < 0) |
282 | + { |
283 | + nuxAssertMsg(level >= 0, "[IOpenGLTexture2D::GetSurfaceData] Invalid mipmap level."); |
284 | + return NULL; |
285 | + } |
286 | + |
287 | + if (level >= _NumMipLevel) |
288 | + { |
289 | + nuxAssertMsg(level < _NumMipLevel, "[IOpenGLTexture2D::GetSurfaceData] Invalid mipmap level."); |
290 | + return NULL; |
291 | + } |
292 | + |
293 | + ObjectPtr<IOpenGLSurface> pSurfaceLevel = _SurfaceArray[level]; |
294 | + return pSurfaceLevel->GetSurfaceData(width, height, stride); |
295 | } |
296 | } |
297 | |
298 | === modified file 'NuxGraphics/IOpenGLTexture2D.h' |
299 | --- NuxGraphics/IOpenGLTexture2D.h 2011-10-19 20:32:38 +0000 |
300 | +++ NuxGraphics/IOpenGLTexture2D.h 2012-01-20 20:42:24 +0000 |
301 | @@ -73,8 +73,19 @@ |
302 | return OGL_OK; |
303 | } |
304 | |
305 | - //! Return the a pointer to the texture mip level data. |
306 | - virtual void* GetSurfaceData(int level, int &width, int &height, int &format); |
307 | + //! Return a pointer to a mipmap level data. |
308 | + /*! |
309 | + Return a pointer to a mipmap level data. The data is in the RGBA format.\n |
310 | + Inherited from IOpenGLBaseTexture. |
311 | + |
312 | + @param level The requested texture mipmap level data. |
313 | + @param width Returns the width in pixel of the image data. |
314 | + @param height Returns the height in pixel of the image data. |
315 | + @param stride Returns the row stride of the image data. |
316 | + |
317 | + @return A pointer to RGBA data. The caller must dlete the data by calling delete []. |
318 | + */ |
319 | + unsigned char* GetSurfaceData(int level, int &width, int &height, int &stride); |
320 | |
321 | private: |
322 | |
323 | |
324 | === modified file 'NuxGraphics/RenderingPipe.cpp' |
325 | --- NuxGraphics/RenderingPipe.cpp 2011-10-21 22:06:35 +0000 |
326 | +++ NuxGraphics/RenderingPipe.cpp 2012-01-20 20:42:24 +0000 |
327 | @@ -206,17 +206,24 @@ |
328 | { |
329 | if (texxform.m_tex_coord_type == TexCoordXForm::OFFSET_SCALE_COORD) |
330 | { |
331 | - texxform.u0 = texxform.uoffset; |
332 | - texxform.v0 = texxform.voffset; |
333 | - texxform.u1 = texxform.u0 + texxform.uscale; |
334 | - texxform.v1 = texxform.v0 + texxform.vscale; |
335 | + // Scale and offset the texture coordinates. |
336 | + // Ensure precise alignment between pixels and the texture coordinates |
337 | + // With a scale of 1.0 for both uscale and vscale, the texture is scaled over the entire surface of the quad. |
338 | + // If the texture and the quad have the same size, then the texture is mapped 1 to 1 with the pixels of the quad. |
339 | + texxform.u0 = texxform.uoffset + texxform.uscale * (tex_width / (float)quad_width) * (1.0f / (2.0f * tex_width)); |
340 | + texxform.v0 = texxform.voffset + texxform.vscale * (tex_height / (float)quad_height) * (1.0f / (2.0f * tex_height)); |
341 | + texxform.u1 = texxform.uoffset + texxform.uscale * (tex_width / (float)quad_width) * (2.0f * quad_width - 1.0f) / (2.0f * tex_width); |
342 | + texxform.v1 = texxform.voffset + texxform.vscale * (tex_height / (float)quad_height) * (2.0f * quad_height - 1.0f) / (2.0f * tex_height); |
343 | } |
344 | else if (texxform.m_tex_coord_type == TexCoordXForm::OFFSET_COORD) |
345 | { |
346 | - texxform.u0 = texxform.uoffset; |
347 | - texxform.v0 = texxform.voffset; |
348 | - texxform.u1 = texxform.u0 + (float) quad_width / tex_width; |
349 | - texxform.v1 = texxform.v0 + (float) quad_height / tex_height; |
350 | + // Offset the texture coordinates but preserve the proportion of the of the texture over the quad. |
351 | + // If the texture size is smaller than the quad, it will be tiled over it. |
352 | + // Ensure precise alignment between pixels and the texture coordinates |
353 | + texxform.u0 = texxform.uoffset + (1.0f / (2.0f * tex_width)); |
354 | + texxform.v0 = texxform.voffset + (1.0f / (2.0f * tex_height)); |
355 | + texxform.u1 = texxform.uoffset + (2.0f * quad_width - 1.0f) / (2.0f * tex_width); |
356 | + texxform.v1 = texxform.voffset + (2.0f * quad_height - 1.0f) / (2.0f * tex_height); |
357 | } |
358 | else if (texxform.m_tex_coord_type == TexCoordXForm::UNNORMALIZED_COORD) |
359 | { |
360 | |
361 | === modified file 'NuxGraphics/RenderingPipe.h' |
362 | --- NuxGraphics/RenderingPipe.h 2011-10-21 22:06:35 +0000 |
363 | +++ NuxGraphics/RenderingPipe.h 2012-01-20 20:42:24 +0000 |
364 | @@ -91,7 +91,7 @@ |
365 | |
366 | //! Texture parameter and coordinate computation class. |
367 | /*! |
368 | - Defines the texture coordinate computation, wraping and filtering modes |
369 | + Defines the texture coordinate computation, wrapping and filtering modes |
370 | */ |
371 | class TexCoordXForm |
372 | { |
373 | @@ -99,8 +99,8 @@ |
374 | //! Texture coordinates computation mode |
375 | typedef enum |
376 | { |
377 | - OFFSET_SCALE_COORD, //!< Texture coordinates are offset and scaled |
378 | - OFFSET_COORD, //!< Textures coordinates are offset only |
379 | + OFFSET_SCALE_COORD, //!< Texture coordinates are scaled and offset. |
380 | + OFFSET_COORD, //!< Textures coordinates are offset. The scaling factor between the texture size and the quad size is preserved. |
381 | NORMALIZED_COORD, //!< Provided normalized texture coordinates in u0, v0, u1, v1 |
382 | UNNORMALIZED_COORD, //!< Provided un-normalized texture coordinates in u0, v0, u1, v1 |
383 | FIXED_COORD, //!< Provided fix coordinates in u0, v0, u1, v1 |
384 | |
385 | === modified file 'NuxGraphics/RenderingPipeTextureBlend.cpp' |
386 | --- NuxGraphics/RenderingPipeTextureBlend.cpp 2011-10-19 20:32:38 +0000 |
387 | +++ NuxGraphics/RenderingPipeTextureBlend.cpp 2012-01-20 20:42:24 +0000 |
388 | @@ -41,7 +41,7 @@ |
389 | // and attribute location. One has to make sure that the vertex attribute get index 0. So use the vertex attribute first. All of this does not make any sense. |
390 | // Need more info from driver developers. |
391 | |
392 | -static NString LayerBlendingVertexShader = "#version 110 \n\ |
393 | +static std::string LayerBlendingVertexShader ="#version 110 \n\ |
394 | uniform mat4 ViewProjectionMatrix; \n\ |
395 | attribute vec4 AVertex; \n\ |
396 | attribute vec4 MyTextureCoord0; \n\ |
397 | @@ -55,243 +55,253 @@ |
398 | gl_Position = ViewProjectionMatrix * (AVertex); \n\ |
399 | }"; |
400 | |
401 | -static NString blend_code_normal = "#version 110 \n\ |
402 | -vec3 BlendNormal(vec3 B /*background layer*/, vec3 L /*foreground layer*/) \n\ |
403 | -{ \n\ |
404 | - return L; \n\ |
405 | -}"; |
406 | - |
407 | -static NString blend_code_lighten = "#version 110 \n\ |
408 | -vec3 BlendLighten(vec3 B /*background layer*/, vec3 L /*foreground layer*/) \n\ |
409 | -{ \n\ |
410 | - // This mode is commutative \n\ |
411 | - vec3 V = max(L, B); \n\ |
412 | - return V; \n\ |
413 | -}"; |
414 | - |
415 | -// static NString blend_code_darken = TEXT("#version 110 \n\ |
416 | -// vec3 BlendDarken(vec3 B /*background layer*/, vec3 L /*foreground layer*/) \n\ |
417 | -// { \n\ |
418 | -// vec3 V = min(L, B); \n\ |
419 | -// return V; \n\ |
420 | -// } \n\ |
421 | -// \n\ |
422 | -// vec3 BlendMultiply(vec3 B /*background layer*/, vec3 L /*foreground layer*/) \n\ |
423 | -// { \n\ |
424 | -// return(B * L); \n\ |
425 | -// } \n\ |
426 | -// \n\ |
427 | -// vec3 BlendAverage(vec3 B /*background layer*/, vec3 L /*foreground layer*/) \n\ |
428 | -// { \n\ |
429 | -// // This mode is commutative \n\ |
430 | -// return((B + L) / 2.0); \n\ |
431 | -// } \n\ |
432 | -// \n\ |
433 | -// // *** Additive Modes *** \n\ |
434 | -// vec3 BlendAdd(vec3 B /*background layer*/, vec3 L /*foreground layer*/) \n\ |
435 | -// { \n\ |
436 | -// return min(B + L, vec3(1.0)); \n\ |
437 | -// } \n\ |
438 | -// \n\ |
439 | -// vec3 BlendSubstract(vec3 B /*background layer*/, vec3 L /*foreground layer*/) \n\ |
440 | -// { \n\ |
441 | -// return max(B + L - vec3(1.0), vec3(0.0)); \n\ |
442 | -// } \n\ |
443 | -// \n\ |
444 | -// // *** Difference Modes *** \n\ |
445 | -// vec3 BlendDifference(vec3 B /*background layer*/, vec3 L /*foreground layer*/) \n\ |
446 | -// { \n\ |
447 | -// return abs(B - L); \n\ |
448 | -// } \n\ |
449 | -// \n\ |
450 | -// vec3 BlendNegation(vec3 B /*background layer*/, vec3 L /*foreground layer*/) \n\ |
451 | -// { \n\ |
452 | -// return(vec3(1.0) - abs(vec3(1.0) - B - L)); \n\ |
453 | -// } \n\ |
454 | -// \n\ |
455 | -// vec3 BlendExclusion(vec3 B /*background layer*/, vec3 L /*foreground layer*/) \n\ |
456 | -// { \n\ |
457 | -// return(B + L - 2.0 * B * L); \n\ |
458 | -// } \n\ |
459 | -// \n\ |
460 | -// vec3 BlendScreen(vec3 B /*background layer*/, vec3 L /*foreground layer*/) \n\ |
461 | -// { \n\ |
462 | -// return(1.0 - (1.0 - B) * (1.0 - L)); \n\ |
463 | -// } \n\ |
464 | -// \n\ |
465 | -// float _BlendOverlay(float B /*background layer*/, float L /*foreground layer*/) \n\ |
466 | -// { \n\ |
467 | -// if (L < 0.5) \n\ |
468 | -// return(2.0 * B * L); \n\ |
469 | -// else \n\ |
470 | -// return(1.0 - 2.0 * (1.0 - B) * (1.0 - L)); \n\ |
471 | -// } \n\ |
472 | -// \n\ |
473 | -// vec3 BlendOverlay(vec3 B /*background layer*/, vec3 L /*foreground layer*/) \n\ |
474 | -// { \n\ |
475 | -// return vec3(_BlendOverlay(B.r + L.r), _BlendOverlay(B.g + L.g), _BlendOverlay(B.b + L.b)); \n\ |
476 | -// } \n\ |
477 | -// \n\ |
478 | -// float _BlendSoftLight(float B /*background layer*/, float L /*foreground layer*/) \n\ |
479 | -// { \n\ |
480 | -// if (L < 0.5) \n\ |
481 | -// return(2.0 * B * L + B * B * (1.0 - 2.0 * L); \n\ |
482 | -// else \n\ |
483 | -// return sqrt(B) * (2.0 * L - 1.0) + 2.0 * B * (1.0 - L); \n\ |
484 | -// } \n\ |
485 | -// \n\ |
486 | -// vec3 BlendSoftLight(vec3 B /*background layer*/, vec3 L /*foreground layer*/) \n\ |
487 | -// { \n\ |
488 | -// return vec3(_BlendSoftLight(B.r + L.r), _BlendSoftLight(B.g + L.g), _BlendSoftLight(B.b + L.b)); \n\ |
489 | -// } \n\ |
490 | -// \n\ |
491 | -// float _BlendHardLight(float B /*background layer*/, float L /*foreground layer*/) \n\ |
492 | -// { \n\ |
493 | -// if (L < 0.5) \n\ |
494 | -// return(2.0 * B * L); \n\ |
495 | -// else \n\ |
496 | -// return(1.0 - 2.0 * (1.0 - B) * (1.0 - L)); \n\ |
497 | -// } \n\ |
498 | -// \n\ |
499 | -// vec3 BlendHardLight(vec3 B /*background layer*/, vec3 L /*foreground layer*/) \n\ |
500 | -// { \n\ |
501 | -// return vec3(_BlendHardLight(B.r + L.r), _BlendHardLight(B.g + L.g), _BlendHardLight(B.b + L.b)); \n\ |
502 | -// } \n\ |
503 | -// \n\ |
504 | -// float _BlendColorDodge(float B /*background layer*/, float L /*foreground layer*/) \n\ |
505 | -// { \n\ |
506 | -// if (L == 1.0) \n\ |
507 | -// return 1.0; \n\ |
508 | -// else \n\ |
509 | -// return min(B / (1.0 - L), 1.0); \n\ |
510 | -// } \n\ |
511 | -// \n\ |
512 | -// vec3 BlendColorDodge(vec3 B /*background layer*/, vec3 L /*foreground layer*/) \n\ |
513 | -// { \n\ |
514 | -// return vec3(_BlendColorDodge(B.r + L.r), _BlendColorDodge(B.g + L.g), _BlendColorDodge(B.b + L.b)); \n\ |
515 | -// } \n\ |
516 | -// \n\ |
517 | -// float _BlendLinearDodge(float B /*background layer*/, float L /*foreground layer*/) \n\ |
518 | -// { \n\ |
519 | -// return min(B + L, 1.0); \n\ |
520 | -// } \n\ |
521 | -// \n\ |
522 | -// vec3 BlendLinearDodge(vec3 B /*background layer*/, vec3 L /*foreground layer*/) \n\ |
523 | -// { \n\ |
524 | -// return vec3(_BlendLinearDodge(B.r + L.r), _BlendLinearDodge(B.g + L.g), _BlendLinearDodge(B.b + L.b)); \n\ |
525 | -// } \n\ |
526 | -// \n\ |
527 | -// float _BlendColorBurn(float B /*background layer*/, float L /*foreground layer*/) \n\ |
528 | -// { \n\ |
529 | -// if (L == 0.0) \n\ |
530 | -// return 0.0; \n\ |
531 | -// else \n\ |
532 | -// return max(1.0 - ((1.0 - B) / L), 0.0); \n\ |
533 | -// } \n\ |
534 | -// \n\ |
535 | -// vec3 BlendColorBurn(vec3 B /*background layer*/, vec3 L /*foreground layer*/) \n\ |
536 | -// { \n\ |
537 | -// return vec3(_BlendColorBurn(B.r + L.r), _BlendColorBurn(B.g + L.g), _BlendColorBurn(B.b + L.b)); \n\ |
538 | -// } \n\ |
539 | -// \n\ |
540 | -// float _BlendLinearBurn(float B /*background layer*/, float L /*foreground layer*/) \n\ |
541 | -// { \n\ |
542 | -// return max(B + L - 1.0, 0.0); \n\ |
543 | -// } \n\ |
544 | -// \n\ |
545 | -// vec3 BlendLinearBurn(vec3 B /*background layer*/, vec3 L /*foreground layer*/) \n\ |
546 | -// { \n\ |
547 | -// return vec3(_BlendLinearBurn(B.r + L.r), _BlendLinearBurn(B.g + L.g), _BlendLinearBurn(B.b + L.b)); \n\ |
548 | -// } \n\ |
549 | -// \n\ |
550 | -// float _BlendLinearLight(float B /*background layer*/, float L /*foreground layer*/) \n\ |
551 | -// { \n\ |
552 | -// if (L < 0.5) \n\ |
553 | -// return _BlendLinearBurn(B, (2.0 * L)); \n\ |
554 | -// else \n\ |
555 | -// return _BlendLinearDodge(B, (2.0 * (L - 0.5))); \n\ |
556 | -// } \n\ |
557 | -// \n\ |
558 | -// vec3 BlendLinearLight(vec3 B /*background layer*/, vec3 L /*foreground layer*/) \n\ |
559 | -// { \n\ |
560 | -// return vec3(_BlendLinearLight(B.r + L.r), _BlendLinearLight(B.g + L.g), _BlendLinearLight(B.b + L.b)); \n\ |
561 | -// } \n\ |
562 | -// \n\ |
563 | -// float _BlendVividLight(float B /*background layer*/, float L /*foreground layer*/) \n\ |
564 | -// { \n\ |
565 | -// if (L < 0.5) \n\ |
566 | -// return _BlendColorBurn(B, (2.0 * L)); \n\ |
567 | -// else \n\ |
568 | -// return _BlendColorDodge(B, (2.0 * (L - 0.5)))); \n\ |
569 | -// } \n\ |
570 | -// \n\ |
571 | -// vec3 BlendVividLight(vec3 B /*background layer*/, vec3 L /*foreground layer*/) \n\ |
572 | -// { \n\ |
573 | -// return vec3(_BlendVividLight(B.r, L.r), _BlendVividLight(B.g, L.g), _BlendVividLight(B.b, L.b)); \n\ |
574 | -// } \n\ |
575 | -// \n\ |
576 | -// float _BlendPinLight(float B /*background layer*/, float L /*foreground layer*/) \n\ |
577 | -// { \n\ |
578 | -// if (L < 0.5) \n\ |
579 | -// return _BlendDarken(B, (2.0 * L)); \n\ |
580 | -// else \n\ |
581 | -// return _BlendLighten(B, (2.0 * (L - 0.5)))); \n\ |
582 | -// } \n\ |
583 | -// \n\ |
584 | -// vec3 BlendPinLight(vec3 B /*background layer*/, vec3 L /*foreground layer*/) \n\ |
585 | -// { \n\ |
586 | -// return vec3(_BlendPinLight(B.r, L.r), _BlendPinLight(B.g, L.g), _BlendPinLight(B.b, L.b)); \n\ |
587 | -// } \n\ |
588 | -// \n\ |
589 | -// float _BlendHardMix(float B /*background layer*/, float L /*foreground layer*/) \n\ |
590 | -// { \n\ |
591 | -// if (_BlendVividLight(B, L) < 0.5) \n\ |
592 | -// return 0.0; \n\ |
593 | -// else \n\ |
594 | -// return 1.0; \n\ |
595 | -// } \n\ |
596 | -// \n\ |
597 | -// vec3 BlendHardMix(vec3 B /*background layer*/, vec3 L /*foreground layer*/) \n\ |
598 | -// { \n\ |
599 | -// return vec3(_BlendHardMix(B.r, L.r), _BlendHardMix(B.g, L.g), _BlendHardMix(B.b, L.b)); \n\ |
600 | -// } \n\ |
601 | -// \n\ |
602 | -// float _BlendReflect(float B /*background layer*/, float L /*foreground layer*/) \n\ |
603 | -// { \n\ |
604 | -// if (L == 1.0) \n\ |
605 | -// return 1.0; \n\ |
606 | -// else \n\ |
607 | -// return min(B * B / (1.0 - L), 1.0); \n\ |
608 | -// } \n\ |
609 | -// \n\ |
610 | -// vec3 BlendReflect(vec3 B /*background layer*/, vec3 L /*foreground layer*/) \n\ |
611 | -// { \n\ |
612 | -// return vec3(_BlendReflect(B.r, L.r), _BlendReflect(B.g, L.g), _BlendReflect(B.b, L.b)); \n\ |
613 | -// } \n\ |
614 | -// \n\ |
615 | -// float _BlendGlow(float B /*background layer*/, float L /*foreground layer*/) \n\ |
616 | -// { \n\ |
617 | -// if (L == 1.0) \n\ |
618 | -// return 1.0; \n\ |
619 | -// else \n\ |
620 | -// return min(L * L / (1.0 - B), 1.0); \n\ |
621 | -// } \n\ |
622 | -// \n\ |
623 | -// vec3 BlendGlow(vec3 B /*background layer*/, vec3 L /*foreground layer*/) \n\ |
624 | -// { \n\ |
625 | -// return vec3(_BlendGlow(B.r, L.r), _BlendGlow(B.g, L.g), _BlendGlow(B.b, L.b)); \n\ |
626 | -// } \n\ |
627 | -// \n\ |
628 | -// vec3 BlendPhoenix(vec3 B /*background layer*/, vec3 L /*foreground layer*/) \n\ |
629 | -// { \n\ |
630 | -// return min(B, L) - max(B, L) + vec3(1.0); \n\ |
631 | -// } \n\ |
632 | -// \n\ |
633 | -// vec3 BlendOpacity(vec3 B /*background layer*/, vec3 L /*foreground layer*/) \n\ |
634 | -// { \n\ |
635 | -// return O * L + (1 - O) * B; \n\ |
636 | -// }" |
637 | - |
638 | +static std::string blend_code_normal = "#version 110 \n\ |
639 | +vec3 BlendNormal(vec3 B /*background layer*/, vec3 L /*foreground layer*/) \n\ |
640 | +{ \n\ |
641 | + return L; \n\ |
642 | +}"; |
643 | + |
644 | +static std::string blend_code_lighten = "#version 110 \n\ |
645 | +vec3 BlendLighten(vec3 B /*background layer*/, vec3 L /*foreground layer*/) \n\ |
646 | +{ \n\ |
647 | + // This mode is commutative \n\ |
648 | + vec3 V = max(L, B); \n\ |
649 | + return V; \n\ |
650 | +}"; |
651 | + |
652 | +static std::string blend_code_darken = "#version 110 \n\ |
653 | +vec3 BlendDarken(vec3 B /*background layer*/, vec3 L /*foreground layer*/) \n\ |
654 | +{ \n\ |
655 | + vec3 V = min(L, B); \n\ |
656 | + return V; \n\ |
657 | +}"; |
658 | + |
659 | +static std::string BlendMultiplyShader = "#version 110 \n\ |
660 | +vec3 BlendMultiply(vec3 B /*background layer*/, vec3 L /*foreground layer*/) \n\ |
661 | +{ \n\ |
662 | + return(B * L); \n\ |
663 | +}"; |
664 | + |
665 | +static std::string BlendAverageShader = "#version 110 \n\ |
666 | +vec3 BlendAverage(vec3 B /*background layer*/, vec3 L /*foreground layer*/) \n\ |
667 | +{ \n\ |
668 | + // This mode is commutative \n\ |
669 | + return((B + L) / 2.0); \n\ |
670 | +}"; |
671 | + |
672 | +// *** Additive Modes *** |
673 | +static std::string BlendAddShader = "#version 110 \n\ |
674 | +vec3 BlendAdd(vec3 B /*background layer*/, vec3 L /*foreground layer*/) \n\ |
675 | +{ \n\ |
676 | + return min(B + L, vec3(1.0)); \n\ |
677 | +}"; |
678 | + |
679 | +static std::string BlendSubstractShader = "#version 110 \n\ |
680 | +vec3 BlendSubstract(vec3 B /*background layer*/, vec3 L /*foreground layer*/) \n\ |
681 | +{ \n\ |
682 | + return max(B + L - vec3(1.0), vec3(0.0)); \n\ |
683 | +}"; |
684 | + |
685 | +// *** Difference Modes *** |
686 | +static std::string BlendDifferenceShader = "#version 110 \n\ |
687 | +vec3 BlendDifference(vec3 B /*background layer*/, vec3 L /*foreground layer*/) \n\ |
688 | +{ \n\ |
689 | + return abs(B - L); \n\ |
690 | +}"; |
691 | + |
692 | +static std::string BlendNegationShader = "#version 110 \n\ |
693 | +vec3 BlendNegation(vec3 B /*background layer*/, vec3 L /*foreground layer*/) \n\ |
694 | +{ \n\ |
695 | + return(vec3(1.0) - abs(vec3(1.0) - B - L)); \n\ |
696 | +}"; |
697 | + |
698 | +static std::string BlendExclusionShader = "#version 110 \n\ |
699 | +vec3 BlendExclusion(vec3 B /*background layer*/, vec3 L /*foreground layer*/) \n\ |
700 | +{ \n\ |
701 | + return(B + L - 2.0 * B * L); \n\ |
702 | +}"; |
703 | + |
704 | +static std::string BlendScreenShader = "#version 110 \n\ |
705 | +vec3 BlendScreen(vec3 B /*background layer*/, vec3 L /*foreground layer*/) \n\ |
706 | +{ \n\ |
707 | + return(1.0 - (1.0 - B) * (1.0 - L)); \n\ |
708 | +}"; |
709 | + |
710 | +static std::string BlendOverlayShader = "#version 110 \n\ |
711 | +float _BlendOverlay(float B /*background layer*/, float L /*foreground layer*/) \n\ |
712 | +{ \n\ |
713 | + if (L < 0.5) \n\ |
714 | + return(2.0 * B * L); \n\ |
715 | + else \n\ |
716 | + return(1.0 - 2.0 * (1.0 - B) * (1.0 - L)); \n\ |
717 | +} \n\ |
718 | +vec3 BlendOverlay(vec3 B /*background layer*/, vec3 L /*foreground layer*/) \n\ |
719 | +{ \n\ |
720 | + return vec3(_BlendOverlay(B.r + L.r), _BlendOverlay(B.g + L.g), _BlendOverlay(B.b + L.b)); \n\ |
721 | +}"; |
722 | + |
723 | +static std::string BlendSoftLightShader = "#version 110 \n\ |
724 | +float _BlendSoftLight(float B /*background layer*/, float L /*foreground layer*/) \n\ |
725 | +{ \n\ |
726 | + if (L < 0.5) \n\ |
727 | + return(2.0 * B * L + B * B * (1.0 - 2.0 * L); \n\ |
728 | + else \n\ |
729 | + return sqrt(B) * (2.0 * L - 1.0) + 2.0 * B * (1.0 - L); \n\ |
730 | +} \n\ |
731 | +vec3 BlendSoftLight(vec3 B /*background layer*/, vec3 L /*foreground layer*/) \n\ |
732 | +{ \n\ |
733 | + return vec3(_BlendSoftLight(B.r + L.r), _BlendSoftLight(B.g + L.g), _BlendSoftLight(B.b + L.b)); \n\ |
734 | +}"; |
735 | + |
736 | +static std::string BlendHardLightShader = "#version 110 \n\ |
737 | +float _BlendHardLight(float B /*background layer*/, float L /*foreground layer*/) \n\ |
738 | +{ \n\ |
739 | + if (L < 0.5) \n\ |
740 | + return(2.0 * B * L); \n\ |
741 | + else \n\ |
742 | + return(1.0 - 2.0 * (1.0 - B) * (1.0 - L)); \n\ |
743 | +} \n\ |
744 | +vec3 BlendHardLight(vec3 B /*background layer*/, vec3 L /*foreground layer*/) \n\ |
745 | +{ \n\ |
746 | + return vec3(_BlendHardLight(B.r + L.r), _BlendHardLight(B.g + L.g), _BlendHardLight(B.b + L.b)); \n\ |
747 | +}"; |
748 | + |
749 | +static std::string BlendColorDodgeShader = "#version 110 \n\ |
750 | +float _BlendColorDodge(float B /*background layer*/, float L /*foreground layer*/) \n\ |
751 | +{ \n\ |
752 | + if (L == 1.0) \n\ |
753 | + return 1.0; \n\ |
754 | + else \n\ |
755 | + return min(B / (1.0 - L), 1.0); \n\ |
756 | +} \n\ |
757 | +vec3 BlendColorDodge(vec3 B /*background layer*/, vec3 L /*foreground layer*/) \n\ |
758 | +{ \n\ |
759 | + return vec3(_BlendColorDodge(B.r + L.r), _BlendColorDodge(B.g + L.g), _BlendColorDodge(B.b + L.b)); \n\ |
760 | +}"; |
761 | + |
762 | +static std::string BlendLinearDodgeShader = "#version 110 \n\ |
763 | +float _BlendLinearDodge(float B /*background layer*/, float L /*foreground layer*/) \n\ |
764 | +{ \n\ |
765 | + return min(B + L, 1.0); \n\ |
766 | +} \n\ |
767 | +vec3 BlendLinearDodge(vec3 B /*background layer*/, vec3 L /*foreground layer*/) \n\ |
768 | +{ \n\ |
769 | + return vec3(_BlendLinearDodge(B.r + L.r), _BlendLinearDodge(B.g + L.g), _BlendLinearDodge(B.b + L.b)); \n\ |
770 | +}"; |
771 | + |
772 | +static std::string BlendColorBurnShader = "#version 110 \n\ |
773 | +float _BlendColorBurn(float B /*background layer*/, float L /*foreground layer*/) \n\ |
774 | +{ \n\ |
775 | + if (L == 0.0) \n\ |
776 | + return 0.0; \n\ |
777 | + else \n\ |
778 | + return max(1.0 - ((1.0 - B) / L), 0.0); \n\ |
779 | +} \n\ |
780 | +vec3 BlendColorBurn(vec3 B /*background layer*/, vec3 L /*foreground layer*/) \n\ |
781 | +{ \n\ |
782 | + return vec3(_BlendColorBurn(B.r + L.r), _BlendColorBurn(B.g + L.g), _BlendColorBurn(B.b + L.b)); \n\ |
783 | +}"; |
784 | + |
785 | +static std::string BlendLinearBurnShader = "#version 110 \n\ |
786 | +float _BlendLinearBurn(float B /*background layer*/, float L /*foreground layer*/) \n\ |
787 | +{ \n\ |
788 | + return max(B + L - 1.0, 0.0); \n\ |
789 | +} \n\ |
790 | +vec3 BlendLinearBurn(vec3 B /*background layer*/, vec3 L /*foreground layer*/) \n\ |
791 | +{ \n\ |
792 | + return vec3(_BlendLinearBurn(B.r + L.r), _BlendLinearBurn(B.g + L.g), _BlendLinearBurn(B.b + L.b)); \n\ |
793 | +}"; |
794 | + |
795 | +static std::string BlendLinearLightShader = "#version 110 \n\ |
796 | +float _BlendLinearLight(float B /*background layer*/, float L /*foreground layer*/) \n\ |
797 | +{ \n\ |
798 | + if (L < 0.5) \n\ |
799 | + return _BlendLinearBurn(B, (2.0 * L)); \n\ |
800 | + else \n\ |
801 | + return _BlendLinearDodge(B, (2.0 * (L - 0.5))); \n\ |
802 | +} \n\ |
803 | +vec3 BlendLinearLight(vec3 B /*background layer*/, vec3 L /*foreground layer*/) \n\ |
804 | +{ \n\ |
805 | + return vec3(_BlendLinearLight(B.r + L.r), _BlendLinearLight(B.g + L.g), _BlendLinearLight(B.b + L.b)); \n\ |
806 | +}"; |
807 | + |
808 | +static std::string BlendVividLightShader = "#version 110 \n\ |
809 | +float _BlendVividLight(float B /*background layer*/, float L /*foreground layer*/) \n\ |
810 | +{ \n\ |
811 | + if (L < 0.5) \n\ |
812 | + return _BlendColorBurn(B, (2.0 * L)); \n\ |
813 | + else \n\ |
814 | + return _BlendColorDodge(B, (2.0 * (L - 0.5)))); \n\ |
815 | +} \n\ |
816 | +vec3 BlendVividLight(vec3 B /*background layer*/, vec3 L /*foreground layer*/) \n\ |
817 | +{ \n\ |
818 | + return vec3(_BlendVividLight(B.r, L.r), _BlendVividLight(B.g, L.g), _BlendVividLight(B.b, L.b)); \n\ |
819 | +}"; |
820 | + |
821 | +static std::string BlendPinLightShader = "#version 110 \n\ |
822 | +float _BlendPinLight(float B /*background layer*/, float L /*foreground layer*/) \n\ |
823 | +{ \n\ |
824 | + if (L < 0.5) \n\ |
825 | + return _BlendDarken(B, (2.0 * L)); \n\ |
826 | + else \n\ |
827 | + return _BlendLighten(B, (2.0 * (L - 0.5)))); \n\ |
828 | +} \n\ |
829 | +vec3 BlendPinLight(vec3 B /*background layer*/, vec3 L /*foreground layer*/) \n\ |
830 | +{ \n\ |
831 | + return vec3(_BlendPinLight(B.r, L.r), _BlendPinLight(B.g, L.g), _BlendPinLight(B.b, L.b)); \n\ |
832 | +}"; |
833 | + |
834 | +static std::string BlendHardMixShader = "#version 110 \n\ |
835 | +float _BlendHardMix(float B /*background layer*/, float L /*foreground layer*/) \n\ |
836 | +{ \n\ |
837 | + if (_BlendVividLight(B, L) < 0.5) \n\ |
838 | + return 0.0; \n\ |
839 | + else \n\ |
840 | + return 1.0; \n\ |
841 | +} \n\ |
842 | +vec3 BlendHardMix(vec3 B /*background layer*/, vec3 L /*foreground layer*/) \n\ |
843 | +{ \n\ |
844 | + return vec3(_BlendHardMix(B.r, L.r), _BlendHardMix(B.g, L.g), _BlendHardMix(B.b, L.b)); \n\ |
845 | +}"; |
846 | + |
847 | +static std::string BlendReflectShader = "#version 110 \n\ |
848 | +float _BlendReflect(float B /*background layer*/, float L /*foreground layer*/) \n\ |
849 | +{ \n\ |
850 | + if (L == 1.0) \n\ |
851 | + return 1.0; \n\ |
852 | + else \n\ |
853 | + return min(B * B / (1.0 - L), 1.0); \n\ |
854 | +} \n\ |
855 | +vec3 BlendReflect(vec3 B /*background layer*/, vec3 L /*foreground layer*/) \n\ |
856 | +{ \n\ |
857 | + return vec3(_BlendReflect(B.r, L.r), _BlendReflect(B.g, L.g), _BlendReflect(B.b, L.b)); \n\ |
858 | +}"; |
859 | + |
860 | +static std::string BlendGlowShader = "#version 110 \n\ |
861 | +float _BlendGlow(float B /*background layer*/, float L /*foreground layer*/) \n\ |
862 | +{ \n\ |
863 | + if (L == 1.0) \n\ |
864 | + return 1.0; \n\ |
865 | + else \n\ |
866 | + return min(L * L / (1.0 - B), 1.0); \n\ |
867 | +} \n\ |
868 | +vec3 BlendGlow(vec3 B /*background layer*/, vec3 L /*foreground layer*/) \n\ |
869 | +{ \n\ |
870 | + return vec3(_BlendGlow(B.r, L.r), _BlendGlow(B.g, L.g), _BlendGlow(B.b, L.b)); \n\ |
871 | +}"; |
872 | + |
873 | +static std::string BlendPhoenixShader = "#version 110 \n\ |
874 | +vec3 BlendPhoenix(vec3 B /*background layer*/, vec3 L /*foreground layer*/) \n\ |
875 | +{ \n\ |
876 | + return min(B, L) - max(B, L) + vec3(1.0); \n\ |
877 | +}"; |
878 | + |
879 | +static std::string BlendOpacityShader = "#version 110 \n\ |
880 | +vec3 BlendOpacity(vec3 B /*background layer*/, vec3 L /*foreground layer*/) \n\ |
881 | +{ \n\ |
882 | + return O * L + (1 - O) * B; \n\ |
883 | +}"; |
884 | + |
885 | // Noise Shader: http://www.ozone3d.net/blogs/lab/20110427/glsl-random-generator/ |
886 | // varying vec3 v; |
887 | // float rand(vec2 n) |
888 | @@ -310,36 +320,36 @@ |
889 | ObjectPtr<IOpenGLVertexShader> vertex_shader = _graphics_display.m_DeviceFactory->CreateVertexShader(); |
890 | ObjectPtr<IOpenGLPixelShader> blend_modes = _graphics_display.m_DeviceFactory->CreatePixelShader(); |
891 | ObjectPtr<IOpenGLPixelShader> blend_operation = _graphics_display.m_DeviceFactory->CreatePixelShader(); |
892 | - NString blending_operation_code; |
893 | + std::string blending_operation_code; |
894 | |
895 | - vertex_shader->SetShaderCode(TCHAR_TO_ANSI(*LayerBlendingVertexShader)); |
896 | - blend_operation->SetShaderCode(TCHAR_TO_ANSI(*blend_code_normal)); |
897 | + vertex_shader->SetShaderCode(TCHAR_TO_ANSI(LayerBlendingVertexShader.c_str())); |
898 | + blend_operation->SetShaderCode(TCHAR_TO_ANSI(blend_code_normal.c_str())); |
899 | |
900 | // For some strange reason, make sure that the attribute holding the vertex position has a name that comes first in alphabetic order before all |
901 | // other attributes. Otherwise you get a bug on NVidia! Why is that??? |
902 | |
903 | - blending_operation_code = "#version 110 \n\ |
904 | - varying vec4 varyTexCoord0; \n\ |
905 | - varying vec4 varyTexCoord1; \n\ |
906 | - uniform vec4 color0; \n\ |
907 | - uniform vec4 color1; \n\ |
908 | - uniform float alpha; \n\ |
909 | - uniform float opacity; \n\ |
910 | - uniform sampler2D TextureObject0; \n\ |
911 | - uniform sampler2D TextureObject1; \n\ |
912 | - vec4 SampleTexture(sampler2D TexObject, vec4 TexCoord) \n\ |
913 | - { \n\ |
914 | - return texture2D(TexObject, TexCoord.st); \n\ |
915 | - } \n\ |
916 | - void main() \n\ |
917 | - { \n\ |
918 | + blending_operation_code = "#version 110 \n\ |
919 | + varying vec4 varyTexCoord0; \n\ |
920 | + varying vec4 varyTexCoord1; \n\ |
921 | + uniform vec4 color0; \n\ |
922 | + uniform vec4 color1; \n\ |
923 | + uniform float alpha; \n\ |
924 | + uniform float opacity; \n\ |
925 | + uniform sampler2D TextureObject0; \n\ |
926 | + uniform sampler2D TextureObject1; \n\ |
927 | + vec4 SampleTexture(sampler2D TexObject, vec4 TexCoord) \n\ |
928 | + { \n\ |
929 | + return texture2D(TexObject, TexCoord.st); \n\ |
930 | + } \n\ |
931 | + void main() \n\ |
932 | + { \n\ |
933 | vec4 b0 = color0*SampleTexture(TextureObject0, varyTexCoord0); \n\ |
934 | vec4 b1 = color1*SampleTexture(TextureObject1, varyTexCoord1); \n\ |
935 | gl_FragColor = vec4(BlendNormal(b0, b1, opacity), alpha); \n\ |
936 | }"; |
937 | |
938 | _shader_layer_blend_normal = _graphics_display.m_DeviceFactory->CreateShaderProgram(); |
939 | - blend_operation->SetShaderCode(TCHAR_TO_ANSI(*blending_operation_code)); |
940 | + blend_operation->SetShaderCode(TCHAR_TO_ANSI(blending_operation_code.c_str())); |
941 | |
942 | _shader_layer_blend_normal->ClearShaderObjects(); |
943 | _shader_layer_blend_normal->AddShaderObject(vertex_shader); |
944 | |
945 | === modified file 'configure.ac' |
946 | --- configure.ac 2012-01-20 20:04:52 +0000 |
947 | +++ configure.ac 2012-01-20 20:42:24 +0000 |
948 | @@ -22,7 +22,7 @@ |
949 | # The number format is : year/month/day |
950 | # e.g.: december 5th, 2011 is: 20111205 |
951 | # So far there is no provision for more than one break in a day. |
952 | -m4_define([nux_abi_version], [20120120.02]) |
953 | +m4_define([nux_abi_version], [20120120.03]) |
954 | |
955 | m4_define([nux_version], |
956 | [nux_major_version.nux_minor_version.nux_micro_version]) |
Apart from the merge-conflict with trunk again in configure.ac...
<<<<<<< TREE [nux_abi_ version] , [20120119.01]) [nux_abi_ version] , [20120116.02])
m4_define(
=======
m4_define(
>>>>>>> MERGE-SOURCE
... looking good.