floor bump fx iwa

This commit is contained in:
shun-iwasawa 2019-11-27 15:57:55 +09:00 committed by manongjohn
parent f390c90d35
commit 3bdad9b457
11 changed files with 1792 additions and 4 deletions

View file

@ -1430,7 +1430,26 @@
<item>"STD_iwa_LinearGradientFx.wave_amplitude" "Amplitude" </item>
<item>"STD_iwa_LinearGradientFx.wave_frequency" "Frequency" </item>
<item>"STD_iwa_LinearGradientFx.wave_phase" "Phase" </item>
<item>"STD_iwa_FloorBumpFx" "Floor Bump Iwa" </item>
<item>"STD_iwa_FloorBumpFx.renderMode" "Render Mode" </item>
<item>"STD_iwa_FloorBumpFx.fov" "Fov" </item>
<item>"STD_iwa_FloorBumpFx.cameraAltitude" "Camera Altitude" </item>
<item>"STD_iwa_FloorBumpFx.eyeLevel" "Eye Level" </item>
<item>"STD_iwa_FloorBumpFx.drawLevel" "Draw Level" </item>
<item>"STD_iwa_FloorBumpFx.waveHeight" "Wave Height" </item>
<item>"STD_iwa_FloorBumpFx.textureOffsetAmount" "Amount" </item>
<item>"STD_iwa_FloorBumpFx.textureOffsetSpread" "Spread" </item>
<item>"STD_iwa_FloorBumpFx.sourcePrecision" "Precision" </item>
<item>"STD_iwa_FloorBumpFx.souceMargin" "Margin" </item>
<item>"STD_iwa_FloorBumpFx.lightAzimuth" "Azimuth" </item>
<item>"STD_iwa_FloorBumpFx.lightElevation" "Elevation" </item>
<item>"STD_iwa_FloorBumpFx.depth" "Depth" </item>
<item>"STD_iwa_FloorBumpFx.refractiveIndex" "Refractive Index" </item>
<item>"STD_iwa_FloorBumpFx.distanceLevel" "Distance Level" </item>
<item>"STD_iwa_FloorBumpFx.differenceMode" "Render difference from unbumped state" </item>
<item>"STD_iwa_FloorBumpFx.displacement" "Displacement" </item>
<item>"STD_iwa_GlareFx" "Glare Iwa" </item>
<item>"STD_iwa_GlareFx.renderMode" "Render Mode" </item>
<item>"STD_iwa_GlareFx.irisMode" "Iris Shape" </item>

View file

@ -0,0 +1,39 @@
<fxlayout>
<page name="Floor Bump Iwa">
<control>renderMode</control>
<control>fov</control>
<control>cameraAltitude</control>
<control>eyeLevel</control>
<control>drawLevel</control>
<control>waveHeight</control>
<control>souceMargin</control>
<control>displacement</control>
<vbox modeSensitive="renderMode" mode="0,4,5">
<separator label="Source Image"/>
<control>sourcePrecision</control>
</vbox>
<vbox modeSensitive="renderMode" mode="0,1,2,3">
<separator label="Texture Offset"/>
<control>textureOffsetAmount</control>
<control>textureOffsetSpread</control>
</vbox>
<vbox modeSensitive="renderMode" mode="1,2">
<separator label="Light Direction"/>
<control>lightAzimuth</control>
<control>lightElevation</control>
</vbox>
<vbox modeSensitive="renderMode" mode="4">
<separator label="Refraction mode"/>
<control>depth</control>
<control>refractiveIndex</control>
</vbox>
<vbox modeSensitive="renderMode" mode="5">
<separator label="Reflection mode"/>
<control>distanceLevel</control>
</vbox>
<vbox modeSensitive="renderMode" mode="0,1,2,3">
<separator label="Difference mode"/>
<control>differenceMode</control>
</vbox>
</page>
</fxlayout>

View file

@ -35,6 +35,7 @@
STD_warpFx
STD_inoWarphvFx
STD_iwa_BarrelDistortFx
STD_iwa_FloorBumpFx
</Distort>
<Gradient>
STD_diamondGradientFx

View file

@ -565,6 +565,8 @@ public:
QSize getPreferredSize() override { return QSize(150, 20); }
int getValue() const;
protected slots:
void onChange(const QString &str);
};

View file

@ -72,6 +72,8 @@ public:
ELLIPSE, // used in spin blur ino and radial blur ino
VERTICAL_POS, // A horizontal line at given height
// { [TDoubleParamP] }
TYPESCOUNT
};

View file

@ -86,6 +86,7 @@ set(HEADERS
iwa_bokeh_advancedfx.h
iwa_bokeh_util.h
globalcontrollablefx.h
iwa_floorbumpfx.h
)
if(OpenCV_FOUND)
@ -280,6 +281,7 @@ set(SOURCES
iwa_rainbowfx.cpp
iwa_bokeh_advancedfx.cpp
iwa_bokeh_util.cpp
iwa_floorbumpfx.cpp
)
if(OpenCV_FOUND)

File diff suppressed because it is too large Load diff

View file

