2016-11-30 22:11:33 +13:00
|
|
|
#pragma once
|
|
|
|
|
|
|
|
/*------------------------------------
|
|
|
|
Iwa_SoapBubbleFx
|
|
|
|
Generates thin film interference colors from two reference images;
|
|
|
|
one is for thickness and the other one is for shape or normal vector
|
|
|
|
distribution of the film.
|
|
|
|
Inherits Iwa_SpectrumFx.
|
|
|
|
------------------------------------*/
|
|
|
|
|
|
|
|
#ifndef IWA_SOAPBUBBLE_H
|
|
|
|
#define IWA_SOAPBUBBLE_H
|
|
|
|
|
|
|
|
#include "iwa_spectrumfx.h"
|
|
|
|
|
|
|
|
class Iwa_SoapBubbleFx final : public Iwa_SpectrumFx {
|
|
|
|
FX_PLUGIN_DECLARATION(Iwa_SoapBubbleFx)
|
|
|
|
|
|
|
|
protected:
|
|
|
|
/* target shape, used to create a pseudo normal vector */
|
|
|
|
TRasterFxPort m_shape;
|
|
|
|
/* another option, to input a depth map directly */
|
|
|
|
TRasterFxPort m_depth;
|
2017-04-28 14:52:23 +12:00
|
|
|
// rendering mode
|
|
|
|
TIntEnumParamP m_renderMode;
|
2016-11-30 22:11:33 +13:00
|
|
|
// shape parameters
|
|
|
|
TDoubleParamP m_binarize_threshold;
|
|
|
|
TDoubleParamP m_shape_aspect_ratio;
|
|
|
|
TDoubleParamP m_blur_radius;
|
|
|
|
TDoubleParamP m_blur_power;
|
2017-03-08 16:34:08 +13:00
|
|
|
TBoolParamP m_multi_source;
|
2017-04-28 14:52:23 +12:00
|
|
|
TDoubleParamP m_center_opacity;
|
|
|
|
TBoolParamP m_fit_thickness;
|
|
|
|
|
2021-07-08 13:39:28 +12:00
|
|
|
// obsolete parameter. to be converted to m_center_opacity
|
2017-03-08 16:34:08 +13:00
|
|
|
TBoolParamP m_mask_center;
|
2016-11-30 22:11:33 +13:00
|
|
|
|
|
|
|
// noise parameters
|
|
|
|
TIntParamP m_normal_sample_distance;
|
|
|
|
TIntParamP m_noise_sub_depth;
|
|
|
|
TDoubleParamP m_noise_resolution_s;
|
|
|
|
TDoubleParamP m_noise_resolution_t;
|
|
|
|
TDoubleParamP m_noise_sub_composite_ratio;
|
|
|
|
TDoubleParamP m_noise_evolution;
|
|
|
|
TDoubleParamP m_noise_depth_mix_ratio;
|
|
|
|
TDoubleParamP m_noise_thickness_mix_ratio;
|
|
|
|
|
2017-04-28 14:52:23 +12:00
|
|
|
enum { RENDER_MODE_BUBBLE, RENDER_MODE_THICKNESS, RENDER_MODE_DEPTH };
|
|
|
|
|
2016-11-30 22:11:33 +13:00
|
|
|
template <typename RASTER, typename PIXEL>
|
2017-03-08 16:34:08 +13:00
|
|
|
void convertToBrightness(const RASTER srcRas, float* dst, float* alpha,
|
|
|
|
TDimensionI dim);
|
2016-11-30 22:11:33 +13:00
|
|
|
|
|
|
|
template <typename RASTER, typename PIXEL>
|
|
|
|
void convertToRaster(const RASTER ras, float* thickness_map_p,
|
2017-03-08 16:34:08 +13:00
|
|
|
float* depth_map_p, float* alpha_map_p, TDimensionI dim,
|
2016-11-30 22:11:33 +13:00
|
|
|
float3* bubbleColor_p);
|
|
|
|
|
|
|
|
void processShape(double frame, TTile& shape_tile, float* depth_map_p,
|
2017-04-28 14:52:23 +12:00
|
|
|
float* alpha_map_p, USHORT* regionIds_p,
|
|
|
|
QList<QRect>& regionBoundingRects, TDimensionI dim,
|
2017-03-08 16:34:08 +13:00
|
|
|
const TRenderSettings& settings);
|
2016-11-30 22:11:33 +13:00
|
|
|
|
2017-03-08 16:34:08 +13:00
|
|
|
int do_binarize(TRaster32P srcRas, USHORT* dst_p, float thres,
|
2017-04-28 14:52:23 +12:00
|
|
|
float* distance_p, float* alpha_map_p,
|
|
|
|
QList<QRect>& regionBoundingRects, TDimensionI dim);
|
2016-11-30 22:11:33 +13:00
|
|
|
|
|
|
|
void do_createBlurFilter(float* dst_p, int size, float radius);
|
|
|
|
|
2022-01-12 04:08:17 +13:00
|
|
|
void do_applyFilter(float* depth_map_p, TDimensionI dim, float* distance_p,
|
2017-03-08 16:34:08 +13:00
|
|
|
USHORT* binarized_p, float* blur_filter_p,
|
|
|
|
int blur_filter_size, double frame,
|
|
|
|
const TRenderSettings& settings);
|
2016-11-30 22:11:33 +13:00
|
|
|
|
|
|
|
void processNoise(float* thickness_map_p, float* depth_map_p, TDimensionI dim,
|
|
|
|
double frame, const TRenderSettings& settings);
|
|
|
|
|
|
|
|
void calc_norm_angle(float* norm_angle_p, float* depth_map_p, TDimensionI dim,
|
|
|
|
int shrink);
|
|
|
|
|
|
|
|
void make_noise_map(float* noise_map_p, float* depth_map_p,
|
|
|
|
float* norm_angle_p, TDimensionI dim,
|
|
|
|
const QList<int>& noise_amount,
|
|
|
|
const QList<QSize>& noise_base_resolution,
|
|
|
|
int noise_sub_depth, float* noise_base);
|
|
|
|
|
|
|
|
float noise_interp(int left, int right, int bottom, int top, float ratio_s,
|
|
|
|
float ratio_t, float* noise_layer_base, int noise_dim_x);
|
|
|
|
|
|
|
|
void add_noise(float* thickness_map_p, float* depth_map_p, TDimensionI dim,
|
|
|
|
float* noise_map_p, float noise_thickness_mix_ratio,
|
|
|
|
float noise_depth_mix_ratio);
|
|
|
|
|
2017-03-08 16:34:08 +13:00
|
|
|
void do_distance_transform(float* dst_p, USHORT* binarized_p, int regionCount,
|
|
|
|
TDimensionI dim, double frame);
|
|
|
|
|
|
|
|
// if the rendering process is canceled, release raster and return TRUE
|
|
|
|
bool checkCancelAndReleaseRaster(const QList<TRasterGR8P>&, TTile&,
|
|
|
|
const TRenderSettings&);
|
|
|
|
|
|
|
|
void applyDistanceToAlpha(float* distance_p, float* alpha_map_p,
|
2017-04-28 14:52:23 +12:00
|
|
|
TDimensionI dim, float center_opacity);
|
|
|
|
|
|
|
|
void fitThicknessPatches(TRasterP thickRas, TDimensionI thickDim,
|
|
|
|
float* thickness_map_p, TDimensionI dim,
|
|
|
|
USHORT* regionIds_p,
|
|
|
|
QList<QRect>& regionBoundingRects);
|
2016-11-30 22:11:33 +13:00
|
|
|
|
|
|
|
public:
|
|
|
|
Iwa_SoapBubbleFx();
|
|
|
|
|
|
|
|
void doCompute(TTile& tile, double frame,
|
|
|
|
const TRenderSettings& settings) override;
|
2017-04-28 14:52:23 +12:00
|
|
|
|
|
|
|
// This will be called in TFx::loadData when obsolete "mask center" value is
|
|
|
|
// loaded
|
|
|
|
void onObsoleteParamLoaded(const std::string& paramName) override;
|
2016-11-30 22:11:33 +13:00
|
|
|
};
|
|
|
|
|
|
|
|
#endif
|