motionblur + sky update
This commit is contained in:
@@ -155,6 +155,37 @@ void DeferredRenderableComponent::RenderScene(wiRenderer::DeviceContext context)
|
||||
wiRenderer::DrawDebugBoxes(wiRenderer::getCamera(), context);
|
||||
}
|
||||
|
||||
//if (getSSSEnabled())
|
||||
//{
|
||||
// wiImage::BatchBegin(context, STENCILREF_SKIN);
|
||||
// fx.quality = QUALITY_BILINEAR;
|
||||
// fx.sampleFlag = SAMPLEMODE_CLAMP;
|
||||
// fx.setDepthMap(rtLinearDepth.shaderResource.back());
|
||||
// for (int i = 0; i<rtSSS.size() - 1; ++i){
|
||||
// rtSSS[i].Activate(context, rtGBuffer.depth);
|
||||
// XMFLOAT2 dir = XMFLOAT2(0, 0);
|
||||
// static const float stren = 0.018f;
|
||||
// if (i % 2)
|
||||
// dir.x = stren*((float)wiRenderer::GetScreenHeight() / (float)wiRenderer::GetScreenWidth());
|
||||
// else
|
||||
// dir.y = stren;
|
||||
// fx.process.setSSSS(dir);
|
||||
// if (i == 0)
|
||||
// wiImage::Draw(rtDeferred.shaderResource.back(), fx, context);
|
||||
// else
|
||||
// wiImage::Draw(rtSSS[i - 1].shaderResource.back(), fx, context);
|
||||
// }
|
||||
// fx.process.clear();
|
||||
// rtSSS.back().Activate(context, rtGBuffer.depth); {
|
||||
// wiImage::BatchBegin(context);
|
||||
// fx.quality = QUALITY_NEAREST;
|
||||
// fx.sampleFlag = SAMPLEMODE_CLAMP;
|
||||
// fx.blendFlag = BLENDMODE_OPAQUE;
|
||||
// wiImage::Draw(rtDeferred.shaderResource.front(), fx, context);
|
||||
// wiImage::BatchBegin(context, STENCILREF_SKIN);
|
||||
// wiImage::Draw(rtSSS[rtSSS.size() - 2].shaderResource.back(), fx, context);
|
||||
// }
|
||||
//}
|
||||
|
||||
if (getSSREnabled()){
|
||||
rtSSR.Activate(context); {
|
||||
@@ -169,6 +200,24 @@ void DeferredRenderableComponent::RenderScene(wiRenderer::DeviceContext context)
|
||||
fx.process.clear();
|
||||
}
|
||||
}
|
||||
|
||||
if (getMotionBlurEnabled()){ //MOTIONBLUR
|
||||
wiImage::BatchBegin(context);
|
||||
rtMotionBlur.Activate(context);
|
||||
fx.process.setMotionBlur(true);
|
||||
fx.setVelocityMap(rtGBuffer.shaderResource.back());
|
||||
fx.setDepthMap(rtLinearDepth.shaderResource.back());
|
||||
fx.blendFlag = BLENDMODE_OPAQUE;
|
||||
if (getSSREnabled()){
|
||||
wiImage::Draw(rtDeferred.shaderResource.front(), fx, context);
|
||||
fx.blendFlag = BLENDMODE_ALPHA;
|
||||
wiImage::Draw(rtSSR.shaderResource.front(), fx, context);
|
||||
}
|
||||
else{
|
||||
wiImage::Draw(rtDeferred.shaderResource.front(), fx, context);
|
||||
}
|
||||
fx.process.clear();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -28,6 +28,8 @@ Luna<DeferredRenderableComponent_BindLua>::FunctionType DeferredRenderableCompon
|
||||
lunamethod(Renderable3DComponent_BindLua, SetVolumeLightsEnabled),
|
||||
lunamethod(Renderable3DComponent_BindLua, SetLightShaftsEnabled),
|
||||
lunamethod(Renderable3DComponent_BindLua, SetLensFlareEnabled),
|
||||
lunamethod(Renderable3DComponent_BindLua, SetMotionBlurEnabled),
|
||||
lunamethod(Renderable3DComponent_BindLua, SetSSSEnabled),
|
||||
{ NULL, NULL }
|
||||
};
|
||||
Luna<DeferredRenderableComponent_BindLua>::PropertyType DeferredRenderableComponent_BindLua::properties[] = {
|
||||
|
||||
@@ -28,6 +28,8 @@ Luna<ForwardRenderableComponent_BindLua>::FunctionType ForwardRenderableComponen
|
||||
lunamethod(Renderable3DComponent_BindLua, SetVolumeLightsEnabled),
|
||||
lunamethod(Renderable3DComponent_BindLua, SetLightShaftsEnabled),
|
||||
lunamethod(Renderable3DComponent_BindLua, SetLensFlareEnabled),
|
||||
lunamethod(Renderable3DComponent_BindLua, SetMotionBlurEnabled),
|
||||
lunamethod(Renderable3DComponent_BindLua, SetSSSEnabled),
|
||||
{ NULL, NULL }
|
||||
};
|
||||
Luna<ForwardRenderableComponent_BindLua>::PropertyType ForwardRenderableComponent_BindLua::properties[] = {
|
||||
|
||||
@@ -45,6 +45,8 @@ void Renderable3DComponent::setProperties()
|
||||
setVolumeLightsEnabled(true);
|
||||
setLightShaftsEnabled(true);
|
||||
setLensFlareEnabled(true);
|
||||
setMotionBlurEnabled(true);
|
||||
setSSSEnabled(true);
|
||||
|
||||
setPreferredThreadingCount(0);
|
||||
}
|
||||
@@ -56,6 +58,9 @@ void Renderable3DComponent::Initialize()
|
||||
rtSSR.Initialize(
|
||||
(UINT)(wiRenderer::GetScreenWidth() * getSSRQuality()), (UINT)(wiRenderer::GetScreenHeight() * getSSRQuality())
|
||||
, 1, false, 1, 0, DXGI_FORMAT_R16G16B16A16_FLOAT);
|
||||
rtMotionBlur.Initialize(
|
||||
(UINT)(wiRenderer::GetScreenWidth()), (UINT)(wiRenderer::GetScreenHeight())
|
||||
, 1, false, 1, 0, DXGI_FORMAT_R16G16B16A16_FLOAT);
|
||||
rtLinearDepth.Initialize(
|
||||
wiRenderer::GetScreenWidth(), wiRenderer::GetScreenHeight()
|
||||
, 1, false, 1, 0, DXGI_FORMAT_R32_FLOAT
|
||||
@@ -104,9 +109,14 @@ void Renderable3DComponent::Initialize()
|
||||
rtSSAO.resize(3);
|
||||
for (unsigned int i = 0; i<rtSSAO.size(); i++)
|
||||
rtSSAO[i].Initialize(
|
||||
(UINT)(wiRenderer::GetScreenWidth()*getSSAOQuality()), (UINT)(wiRenderer::GetScreenHeight()*getSSAOQuality())
|
||||
, 1, false, 1, 0, DXGI_FORMAT_R8_UNORM
|
||||
);
|
||||
(UINT)(wiRenderer::GetScreenWidth()*getSSAOQuality()), (UINT)(wiRenderer::GetScreenHeight()*getSSAOQuality())
|
||||
, 1, false, 1, 0, DXGI_FORMAT_R8_UNORM
|
||||
);
|
||||
rtSSS.resize(3);
|
||||
for (int i = 0; i < 3; ++i)
|
||||
rtSSS[i].Initialize(
|
||||
(UINT)(wiRenderer::GetScreenWidth()), (UINT)(wiRenderer::GetScreenHeight())
|
||||
, 1, false, 1, 0, DXGI_FORMAT_R16G16B16A16_FLOAT);
|
||||
|
||||
|
||||
rtSun.resize(2);
|
||||
@@ -311,7 +321,10 @@ void Renderable3DComponent::RenderComposition1(wiRenderTarget& shadedSceneRT, wi
|
||||
wiImage::Draw(shadedSceneRT.shaderResource.front(), fx, context);
|
||||
|
||||
fx.blendFlag = BLENDMODE_ALPHA;
|
||||
if (getSSREnabled()){
|
||||
if (getMotionBlurEnabled()){
|
||||
wiImage::Draw(rtMotionBlur.shaderResource.back(), fx, context);
|
||||
}
|
||||
else if (getSSREnabled()){
|
||||
wiImage::Draw(rtSSR.shaderResource.back(), fx, context);
|
||||
}
|
||||
wiImage::Draw(rtWater.shaderResource.back(), fx, context);
|
||||
|
||||
@@ -34,11 +34,14 @@ private:
|
||||
bool volumeLightsEnabled;
|
||||
bool lightShaftsEnabled;
|
||||
bool lensFlareEnabled;
|
||||
bool motionBlurEnabled;
|
||||
bool sssEnabled;
|
||||
|
||||
protected:
|
||||
wiRenderTarget
|
||||
rtReflection
|
||||
, rtSSR
|
||||
, rtMotionBlur
|
||||
, rtVolumeLight
|
||||
, rtTransparent
|
||||
, rtWater
|
||||
@@ -49,7 +52,7 @@ protected:
|
||||
, rtLensFlare
|
||||
, rtFinal[2]
|
||||
;
|
||||
vector<wiRenderTarget> rtSun, rtBloom, rtSSAO;
|
||||
vector<wiRenderTarget> rtSun, rtBloom, rtSSAO, rtSSS;
|
||||
wiDepthTarget dtDepthCopy;
|
||||
|
||||
vector<wiTaskThread*> workerThreads;
|
||||
@@ -90,6 +93,8 @@ public:
|
||||
bool getVolumeLightsEnabled(){ return volumeLightsEnabled; }
|
||||
bool getLightShaftsEnabled(){ return lightShaftsEnabled; }
|
||||
bool getLensFlareEnabled(){ return lensFlareEnabled; }
|
||||
bool getMotionBlurEnabled(){ return motionBlurEnabled; }
|
||||
bool getSSSEnabled(){ return sssEnabled; }
|
||||
|
||||
unsigned short getThreadingCount(){ return workerThreads.size(); }
|
||||
|
||||
@@ -119,6 +124,8 @@ public:
|
||||
void setVolumeLightsEnabled(bool value){ volumeLightsEnabled = value; }
|
||||
void setLightShaftsEnabled(bool value){ lightShaftsEnabled = value; }
|
||||
void setLensFlareEnabled(bool value){ lensFlareEnabled = value; }
|
||||
void setMotionBlurEnabled(bool value){ motionBlurEnabled = value; }
|
||||
void setSSSEnabled(bool value){ sssEnabled = value; }
|
||||
|
||||
virtual void setPreferredThreadingCount(unsigned short value);
|
||||
|
||||
|
||||
@@ -29,6 +29,8 @@ Luna<Renderable3DComponent_BindLua>::FunctionType Renderable3DComponent_BindLua:
|
||||
lunamethod(Renderable3DComponent_BindLua, SetVolumeLightsEnabled),
|
||||
lunamethod(Renderable3DComponent_BindLua, SetLightShaftsEnabled),
|
||||
lunamethod(Renderable3DComponent_BindLua, SetLensFlareEnabled),
|
||||
lunamethod(Renderable3DComponent_BindLua, SetMotionBlurEnabled),
|
||||
lunamethod(Renderable3DComponent_BindLua, SetSSSEnabled),
|
||||
{ NULL, NULL }
|
||||
};
|
||||
Luna<Renderable3DComponent_BindLua>::PropertyType Renderable3DComponent_BindLua::properties[] = {
|
||||
@@ -206,6 +208,32 @@ int Renderable3DComponent_BindLua::SetLensFlareEnabled(lua_State* L)
|
||||
wiLua::SError(L, "SetLensFlareEnabled(bool value) not enough arguments!");
|
||||
return 0;
|
||||
}
|
||||
int Renderable3DComponent_BindLua::SetMotionBlurEnabled(lua_State* L)
|
||||
{
|
||||
if (component == nullptr)
|
||||
{
|
||||
wiLua::SError(L, "SetMotionBlurEnabled(bool value) component is null!");
|
||||
return 0;
|
||||
}
|
||||
if (wiLua::SGetArgCount(L) > 1)
|
||||
((Renderable3DComponent*)component)->setMotionBlurEnabled(wiLua::SGetBool(L, 2));
|
||||
else
|
||||
wiLua::SError(L, "SetMotionBlurEnabled(bool value) not enough arguments!");
|
||||
return 0;
|
||||
}
|
||||
int Renderable3DComponent_BindLua::SetSSSEnabled(lua_State* L)
|
||||
{
|
||||
if (component == nullptr)
|
||||
{
|
||||
wiLua::SError(L, "SetSSSEnabled(bool value) component is null!");
|
||||
return 0;
|
||||
}
|
||||
if (wiLua::SGetArgCount(L) > 1)
|
||||
((Renderable3DComponent*)component)->setSSSEnabled(wiLua::SGetBool(L, 2));
|
||||
else
|
||||
wiLua::SError(L, "SetSSSEnabled(bool value) not enough arguments!");
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
void Renderable3DComponent_BindLua::Bind()
|
||||
|
||||
@@ -27,6 +27,8 @@ public:
|
||||
int SetVolumeLightsEnabled(lua_State* L);
|
||||
int SetLightShaftsEnabled(lua_State* L);
|
||||
int SetLensFlareEnabled(lua_State* L);
|
||||
int SetMotionBlurEnabled(lua_State* L);
|
||||
int SetSSSEnabled(lua_State* L);
|
||||
|
||||
static void Bind();
|
||||
};
|
||||
|
||||
@@ -55,7 +55,7 @@ PixelInputType main(Input input)
|
||||
Out.ReflectionMapSamplingPos = mul(pos, xRefViewProjection );
|
||||
|
||||
|
||||
Out.vel = mul( mul(vel.xyz,(float3x3)WORLD), xViewProjection ).xyz;
|
||||
Out.vel = mul( vel.xyz, xViewProjection ).xyz;
|
||||
|
||||
Out.ao = input.nor.w;
|
||||
|
||||
|
||||
@@ -13,7 +13,7 @@ float4 main(VSOut PSIn):SV_TARGET
|
||||
float3 sun = 0;
|
||||
float3 col = 0;
|
||||
[branch]if(xFx.x==0){
|
||||
col = lerp(xHorizon.rgb,enviroTex.SampleLevel( texSampler,nor,0 ).rgb,saturate(nor.y/0.3f));
|
||||
col = /*lerp( xHorizon.rgb,*/ enviroTex.SampleLevel( texSampler,nor,0 ).rgb/*, saturate(nor.y/0.3f) )*/;
|
||||
sun = clamp(pow(dot(xSun,nor),256)*xSunColor.rgb, 0, inf);
|
||||
}
|
||||
else{
|
||||
|
||||
Reference in New Issue
Block a user