updated postprocess pipeline, added missing effects

This commit is contained in:
turanszkij
2015-09-11 01:27:12 +02:00
parent 45b3258e23
commit abe7558f8c
27 changed files with 202 additions and 160 deletions
+63 -47
View File
@@ -5,6 +5,7 @@
#include "wiStencilRef.h"
#include "wiHelper.h"
#include "wiTextureHelper.h"
#include "wiSprite.h"
DeferredRenderableComponent::DeferredRenderableComponent(){
Renderable3DComponent::setProperties();
@@ -63,9 +64,9 @@ void DeferredRenderableComponent::Render(){
RenderShadows();
RenderReflections();
RenderScene();
RenderSecondaryScene(rtGBuffer, rtDeferred);
RenderSecondaryScene(rtGBuffer, GetFinalRT());
RenderLightShafts(rtGBuffer);
RenderComposition1(rtDeferred);
RenderComposition1(GetFinalRT());
RenderBloom();
RenderComposition2();
}
@@ -82,12 +83,12 @@ void DeferredRenderableComponent::RenderScene(wiRenderer::DeviceContext context)
rtGBuffer.Activate(context); {
wiRenderer::UpdatePerRenderCB(context, tessellationQuality);
wiRenderer::UpdatePerViewCB(context, wiRenderer::getCamera(), wiRenderer::getRefCamera());
wiRenderer::UpdatePerEffectCB(context, XMFLOAT4(0, 0, 0, 0), XMFLOAT4(0, 0, 0, 0));
wiRenderer::DrawWorld(wiRenderer::getCamera(), wiRenderer::DX11, tessellationQuality, context, false
, wiRenderer::SHADED_DEFERRED, rtReflection.shaderResource.front(), true, GRAPHICSTHREAD_SCENE);
wiRenderer::DrawSky(context);
}
@@ -144,48 +145,47 @@ void DeferredRenderableComponent::RenderScene(wiRenderer::DeviceContext context)
}
rtDeferred.Activate(context, rtGBuffer.depth); {
rtDeferred.Activate(context); {
wiImage::DrawDeferred(rtGBuffer.shaderResource[0]
, rtLinearDepth.shaderResource.back(), rtLight.shaderResource.front(), rtGBuffer.shaderResource[1]
, getSSAOEnabled() ? rtSSAO.back().shaderResource.back() : wiTextureHelper::getInstance()->getWhite()
, context, STENCILREF_DEFAULT);
wiRenderer::DrawSky(context);
, context, 0);
wiRenderer::DrawDebugBoneLines(wiRenderer::getCamera(), context);
wiRenderer::DrawDebugLines(wiRenderer::getCamera(), 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 (getSSSEnabled())
{
wiImage::BatchBegin(context, STENCILREF_SKIN);
fx.quality = QUALITY_BILINEAR;
fx.sampleFlag = SAMPLEMODE_CLAMP;
fx.setDepthMap(rtLinearDepth.shaderResource.back());
for (unsigned 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); {
@@ -196,7 +196,10 @@ void DeferredRenderableComponent::RenderScene(wiRenderer::DeviceContext context)
fx.setNormalMap(rtGBuffer.shaderResource[1]);
fx.setVelocityMap(rtGBuffer.shaderResource[2]);
fx.setMaskMap(rtLinearDepth.shaderResource.front());
wiImage::Draw(rtDeferred.shaderResource.front(), fx, context);
if (getSSSEnabled())
wiImage::Draw(rtSSS.back().shaderResource.front(), fx, context);
else
wiImage::Draw(rtDeferred.shaderResource.front(), fx, context);
fx.process.clear();
}
}
@@ -209,10 +212,12 @@ void DeferredRenderableComponent::RenderScene(wiRenderer::DeviceContext context)
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 if (getSSSEnabled())
{
wiImage::Draw(rtSSS.back().shaderResource.front(), fx, context);
}
else{
wiImage::Draw(rtDeferred.shaderResource.front(), fx, context);
}
@@ -220,6 +225,17 @@ void DeferredRenderableComponent::RenderScene(wiRenderer::DeviceContext context)
}
}
wiRenderTarget& DeferredRenderableComponent::GetFinalRT()
{
if (getMotionBlurEnabled())
return rtMotionBlur;
else if (getSSREnabled())
return rtSSR;
else if (getSSSEnabled())
return rtSSS.back();
else
return rtDeferred;
}
void DeferredRenderableComponent::setPreferredThreadingCount(unsigned short value)
{
@@ -242,9 +258,9 @@ void DeferredRenderableComponent::setPreferredThreadingCount(unsigned short valu
workerThreads.push_back(new wiTaskThread([&]
{
RenderScene(wiRenderer::getDeferredContext(GRAPHICSTHREAD_REFLECTIONS));
RenderSecondaryScene(rtGBuffer, rtDeferred, wiRenderer::getDeferredContext(GRAPHICSTHREAD_REFLECTIONS));
RenderSecondaryScene(rtGBuffer, GetFinalRT(), wiRenderer::getDeferredContext(GRAPHICSTHREAD_REFLECTIONS));
RenderLightShafts(rtGBuffer, wiRenderer::getDeferredContext(GRAPHICSTHREAD_REFLECTIONS));
RenderComposition1(rtDeferred, wiRenderer::getDeferredContext(GRAPHICSTHREAD_REFLECTIONS));
RenderComposition1(GetFinalRT(), wiRenderer::getDeferredContext(GRAPHICSTHREAD_REFLECTIONS));
RenderBloom(wiRenderer::getDeferredContext(GRAPHICSTHREAD_REFLECTIONS));
RenderComposition2(wiRenderer::getDeferredContext(GRAPHICSTHREAD_REFLECTIONS));
wiRenderer::FinishCommandList(GRAPHICSTHREAD_REFLECTIONS);
@@ -264,9 +280,9 @@ void DeferredRenderableComponent::setPreferredThreadingCount(unsigned short valu
workerThreads.push_back(new wiTaskThread([&]
{
RenderScene(wiRenderer::getDeferredContext(GRAPHICSTHREAD_SCENE));
RenderSecondaryScene(rtGBuffer, rtDeferred, wiRenderer::getDeferredContext(GRAPHICSTHREAD_SCENE));
RenderSecondaryScene(rtGBuffer, GetFinalRT(), wiRenderer::getDeferredContext(GRAPHICSTHREAD_SCENE));
RenderLightShafts(rtGBuffer, wiRenderer::getDeferredContext(GRAPHICSTHREAD_SCENE));
RenderComposition1(rtDeferred, wiRenderer::getDeferredContext(GRAPHICSTHREAD_SCENE));
RenderComposition1(GetFinalRT(), wiRenderer::getDeferredContext(GRAPHICSTHREAD_SCENE));
RenderBloom(wiRenderer::getDeferredContext(GRAPHICSTHREAD_SCENE));
RenderComposition2(wiRenderer::getDeferredContext(GRAPHICSTHREAD_SCENE));
wiRenderer::FinishCommandList(GRAPHICSTHREAD_SCENE);
@@ -290,9 +306,9 @@ void DeferredRenderableComponent::setPreferredThreadingCount(unsigned short valu
}));
workerThreads.push_back(new wiTaskThread([&]
{
RenderSecondaryScene(rtGBuffer, rtDeferred, wiRenderer::getDeferredContext(GRAPHICSTHREAD_MISC1));
RenderSecondaryScene(rtGBuffer, GetFinalRT(), wiRenderer::getDeferredContext(GRAPHICSTHREAD_MISC1));
RenderLightShafts(rtGBuffer, wiRenderer::getDeferredContext(GRAPHICSTHREAD_MISC1));
RenderComposition1(rtDeferred, wiRenderer::getDeferredContext(GRAPHICSTHREAD_MISC1));
RenderComposition1(GetFinalRT(), wiRenderer::getDeferredContext(GRAPHICSTHREAD_MISC1));
RenderBloom(wiRenderer::getDeferredContext(GRAPHICSTHREAD_MISC1));
RenderComposition2(wiRenderer::getDeferredContext(GRAPHICSTHREAD_MISC1));
wiRenderer::FinishCommandList(GRAPHICSTHREAD_MISC1);
@@ -9,6 +9,7 @@ protected:
wiRenderTarget rtGBuffer, rtDeferred, rtLight;
virtual void RenderScene(wiRenderer::DeviceContext context = wiRenderer::getImmediateContext());
wiRenderTarget& GetFinalRT();
public:
DeferredRenderableComponent();
+1 -9
View File
@@ -27,7 +27,6 @@ void Renderable3DComponent::setProperties()
setReflectionQuality(0.5f);
setSSAOQuality(0.5f);
setSSAOBlur(2.3f);
setSSRQuality(0.4f);
setBloomStrength(19.3f);
setBloomThreshold(0.99f);
setBloomSaturation(-3.86f);
@@ -56,7 +55,7 @@ void Renderable3DComponent::Initialize()
RenderableComponent::Initialize();
rtSSR.Initialize(
(UINT)(wiRenderer::GetScreenWidth() * getSSRQuality()), (UINT)(wiRenderer::GetScreenHeight() * getSSRQuality())
(UINT)(wiRenderer::GetScreenWidth()), (UINT)(wiRenderer::GetScreenHeight())
, 1, false, 1, 0, DXGI_FORMAT_R16G16B16A16_FLOAT);
rtMotionBlur.Initialize(
(UINT)(wiRenderer::GetScreenWidth()), (UINT)(wiRenderer::GetScreenHeight())
@@ -319,14 +318,7 @@ void Renderable3DComponent::RenderComposition1(wiRenderTarget& shadedSceneRT, wi
fx.blendFlag = BLENDMODE_OPAQUE;
wiImage::Draw(shadedSceneRT.shaderResource.front(), fx, context);
fx.blendFlag = BLENDMODE_ALPHA;
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);
wiImage::Draw(rtTransparent.shaderResource.back(), fx, context);
if (getEmittedParticlesEnabled()){
-3
View File
@@ -18,7 +18,6 @@ private:
float reflectionQuality;
float ssaoQuality;
float ssaoBlur;
float ssrQuality;
wiWaterPlane waterPlane;
@@ -77,7 +76,6 @@ public:
float getReflectionQuality(){ return reflectionQuality; }
float getSSAOQuality(){ return ssaoQuality; }
float getSSAOBlur(){ return ssaoBlur; }
float getSSRQuality(){ return ssrQuality; }
wiWaterPlane getWaterPlane(){ return waterPlane; }
@@ -108,7 +106,6 @@ public:
void setReflectionQuality(float value){ reflectionQuality = value; }
void setSSAOQuality(float value){ ssaoQuality = value; }
void setSSAOBlur(float value){ ssaoBlur = value; }
void setSSRQuality(float value){ ssrQuality = value; }
void setWaterPlane(const wiWaterPlane& value){ waterPlane = value; }
@@ -99,7 +99,7 @@ int Renderable3DComponent_BindLua::SetReflectionsEnabled(lua_State* L)
return 0;
}
if (wiLua::SGetArgCount(L) > 1)
((Renderable3DComponent*)component)->setShadowsEnabled(wiLua::SGetBool(L, 2));
((Renderable3DComponent*)component)->setReflectionsEnabled(wiLua::SGetBool(L, 2));
else
wiLua::SError(L, "SetShadowsEnabled(bool value) not enough arguments!");
return 0;
+2 -3
View File
@@ -17,11 +17,10 @@ cbuffer prop:register(b0){
float4 main(VertextoPixel PSIn) : SV_TARGET
{
float4 color=0;
float depth = ( xSceneDepthMap.Load(int4(PSIn.pos.xy,0,0)).r );
float4 color = xTexture.Load(int3(PSIn.pos.xy, 0));
float depth = xSceneDepthMap.Load(int3(PSIn.pos.xy, 0)).r;
[branch]if(depth<zFarP){
color = xTexture.SampleLevel(Sampler,PSIn.tex,0);
color=pow(color,GAMMA);
float4 lighting = xLightMap.SampleLevel(Sampler,PSIn.tex,0);
color.rgb *= lighting.rgb + xAmbient * xAOMap.SampleLevel(Sampler, PSIn.tex, 0).r;
+1 -1
View File
@@ -126,7 +126,7 @@ PixelInputType main(ConstantOutputType input, float3 uvwCoord : SV_DomainLocatio
//Out.EyeVec = normalize(xCamPos.xyz - vertexPosition.xyz);
Out.vel = vertexVel;
//Out.vel = vertexVel;
//Out.vel += (Out.pos.xyz-mul(vertexPosition,xPrevViewProjection).xyz)*0.10;
//Out.mat = mat;
+1 -1
View File
@@ -6,9 +6,9 @@ struct PixelInputType
float3 nor : NORMAL;
float4 pos2D : SCREENPOSITION;
float3 pos3D : WORLDPOSITION;
float4 pos2DPrev : SCREENPOSITIONPREV;
float3 cam : CAMERAPOS;
float4 ReflectionMapSamplingPos : TEXCOORD1;
float3 vel : TEXCOORD2;
float ao : AMBIENT_OCCLUSION;
float dither : DITHER;
float3 instanceColor : INSTANCECOLOR;
+1
View File
@@ -4,6 +4,7 @@
cbuffer staticBuffer:register(b0){
float4x4 xViewProjection;
float4x4 xRefViewProjection;
float4x4 xPrevViewProjection;
float4 xCamPos;
float4 xClipPlane;
float3 xWind; float time;
+8 -4
View File
@@ -16,9 +16,11 @@ PixelOutputType main(PixelInputType PSIn)
float depth = PSIn.pos.z/PSIn.pos.w;
float3 eyevector = normalize(PSIn.cam - PSIn.pos3D);
//float2 ScreenCoord;
//ScreenCoord.x = PSIn.pos2D.x / PSIn.pos2D.w / 2.0f + 0.5f;
//ScreenCoord.y = -PSIn.pos2D.y / PSIn.pos2D.w / 2.0f + 0.5f;
float2 ScreenCoord, ScreenCoordPrev;
ScreenCoord.x = PSIn.pos2D.x / PSIn.pos2D.w / 2.0f + 0.5f;
ScreenCoord.y = -PSIn.pos2D.y / PSIn.pos2D.w / 2.0f + 0.5f;
ScreenCoordPrev.x = PSIn.pos2DPrev.x / PSIn.pos2DPrev.w / 2.0f + 0.5f;
ScreenCoordPrev.y = -PSIn.pos2DPrev.y / PSIn.pos2DPrev.w / 2.0f + 0.5f;
PSIn.tex+=movingTex;
@@ -88,10 +90,12 @@ PixelOutputType main(PixelInputType PSIn)
bool unshaded = shadeless||colorMask.a;
float properties = unshaded ? RT_UNSHADED : toonshaded ? RT_TOON : 0.0f;
float2 vel = ScreenCoord - ScreenCoordPrev;
Out.col = float4((baseColor.rgb+colorMask.rgb)*(1+emit)*PSIn.ao,1);
Out.nor = float4((normal.xyz),properties);
Out.vel = float4(PSIn.vel.xy*float2(-1,1),specular_power,spec.a);
Out.vel = float4(/*PSIn.vel.xy*float2(-1,1)*/ vel,specular_power,spec.a);
return Out;
+1 -1
View File
@@ -53,7 +53,7 @@ HullInputType main(Input input)
Out.pos=pos.xyz;
Out.tex=input.tex.xyz;
Out.nor = normalize(normal);
Out.vel = mul( mul(vel.xyz,(float3x3)WORLD), xViewProjection ).xyz;
//Out.vel = mul( mul(vel.xyz,(float3x3)WORLD), xViewProjection ).xyz;
}
+9 -5
View File
@@ -24,15 +24,18 @@ PixelInputType main(Input input)
float4 pos = input.pos;
float4 posPrev = input.pre;
float4 vel = float4(0,0,0,1);
//float4 vel = float4(0,0,0,1);
pos = mul( pos,WORLD );
if(posPrev.w){
posPrev = mul( posPrev,WORLD );
vel = pos - posPrev;
[branch]
if (posPrev.w){
posPrev = mul(posPrev, WORLD);
//vel = pos - posPrev;
}
else
posPrev = pos;
Out.clip = dot(pos, xClipPlane);
@@ -46,6 +49,7 @@ PixelInputType main(Input input)
//}
Out.pos = Out.pos2D = mul( pos, xViewProjection );
Out.pos2DPrev = mul(posPrev, xPrevViewProjection);
Out.pos3D = pos.xyz;
Out.cam = xCamPos.xyz;
Out.tex = input.tex.xy;
@@ -55,7 +59,7 @@ PixelInputType main(Input input)
Out.ReflectionMapSamplingPos = mul(pos, xRefViewProjection );
Out.vel = mul( vel.xyz, xViewProjection ).xyz;
//Out.vel = mul( vel.xyz, xViewProjection ).xyz;
Out.ao = input.nor.w;
+3
View File
@@ -23,10 +23,13 @@ struct QGS_OUT
float3 nor : NORMAL;
float2 tex : TEXCOORD;
float fade : DITHERFADE;
float4 pos2D : SCREENPOSITION;
float4 pos2DPrev : SCREENPOSITIONPREV;
};
cbuffer cbgs:register(b0){
float4x4 xView;
float4x4 xProjection;
float4x4 xPrevViewProjection;
float4 colTime;
float3 eye;
float drawdistance;
+1
View File
@@ -2,6 +2,7 @@ struct PS_OUT
{
float4 col : SV_TARGET0;
float4 nor : SV_TARGET1;
float4 vel : SV_TARGET2;
//float4 spe : SV_TARGET2;
//float4 mat : SV_TARGET3;
};
+5 -13
View File
@@ -4,23 +4,15 @@ float4 main(VertextoPixel PSIn) : SV_TARGET
{
float3 color = float3(0,0,0);
float numSampling = 0.0f;
float2 depthMapSize;
xSceneDepthMap.GetDimensions(depthMapSize.x,depthMapSize.y);
float depth = ( xSceneDepthMap.Load(int4(depthMapSize*PSIn.tex.xy,0,0)).r );
float2 vel = xSceneVelocityMap.SampleLevel(Sampler,PSIn.tex,0).xy/xDimension.xy*50
/ depth;
float2 vel = xSceneVelocityMap.SampleLevel(Sampler, PSIn.tex, 0).xy / xDimension.xy * 50;
numSampling++;
//if(vel.x || vel.y) //BLUR PHASE
for(float i=0;i<=5;i+=0.5){
color.rgb += xTexture.SampleLevel(Sampler,PSIn.tex+vel*i,0).rgb;
numSampling++;
}
for(float i=0;i<=5;i+=0.5){
color.rgb += xTexture.SampleLevel(Sampler,PSIn.tex+vel*i,0).rgb;
numSampling++;
}
return float4(color/numSampling,1);
}
+30 -14
View File
@@ -34,25 +34,33 @@ void main(
element.tex=float2(0,0);
element.pos=pos;
element.pos.xyz+=-right*frame.x+normal*frame.y+wind;
element.pos = mul(element.pos,xViewProjection);
float4 savedPos = element.pos;
element.pos = element.pos2D = mul(element.pos, xViewProjection);
element.pos2DPrev = mul(savedPos, xPrevViewProjection);
output.Append(element);
element.tex=float2(1,0);
element.pos=pos;
element.pos.xyz+=right*frame.x+normal*frame.y+wind;
element.pos = mul(element.pos,xViewProjection);
savedPos = element.pos;
element.pos = element.pos2D = mul(element.pos, xViewProjection);
element.pos2DPrev = mul(savedPos, xPrevViewProjection);
output.Append(element);
element.tex=float2(0,1);
element.pos=pos;
element.pos.xyz+=-right*frame.x;
element.pos = mul(element.pos,xViewProjection);
element.pos.xyz += -right*frame.x;
savedPos = element.pos;
element.pos = element.pos2D = mul(element.pos, xViewProjection);
element.pos2DPrev = mul(savedPos, xPrevViewProjection);
output.Append(element);
element.tex=float2(1,1);
element.pos=pos;
element.pos.xyz+=right*frame.x;
element.pos = mul(element.pos,xViewProjection);
element.pos.xyz += right*frame.x;
savedPos = element.pos;
element.pos = element.pos2D = mul(element.pos, xViewProjection);
element.pos2DPrev = mul(savedPos, xPrevViewProjection);
output.Append(element);
output.RestartStrip();
@@ -61,25 +69,33 @@ void main(
element.tex=float2(0,0);
element.pos=pos;
element.pos.xyz+=-front*frame.x+normal*frame.y+wind;
element.pos = mul(element.pos,xViewProjection);
element.pos.xyz += -front*frame.x + normal*frame.y + wind;
savedPos = element.pos;
element.pos = element.pos2D = mul(element.pos, xViewProjection);
element.pos2DPrev = mul(savedPos, xPrevViewProjection);
output.Append(element);
element.tex=float2(1,0);
element.pos=pos;
element.pos.xyz+=front*frame.x+normal*frame.y+wind;
element.pos = mul(element.pos,xViewProjection);
element.pos.xyz += front*frame.x + normal*frame.y + wind;
savedPos = element.pos;
element.pos = element.pos2D = mul(element.pos, xViewProjection);
element.pos2DPrev = mul(savedPos, xPrevViewProjection);
output.Append(element);
element.tex=float2(0,1);
element.pos=pos;
element.pos.xyz+=-front*frame.x;
element.pos = mul(element.pos,xViewProjection);
element.pos.xyz += -front*frame.x;
savedPos = element.pos;
element.pos = element.pos2D = mul(element.pos, xViewProjection);
element.pos2DPrev = mul(savedPos, xPrevViewProjection);
output.Append(element);
element.tex=float2(1,1);
element.pos=pos;
element.pos.xyz+=front*frame.x;
element.pos = mul(element.pos,xViewProjection);
element.pos.xyz += front*frame.x;
savedPos = element.pos;
element.pos = element.pos2D = mul(element.pos, xViewProjection);
element.pos2DPrev = mul(savedPos, xPrevViewProjection);
output.Append(element);
}
+14 -6
View File
@@ -42,24 +42,32 @@ void main(
element.tex=float2(rand%2?1:0,0);
element.pos=pos;
element.pos.xyz+=-right*frame.x+normal*frame.y+wind;
element.pos = mul(element.pos,xViewProjection);
float4 savedPos = element.pos;
element.pos = element.pos2D = mul(element.pos,xViewProjection);
element.pos2DPrev = mul(savedPos, xPrevViewProjection);
output.Append(element);
element.tex=float2(rand%2?0:1,0);
element.pos=pos;
element.pos.xyz+=right*frame.x+normal*frame.y+wind;
element.pos = mul(element.pos,xViewProjection);
savedPos = element.pos;
element.pos = element.pos2D = mul(element.pos, xViewProjection);
element.pos2DPrev = mul(savedPos, xPrevViewProjection);
output.Append(element);
element.tex=float2(rand%2?1:0,1);
element.pos=pos;
element.pos.xyz+=-right*frame.x;
element.pos = mul(element.pos,xViewProjection);
element.pos.xyz += -right*frame.x;
savedPos = element.pos;
element.pos = element.pos2D = mul(element.pos, xViewProjection);
element.pos2DPrev = mul(savedPos, xPrevViewProjection);
output.Append(element);
element.tex=float2(rand%2?0:1,1);
element.pos=pos;
element.pos.xyz+=right*frame.x;
element.pos = mul(element.pos,xViewProjection);
element.pos.xyz += right*frame.x;
savedPos = element.pos;
element.pos = element.pos2D = mul(element.pos, xViewProjection);
element.pos2DPrev = mul(savedPos, xPrevViewProjection);
output.Append(element);
}
+8
View File
@@ -10,11 +10,19 @@ PS_OUT main(QGS_OUT PSIn)
clip(dither(PSIn.pos.xy) - PSIn.fade);
#endif
float2 ScreenCoord, ScreenCoordPrev;
ScreenCoord.x = PSIn.pos2D.x / PSIn.pos2D.w / 2.0f + 0.5f;
ScreenCoord.y = -PSIn.pos2D.y / PSIn.pos2D.w / 2.0f + 0.5f;
ScreenCoordPrev.x = PSIn.pos2DPrev.x / PSIn.pos2DPrev.w / 2.0f + 0.5f;
ScreenCoordPrev.y = -PSIn.pos2DPrev.y / PSIn.pos2DPrev.w / 2.0f + 0.5f;
float2 vel = ScreenCoord - ScreenCoordPrev;
PS_OUT Out = (PS_OUT)0;
float4 col = xTexture.Sample(xSampler,PSIn.tex);
clip( col.a < 0.1 ? -1:1 );
Out.col = float4(col.rgb,1);
Out.nor = float4(PSIn.nor,0);
Out.vel = float4(vel,0,0);
//Out.spe = float4(PSIn.col,0.1f);
return Out;
}
+25 -3
View File
@@ -4,12 +4,28 @@
struct VSOut{
float4 pos : SV_POSITION;
float3 nor : TEXCOORD0;
float4 pos2D : SCREENPOSITION;
float4 pos2DPrev : SCREENPOSITIONPREV;
};
float4 main(VSOut PSIn):SV_TARGET
struct PSOut{
float4 col : SV_TARGET0;
float4 nor : SV_TARGET1;
float4 vel : SV_TARGET2;
};
PSOut main(VSOut PSIn)
{
float2 ScreenCoord, ScreenCoordPrev;
ScreenCoord.x = PSIn.pos2D.x / PSIn.pos2D.w / 2.0f + 0.5f;
ScreenCoord.y = -PSIn.pos2D.y / PSIn.pos2D.w / 2.0f + 0.5f;
ScreenCoordPrev.x = PSIn.pos2DPrev.x / PSIn.pos2DPrev.w / 2.0f + 0.5f;
ScreenCoordPrev.y = -PSIn.pos2DPrev.y / PSIn.pos2DPrev.w / 2.0f + 0.5f;
float2 vel = ScreenCoord - ScreenCoordPrev;
static const float overBright = 1.005f;
float3 nor = normalize(PSIn.nor)*overBright;
float3 inNor = normalize(PSIn.nor);
float3 nor = inNor*overBright;
float3 sun = 0;
float3 col = 0;
[branch]if(xFx.x==0){
@@ -19,7 +35,13 @@ float4 main(VSOut PSIn):SV_TARGET
else{
sun = clamp(pow(dot(xSun,nor),64)*xSunColor.rgb, 0, inf);
}
return float4( col+sun ,1);
//return float4( col+sun ,1);
PSOut Out = (PSOut)0;
Out.col = float4(col + sun, 1);
Out.nor = float4(inNor,0);
Out.vel = float4(vel, 0, 0);
return Out;
}
//struct VSOut{
+6 -2
View File
@@ -3,19 +3,23 @@
cbuffer skyCB:register(b3){
float4x4 xV;
float4x4 xP;
float4 xSun;
float4x4 xPrevView;
float4x4 xPrevProjection;
}
struct VSOut{
float4 pos : SV_POSITION;
float3 nor : TEXCOORD0;
float4 pos2D : SCREENPOSITION;
float4 pos2DPrev : SCREENPOSITIONPREV;
};
VSOut main(uint vid : SV_VERTEXID)
{
VSOut Out = (VSOut)0;
Out.pos=mul(mul(float4(ICOSPHERE[vid],1),(float3x3)xV),xP);
Out.pos=Out.pos2D=mul(mul(float4(ICOSPHERE[vid],1),(float3x3)xV),xP);
Out.nor=ICOSPHERE[vid];
Out.pos2DPrev = mul(mul(float4(ICOSPHERE[vid], 1), (float3x3)xPrevView), xPrevProjection);
return Out;
}
+3 -18
View File
@@ -129,26 +129,11 @@ float4 main( VertextoPixel input ) : SV_Target
* saturate( ( g_fSearchDist - length( vViewPos - vHitPos ) ) * g_fSearchDistInv ) //reflected object distance fade
* vCoords.w //rayhit binary fade
;
//float3 vReflectionColor = loadScene(vCoords.xy).rgb;
//float3 vReflectionColor=0;
float3 vReflectionColor = xTexture.SampleLevel(Sampler, vCoords.xy, 3).rgb;
float3 vSceneColor = xTexture.Load(int3(input.pos.x,input.pos.y,0)).rgb;
//static const float range = 2.5f;
//float2 dim;
//xTexture.GetDimensions(dim.x, dim.y);
//dim /= 2.f;
//float samples = 0;
//for (float x = -range; x <= range; x += 1.f){
// for (float y = -range; y <= range; y += 1.f){
// vReflectionColor += xTexture.SampleLevel(Sampler, vCoords.xy+float2(x,y)/dim, 4);
// samples += 1.f;
// }
//}
//vReflectionColor /= samples;
float3 vReflectionColor = xTexture.SampleLevel(Sampler, vCoords.xy, 3);
o = float4(vReflectionColor, fReflectionIntensity);
o = float4(lerp(vSceneColor, vReflectionColor, fReflectionIntensity), 1);
return o;
+2
View File
@@ -44,6 +44,8 @@ private:
XMMATRIX mProjection;
XMVECTOR mCamPos;
XMFLOAT4 mAdd;
ALIGN_16
};
ID3D11Buffer *vertexBuffer;
static ID3D11InputLayout *vertexLayout;
+1
View File
@@ -484,6 +484,7 @@ void wiHairParticle::Draw(Camera* camera, ID3D11DeviceContext *context)
CBGS gcb;
gcb.mView = XMMatrixTranspose(camera->GetView());
gcb.mProj = XMMatrixTranspose(camera->GetProjection());
gcb.mPrevViewProjection = XMMatrixTranspose(wiRenderer::prevFrameCam->GetViewProjection());
gcb.colTime=XMFLOAT4(material->diffuseColor.x,material->diffuseColor.y,material->diffuseColor.z,wiRenderer::wind.time);
gcb.eye=camera->translation;
gcb.drawdistance = (float)LOD[2];
+3
View File
@@ -33,12 +33,15 @@ private:
{
XMMATRIX mView;
XMMATRIX mProj;
XMMATRIX mPrevViewProjection;
XMFLOAT4 colTime;
XMFLOAT3 eye; float drawdistance;
XMFLOAT3 wind; float pad;
float windRandomness;
float windWaveSize;
float padding[2];
ALIGN_16
};
static ID3D11InputLayout* il;
static ID3D11VertexShader* vs;
+1 -1
View File
@@ -552,7 +552,7 @@ void wiImage::DrawDeferred(wiRenderer::TextureView texture
wiRenderer::BindPrimitiveTopology(wiRenderer::PRIMITIVETOPOLOGY::TRIANGLESTRIP,context);
wiRenderer::BindRasterizerState(rasterizerState,context);
wiRenderer::BindDepthStencilState(depthStencilStateLess,stencilRef,context);
wiRenderer::BindDepthStencilState(depthNoStencilState,stencilRef,context);
//context->VSSetShader(screenVS,0,0);
//context->PSSetShader(deferredPS,0,0);
+7 -27
View File
@@ -68,7 +68,7 @@ float wiRenderer::GameSpeed=1,wiRenderer::overrideGameSpeed=1;
int wiRenderer::visibleCount;
float wiRenderer::shBias;
wiRenderTarget wiRenderer::normalMapRT, wiRenderer::imagesRT, wiRenderer::imagesRTAdd;
Camera *wiRenderer::cam = nullptr, *wiRenderer::refCam = nullptr;
Camera *wiRenderer::cam = nullptr, *wiRenderer::refCam = nullptr, *wiRenderer::prevFrameCam = nullptr;
PHYSICS* wiRenderer::physicsEngine = nullptr;
Wind wiRenderer::wind;
WorldInfo wiRenderer::worldInfo;
@@ -397,6 +397,7 @@ void wiRenderer::SetUpStaticComponents()
cam->SetUp(SCREENWIDTH, SCREENHEIGHT, 0.1f, 800);
refCam = new Camera();
refCam->SetUp(SCREENWIDTH, SCREENHEIGHT, 0.1f, 800);
prevFrameCam = new Camera;
noiseTex = wiTextureHelper::getInstance()->getRandom64x64();
trailDistortTex = wiTextureHelper::getInstance()->getNormalMapDefault();
@@ -1868,6 +1869,7 @@ XMFLOAT3 wiRenderer::VertexVelocity(const Mesh* mesh, const int& vertexI){
}
void wiRenderer::Update(float amount)
{
*prevFrameCam = *cam;
cam->Update();
refCam->Reflect(cam);
@@ -3432,30 +3434,16 @@ void wiRenderer::DrawSky(ID3D11DeviceContext* context)
if (enviroMap == nullptr)
return;
//context->IASetPrimitiveTopology( D3D11_PRIMITIVE_TOPOLOGY_TRIANGLELIST );
BindPrimitiveTopology(TRIANGLELIST,context);
//context->RSSetState(backFaceRS);
//context->OMSetDepthStencilState(depthReadStencilState, STENCILREF_SKY);
//float blendFactor[4] = { 0.0f, 0.0f, 0.0f, 0.0f };
//UINT sampleMask = 0xffffffff;
//context->OMSetBlendState(blendState, blendFactor, sampleMask);
BindRasterizerState(backFaceRS,context);
BindDepthStencilState(depthReadStencilState,STENCILREF_SKY,context);
BindBlendState(blendState,context);
//context->VSSetShader( skyVS, NULL, 0 );
//context->PSSetShader( skyPS, NULL, 0 );
BindVS(skyVS,context);
BindPS(skyPS,context);
BindTexturePS(enviroMap,0,context);
//context->PSSetSamplers(0, 1, &skySampler);
BindSamplerPS(skySampler,0,context);
//context->VSSetConstantBuffers( 3, 1, &skyCb );
//context->PSSetConstantBuffers( 0, 1, &pixelCB );
//context->Draw(240,0);
BindConstantBufferVS(skyCb,3,context);
BindConstantBufferPS(pixelCB,0,context);
@@ -3552,17 +3540,6 @@ void wiRenderer::UpdatePerRenderCB(ID3D11DeviceContext* context, int tessF){
UpdateBuffer(tessBuf,&tb,context);
}
//D3D11_MAPPED_SUBRESOURCE mappedResource;
//if(tessF){
// TessBuffer tb;
// tb.g_f4Eye = wiRenderer::getCamera()->Eye;
// tb.g_f4TessFactors = XMFLOAT4A( tessF,2,4,6 );
// TessBuffer* dataPtr;
// context->Map(tessBuf,0,D3D11_MAP_WRITE_DISCARD,0,&mappedResource);
// dataPtr = (TessBuffer*)mappedResource.pData;
// memcpy(dataPtr,&tb,sizeof(TessBuffer));
// context->Unmap(tessBuf,0);
//}
}
void wiRenderer::UpdatePerViewCB(ID3D11DeviceContext* context, Camera* camera, Camera* refCamera, const XMFLOAT4& newClipPlane){
@@ -3570,6 +3547,7 @@ void wiRenderer::UpdatePerViewCB(ID3D11DeviceContext* context, Camera* camera, C
StaticCB cb;
cb.mViewProjection = XMMatrixTranspose(camera->GetViewProjection());
cb.mRefViewProjection = XMMatrixTranspose( refCamera->GetViewProjection());
cb.mPrevViewProjection = XMMatrixTranspose(prevFrameCam->GetViewProjection());
cb.mCamPos = camera->GetEye();
cb.mClipPlane = newClipPlane;
cb.mWind=wind.direction;
@@ -3580,7 +3558,9 @@ void wiRenderer::UpdatePerViewCB(ID3D11DeviceContext* context, Camera* camera, C
SkyBuffer scb;
scb.mV=XMMatrixTranspose(camera->GetView());
scb.mP=XMMatrixTranspose(camera->GetProjection());
scb.mP = XMMatrixTranspose(camera->GetProjection());
scb.mPrevView = XMMatrixTranspose(prevFrameCam->GetView());
scb.mPrevProjection = XMMatrixTranspose(prevFrameCam->GetProjection());
UpdateBuffer(skyCb,&scb,context);
UpdateBuffer(trailCB, &XMMatrixTranspose(camera->GetViewProjection()), context);
+4 -1
View File
@@ -150,6 +150,7 @@ protected:
{
XMMATRIX mViewProjection;
XMMATRIX mRefViewProjection;
XMMATRIX mPrevViewProjection;
XMVECTOR mCamPos;
//XMFLOAT4A mMotionBlur;
XMFLOAT4 mClipPlane;
@@ -268,6 +269,8 @@ protected:
{
XMMATRIX mV;
XMMATRIX mP;
XMMATRIX mPrevView;
XMMATRIX mPrevProjection;
ALIGN_16
};
@@ -1086,7 +1089,7 @@ public:
static wiRenderTarget normalMapRT, imagesRT, imagesRTAdd;
static Camera* cam, *refCam;
static Camera* cam, *refCam, *prevFrameCam;
static Camera* getCamera(){ return cam; }
static Camera* getRefCamera(){ return refCam; }