@ -0,0 +1,163 @@
#pragma once
#ifndef IWA_FLOORBUMPFX_H
#define IWA_FLOORBUMPFX_H
#include "tfxparam.h"
#include "stdfx.h"
#include "tparamset.h"
#include <QVector3D>
struct float4 {
float x, y, z, w;
float4 operator*(const float &v) const {
return float4{x * v, y * v, z * v, w * v};
}
float4 &operator+=(const float4 &v) {
x += v.x;
y += v.y;
z += v.z;
w += v.w;
return *this;
}
};
class Iwa_FloorBumpFx final : public TStandardRasterFx {
FX_PLUGIN_DECLARATION(Iwa_FloorBumpFx)
public:
enum RenderMode {
TextureMode = 0,
DiffuseMode,
SpecularMode,
FresnelMode,
RefractionMode,
ReflectionMode
};
struct FloorBumpVars {
double waveHeight;
double displacement;
int refHeight;
TDimensionI outDim;
TDimensionI resultDim;
int margin;
double precision;
// add margins to all ends and multiply by precision value
TDimensionI sourceDim; // u
// only add margins for height image
TDimensionI refDim; // u
// collecting parameters
double textureOffsetAmount; // u
double spread; // u
double camAltitude;
int renderMode; // u
bool differenceMode; // u
// making pixels in gray128 to be zero level height
// ( 128/255. IT'S NOT 0.5! )
double zeroLevel; // u
double H; // u
double W; // u
// angle between the optical axis and the horizontal axis
double angle_el; // u
// Y coordinate of the Eye position (P)
double P_y; // u
// distance from the Eye (P) to the center of the projection plane (T)
double d_PT; // u
// Z-Y position of the center of top edge of the projection plane (A)
QPointF A; // u
// Z-Y position of the center of bottom edge of the projection plane (B)
QPointF B; // u
// (C) is an intersection between the XZ plane and the line P->B
double C_z; // u
QVector3D sunVec; // u
double base_fresnel_ref; // u
double depth, r_index; // uu
double distance; // u
QVector3D eyePos; // u
};
protected:
TRasterFxPort m_heightRef; // height reference image
TRasterFxPort m_texture; // texture image
TRasterFxPort m_dispRef; // displacement image
TIntEnumParamP m_renderMode;
TDoubleParamP m_fov; // camera fov (degrees)
TDoubleParamP
m_cameraAltitude; // height of the bottom edge of projection plane
TDoubleParamP m_eyeLevel; // height of the vanishing point
TDoubleParamP m_drawLevel; // upper rendering boundary
TDoubleParamP m_waveHeight; // height of waves to the both sides (i.e.
// amplitude becomes 2*waveHeight)
TBoolParamP
m_differenceMode; // available in diffuse and fresnel mode,
// render brightness difference from unbumped state
// Texture mode parameters
TDoubleParamP m_textureOffsetAmount; // amount of texture trailing along with
// gradient of the bump
TDoubleParamP
m_textureOffsetSpread; // adding "blur" to the gradient distribution
TDoubleParamP m_sourcePrecision; // to load the texture with higher dpi
TDoubleParamP m_souceMargin; // margins to be added to all edges for both the
// height reference and the texture images
TDoubleParamP m_displacement;
// Shading (Diffuse and Specular) modes parameters
TDoubleParamP m_lightAzimuth; // light is in front of camera with azimuth=0.
// clockwise angle (degrees)
TDoubleParamP m_lightElevation; // (degrees)
// Refraction mode parameters
TDoubleParamP m_depth; // water depth. the bottom will be placed at -depth
TDoubleParamP
m_refractiveIndex; // refractive index of the medium under the surface
// Reflection mode parameter
TDoubleParamP m_distanceLevel; // the distance of the reflected object
// specified by the postion on the surface
// convert output values (in float4) to channel value
template <typename RASTER, typename PIXEL>
void setOutputRaster(float4 *srcMem, const RASTER dstRas, TDimensionI dim,
int drawLevel);
// convert input tile's channel values to float4 values
template <typename RASTER, typename PIXEL>
void setSourceRaster(const RASTER srcRas, float4 *srcMem, TDimensionI dim);
void setRefRaster(const TRaster64P refRas, float *refMem, TDimensionI dim,
bool isRef);
inline void initVars(FloorBumpVars &vars, TTile &tile,
const TRenderSettings &settings, double frame);
public:
Iwa_FloorBumpFx();
bool doGetBBox(double frame, TRectD &bBox,
const TRenderSettings &info) override;
bool canHandle(const TRenderSettings &info, double frame) override;
void doCompute(TTile &tile, double frame,
const TRenderSettings &rend_sets) override;
void doCompute_CPU(TTile &tile, const double frame,
const TRenderSettings &settings, const FloorBumpVars &vars,
float4 *source_host, float *ref_host, float4 *result_host);
void doCompute_with_Displacement(TTile &tile, const double frame,
const TRenderSettings &settings,
const FloorBumpVars &vars,
float4 *source_host, float *ref_host,
float *disp_host, float4 *result_host);
void getParamUIs(TParamUIConcept *&concepts, int &length) override;
};
#endif

View file

