Skip to content

Commit

Permalink
CPlot: add spec post
Browse files Browse the repository at this point in the history
  • Loading branch information
benoit128 committed Dec 3, 2024
1 parent 5c02035 commit 8d0258a
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 12 deletions.
15 changes: 11 additions & 4 deletions Cassiopee/CPlot/CPlot/Plugins/screenDump.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@
void accumulateSlit(E_Int ni, E_Int nj, char* imf, char* imt, char* imb,
E_Int i, E_Int nil, E_Int njl, char* imOut);

void specPostProcess(char* in, E_Int ni, E_Int nj, float* depth, char* out);

//=============================================================================
// Screen dump plugins
//=============================================================================
Expand Down Expand Up @@ -332,8 +334,16 @@ char* Data::export2Image(E_Int exportWidth, E_Int exportHeight)
}
free(localBuf); free(localDepth);
}
free(depth);

// software postprocessing on final buffer (just before screen dump)
if (rank == 0)
{
char* bfl = new char [_view.w * _view.h];
for (E_Int i = 0; i < 3*_view.w*_view.h; i++) bfl[i] = buffer[i];
specPostProcess(bfl, _view.w, _view.h, depth, buffer);
delete [] bfl;
}
free(depth);
MPI_Barrier(MPI_COMM_WORLD); // seems needed

#else
Expand Down Expand Up @@ -429,9 +439,6 @@ char* Data::export2Image(E_Int exportWidth, E_Int exportHeight)
glDeleteFramebuffersEXT(1, &fb);
#endif

// software postprocessing on final buffer (just before screen dump)


return buffer;
}

Expand Down
11 changes: 5 additions & 6 deletions Cassiopee/CPlot/CPlot/PyTree.py
Original file line number Diff line number Diff line change
Expand Up @@ -1535,7 +1535,7 @@ def display360ODS2__(t, posCam, posEye, dirCam, offscreen, exportRez, stereoShif
# display360 (offscreen=1, 2 or 7)
# type360=0 (360 degres), =1 (180 degres)
#==============================================================================
def display360(t, type360=0, blurSigma=-1., **kwargs):
def display360(t, type360=0, **kwargs):
"""Display for 360 images."""
import KCore.Vector as Vector
import Converter.Mpi as Cmpi
Expand Down Expand Up @@ -1564,7 +1564,7 @@ def display360(t, type360=0, blurSigma=-1., **kwargs):
display360__(t, posCam, posEye, dirCam, offscreen, exportRez, kwargs)
# Create the 360 image from cube images
if Cmpi.rank == 0:
panorama(export, exportRez, type360=type360, blurSigma=blurSigma)
panorama(export, exportRez, type360=type360)
Cmpi.barrier() # wait for completion

elif stereo == 1: # stereo ODS internal (only offscreen=1 or 7)
Expand Down Expand Up @@ -1635,14 +1635,14 @@ def display360(t, type360=0, blurSigma=-1., **kwargs):
posCam0 = Vector.add(posCam, dv)
display360__(t, posCam0, posEye, dirCam, offscreen, exportRez, kwargs)
if Cmpi.rank == 0:
panorama(export1, exportRez, type360=type360, blueSigma=blurSigma)
panorama(export1, exportRez, type360=type360)
Cmpi.barrier() # wait for completion

# left eye
posCam0 = Vector.sub(posCam, dv)
display360__(t, posCam0, posEye, dirCam, offscreen, exportRez, kwargs)
if Cmpi.rank == 0:
panorama(export2, exportRez, type360=type360, blueSigma=blurSigma)
panorama(export2, exportRez, type360=type360)
Cmpi.barrier() # wait for completion

# stitch
Expand Down Expand Up @@ -1683,7 +1683,7 @@ def display360(t, type360=0, blurSigma=-1., **kwargs):

# assemble 6 cube images en une image panoramique
# type360=0 -> 360, type360=1 -> 180
def panorama(export, exportRez, type360=0, blurSigma=-1.):
def panorama(export, exportRez, type360=0):
res = exportRez.split('x')
if type360 == 0: resx = int(res[0]); resy = int(res[1])
else: resx = int(res[1]); resy = int(res[1])
Expand All @@ -1705,7 +1705,6 @@ def panorama(export, exportRez, type360=0, blurSigma=-1.):
C._addVars(a7, ['r','g','b','a'])
a7f = C.getFields('nodes', a7, api=3)[0]
CPlot.cplot.panorama(a1, a2, a3, a4, a5, a6, a7f, type360)
CPlot.cplot.blur(a7f, blurSigma)
C.convertPyTree2File(a7, export)
return a7

Expand Down
4 changes: 2 additions & 2 deletions Cassiopee/CPlot/CPlot/blur.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -94,8 +94,8 @@ void gaussianBlur2(E_Float* in, E_Int ni, E_Int nj, E_Float* c, E_Int n, E_Float
}
}

// identical but applied to interlaced color buffer (3), return out
void gaussianBlur3(char* in, E_Int ni, E_Int nj, E_Float* c, E_Int n, float* depth, char* out)
// specific post-processing applied to interlaced color buffer (3), return out
void specPostProcess(char* in, E_Int ni, E_Int nj, float* depth, char* out)
{
float dmin, dmax;
// compute min/max of depth
Expand Down

0 comments on commit 8d0258a

Please sign in to comment.