VR-Vantage 3.1 API Documentation
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
cgdisplay_hdr.h
Go to the documentation of this file.
1 
2 // Copyright JRM Enterprises, Inc. 2006
3 // All rights reserved.
4 //
5 // This code is the intellectual property of JRM Enterprises, Inc.
6 // It may not be used or released as source or compiled binary form
7 // without the prior written consent of JRM Enterprises, Inc.
8 //
9 // Original Authors: Ken George
11 
12 // This is a method of performing filtering for the color mapping and histogram processing. Standard bilinear
13 // texture filtering (GL_LINEAR) is not desired here since the texture lookups can only be filtered along
14 // the x direction. This is because the data for these textures is continuous only along x and not y hence
15 // leading to a shader implementation of this effect if enabled.
16 // As of now, results are pretty good without this filtering technique and really don't warrant the extra
17 // processing. Keep commented out for now.
18 #define ENABLE_FILTERING 0
19 
20 const char* cgdisplay_hdr =
21 "#ifndef NVI_TYPES \n"
22 "#define NVI_TYPES \n"
23 " \n"
24 "#ifdef USE_HALF \n"
25 "typedef half4 color4; \n"
26 "typedef half3 color3; \n"
27 "typedef half2 color2; \n"
28 "typedef half color; \n"
29 "#define texRECT h4texRECT \n"
30 "#define tex2D h4tex2D \n"
31 "#else \n"
32 " \n"
33 "typedef float4 color4; \n"
34 "typedef float3 color3; \n"
35 "typedef float2 color2; \n"
36 "typedef float color; \n"
37 " \n"
38 "#endif \n"
39 " \n"
40 "#if COMPONENTS == 1 \n"
41 " #define COLORTYPE color \n"
42 "#elif COMPONENTS == 2 \n"
43 " #define COLORTYPE color2 \n"
44 "#elif COMPONENTS == 3 \n"
45 " #define COLORTYPE color3 \n"
46 "#else \n"
47 " #define COLORTYPE color4 \n"
48 "#endif \n"
49 " \n"
50 "#endif \n"
51 " \n"
52 "struct vertexData { \n"
53 " float4 Position : POSITION; \n"
54 " float3 Normal : NORMAL; \n"
55 " float2 TexCoord0 : TEXCOORD0; \n"
56 "}; \n"
57 " \n"
58 "struct fragmentData { \n"
59 " float4 Position : POSITION; \n"
60 " float2 TexCoord0 : TEXCOORD0; \n"
61 " float4 fragPosition : WPOS; \n"
62 "}; \n"
63 " \n"
64 "fragmentData vpQuad(vertexData input) \n"
65 "{ \n"
66 " fragmentData output; \n"
67 " \n"
68 "float4x4 ModelViewProj = glstate.matrix.mvp; \n"
69 "float4x4 ModelView = glstate.matrix.modelview[0]; \n"
70 "float4x4 ViewInverse = glstate.matrix.invtrans.modelview[0]; \n"
71 " \n"
72 " // pass texture coordinates for the pbuffer map \n"
73 " output.TexCoord0.xy = input.TexCoord0.xy; \n"
74 " // transform position to projection space \n"
75 " // output.Position = mul(ModelViewProj, input.Position); \n"
76 " output.Position = input.Position; \n"
77 " \n"
78 " return output; \n"
79 "} \n"
80 " \n"
81 "// bilinear interpolation for texture rectangles - 16/32 bit float \n"
82 "COLORTYPE \n"
83 "bilinear (samplerIMG image, // the input image \n"
84 " float2 pos // texture coordinate \n"
85 " ) \n"
86 "{ \n"
87 " COLORTYPE c00, c01, c10, c11; \n"
88 " float2 fracTex = frac(pos); \n"
89 " float2 texC = floor(pos); \n"
90 " texC = texC + float2(0.5, 0.5); \n"
91 " c00 = texIMG(image, texC); \n"
92 " texC.x++; \n"
93 " c10 = texIMG(image, texC); \n"
94 " texC.y++; \n"
95 " c11 = texIMG(image, texC); \n"
96 " texC.x--; \n"
97 " c01 = texIMG(image, texC); \n"
98 " \n"
99 " float2 fracTex1 = 1.0 - fracTex; \n"
100 " COLORTYPE c0 = c00 * fracTex1.x + c10 * fracTex.x; \n"
101 " COLORTYPE c1 = c01 * fracTex1.x + c11 * fracTex.x; \n"
102 " COLORTYPE c = c0 * fracTex1.y + c1 * fracTex.y; \n"
103 "// COLORTYPE c0 = lerp(c00, c10, fracTex.x); \n"
104 "// COLORTYPE c1 = lerp(c01, c11, fracTex.x); \n"
105 "// COLORTYPE c = lerp(c0, c1, fracTex.y); \n"
106 " \n"
107 " return c; \n"
108 "} \n"
109 " \n"
110 "color revert888(float3 inValue, float gain, float level) \n"
111 "{ \n"
112 " // revert back from 888 format to floating point \n"
113 " // the red channel is the scaled value for display - so the gain/level have already been applied \n"
114 " // the green channel is the unscaled value before gain/level are applied for display \n"
115 " // the blue channel is a log scaling of this range to maintain the values clipped by the green channel. \n"
116 " // the result of this function gives the most accurate value for each value \n"
117 " // only handles positive numbers with most accuracy in the red channel to avoid mach bands on the display. \n"
118 " color outValue; \n"
119 " outValue = inValue.r; // use red unless clipping or blending occurred. \n"
120 "\n"
121 " float logNum = exp(inValue.b * 25) - 1.0; \n"
122 " logNum = logNum * gain + level; // shift to display range. \n"
123 "\n"
124 " float clippedNum = inValue.g * gain + level; // shift to display range. \n"
125 "\n"
126 " if (inValue.r == 0.0) { \n"
127 " if (clippedNum < inValue.r) { \n"
128 " if ((clippedNum > logNum) || (logNum > inValue.r)) { \n"
129 " outValue = clippedNum; \n"
130 " } else { \n"
131 " outValue = logNum; \n"
132 " } \n"
133 " } \n"
134 " } else if (clippedNum >= inValue.r) { \n"
135 " if (clippedNum > logNum) \n"
136 " outValue = clippedNum; \n"
137 " else \n"
138 " outValue = logNum; \n"
139 " } else if (logNum >= inValue.r) { \n"
140 " outValue = logNum; \n"
141 " } \n"
142 " return outValue; \n"
143 "} \n"
144 " \n"
145 "// apply gain and level and optionally log scaling to texture 0 \n"
146 "color3 gainLevel(fragmentData input, \n"
147 " uniform samplerIMG inTex : TEXUNIT0, \n"
148 " uniform sampler2D noiseIndexTex : TEXUNIT1, \n"
149 " uniform samplerIMG noiseTex : TEXUNIT2, \n"
150 " uniform sampler2D colorMapTex : TEXUNIT3, \n"
151 " uniform sampler2D scanMaskTex : TEXUNIT4, \n"
152 " uniform sampler2D HistogramEqTex : TEXUNIT5, \n"
153 " uniform sampler2D BayerFilterMapTex : TEXUNIT6, \n"
154 " uniform float gain = 1.0, \n"
155 " uniform float level = 0.0, \n"
156 " uniform float colorMapScale = 1.0, \n"
157 " uniform float scanLevelScale = 1.0, \n"
158 " uniform int aeroHeatingControl = 0, \n"
159 " uniform float2 aeroHeatingAngularSpread = float2(0.0, 0.0), \n"
160 " uniform float2 aeroHeatingAngleOffsets = float2(0.0, 0.0), \n"
161 " uniform float bitDepth = -1.0, \n"
162 " uniform float imageClipRadius = -1.0, \n"
163 " uniform float2 imageRadiusScale = float2(1.0, 1.0), \n"
164 " uniform float finalGain = 1.0, \n"
165 " uniform float finalLevel = 0.0, \n"
166 " uniform float2 texOffset, \n"
167 " uniform float3 channelSelect = float3(1.0, 0.0, 0.0), \n"
168 " uniform int texRectFilter = 0, // flag indicating use of texture rectangular filtering \n"
169 " uniform int noiseEnable = 0, // flag indicating use of noise \n"
170 " uniform int scanningSensorEnable = 0, // flag indicating use of a scanning sensor \n"
171 " uniform int logScaleEnable = 0, // flag indicating use of log scaling the output \n"
172 " uniform int revert888Enable = 0, // flag indicating use of reverting the input from 888 encoded format \n"
173 " uniform int colorConversion = 0, // flag indicating use of color converting the output for NVG green display \n"
174 " uniform int polaritySwitch = 0, // flag indicating use of reversal of the polarity for a black-hot IR display \n"
175 " uniform int fullColorEnable = 0, // flag indicating full color input and output \n"
176 " uniform int HistogramEnable = 0, // flag indicating to perform histogram lookup \n"
177 " uniform int normalizeOutput = 0, // saturate the output to prevent greater than 1 output \n"
178 " uniform float passObjectID = 0.0 // flag for passing the objectID for target acquisition \n"
179 " ) : COLOR \n"
180 "{ \n"
181 " color3 c; \n"
182 " color3 output, inVal; \n"
183 " float4 noiseIndex; \n"
184 " color3 noise; \n"
185 " color objectID; \n"
186 " if (!texRectFilter) { \n"
187 " if ( colorConversion >= 4 ) { // Bayer filter - use 2x2 filter. \n"
188 " float2 TexC = input.TexCoord0.xy; \n"
189 " inVal = texIMG(inTex, TexC); \n"
190 " int3 texSize = tex2Dsize(inTex, 0); \n"
191 " TexC.x += 1.0 / texSize.x; \n"
192 " inVal += texIMG(inTex, TexC); \n"
193 " TexC.y += 1.0 / texSize.x; \n"
194 " inVal += texIMG(inTex, TexC); \n"
195 " TexC.x -= 1.0 / texSize.x; \n"
196 " inVal += texIMG(inTex, TexC); \n"
197 " inVal /= 4.0; \n"
198 " } else { \n"
199 " inVal = texIMG(inTex, input.TexCoord0); \n"
200 " } \n"
201 //" inVal = clamp(inVal, -60000, 65000); // clamp to limit of 16f - should be already the case if 16f fbo is used but when alpha==0 it isn't \n"
202 " objectID = inVal.g; \n"
203 " if (fullColorEnable) { \n"
204 " c = inVal; \n"
205 " } else if (revert888Enable) { \n"
206 " c = revert888(inVal.rgb, gain, level); \n"
207 " } else { \n"
208 " c = inVal.rgb * channelSelect; \n"
209 " float channels = dot(channelSelect, float3(1.0, 1.0, 1.0)); \n"
210 // right now we really only support 3 and 1 channel options. This is a bit of a hack but does work. Consider revising
211 // so that you get all rgb channels when channel select has all 3 but only support a single channel across rgb for a single channel select
212 " if ( channels < 1.5 ) \n"
213 " c = c.rrr; \n"
214 " } \n"
215 " } else { \n"
216 " objectID = texIMG(inTex, input.TexCoord0).g; \n"
217 " inVal = bilinear(inTex, input.TexCoord0); \n"
218 " c = inVal; \n"
219 " } \n"
220 " \n"
221 " c = c * finalGain + finalLevel; \n"
222 " \n"
223 " if(HistogramEnable) \n"
224 " { \n"
225 " color3 histogramProcessing = c; \n"
226 " float2 mapCoord; \n"
227 " if (histogramProcessing.r < 0.0) \n"
228 " histogramProcessing = 0.0; \n"
229 " mapCoord.xy = histogramProcessing.r; \n"
230 
231 #if 1
232 
233 " if (histogramProcessing.r < 1.0) \n"
234 " mapCoord.x = fract(histogramProcessing.r * 256.0); \n"
235 " c = tex2D(HistogramEqTex, mapCoord); \n"
236 
237 // Applying the filtering to the histogram seems to create more issues. Keep commented out for now
238 #else
239 " if (histogramProcessing.r < 1.0) \n"
240 " { \n"
241 " float Xcoord = fract(histogramProcessing.r * 256); \n"
242 " mapCoord.x = Xcoord; \n"
243 " float2 mapCoord2 = mapCoord; \n"
244 " int3 texSize = tex2Dsize(HistogramEqTex, 0); \n"
245 " float texelDivision = float(1.0 / texSize.x); \n"
246 " float adjacentTexel = fract(Xcoord / texelDivision) - 0.5; \n"
247 " mapCoord2.x = Xcoord + adjacentTexel * texelDivision; \n"
248 " float weight = 1.0 - abs(adjacentTexel); \n"
249 " output = lerp(tex2D(HistogramEqTex, mapCoord), tex2D(HistogramEqTex, mapCoord2), weight); \n"
250 " } \n"
251 " else \n"
252 " output = tex2D(HistogramEqTex, mapCoord); \n"
253 #endif
254 " } \n"
255 " \n"
256 " if (noiseEnable) { \n"
257 " noiseIndex = tex2D(noiseIndexTex, input.TexCoord0); \n"
258 "// noiseIndex += texOffset; // used with optimization where only portion of noise map is updated every frame \n"
259 " noise.r = texIMG(noiseTex, noiseIndex.xy).r; \n"
260 " noise.gb = texIMG(noiseTex, noiseIndex.zw).gb; \n"
261 " float totalNoise = sqrt(dot(noise.rgb, noise.rgb)); \n"
262 " c = c + float3(totalNoise); \n"
263 
264 
265 " } \n"
266 " \n"
267 // Note that the scanning Sensor block serves 2 purposes. It can perform aerodynamic heating in the first pass (pass thru program)
268 // as well as the existing scanning that is typically done in the final shader. If aerodynamic heating is disabled, this block is
269 // bypassed entirely in the pass thru program.
270 " if (scanningSensorEnable) \n"
271 " { \n"
272 " float2 PIDIV2 = float2(3.14159265359 / 2.0); \n"
273 " float4 scanMaskValue; \n"
274 " scanMaskValue = aeroHeatingControl; \n"
275 " float2 texC = input.TexCoord0.xy; \n"
276 " float2 texcoord = 2.0 * texC - 1.0; \n"
277 " texcoord.y = texC.y; \n"
278 " float4 maskLookup = texIMG(scanMaskTex, texC); \n"
279 " float2 angSpread = texcoord * aeroHeatingAngularSpread; \n"
280 " float2 totalAngle = clamp(aeroHeatingAngleOffsets + angSpread, -PIDIV2, PIDIV2); \n"
281 " scanMaskValue = lerp( float4(1.0, 0.0, 0.0, 0.0), maskLookup, abs(cos(totalAngle.x)) ); \n"
282 " scanMaskValue = lerp( float4(1.0, 0.0, 0.0, 0.0), scanMaskValue, abs(cos(totalAngle.y)) ); \n"
283 " scanMaskValue = lerp(maskLookup, scanMaskValue, aeroHeatingControl); \n"
284 " c = c * scanMaskValue.r; // multiply the gain/scan mask \n"
285 " c = c + scanMaskValue.a * scanLevelScale; // add the offset mask after scaling by the adjustment factor \n"
286 " } \n"
287 " \n"
288 " \n"
289 " if ( colorConversion ) { \n"
290 " if (polaritySwitch) { \n"
291 " c.rgb = 1.0 - c.rgb; \n"
292 " } \n"
293 " c = c * colorMapScale; \n"
294 " float2 mapCoord; \n"
295 " float colorIndex = c.r; \n"
296 " if ( colorConversion >= 2 ) // Bayer filter is enabled \n"
297 " { \n"
298 " int3 texSize = tex2Dsize(BayerFilterMapTex, 0); \n"
299 " float2 coords = float2(input.fragPosition.x, input.fragPosition.y) / texSize.xy; \n"
300 " float3 filter = tex2D(BayerFilterMapTex, coords).rgb; \n"
301 " colorIndex = dot(c.rgb, filter); \n"
302 " } \n"
303 // Add a very small offset because FP buffers have some slight error that makes values slightly smaller than they should
304 // for example, a value of 0.25 in a FP buffer can come out to be 0.249999. This small offset helps with the
305 // indexing into the color buffer for more accurate results
306 " colorIndex += 0.00000001; \n"
307 " if (colorIndex < 0.0) colorIndex = 0.0; \n"
308 " mapCoord.xy = colorIndex; \n"
309 
310 #if !ENABLE_FILTERING
311 
312 " if (colorIndex < 1.0) \n"
313 " mapCoord.x = fract(colorIndex * 256); \n"
314 " output = tex2D(colorMapTex, mapCoord); \n"
315 #else
316 " if (colorIndex < 1.0) \n"
317 " { \n"
318 " float Xcoord = fract(colorIndex * 256); \n"
319 " mapCoord.x = Xcoord; \n"
320 " float2 mapCoord2 = mapCoord; \n"
321 " int3 texSize = tex2Dsize(colorMapTex, 0); \n"
322 " float texelDivision = float(1.0 / texSize.x); \n"
323 " float adjacentTexel = fract(Xcoord / texelDivision) - 0.5; \n"
324 " mapCoord2.x = Xcoord + adjacentTexel * texelDivision; \n"
325 " float weight = 1.0 - abs(adjacentTexel); \n"
326 " output = lerp(tex2D(colorMapTex, mapCoord), tex2D(colorMapTex, mapCoord2), weight); \n"
327 " } \n"
328 " else \n"
329 " output = tex2D(colorMapTex, mapCoord); \n"
330 #endif
331 " } else { \n"
332 " if (logScaleEnable) { \n"
333 " // eric's log scale \n"
334 " // output.rgb = 0.5 * log10(c.r * 99.0 + 1.0); \n"
335 " // alternate log scale \n"
336 " output.rgb = 1.0 - exp(-c.r); \n"
337 " } else { \n"
338 " output.rgb = c.rgb; \n"
339 " } \n"
340 " if (polaritySwitch) { \n"
341 " output.rgb = 1.0 - output.rgb; \n"
342 " } \n"
343 " } \n"
344 " \n"
345 //" if (!texRectFilter) { \n"
346 //" output = clamp(output, -60000, 65000); // clamp to limit of 16f \n"
347 //" } \n"
348 " output.rgb = lerp(output.rgb, saturate(output.rgb), float3(normalizeOutput)); \n"
349 " if ( bitDepth > 0.0 ) \n"
350 " output.rgb = trunc(output.rgb * (pow(2.0, bitDepth) - 1.0)) / (pow(2.0, bitDepth) - 1.0); \n"
351 " output.g = lerp(output.g, objectID, passObjectID); \n"
352 " if ( imageClipRadius > 0.0 ) \n"
353 " { \n"
354 " float2 coords = 2.0 * input.TexCoord0 - 1.0; \n"
355 " coords *= imageRadiusScale; \n"
356 " float radius = length(coords); \n"
357 " if( radius > imageClipRadius) \n"
358 " output.rgb = float3(0.0, 0.0, 0.0); \n"
359 " } \n"
360 " return output; \n"
361 "} \n"
362 " \n"
363 " \n"
364 "// display with simple tone mapping, does exposure and gamma correction \n"
365 "color3 display_hdr(fragmentData input, \n"
366 " uniform samplerIMG tex : TEXUNIT0, \n"
367 " uniform float exposure = 1.0, \n"
368 " uniform float gamma = 1.0 / 2.2, \n"
369 " uniform int texRectFilter // flag indicating use of texture rectangular filtering \n"
370 " ) : COLOR \n"
371 "{ \n"
372 " color3 c; \n"
373 " if (!texRectFilter) { \n"
374 " c = texIMG(tex, input.TexCoord0); \n"
375 " } else { \n"
376 " c = bilinear(tex, input.TexCoord0); \n"
377 " } \n"
378 " c.rgb = c.r * exposure; \n"
379 " // c.rgb = pow(c.r, gamma); \n"
380 " return c; \n"
381 "} \n"
382 " \n"
383 "// threshold the image leaving output 1.0 if above threshold and 0.0 otherwise \n"
384 "COLORTYPE threshold(fragmentData input, \n"
385 " uniform samplerIMG tex : TEXUNIT0, \n"
386 " uniform float thresholdGain = 2.0, \n"
387 " uniform float thresholdOffset = -4.0, \n"
388 " uniform int texRectFilter // flag indicating use of texture rectangular filtering \n"
389 " ) : COLOR \n"
390 "{ \n"
391 " COLORTYPE c = 0; \n"
392 " if (!texRectFilter) { \n"
393 " if ((input.TexCoord0.x < 1.0) && (input.TexCoord0.y < 1.0) // this test eliminates a edge effect problem with halo turning on brighter on the edge. \n"
394 " && (input.TexCoord0.x > 0.004) && (input.TexCoord0.y > 0.004)) { \n"
395 " c = texIMG(tex, input.TexCoord0); \n"
396 " } \n"
397 " } else { \n"
398 " c = bilinear(tex, input.TexCoord0); \n"
399 " } \n"
400 " c = c * thresholdGain + thresholdOffset; \n"
401 " c = clamp (c, 0.0, 10000.0); \n"
402 "// if (c.r < 10.0) c = 0; \n"
403 "// c = 0.5 * log10(c * 0.99 + 1.0); \n"
404 " \n"
405 " return c; \n"
406 "} \n"
407 " \n"
408 "// threshold the image leaving output 1.0 if above threshold and 0.0 otherwise \n"
409 "COLORTYPE haloBlend(fragmentData input, \n"
410 " uniform samplerIMG maskTex : TEXUNIT0, \n"
411 " uniform samplerIMG tex : TEXUNIT1, \n"
412 " uniform float intensityScale = 10.0, \n"
413 " uniform int texRectFilter // flag indicating use of texture rectangular filtering \n"
414 " ) : COLOR \n"
415 "{ \n"
416 " COLORTYPE c; \n"
417 " color mask; \n"
418 "// float2 texC2 = input.TexCoord0 * 4.0; // if mask is 1/4 size for 4x4 reduction. \n"
419 " float2 texC2 = input.TexCoord0 * 2.0; // if mask is 1/2 size for 2x2 reduction. \n"
420 "// float2 texC2 = input.TexCoord0; \n"
421 " if (!texRectFilter) { \n"
422 " c = texIMG(tex, texC2); \n"
423 " mask = texIMG(maskTex, input.TexCoord0); \n"
424 " } else { \n"
425 " c = bilinear(tex, texC2); \n"
426 " mask = bilinear(maskTex, input.TexCoord0); \n"
427 " } \n"
428 "// if (mask != 0.0f) \n"
429 "// mask = clamp (mask * intensityScale, 0.0, 1.5); \n"
430 "// mask = clamp (mask * intensityScale, 0.0, 1.5); \n"
431 " mask = 1 - 1/(mask + 0.9); // scale between 0-1 \n"
432 " mask = clamp(mask, 0.0, 1.0); // scale between 0-1 \n"
433 "// c += mask * intensityScale; \n"
434 " COLORTYPE b = (intensityScale * mask) + c * (1 - mask) ; // do a blend with the background \n"
435 " c = max(c, b); \n"
436 " return c; \n"
437 "}\n"
438 "\n"
439 "\n"
440 "\n"
441 "COLORTYPE motionBlur(fragmentData input, \n"
442 " uniform samplerIMG inTexCurrent : TEXUNIT0, \n"
443 " uniform samplerIMG inTexPrevious : TEXUNIT1, \n"
444 " uniform float blurWeight = 0.0 ) : COLOR \n"
445 "{\n"
446 " COLORTYPE cInCurrent = saturate(texIMG(inTexCurrent, input.TexCoord0));\n"
447 " COLORTYPE cInPrevious = texIMG(inTexPrevious, input.TexCoord0);\n"
448 " return lerp(cInCurrent, cInPrevious, blurWeight); \n"
449 "}\n"
450 "\n"
451 "// blur the image based on the doppler blur in the green channel \n"
452 "COLORTYPE dopplerBlur(fragmentData input, \n"
453 " uniform samplerIMG tex : TEXUNIT0, \n"
454 " uniform int texRectFilter, // flag indicating use of texture rectangular filtering \n"
455 " uniform int textureWidth, // texture width \n"
456 " uniform int ROIwidth // region of interest width [m] \n"
457 " ) : COLOR \n"
458 "{ \n"
459 " COLORTYPE c = 0; \n"
460 " c = texIMG(tex, input.TexCoord0); \n"
461 " if (ROIwidth == 0) { \n"
462 " c.g = c.r; \n"
463 " return c; \n"
464 " } \n"
465 " float initialPower = c.r; \n"
466 " float accum_power = initialPower; \n"
467 " float2 initialCoords = input.TexCoord0.xy; \n"
468 " float2 samplePoint = input.TexCoord0.xy; \n"
469 " float norm2 = 12.0/11.0; \n"
470 " float span = textureWidth * 2; // do full screen - could be optimized but didn't change performance enough. \n"
471 " float deltaX = 1.0 / textureWidth; \n"
472 " float lmin = -0.5*span * deltaX; \n"
473 " float lmax = 0.5*span * deltaX; \n"
474 " for (float l = lmin; l <= lmax; l += deltaX) \n"
475 " { \n"
476 " samplePoint.x = initialCoords.x + l; \n"
477 " if ((samplePoint.x > 1.0) || (samplePoint.x < 0.0)) continue; \n"
478 " \n"
479 " float3 Return = texIMG(tex, samplePoint); \n"
480 " float sampled_power = Return.r; // [1] Scaled Power \n"
481 " float dopblur = Return.g; // [m] Doppler blur \n"
482 " \n"
483 " // filter only if and only from -dopblur/2 to +dopblur/2 \n"
484 " if ((abs(l*ROIwidth) < dopblur/2.0) // filter only from -dopblur/2 to +dopblur/2 [m] \n"
485 " && (dopblur > 0.0) // there is a doppler blur component \n"
486 " && (abs(l)>deltaX*0.5)) // skip the center point - it already has initial power \n"
487 " { \n"
488 " float weight = (1.0 - pow(abs(l*ROIwidth) / dopblur,2)) * norm2/dopblur; \n"
489 " sampled_power *= weight; \n"
490 " accum_power += sampled_power; \n"
491 " } \n"
492 " } \n"
493 " c = float3(accum_power); \n"
494 " \n"
495 " return c; \n"
496 "} \n"
497 " \n"
498 "\n"
499 "\n"
500 "\n";


Copyright © 2005-2024 MAK Technologies. All Rights Reserved (www.mak.com)