@ -2366,6 +2366,78 @@ void EllipseFxGadget::leftButtonDrag(const TPointD &pos, const TMouseEvent &e) {
void EllipseFxGadget::leftButtonUp() { m_handle = None; }
//=============================================================================
class VerticalPosFxGadget final : public FxGadget {
TPointD m_pos;
TDoubleParamP m_yParam;
TIntEnumParamP m_mode;
public:
VerticalPosFxGadget(FxGadgetController *controller,
const TDoubleParamP &param, const TIntEnumParamP &mode)
: FxGadget(controller), m_yParam(param), m_mode(mode) {
addParam(m_yParam);
}
void draw(bool picking) override;
bool isVisible();
void leftButtonDown(const TPointD &pos, const TMouseEvent &) override;
void leftButtonDrag(const TPointD &pos, const TMouseEvent &) override;
};
//---------------------------------------------------------------------------
// Dirty resolution to hide gadget when selecting unrelated modes
bool VerticalPosFxGadget::isVisible() {
if (!m_mode) return true;
// condition for Distance Level parameter of Iwa_FloorBumpFx
if (m_yParam->getName() == "distanceLevel" && m_mode->getValue() != 5)
return false;
return true;
}
//---------------------------------------------------------------------------
void VerticalPosFxGadget::draw(bool picking) {
if (!isVisible()) return;
setPixelSize();
if (isSelected())
glColor3dv(m_selectedColor);
else
glColor3d(0, 0, 1);
glPushName(getId());
double vPos = getValue(m_yParam);
double unit = getPixelSize();
glPushMatrix();
glTranslated(0, vPos, 0);
double r = unit * 3;
double d = unit * 300;
glBegin(GL_LINES);
glVertex2d(0, r);
glVertex2d(0, -r);
glVertex2d(-d, 0);
glVertex2d(d, 0);
glEnd();
drawTooltip(TPointD(7, 7) * unit, getLabel());
glPopMatrix();
glPopName();
}
//---------------------------------------------------------------------------
void VerticalPosFxGadget::leftButtonDown(const TPointD &pos,
const TMouseEvent &) {}
//---------------------------------------------------------------------------
void VerticalPosFxGadget::leftButtonDrag(const TPointD &pos,
const TMouseEvent &) {
if (m_yParam) setValue(m_yParam, pos.y);
}
//*************************************************************************************
// FxGadgetController implementation
//*************************************************************************************
@ -2599,6 +2671,15 @@ FxGadget *FxGadgetController::allocateGadget(const TParamUIConcept &uiConcept) {
break;
}
case TParamUIConcept::VERTICAL_POS: {
assert(uiConcept.m_params.size() >= 1 && uiConcept.m_params.size() <= 2);
TIntEnumParamP mode((uiConcept.m_params.size() >= 2)
? (TIntEnumParamP)uiConcept.m_params[1]
: TIntEnumParamP());
gadget = new VerticalPosFxGadget(this, uiConcept.m_params[0], mode);
break;
}
default:
break;
}

View file

@ -343,6 +343,7 @@ void ParamsPage::setPageField(TIStream &is, const TFxP &fx, bool isVertical) {
m_mainLayout->setColumnStretch(0, 0);
m_mainLayout->setColumnStretch(1, 1);
setPageField(is, fx, true);
tmpWidget->setLayout(m_mainLayout);
// turn back the layout
m_mainLayout = keepMainLay;
@ -872,7 +873,7 @@ void ParamsPageSet::addParamsPage(ParamsPage *page, const char *name) {
/*-- このFxで最大サイズのページに合わせてダイアログをリサイズ --*/
QSize pagePreferredSize = page->getPreferredSize();
m_preferredSize = m_preferredSize.expandedTo(
pagePreferredSize + QSize(m_tabBarContainer->height() + 2,
pagePreferredSize + QSize(m_tabBarContainer->height() + 2,
2)); /*-- 2は上下左右のマージン --*/
QScrollArea *pane = new QScrollArea(this);
@ -976,7 +977,7 @@ void ParamsPageSet::createPage(TIStream &is, const TFxP &fx, int index) {
/*-- このFxで最大サイズのページに合わせてダイアログをリサイズ --*/
QSize pagePreferredSize = paramsPage->getPreferredSize();
m_preferredSize = m_preferredSize.expandedTo(
pagePreferredSize + QSize(m_tabBarContainer->height() + 2,
pagePreferredSize + QSize(m_tabBarContainer->height() + 2,
2)); /*-- 2は上下左右のマージン --*/
QScrollArea *scrollAreaPage = new QScrollArea(this);

View file

@ -1387,7 +1387,6 @@ void EnumParamField::onChange(const QString &str) {
emit currentParamChanged();
emit actualParamChanged();
emit modeChanged(m_actualParam->getValue());
if (undo) TUndoManager::manager()->add(undo);
@ -1421,6 +1420,10 @@ void EnumParamField::update(int frame) {
}
}
//-----------------------------------------------------------------------------
int EnumParamField::getValue() const { return m_actualParam->getValue(); }
//=============================================================================
// BoolParamField
//-----------------------------------------------------------------------------