Constant buffer refactor - part4

This commit is contained in:
turanszkij
2016-01-28 18:43:40 +01:00
parent c5faed2c58
commit d9a3a17cf4
14 changed files with 127 additions and 110 deletions
+1 -8
View File
@@ -119,7 +119,6 @@ void DeferredRenderableComponent::RenderScene(DeviceContext context){
if (getSSAOEnabled()){
//wiImage::BatchBegin(context, STENCILREF_DEFAULT);
fx.stencilRef = STENCILREF_DEFAULT;
fx.stencilComp = D3D11_COMPARISON_LESS;
rtSSAO[0].Activate(context); {
@@ -127,11 +126,9 @@ void DeferredRenderableComponent::RenderScene(DeviceContext context){
fx.setDepthMap(rtLinearDepth.shaderResource.back());
fx.setNormalMap(rtGBuffer.shaderResource[1]);
fx.setMaskMap(wiTextureHelper::getInstance()->getRandom64x64());
//fx.sampleFlag=SAMPLEMODE_CLAMP;
fx.quality = QUALITY_BILINEAR;
fx.sampleFlag = SAMPLEMODE_MIRROR;
wiImage::Draw(nullptr, fx, context);
//fx.sampleFlag=SAMPLEMODE_CLAMP;
fx.process.clear();
}
rtSSAO[1].Activate(context); {
@@ -164,7 +161,7 @@ void DeferredRenderableComponent::RenderScene(DeviceContext context){
if (getSSSEnabled())
{
//wiImage::BatchBegin(context, STENCILREF_SKIN);
wiRenderer::UnbindTextures(0, 16, context);
fx.stencilRef = STENCILREF_SKIN;
fx.stencilComp = D3D11_COMPARISON_LESS;
fx.quality = QUALITY_BILINEAR;
@@ -186,14 +183,12 @@ void DeferredRenderableComponent::RenderScene(DeviceContext 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;
fx.stencilRef = 0;
fx.stencilComp = 0;
wiImage::Draw(rtDeferred.shaderResource.front(), fx, context);
//wiImage::BatchBegin(context, STENCILREF_SKIN);
fx.stencilRef = STENCILREF_SKIN;
fx.stencilComp = D3D11_COMPARISON_LESS;
wiImage::Draw(rtSSS[rtSSS.size() - 2].shaderResource.back(), fx, context);
@@ -205,7 +200,6 @@ void DeferredRenderableComponent::RenderScene(DeviceContext context){
if (getSSREnabled()){
rtSSR.Activate(context); {
//wiImage::BatchBegin(context);
context->GenerateMips(rtDeferred.shaderResource[0]);
fx.process.setSSR(true);
fx.setDepthMap(dtDepthCopy.shaderResource);
@@ -221,7 +215,6 @@ void DeferredRenderableComponent::RenderScene(DeviceContext context){
}
if (getMotionBlurEnabled()){ //MOTIONBLUR
//wiImage::BatchBegin(context);
rtMotionBlur.Activate(context);
fx.process.setMotionBlur(true);
fx.setVelocityMap(rtGBuffer.shaderResource.back());
+2 -1
View File
@@ -221,7 +221,7 @@ void Renderable3DComponent::RenderReflections(DeviceContext context){
wiRenderer::DrawWorld(wiRenderer::getRefCamera(), false, 0, context
, false, true, SHADERTYPE_NONE
, nullptr, getHairParticlesReflectionEnabled(), GRAPHICSTHREAD_REFLECTIONS);
wiRenderer::DrawSky(context);
wiRenderer::DrawSky(context,true);
}
}
void Renderable3DComponent::RenderShadows(DeviceContext context){
@@ -424,6 +424,7 @@ void Renderable3DComponent::RenderColorGradedComposition(){
}
}
wiImage::Draw(rtFinal[1].shaderResource.back(), fx);
}
+29
View File
@@ -861,6 +861,7 @@
<None Include="reconstructPositionHF.hlsli" />
<None Include="samplersHF.hlsli" />
<None Include="skinningHF.hlsli" />
<None Include="skyHF.hlsli" />
<None Include="sOHF.hlsli" />
<None Include="specularHF.hlsli" />
<None Include="spotLightHF.hlsli" />
@@ -1961,6 +1962,20 @@
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='WinRT|Win32'">
</ExcludedFromBuild>
</FxCompile>
<FxCompile Include="skyPS_reflection.hlsl">
<ShaderType Condition="'$(Configuration)|$(Platform)'=='WinRT|Win32'">Pixel</ShaderType>
<ShaderType Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">Pixel</ShaderType>
<ShaderType Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">Pixel</ShaderType>
<ShaderType Condition="'$(Configuration)|$(Platform)'=='Release_RT|Win32'">Pixel</ShaderType>
<ObjectFileOutput Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">shaders/%(Filename).cso</ObjectFileOutput>
<ObjectFileOutput Condition="'$(Configuration)|$(Platform)'=='Release_RT|Win32'">shaders/%(Filename).cso</ObjectFileOutput>
<ObjectFileOutput Condition="'$(Configuration)|$(Platform)'=='WinRT|Win32'">shaders/%(Filename).cso</ObjectFileOutput>
<ObjectFileOutput Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">shaders/%(Filename).cso</ObjectFileOutput>
<ShaderModel Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">4.1</ShaderModel>
<ShaderModel Condition="'$(Configuration)|$(Platform)'=='Release_RT|Win32'">4.1</ShaderModel>
<ShaderModel Condition="'$(Configuration)|$(Platform)'=='WinRT|Win32'">4.1</ShaderModel>
<ShaderModel Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">4.1</ShaderModel>
</FxCompile>
<FxCompile Include="skyVS.hlsl">
<ShaderModel Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">4.1</ShaderModel>
<ObjectFileOutput Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">shaders/%(Filename).cso</ObjectFileOutput>
@@ -1980,6 +1995,20 @@
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='WinRT|Win32'">
</ExcludedFromBuild>
</FxCompile>
<FxCompile Include="skyVS_reflection.hlsl">
<ShaderType Condition="'$(Configuration)|$(Platform)'=='WinRT|Win32'">Vertex</ShaderType>
<ShaderType Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">Vertex</ShaderType>
<ShaderType Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">Vertex</ShaderType>
<ShaderType Condition="'$(Configuration)|$(Platform)'=='Release_RT|Win32'">Vertex</ShaderType>
<ObjectFileOutput Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">shaders/%(Filename).cso</ObjectFileOutput>
<ObjectFileOutput Condition="'$(Configuration)|$(Platform)'=='Release_RT|Win32'">shaders/%(Filename).cso</ObjectFileOutput>
<ObjectFileOutput Condition="'$(Configuration)|$(Platform)'=='WinRT|Win32'">shaders/%(Filename).cso</ObjectFileOutput>
<ObjectFileOutput Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">shaders/%(Filename).cso</ObjectFileOutput>
<ShaderModel Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">4.1</ShaderModel>
<ShaderModel Condition="'$(Configuration)|$(Platform)'=='Release_RT|Win32'">4.1</ShaderModel>
<ShaderModel Condition="'$(Configuration)|$(Platform)'=='WinRT|Win32'">4.1</ShaderModel>
<ShaderModel Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">4.1</ShaderModel>
</FxCompile>
<FxCompile Include="sOGS.hlsl">
<ShaderModel Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">4.1</ShaderModel>
<ShaderModel Condition="'$(Configuration)|$(Platform)'=='Release_RT|Win32'">4.1</ShaderModel>
@@ -1901,6 +1901,9 @@
<None Include="globals.hlsli">
<Filter>shaders</Filter>
</None>
<None Include="skyHF.hlsli">
<Filter>shaders</Filter>
</None>
</ItemGroup>
<ItemGroup>
<Text Include="..\features.txt" />
@@ -2136,6 +2139,12 @@
<FxCompile Include="effectVS_reflection.hlsl">
<Filter>shaders</Filter>
</FxCompile>
<FxCompile Include="skyVS_reflection.hlsl">
<Filter>shaders</Filter>
</FxCompile>
<FxCompile Include="skyPS_reflection.hlsl">
<Filter>shaders</Filter>
</FxCompile>
</ItemGroup>
<ItemGroup>
<Image Include="fonts\basic.dds">
+9 -2
View File
@@ -13,8 +13,14 @@ VertextoPixel main(uint vI : SV_VERTEXID)
if (xMirror<0)
inTex.x = 1 - inTex.x;
inPos.x -= xDimensions.x*0.5f;
inPos.y += xDimensions.y*0.5f;
if (!xPivot) {//upperleft pivot
inPos.x-=xDimensions.x*0.5f;
inPos.y+=xDimensions.y*0.5f;
}
else if(xPivot==1){//center pivot
inPos.x-=xDimensions.z*0.5f;
inPos.y+=xDimensions.w*0.5f;
}
if(inTex.x==1) inPos.x+=xDimensions.z*xMirror;
if(inTex.y==1) inPos.y-=xDimensions.w;
@@ -22,6 +28,7 @@ VertextoPixel main(uint vI : SV_VERTEXID)
Out.tex.xy = inTex;
////if(xDrawRec.x==0 && xDrawRec.y==0 && xDrawRec.z==0 && xDrawRec.w==0){
//// if(!xPivot){//upperleft pivot
//// inPos.x-=xDimensions.x*0.5f;
+19
View File
@@ -0,0 +1,19 @@
#ifndef _SKY_HF_
#define _SKY_HF_
#include "globals.hlsli"
#include "effectHF_PS.hlsli"
inline float4 GetSkyColor(in float3 normal)
{
static const float overBright = 1.005f;
normal = normalize(normal) * overBright;
float3 col = /*lerp( xHorizon.rgb,*/ enviroTex.SampleLevel(texSampler, normal, 0).rgb/*, saturate(nor.y/0.3f) )*/;
float3 sun = max(pow(abs(dot(g_xWorld_SunDir.xyz, normal)), 256)*g_xWorld_SunColor.rgb, 0);
return float4(col + sun, 1);
}
#endif // _SKY_HF_
+3 -82
View File
@@ -1,6 +1,5 @@
#include "effectHF_PS.hlsli"
#include "globalsHF.hlsli"
#include "globals.hlsli"
#include "skyHF.hlsli"
struct VSOut{
float4 pos : SV_POSITION;
@@ -24,87 +23,9 @@ PSOut main(VSOut PSIn)
ScreenCoordPrev.y = -PSIn.pos2DPrev.y / PSIn.pos2DPrev.w / 2.0f + 0.5f;
float2 vel = ScreenCoord - ScreenCoordPrev;
static const float overBright = 1.005f;
float3 inNor = normalize(PSIn.nor);
float3 nor = inNor*overBright;
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) )*/;
sun = max(pow(abs(dot(g_xWorld_SunDir.xyz,nor)),256)*g_xWorld_SunColor.rgb, 0);
//}
//else
//{
// sun = clamp(pow(abs(dot(g_xWorld_SunDir.xyz,nor)),64)*g_xWorld_SunColor.rgb, 0, inf);
//}
//return float4( col+sun ,1);
PSOut Out = (PSOut)0;
Out.col = float4(col + sun, 1);
Out.nor = float4(inNor,0);
Out.col = GetSkyColor(PSIn.nor);
Out.nor = float4(0, 0, 0, 0);
Out.vel = float4(vel, 0, 0);
return Out;
}
//struct VSOut{
// float4 pos : SV_POSITION;
// float3 tex : TEXCOORD0;
//};
//
//float4 main(VSOut PSIn):SV_TARGET
//{
// //float sun = pow( saturate( dot(PSIn.tex,normalize(xSun.xyz)) ),2 )<0.5?0:1;
// return enviroTex.Sample( texSampler,PSIn.tex );
//}
//struct VertextoPixel
//{
// float4 pos : SV_POSITION;
// float2 tex : TEXCOORD0;
// float3 Position3D : TEXCOORD1;
// //float4 SunPos : TEXCOORD2;
// float3 CamPos : TEXCOORD2;
// float AtmospherePos : TEXCOORD3;
// //float3 vel : TEXCOORD5;
//};
///*struct PixelOutputType
//{
// float4 col : SV_TARGET0;
// float4 nor : SV_TARGET1;
// float4 spe : SV_TARGET2;
// float4 vel : SV_TARGET4;
//};*/
//
///*PixelOutputType*/float4 main(VertextoPixel PSIn):SV_TARGET
//{
// /*float4 color = float4(0,0,0,1);
// if(xFx.x!=1)
// {
// float3 ref = normalize(PSIn.Position3D-PSIn.CamPos);
// color = lerp(float4(xHorizon.xyz,1), enviroTex.Sample(texSampler,ref), saturate(PSIn.AtmospherePos));
// }
//
// if(xSun.w){
// float3 lightdirection = normalize(xSun.xyz);
// float3 eyeVector = normalize(PSIn.CamPos - PSIn.Position3D);
// float spec = dot(lightdirection, eyeVector);
// spec = pow(abs(spec), (2-specular.a)*150 );
// color.rgb += (spec * xSunColor.rgb);
// }
//
// if(xFx.y==1){
// float avg=0;
// avg+=color.r; avg+=color.g; avg+=color.b; avg/=3.0f;
// color=avg;
// }
//
// if(xFx.z==1){
// color.r=1-color.r;
// color.g=1-color.g;
// color.b=1-color.b;
// }
//
// return float4(color.rgb,1);*/
//
// return enviroTex.Sample(texSampler,normalize(PSIn.Position3D-PSIn.CamPos));
//}
+11
View File
@@ -0,0 +1,11 @@
#include "skyHF.hlsli"
struct VSOut {
float4 pos : SV_POSITION;
float3 nor : TEXCOORD0;
};
float4 main(VSOut PSIn) : SV_TARGET
{
return GetSkyColor(PSIn.nor);
}
+3 -3
View File
@@ -1,5 +1,5 @@
#include "icosphere.hlsli"
#include "globals.hlsli"
#include "icosphere.hlsli"
struct VSOut{
float4 pos : SV_POSITION;
@@ -11,8 +11,8 @@ struct VSOut{
VSOut main(uint vid : SV_VERTEXID)
{
VSOut Out = (VSOut)0;
Out.pos = Out.pos2D = mul(float4(mul(ICOSPHERE[vid], (float3x3)g_xCamera_View), 0), g_xCamera_Proj);
Out.pos = Out.pos2D = mul(float4(ICOSPHERE[vid], 0), g_xCamera_VP);
Out.nor=ICOSPHERE[vid];
Out.pos2DPrev = mul(float4(mul(ICOSPHERE[vid], (float3x3)g_xCamera_PrevV), 0), g_xCamera_PrevP);
Out.pos2DPrev = mul(float4(ICOSPHERE[vid], 0), g_xCamera_PrevVP);
return Out;
}
+15
View File
@@ -0,0 +1,15 @@
#include "globals.hlsli"
#include "icosphere.hlsli"
struct VSOut {
float4 pos : SV_POSITION;
float3 nor : TEXCOORD0;
};
VSOut main(uint vid : SV_VERTEXID)
{
VSOut Out = (VSOut)0;
Out.pos = mul(float4(ICOSPHERE[vid], 0), g_xCamera_ReflVP);
Out.nor = ICOSPHERE[vid];
return Out;
}
+6 -4
View File
@@ -43,15 +43,17 @@ float4 main( PixelInputType PSIn) : SV_TARGET
}
//ENVIROMENT MAP
////ENVIROMENT MAP
//float3 ref = (reflect(-eyevector, normal));
//float3 reflectiveColor = enviroTex.Sample(texSampler,ref);
//float3 skyColor = enviroTex.Sample(texSampler,ref).rgb;
//REFLECTION
float2 RefTex;
RefTex.x = PSIn.ReflectionMapSamplingPos.x/PSIn.ReflectionMapSamplingPos.w/2.0f + 0.5f;
RefTex.y = -PSIn.ReflectionMapSamplingPos.y/PSIn.ReflectionMapSamplingPos.w/2.0f + 0.5f;
float3 reflectiveColor = xTextureRef.SampleLevel(mapSampler,RefTex+bumpColor.rg,0).rgb;
float4 reflectiveColor = xTextureRef.SampleLevel(mapSampler,RefTex+bumpColor.rg,0);
//reflectiveColor.rgb = lerp(skyColor, reflectiveColor.rgb, reflectiveColor.a);
//REFRACTION
float2 perturbatedRefrTexCoords = screenPos.xy + bumpColor.rg;
@@ -65,7 +67,7 @@ float4 main( PixelInputType PSIn) : SV_TARGET
//FRESNEL TERM
float fresnelTerm = abs(eyeDot);
baseColor.rgb = lerp(reflectiveColor, refractiveColor, fresnelTerm);
baseColor.rgb = lerp(reflectiveColor.rgb, refractiveColor, fresnelTerm);
//DULL COLOR
baseColor.rgb = lerp(baseColor.rgb, g_xMat_diffuseColor.rgb, 0.16);
+15 -5
View File
@@ -58,8 +58,8 @@ RasterizerState wiRenderer::rasterizerState, wiRenderer::rssh, wiRenderer::nonCu
,wiRenderer::backFaceRS;
DepthStencilState wiRenderer::depthStencilState,wiRenderer::xRayStencilState,wiRenderer::depthReadStencilState,wiRenderer::stencilReadState
,wiRenderer::stencilReadMatch;
PixelShader wiRenderer::skyPS, wiRenderer::sunPS;
VertexShader wiRenderer::skyVS;
PixelShader wiRenderer::skyPS, wiRenderer::skyPS_refl, wiRenderer::sunPS;
VertexShader wiRenderer::skyVS, wiRenderer::skyVS_refl;
Sampler wiRenderer::skySampler;
TextureView wiRenderer::enviroMap,wiRenderer::colorGrading;
float wiRenderer::GameSpeed=1,wiRenderer::overrideGameSpeed=1;
@@ -938,6 +938,8 @@ void wiRenderer::LoadSkyShaders()
{
skyVS = static_cast<VertexShaderInfo*>(wiResourceManager::GetShaderManager()->add(SHADERPATH + "skyVS.cso", wiResourceManager::VERTEXSHADER))->vertexShader;
skyPS = static_cast<PixelShader>(wiResourceManager::GetShaderManager()->add(SHADERPATH + "skyPS.cso", wiResourceManager::PIXELSHADER));
skyVS_refl = static_cast<VertexShaderInfo*>(wiResourceManager::GetShaderManager()->add(SHADERPATH + "skyVS_reflection.cso", wiResourceManager::VERTEXSHADER))->vertexShader;
skyPS_refl = static_cast<PixelShader>(wiResourceManager::GetShaderManager()->add(SHADERPATH + "skyPS_reflection.cso", wiResourceManager::PIXELSHADER));
sunPS = static_cast<PixelShader>(wiResourceManager::GetShaderManager()->add(SHADERPATH + "sunPS.cso", wiResourceManager::PIXELSHADER));
}
void wiRenderer::LoadShadowShaders()
@@ -3054,7 +3056,7 @@ void wiRenderer::DrawWorldTransparent(Camera* camera, TextureView refracRes, Tex
}
void wiRenderer::DrawSky(DeviceContext context)
void wiRenderer::DrawSky(DeviceContext context, bool isReflection)
{
if (enviroMap == nullptr)
return;
@@ -3064,8 +3066,16 @@ void wiRenderer::DrawSky(DeviceContext context)
BindDepthStencilState(depthReadStencilState,STENCILREF_SKY,context);
BindBlendState(blendState,context);
BindVS(skyVS,context);
BindPS(skyPS,context);
if (!isReflection)
{
BindVS(skyVS, context);
BindPS(skyPS, context);
}
else
{
BindVS(skyVS_refl, context);
BindPS(skyPS_refl, context);
}
BindTexturePS(enviroMap,0,context);
BindSamplerPS(skySampler,0,context);
+3 -3
View File
@@ -316,8 +316,8 @@ protected:
static Sampler texSampler, mapSampler, comparisonSampler, mirSampler, pointSampler;
static RasterizerState rasterizerState,rssh,nonCullRSsh,wireRS,nonCullRS,nonCullWireRS,backFaceRS;
static DepthStencilState depthStencilState,xRayStencilState,depthReadStencilState,stencilReadState,stencilReadMatch;
static PixelShader skyPS, sunPS;
static VertexShader skyVS;
static PixelShader skyPS, skyPS_refl, sunPS;
static VertexShader skyVS,skyVS_refl;
static Sampler skySampler;
static TextureView enviroMap,colorGrading;
static void LoadBuffers();
@@ -685,7 +685,7 @@ public:
static void UpdateCameraCB(DeviceContext context);
static void SetClipPlane(XMFLOAT4 clipPlane, DeviceContext context);
static void DrawSky(DeviceContext context);
static void DrawSky(DeviceContext context, bool isReflection = false);
static void DrawSun(DeviceContext context);
static void DrawWorld(Camera* camera, bool DX11Eff, int tessF, DeviceContext context
, bool BlackOut, bool isReflection, SHADERTYPE shaded, TextureView refRes, bool grass, GRAPHICSTHREAD thread);
+2 -2
View File
@@ -5,9 +5,9 @@ namespace wiVersion
// major features
const int major = 0;
// minor features, major bug fixes
const int minor = 5;
const int minor = 6;
// minor bug fixes, alterations, refactors
const int revision = 1;
const int revision = 0;
long GetVersion()