diff --git a/WickedEngine/DeferredRenderableComponent.cpp b/WickedEngine/DeferredRenderableComponent.cpp
index 27261ae00..f4a401509 100644
--- a/WickedEngine/DeferredRenderableComponent.cpp
+++ b/WickedEngine/DeferredRenderableComponent.cpp
@@ -88,7 +88,7 @@ void DeferredRenderableComponent::RenderScene(DeviceContext context){
wiRenderer::SetClipPlane(XMFLOAT4(0, 0, 0, 0), context);
- wiRenderer::DrawWorld(wiRenderer::getCamera(), wiRenderer::DX11, tessellationQuality, context, false
+ wiRenderer::DrawWorld(wiRenderer::getCamera(), wiRenderer::DX11, tessellationQuality, context, false, false
, SHADERTYPE_DEFERRED, rtReflection.shaderResource.front(), true, GRAPHICSTHREAD_SCENE);
wiRenderer::DrawSky(context);
diff --git a/WickedEngine/ForwardRenderableComponent.cpp b/WickedEngine/ForwardRenderableComponent.cpp
index 12eb622d4..68b69ee2d 100644
--- a/WickedEngine/ForwardRenderableComponent.cpp
+++ b/WickedEngine/ForwardRenderableComponent.cpp
@@ -76,7 +76,7 @@ void ForwardRenderableComponent::RenderScene(DeviceContext context)
wiRenderer::SetClipPlane(XMFLOAT4(0, 0, 0, 0), context);
wiRenderer::DrawWorld(wiRenderer::getCamera(), false, 0, context
- , false, SHADERTYPE_FORWARD_SIMPLE
+ , false, false, SHADERTYPE_FORWARD_SIMPLE
, nullptr, true, GRAPHICSTHREAD_SCENE);
wiRenderer::DrawSky(context);
wiRenderer::DrawDebugBoneLines(wiRenderer::getCamera(), context);
diff --git a/WickedEngine/Renderable3DComponent.cpp b/WickedEngine/Renderable3DComponent.cpp
index c7befe4aa..6e9732f49 100644
--- a/WickedEngine/Renderable3DComponent.cpp
+++ b/WickedEngine/Renderable3DComponent.cpp
@@ -219,7 +219,7 @@ void Renderable3DComponent::RenderReflections(DeviceContext context){
wiRenderer::SetClipPlane(water, context);
wiRenderer::DrawWorld(wiRenderer::getRefCamera(), false, 0, context
- , false, SHADERTYPE_NONE
+ , false, true, SHADERTYPE_NONE
, nullptr, getHairParticlesReflectionEnabled(), GRAPHICSTHREAD_REFLECTIONS);
wiRenderer::DrawSky(context);
}
@@ -316,7 +316,7 @@ void Renderable3DComponent::RenderLightShafts(wiRenderTarget& mainRT, DeviceCont
wiRenderer::UnbindTextures(0, 16, context);
rtSun[0].Activate(context, mainRT.depth); {
- wiRenderer::DrawSky(context);
+ wiRenderer::DrawSun(context);
}
//wiImage::BatchBegin(context);
diff --git a/WickedEngine/WickedEngine.vcxproj b/WickedEngine/WickedEngine.vcxproj
index dad607998..a7a4956f3 100644
--- a/WickedEngine/WickedEngine.vcxproj
+++ b/WickedEngine/WickedEngine.vcxproj
@@ -2108,6 +2108,21 @@
+
+ Pixel
+ Pixel
+ Pixel
+ Pixel
+ true
+ 4.1
+ 4.1
+ 4.1
+ 4.1
+ shaders/%(Filename).cso
+ shaders/%(Filename).cso
+ shaders/%(Filename).cso
+ shaders/%(Filename).cso
+
4.1
shaders/%(Filename).cso
@@ -2146,6 +2161,21 @@
+
+ Vertex
+ Vertex
+ Vertex
+ Vertex
+ 4.1
+ true
+ 4.1
+ 4.1
+ 4.1
+ shaders/%(Filename).cso
+ shaders/%(Filename).cso
+ shaders/%(Filename).cso
+ shaders/%(Filename).cso
+
shaders/%(Filename).cso
shaders/%(Filename).cso
diff --git a/WickedEngine/WickedEngine.vcxproj.filters b/WickedEngine/WickedEngine.vcxproj.filters
index 573431774..99731ea7d 100644
--- a/WickedEngine/WickedEngine.vcxproj.filters
+++ b/WickedEngine/WickedEngine.vcxproj.filters
@@ -2130,6 +2130,12 @@
shaders\image
+
+ shaders
+
+
+ shaders
+
diff --git a/WickedEngine/bloomSeparatePS.hlsl b/WickedEngine/bloomSeparatePS.hlsl
index b8e06143c..7d3b6ab61 100644
--- a/WickedEngine/bloomSeparatePS.hlsl
+++ b/WickedEngine/bloomSeparatePS.hlsl
@@ -12,5 +12,6 @@ float4 main(VertexToPixelPostProcess PSIn) : SV_TARGET
//return lerp(color,grey,xBloom.z);
- return max(xTexture.SampleLevel(Sampler,PSIn.tex,0)-1, 0);
+ return max(float4(xTexture.SampleLevel(Sampler,PSIn.tex,6).rgb-1,1), 0);
+ //return float4(0,1,0,1);
}
\ No newline at end of file
diff --git a/WickedEngine/depthofFieldPS.hlsl b/WickedEngine/depthofFieldPS.hlsl
index b273ee0d1..fe39d4db2 100644
--- a/WickedEngine/depthofFieldPS.hlsl
+++ b/WickedEngine/depthofFieldPS.hlsl
@@ -10,7 +10,7 @@ float4 main(VertexToPixelPostProcess PSIn) : SV_TARGET
color += xTexture.SampleLevel(Sampler,PSIn.tex,0);
//numSampling++;
- float targetDepth = xPPParams[2];
+ float targetDepth = xPPParams0[2];
//if(targetDepth){
float fragmentDepth = ( xSceneDepthMap.SampleLevel(Sampler,PSIn.tex,0).r );
diff --git a/WickedEngine/effectVS_reflection.hlsl b/WickedEngine/effectVS_reflection.hlsl
new file mode 100644
index 000000000..7267a727b
--- /dev/null
+++ b/WickedEngine/effectVS_reflection.hlsl
@@ -0,0 +1,60 @@
+#include "effectHF_PSVS.hlsli"
+#include "effectHF_VS.hlsli"
+
+Texture2D noiseTex:register(t0);
+SamplerState texSampler:register(s0);
+
+PixelInputType main(Input input)
+{
+ PixelInputType Out = (PixelInputType)0;
+
+
+ [branch]if ((uint)input.tex.z == g_xMat_matIndex)
+ {
+
+ float4x4 WORLD = float4x4(
+ float4(input.wi0.x, input.wi1.x, input.wi2.x, 0)
+ , float4(input.wi0.y, input.wi1.y, input.wi2.y, 0)
+ , float4(input.wi0.z, input.wi1.z, input.wi2.z, 0)
+ , float4(input.wi0.w, input.wi1.w, input.wi2.w, 1)
+ );
+
+ Out.instanceColor = input.color_dither.rgb;
+ Out.dither = input.color_dither.a;
+
+ float4 pos = input.pos;
+ float4 posPrev = input.pre;
+
+
+ pos = mul(pos, WORLD);
+
+
+ Out.clip = dot(pos, g_xClipPlane);
+
+ float3 normal = mul(normalize(input.nor.xyz), (float3x3)WORLD);
+ affectWind(pos.xyz, input.tex.w, input.id);
+
+
+ [branch]
+ if (posPrev.w) {
+ posPrev = mul(posPrev, WORLD);
+ }
+ else
+ posPrev = pos;
+
+ Out.pos = Out.pos2D = mul(pos, g_xCamera_ReflVP);
+ Out.pos2DPrev = float4(0,0,0,0);
+ Out.pos3D = pos.xyz;
+ Out.tex = input.tex.xy;
+ Out.nor = normalize(normal);
+ Out.nor2D = float3(0,0,0);
+
+
+ Out.ReflectionMapSamplingPos = float4(0,0,0,0);
+
+ Out.ao = input.nor.w;
+
+ }
+
+ return Out;
+}
\ No newline at end of file
diff --git a/WickedEngine/globals.hlsli b/WickedEngine/globals.hlsli
index 425ca87f1..4889610cf 100644
--- a/WickedEngine/globals.hlsli
+++ b/WickedEngine/globals.hlsli
@@ -12,7 +12,7 @@ CBUFFER(WorldCB, CBSLOT_RENDERER_WORLD)
float3 g_xWorld_Fog; float xPadding3_WorldCB;
float2 g_xWorld_ScreenWidthHeight;
float xPadding_WorldCB[2];
-}
+};
CBUFFER(FrameCB, CBSLOT_RENDERER_FRAME)
{
diff --git a/WickedEngine/horizontalBlurPS.hlsl b/WickedEngine/horizontalBlurPS.hlsl
index 714c342c8..4272e7259 100644
--- a/WickedEngine/horizontalBlurPS.hlsl
+++ b/WickedEngine/horizontalBlurPS.hlsl
@@ -2,17 +2,18 @@
float4 main(VertexToPixelPostProcess PSIn) : SV_TARGET
{
+ //return float4(xPPParams1[2].xxx,1);
+ //return float4(xTexture.SampleLevel(Sampler, PSIn.tex, 4).rgb,1);
float4 color = float4(0,0,0,0);
- float2 texelSize = xPPParams[7] * xPPParams[5];
- color += xTexture.SampleLevel(Sampler, PSIn.tex + float2(-4.0f, 0.0f) * texelSize, xPPParams[6]) * xPPParams[4];
- color += xTexture.SampleLevel(Sampler, PSIn.tex + float2(-3.0f, 0.0f) * texelSize, xPPParams[6]) * xPPParams[3];
- color += xTexture.SampleLevel(Sampler, PSIn.tex + float2(-2.0f, 0.0f) * texelSize, xPPParams[6]) * xPPParams[2];
- color += xTexture.SampleLevel(Sampler, PSIn.tex + float2(-1.0f, 0.0f) * texelSize, xPPParams[6]) * xPPParams[1];
- color += xTexture.SampleLevel(Sampler, PSIn.tex, xPPParams[6]) * xPPParams[0];
- color += xTexture.SampleLevel(Sampler, PSIn.tex + float2(1.0f, 0.0f) * texelSize, xPPParams[6]) * xPPParams[1];
- color += xTexture.SampleLevel(Sampler, PSIn.tex + float2(2.0f, 0.0f) * texelSize, xPPParams[6]) * xPPParams[2];
- color += xTexture.SampleLevel(Sampler, PSIn.tex + float2(3.0f, 0.0f) * texelSize, xPPParams[6]) * xPPParams[3];
- color += xTexture.SampleLevel(Sampler, PSIn.tex + float2(4.0f, 0.0f) * texelSize, xPPParams[6]) * xPPParams[4];
+ float2 texelSize = xPPParams1[3] * xPPParams1[1];
+ color += xTexture.SampleLevel(Sampler, PSIn.tex + float2(-4.0f, 0.0f) * texelSize, xPPParams1[2]) * xPPParams1[0];
+ color += xTexture.SampleLevel(Sampler, PSIn.tex + float2(-3.0f, 0.0f) * texelSize, xPPParams1[2]) * xPPParams0[3];
+ color += xTexture.SampleLevel(Sampler, PSIn.tex + float2(-2.0f, 0.0f) * texelSize, xPPParams1[2]) * xPPParams0[2];
+ color += xTexture.SampleLevel(Sampler, PSIn.tex + float2(-1.0f, 0.0f) * texelSize, xPPParams1[2]) * xPPParams0[1];
+ color += xTexture.SampleLevel(Sampler, PSIn.tex, xPPParams1[2]) * xPPParams0[0];
+ color += xTexture.SampleLevel(Sampler, PSIn.tex + float2(1.0f, 0.0f) * texelSize, xPPParams1[2]) * xPPParams0[1];
+ color += xTexture.SampleLevel(Sampler, PSIn.tex + float2(2.0f, 0.0f) * texelSize, xPPParams1[2]) * xPPParams0[2];
+ color += xTexture.SampleLevel(Sampler, PSIn.tex + float2(3.0f, 0.0f) * texelSize, xPPParams1[2]) * xPPParams0[3];
+ color += xTexture.SampleLevel(Sampler, PSIn.tex + float2(4.0f, 0.0f) * texelSize, xPPParams1[2]) * xPPParams1[0];
return color;
- //return xTexture.SampleLevel(Sampler, PSIn.tex, 0);
}
\ No newline at end of file
diff --git a/WickedEngine/imageHF.hlsli b/WickedEngine/imageHF.hlsli
index a09603f0a..5c2f468aa 100644
--- a/WickedEngine/imageHF.hlsli
+++ b/WickedEngine/imageHF.hlsli
@@ -42,11 +42,12 @@ CBUFFER(ImageCB, CBSLOT_IMAGE_IMAGE)
float xOpacity;
float xMipLevel;
float xPadding_ImageCB[2];
-}
+};
CBUFFER(PostProcessCB, CBSLOT_IMAGE_POSTPROCESS)
{
- float xPPParams[8];
+ float4 xPPParams0;
+ float4 xPPParams1;
};
#endif // _IMAGEHF_
diff --git a/WickedEngine/lightShaftPS.hlsl b/WickedEngine/lightShaftPS.hlsl
index 058136be6..dfbb677a0 100644
--- a/WickedEngine/lightShaftPS.hlsl
+++ b/WickedEngine/lightShaftPS.hlsl
@@ -11,23 +11,23 @@ float4 main(VertexToPixelPostProcess PSIn) : SV_TARGET
color += xTexture.Sample(Sampler,PSIn.tex);
numSampling++;
- [branch]if(xPPParams[4] || xPPParams[5]) //LIGHTSHAFTS
+ [branch]if(xPPParams1[0] || xPPParams1[1]) //LIGHTSHAFTS
{
- float2 lightPos = float2(xPPParams[4] / g_xWorld_ScreenWidthHeight.x, xPPParams[5] / g_xWorld_ScreenWidthHeight.y);
+ float2 lightPos = float2(xPPParams1[0] / g_xWorld_ScreenWidthHeight.x, xPPParams1[1] / g_xWorld_ScreenWidthHeight.y);
float2 deltaTexCoord = PSIn.tex - lightPos;
- deltaTexCoord *= 1.0f/NUM_SAMPLES * xPPParams[0];
+ deltaTexCoord *= 1.0f/NUM_SAMPLES * xPPParams0[0];
float illuminationDecay = 1.0f;
for( int i=0; i(wiResourceManager::GetShaderManager()->add(SHADERPATH + "effectVS.cso", wiResourceManager::VERTEXSHADER))->vertexShader;
+ vertexShaderRefl = static_cast(wiResourceManager::GetShaderManager()->add(SHADERPATH + "effectVS_reflection.cso", wiResourceManager::VERTEXSHADER))->vertexShader;
lightVS[0] = static_cast(wiResourceManager::GetShaderManager()->add(SHADERPATH + "dirLightVS.cso", wiResourceManager::VERTEXSHADER))->vertexShader;
lightVS[1] = static_cast(wiResourceManager::GetShaderManager()->add(SHADERPATH + "pointLightVS.cso", wiResourceManager::VERTEXSHADER))->vertexShader;
lightVS[2] = static_cast(wiResourceManager::GetShaderManager()->add(SHADERPATH + "spotLightVS.cso", wiResourceManager::VERTEXSHADER))->vertexShader;
@@ -937,7 +938,7 @@ void wiRenderer::LoadSkyShaders()
{
skyVS = static_cast(wiResourceManager::GetShaderManager()->add(SHADERPATH + "skyVS.cso", wiResourceManager::VERTEXSHADER))->vertexShader;
skyPS = static_cast(wiResourceManager::GetShaderManager()->add(SHADERPATH + "skyPS.cso", wiResourceManager::PIXELSHADER));
-
+ sunPS = static_cast(wiResourceManager::GetShaderManager()->add(SHADERPATH + "sunPS.cso", wiResourceManager::PIXELSHADER));
}
void wiRenderer::LoadShadowShaders()
{
@@ -1670,6 +1671,7 @@ void wiRenderer::UpdateRenderData(DeviceContext context)
if (context == nullptr)
return;
+ //UpdateWorldCB(context);
UpdateFrameCB(context);
UpdateCameraCB(context);
@@ -1696,6 +1698,8 @@ void wiRenderer::UpdateRenderData(DeviceContext context)
BindVS(sOVS, context);
BindGS(sOGS, context);
BindPS(nullptr, context);
+ BindConstantBufferVS(constantBuffers[CBTYPE_BONEBUFFER], CB_GETBINDSLOT(BoneCB), context);
+ BindConstantBufferGS(constantBuffers[CBTYPE_BONEBUFFER], CB_GETBINDSLOT(BoneCB), context);
}
// Upload bones for skinning to shader
@@ -1706,7 +1710,6 @@ void wiRenderer::UpdateRenderData(DeviceContext context)
}
UpdateBuffer(constantBuffers[CBTYPE_BONEBUFFER], bonebuf, context);
- BindConstantBufferVS(constantBuffers[CBTYPE_BONEBUFFER], CB_GETBINDSLOT(BoneCB), context);
// Do the skinning
BindVertexBuffer(mesh->meshVertBuff, 0, sizeof(SkinnedVertex), context);
@@ -2750,7 +2753,7 @@ void wiRenderer::SetSpotLightShadowProps(int shadowMapCount, int resolution)
}
void wiRenderer::DrawWorld(Camera* camera, bool DX11Eff, int tessF, DeviceContext context
- , bool BlackOut, SHADERTYPE shaded
+ , bool BlackOut, bool isReflection, SHADERTYPE shaded
, TextureView refRes, bool grass, GRAPHICSTHREAD thread)
{
CulledCollection culledRenderer;
@@ -2779,7 +2782,16 @@ void wiRenderer::DrawWorld(Camera* camera, bool DX11Eff, int tessF, DeviceContex
if(DX11Eff && tessF)
BindVS(vertexShader,context);
else
- BindVS(vertexShader10,context);
+ {
+ if (isReflection)
+ {
+ BindVS(vertexShaderRefl, context);
+ }
+ else
+ {
+ BindVS(vertexShader10, context);
+ }
+ }
if(DX11Eff && tessF)
BindHS(hullShader,context);
else
@@ -3059,8 +3071,23 @@ void wiRenderer::DrawSky(DeviceContext context)
BindSamplerPS(skySampler,0,context);
BindVertexBuffer(nullptr,0,0,context);
+ BindVertexLayout(nullptr, context);
Draw(240,context);
}
+void wiRenderer::DrawSun(DeviceContext context)
+{
+ BindPrimitiveTopology(TRIANGLELIST, context);
+ BindRasterizerState(backFaceRS, context);
+ BindDepthStencilState(depthReadStencilState, STENCILREF_SKY, context);
+ BindBlendState(blendStateAdd, context);
+
+ BindVS(skyVS, context);
+ BindPS(sunPS, context);
+
+ BindVertexBuffer(nullptr, 0, 0, context);
+ BindVertexLayout(nullptr, context);
+ Draw(240, context);
+}
void wiRenderer::DrawDecals(Camera* camera, DeviceContext context, TextureView depth)
{
@@ -3443,7 +3470,6 @@ Model* wiRenderer::LoadModel(const string& dir, const string& name, const XMMATR
Model* model = new Model;
model->LoadFromDisk(dir,name,idss.str());
- LoadWorldInfo(dir, name);
model->transform(transform);
@@ -3487,6 +3513,7 @@ Model* wiRenderer::LoadModel(const string& dir, const string& name, const XMMATR
Unlock();
+ LoadWorldInfo(dir, name);
return model;
diff --git a/WickedEngine/wiRenderer.h b/WickedEngine/wiRenderer.h
index f69bf29e7..7356bf257 100644
--- a/WickedEngine/wiRenderer.h
+++ b/WickedEngine/wiRenderer.h
@@ -305,7 +305,7 @@ protected:
};
static BufferResource constantBuffers[CBTYPE_LAST];
static BlendState blendState, blendStateTransparent, blendStateAdd;
- static VertexShader vertexShader10, vertexShader,shVS,lineVS,trailVS,waterVS
+ static VertexShader vertexShader10, vertexShader, vertexShaderRefl,shVS,lineVS,trailVS,waterVS
,lightVS[3],vSpotLightVS,vPointLightVS,cubeShVS,sOVS,decalVS;
static PixelShader pixelShader,shPS,linePS,trailPS,simplestPS,blackoutPS,textureonlyPS,waterPS,transparentPS
,lightPS[3],vLightPS,cubeShPS,decalPS,fowardSimplePS;
@@ -316,7 +316,7 @@ 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;
+ static PixelShader skyPS, sunPS;
static VertexShader skyVS;
static Sampler skySampler;
static TextureView enviroMap,colorGrading;
@@ -684,10 +684,11 @@ public:
static void UpdateFrameCB(DeviceContext context);
static void UpdateCameraCB(DeviceContext context);
static void SetClipPlane(XMFLOAT4 clipPlane, DeviceContext context);
-
+
static void DrawSky(DeviceContext context);
+ static void DrawSun(DeviceContext context);
static void DrawWorld(Camera* camera, bool DX11Eff, int tessF, DeviceContext context
- , bool BlackOut, SHADERTYPE shaded, TextureView refRes, bool grass, GRAPHICSTHREAD thread);
+ , bool BlackOut, bool isReflection, SHADERTYPE shaded, TextureView refRes, bool grass, GRAPHICSTHREAD thread);
//static void DrawForSO(DeviceContext context);
static void ClearShadowMaps(DeviceContext context);
static void DrawForShadowMap(DeviceContext context);