big visual update: ssr and ssao reprojection, enabled for all render paths; better reflection fallback system; updated lighting system; updated refractions; renderer updates; render path updates;

This commit is contained in:
turanszkij
2018-03-06 16:34:27 +00:00
parent 42089dff63
commit dd2c7d89a9
22 changed files with 145 additions and 92 deletions
+7 -3
View File
@@ -131,8 +131,8 @@ void DeferredRenderableComponent::RenderScene(GRAPHICSTHREAD threadID)
rtGBuffer.Activate(threadID, 0, 0, 0, 0);
{
wiRenderer::DrawWorld(wiRenderer::getCamera(), getTessellationEnabled(), threadID, SHADERTYPE_DEFERRED,
rtReflection.GetTexture(), nullptr, nullptr, getHairParticlesEnabled(), true);
wiRenderer::GetDevice()->BindResource(PS, getReflectionsEnabled() ? rtReflection.GetTexture() : wiTextureHelper::getInstance()->getTransparent(), TEXSLOT_RENDERABLECOMPONENT_REFLECTION, threadID);
wiRenderer::DrawWorld(wiRenderer::getCamera(), getTessellationEnabled(), threadID, SHADERTYPE_DEFERRED, getHairParticlesEnabled(), true);
}
wiRenderer::GetDevice()->TransitionBarrier(dsv, ARRAYSIZE(dsv), RESOURCE_STATE_DEPTH_WRITE, RESOURCE_STATE_COPY_SOURCE, threadID);
@@ -168,12 +168,16 @@ void DeferredRenderableComponent::RenderScene(GRAPHICSTHREAD threadID)
wiRenderer::UpdateGBuffer(rtGBuffer.GetTexture(0), rtGBuffer.GetTexture(1), rtGBuffer.GetTexture(2), rtGBuffer.GetTexture(3), nullptr, threadID);
rtLight.Activate(threadID, rtGBuffer.depth); {
wiRenderer::GetDevice()->BindResource(PS, getSSREnabled() ? rtSSR.GetTexture() : wiTextureHelper::getInstance()->getTransparent(), TEXSLOT_RENDERABLECOMPONENT_SSR, threadID);
wiRenderer::DrawLights(wiRenderer::getCamera(), threadID);
}
if (getSSAOEnabled()) {
wiRenderer::GetDevice()->UnBindResources(TEXSLOT_RENDERABLECOMPONENT_SSAO, 1, threadID);
wiRenderer::GetDevice()->EventBegin("SSAO", threadID);
fx.stencilRef = STENCILREF_DEFAULT;
fx.stencilComp = STENCILMODE_LESS;
@@ -267,6 +271,7 @@ void DeferredRenderableComponent::RenderScene(GRAPHICSTHREAD threadID)
}
if (getSSREnabled()) {
wiRenderer::GetDevice()->UnBindResources(TEXSLOT_RENDERABLECOMPONENT_SSR, 1, threadID);
wiRenderer::GetDevice()->EventBegin("SSR", threadID);
rtSSR.Activate(threadID); {
fx.process.clear();
@@ -280,7 +285,6 @@ void DeferredRenderableComponent::RenderScene(GRAPHICSTHREAD threadID)
wiRenderer::GetDevice()->EventEnd(threadID);
}
wiProfiler::GetInstance().EndRange(threadID); // Opaque Scene
}
+54 -3
View File
@@ -4,6 +4,7 @@
#include "wiImageEffects.h"
#include "wiHelper.h"
#include "wiProfiler.h"
#include "wiTextureHelper.h"
using namespace wiGraphicsTypes;
@@ -105,10 +106,14 @@ void ForwardRenderableComponent::RenderScene(GRAPHICSTHREAD threadID)
GPUResource* dsv[] = { rtMain.depth->GetTexture() };
wiRenderer::GetDevice()->TransitionBarrier(dsv, ARRAYSIZE(dsv), RESOURCE_STATE_DEPTH_READ, RESOURCE_STATE_DEPTH_WRITE, threadID);
wiImageEffects fx((float)wiRenderer::GetInternalResolution().x, (float)wiRenderer::GetInternalResolution().y);
rtMain.Activate(threadID, 0, 0, 0, 0);
{
wiRenderer::DrawWorld(wiRenderer::getCamera(), getTessellationEnabled(), threadID, SHADERTYPE_FORWARD,
rtReflection.GetTexture(), nullptr, nullptr, getHairParticlesEnabled(), true);
wiRenderer::GetDevice()->BindResource(PS, getReflectionsEnabled() ? rtReflection.GetTexture() : wiTextureHelper::getInstance()->getTransparent(), TEXSLOT_RENDERABLECOMPONENT_REFLECTION, threadID);
wiRenderer::GetDevice()->BindResource(PS, getSSAOEnabled() ? rtSSAO.back().GetTexture() : wiTextureHelper::getInstance()->getWhite(), TEXSLOT_RENDERABLECOMPONENT_SSAO, threadID);
wiRenderer::GetDevice()->BindResource(PS, getSSREnabled() ? rtSSR.GetTexture() : wiTextureHelper::getInstance()->getTransparent(), TEXSLOT_RENDERABLECOMPONENT_SSR, threadID);
wiRenderer::DrawWorld(wiRenderer::getCamera(), getTessellationEnabled(), threadID, SHADERTYPE_FORWARD, getHairParticlesEnabled(), true);
wiRenderer::DrawSky(threadID);
}
rtMain.Deactivate(threadID);
@@ -121,17 +126,63 @@ void ForwardRenderableComponent::RenderScene(GRAPHICSTHREAD threadID)
wiRenderer::GetDevice()->TransitionBarrier(dsv, ARRAYSIZE(dsv), RESOURCE_STATE_COPY_SOURCE, RESOURCE_STATE_DEPTH_READ, threadID);
rtLinearDepth.Activate(threadID); {
wiImageEffects fx;
fx.blendFlag = BLENDMODE_OPAQUE;
fx.sampleFlag = SAMPLEMODE_CLAMP;
fx.quality = QUALITY_NEAREST;
fx.process.setLinDepth(true);
wiImage::Draw(dtDepthCopy.GetTextureResolvedMSAA(threadID), fx, threadID);
fx.process.clear();
}
rtLinearDepth.Deactivate(threadID);
wiRenderer::UpdateDepthBuffer(dtDepthCopy.GetTextureResolvedMSAA(threadID), rtLinearDepth.GetTexture(), threadID);
if (getSSAOEnabled()) {
wiRenderer::GetDevice()->UnBindResources(TEXSLOT_RENDERABLECOMPONENT_SSAO, 1, threadID);
wiRenderer::GetDevice()->EventBegin("SSAO", threadID);
fx.stencilRef = STENCILREF_DEFAULT;
fx.stencilComp = STENCILMODE_LESS;
rtSSAO[0].Activate(threadID); {
fx.process.setSSAO(true);
fx.setMaskMap(wiTextureHelper::getInstance()->getRandom64x64());
fx.quality = QUALITY_BILINEAR;
fx.sampleFlag = SAMPLEMODE_MIRROR;
wiImage::Draw(nullptr, fx, threadID);
fx.process.clear();
}
rtSSAO[1].Activate(threadID); {
fx.blur = getSSAOBlur();
fx.blurDir = 0;
fx.blendFlag = BLENDMODE_OPAQUE;
wiImage::Draw(rtSSAO[0].GetTexture(), fx, threadID);
}
rtSSAO[2].Activate(threadID); {
fx.blur = getSSAOBlur();
fx.blurDir = 1;
fx.blendFlag = BLENDMODE_OPAQUE;
wiImage::Draw(rtSSAO[1].GetTexture(), fx, threadID);
fx.blur = 0;
}
fx.stencilRef = 0;
fx.stencilComp = STENCILMODE_DISABLED;
wiRenderer::GetDevice()->EventEnd(threadID);
}
if (getSSREnabled()) {
wiRenderer::GetDevice()->UnBindResources(TEXSLOT_RENDERABLECOMPONENT_SSR, 1, threadID);
wiRenderer::GetDevice()->EventBegin("SSR", threadID);
rtSSR.Activate(threadID); {
fx.process.clear();
fx.presentFullScreen = false;
fx.process.setSSR(true);
fx.setMaskMap(nullptr);
wiImage::Draw(rtMain.GetTexture(), fx, threadID);
fx.process.clear();
}
wiRenderer::GetDevice()->EventEnd(threadID);
}
wiProfiler::GetInstance().EndRange(threadID); // Opaque Scene
}
+5 -4
View File
@@ -290,8 +290,7 @@ void Renderable3DComponent::RenderReflections(GRAPHICSTHREAD threadID)
wiRenderer::SetClipPlane(water, threadID);
wiRenderer::DrawWorld(wiRenderer::getRefCamera(), false, threadID, SHADERTYPE_TEXTURE,
nullptr, nullptr, nullptr, getHairParticlesReflectionEnabled(), false);
wiRenderer::DrawWorld(wiRenderer::getRefCamera(), false, threadID, SHADERTYPE_TEXTURE, getHairParticlesReflectionEnabled(), false);
wiRenderer::DrawSky(threadID);
wiRenderer::SetClipPlane(XMFLOAT4(0, 0, 0, 0), threadID);
@@ -483,8 +482,10 @@ void Renderable3DComponent::RenderTransparentScene(wiRenderTarget& refractionRT,
{
wiProfiler::GetInstance().BeginRange("Transparent Scene", wiProfiler::DOMAIN_GPU, threadID);
wiRenderer::DrawWorldTransparent(wiRenderer::getCamera(), SHADERTYPE_FORWARD, refractionRT.GetTexture(), rtReflection.GetTexture()
, rtWaterRipple.GetTexture(), threadID, false, true);
wiRenderer::GetDevice()->BindResource(PS, getReflectionsEnabled() ? rtReflection.GetTexture() : wiTextureHelper::getInstance()->getTransparent(), TEXSLOT_RENDERABLECOMPONENT_REFLECTION, threadID);
wiRenderer::GetDevice()->BindResource(PS, refractionRT.GetTexture(), TEXSLOT_RENDERABLECOMPONENT_REFRACTION, threadID);
wiRenderer::GetDevice()->BindResource(PS, rtWaterRipple.GetTexture(), TEXSLOT_RENDERABLECOMPONENT_WATERRIPPLES, threadID);
wiRenderer::DrawWorldTransparent(wiRenderer::getCamera(), SHADERTYPE_FORWARD, threadID, false, true);
wiProfiler::GetInstance().EndRange(threadID); // Transparent Scene
}
+9
View File
@@ -69,4 +69,13 @@
#define SKINNINGSLOT_OUT_VERTEX_PRE 1
// RenderableComponent texture mappings:
#define TEXSLOT_RENDERABLECOMPONENT_REFLECTION TEXSLOT_ONDEMAND6
#define TEXSLOT_RENDERABLECOMPONENT_REFRACTION TEXSLOT_ONDEMAND7
#define TEXSLOT_RENDERABLECOMPONENT_WATERRIPPLES TEXSLOT_ONDEMAND8
#define TEXSLOT_RENDERABLECOMPONENT_SSAO TEXSLOT_ONDEMAND8
#define TEXSLOT_RENDERABLECOMPONENT_SSR TEXSLOT_ONDEMAND9
#endif // _RESOURCEBUFFER_MAPPING_H_
@@ -41,8 +41,8 @@ void TiledDeferredRenderableComponent::RenderScene(GRAPHICSTHREAD threadID)
{
wiRenderer::SetAlphaRef(0.25f, threadID);
}
wiRenderer::DrawWorld(wiRenderer::getCamera(), getTessellationEnabled(), threadID, SHADERTYPE_DEFERRED,
rtReflection.GetTexture(), nullptr, nullptr, getHairParticlesEnabled(), true);
wiRenderer::GetDevice()->BindResource(PS, getReflectionsEnabled() ? rtReflection.GetTexture() : wiTextureHelper::getInstance()->getTransparent(), TEXSLOT_RENDERABLECOMPONENT_REFLECTION, threadID);
wiRenderer::DrawWorld(wiRenderer::getCamera(), getTessellationEnabled(), threadID, SHADERTYPE_DEFERRED, getHairParticlesEnabled(), true);
}
@@ -80,10 +80,14 @@ void TiledDeferredRenderableComponent::RenderScene(GRAPHICSTHREAD threadID)
wiRenderer::UpdateGBuffer(rtGBuffer.GetTexture(0), rtGBuffer.GetTexture(1), rtGBuffer.GetTexture(2), rtGBuffer.GetTexture(3), nullptr, threadID);
wiRenderer::GetDevice()->BindResource(CS, getSSREnabled() ? rtSSR.GetTexture() : wiTextureHelper::getInstance()->getTransparent(), TEXSLOT_RENDERABLECOMPONENT_SSR, threadID);
wiRenderer::ComputeTiledLightCulling(true, threadID);
if (getSSAOEnabled()) {
wiRenderer::GetDevice()->UnBindResources(TEXSLOT_RENDERABLECOMPONENT_SSAO, 1, threadID);
wiRenderer::GetDevice()->EventBegin("SSAO", threadID);
fx.stencilRef = STENCILREF_DEFAULT;
fx.stencilComp = STENCILMODE_LESS;
@@ -178,6 +182,7 @@ void TiledDeferredRenderableComponent::RenderScene(GRAPHICSTHREAD threadID)
}
if (getSSREnabled()) {
wiRenderer::GetDevice()->UnBindResources(TEXSLOT_RENDERABLECOMPONENT_SSR, 1, threadID);
wiRenderer::GetDevice()->EventBegin("SSR", threadID);
rtSSR.Activate(threadID); {
fx.process.clear();
@@ -197,8 +202,10 @@ void TiledDeferredRenderableComponent::RenderTransparentScene(wiRenderTarget& re
{
wiProfiler::GetInstance().BeginRange("Transparent Scene", wiProfiler::DOMAIN_GPU, threadID);
wiRenderer::DrawWorldTransparent(wiRenderer::getCamera(), SHADERTYPE_TILEDFORWARD, refractionRT.GetTexture(), rtReflection.GetTexture()
, rtWaterRipple.GetTexture(), threadID, getHairParticlesEnabled() && getHairParticleAlphaCompositionEnabled(), true);
wiRenderer::GetDevice()->BindResource(PS, getReflectionsEnabled() ? rtReflection.GetTexture() : wiTextureHelper::getInstance()->getTransparent(), TEXSLOT_RENDERABLECOMPONENT_REFLECTION, threadID);
wiRenderer::GetDevice()->BindResource(PS, refractionRT.GetTexture(), TEXSLOT_RENDERABLECOMPONENT_REFRACTION, threadID);
wiRenderer::GetDevice()->BindResource(PS, rtWaterRipple.GetTexture(), TEXSLOT_RENDERABLECOMPONENT_WATERRIPPLES, threadID);
wiRenderer::DrawWorldTransparent(wiRenderer::getCamera(), SHADERTYPE_TILEDFORWARD, threadID, getHairParticlesEnabled() && getHairParticleAlphaCompositionEnabled(), true);
wiProfiler::GetInstance().EndRange(); // Transparent Scene
}
@@ -35,8 +35,7 @@ void TiledForwardRenderableComponent::RenderScene(GRAPHICSTHREAD threadID)
{
wiRenderer::SetAlphaRef(0.25f, threadID);
}
wiRenderer::DrawWorld(wiRenderer::getCamera(), getTessellationEnabled(), threadID, SHADERTYPE_DEPTHONLY,
nullptr, nullptr, nullptr, getHairParticlesEnabled(), true);
wiRenderer::DrawWorld(wiRenderer::getCamera(), getTessellationEnabled(), threadID, SHADERTYPE_DEPTHONLY, getHairParticlesEnabled(), true);
}
wiProfiler::GetInstance().EndRange(threadID);
@@ -65,24 +64,19 @@ void TiledForwardRenderableComponent::RenderScene(GRAPHICSTHREAD threadID)
wiProfiler::GetInstance().BeginRange("Opaque Scene", wiProfiler::DOMAIN_GPU, threadID);
rtMain.Set(threadID);
{
if (getSSAOEnabled()) {
wiRenderer::GetDevice()->BindResource(PS, rtSSAO.back().GetTexture(), TEXSLOT_ONDEMAND8, threadID);
}
if (getSSREnabled()) {
wiRenderer::GetDevice()->BindResource(PS, rtSSR.GetTexture(), TEXSLOT_ONDEMAND9, threadID);
}
wiRenderer::DrawWorld(wiRenderer::getCamera(), getTessellationEnabled(), threadID, SHADERTYPE_TILEDFORWARD,
rtReflection.GetTexture(), getSSAOEnabled() ? rtSSAO.back().GetTexture() : nullptr, getSSREnabled() ? rtSSR.GetTexture() : nullptr, true, true);
wiRenderer::GetDevice()->BindResource(PS, getReflectionsEnabled() ? rtReflection.GetTexture() : wiTextureHelper::getInstance()->getTransparent(), TEXSLOT_RENDERABLECOMPONENT_REFLECTION, threadID);
wiRenderer::GetDevice()->BindResource(PS, getSSAOEnabled() ? rtSSAO.back().GetTexture() : wiTextureHelper::getInstance()->getWhite(), TEXSLOT_RENDERABLECOMPONENT_SSAO, threadID);
wiRenderer::GetDevice()->BindResource(PS, getSSREnabled() ? rtSSR.GetTexture() : wiTextureHelper::getInstance()->getTransparent(), TEXSLOT_RENDERABLECOMPONENT_SSR, threadID);
wiRenderer::DrawWorld(wiRenderer::getCamera(), getTessellationEnabled(), threadID, SHADERTYPE_TILEDFORWARD, true, true);
wiRenderer::DrawSky(threadID);
}
rtMain.Deactivate(threadID);
wiRenderer::UpdateGBuffer(rtMain.GetTextureResolvedMSAA(threadID, 0), rtMain.GetTextureResolvedMSAA(threadID, 1), nullptr, nullptr, nullptr, threadID);
wiProfiler::GetInstance().EndRange(threadID); // Opaque Scene
if (getSSAOEnabled()) {
wiRenderer::GetDevice()->UnBindResources(TEXSLOT_RENDERABLECOMPONENT_SSAO, 1, threadID);
wiRenderer::GetDevice()->EventBegin("SSAO", threadID);
fx.stencilRef = STENCILREF_DEFAULT;
fx.stencilComp = STENCILMODE_LESS;
@@ -113,6 +107,7 @@ void TiledForwardRenderableComponent::RenderScene(GRAPHICSTHREAD threadID)
}
if (getSSREnabled()) {
wiRenderer::GetDevice()->UnBindResources(TEXSLOT_RENDERABLECOMPONENT_SSR, 1, threadID);
wiRenderer::GetDevice()->EventBegin("SSR", threadID);
rtSSR.Activate(threadID); {
fx.process.clear();
@@ -124,13 +119,17 @@ void TiledForwardRenderableComponent::RenderScene(GRAPHICSTHREAD threadID)
}
wiRenderer::GetDevice()->EventEnd(threadID);
}
wiProfiler::GetInstance().EndRange(threadID); // Opaque Scene
}
void TiledForwardRenderableComponent::RenderTransparentScene(wiRenderTarget& refractionRT, GRAPHICSTHREAD threadID)
{
wiProfiler::GetInstance().BeginRange("Transparent Scene", wiProfiler::DOMAIN_GPU, threadID);
wiRenderer::DrawWorldTransparent(wiRenderer::getCamera(), SHADERTYPE_TILEDFORWARD, refractionRT.GetTexture(), rtReflection.GetTexture()
, rtWaterRipple.GetTexture(), threadID, getHairParticlesEnabled() && getHairParticleAlphaCompositionEnabled(), true);
wiRenderer::GetDevice()->BindResource(PS, getReflectionsEnabled() ? rtReflection.GetTexture() : wiTextureHelper::getInstance()->getTransparent(), TEXSLOT_RENDERABLECOMPONENT_REFLECTION, threadID);
wiRenderer::GetDevice()->BindResource(PS, refractionRT.GetTexture(), TEXSLOT_RENDERABLECOMPONENT_REFRACTION, threadID);
wiRenderer::GetDevice()->BindResource(PS, rtWaterRipple.GetTexture(), TEXSLOT_RENDERABLECOMPONENT_WATERRIPPLES, threadID);
wiRenderer::DrawWorldTransparent(wiRenderer::getCamera(), SHADERTYPE_TILEDFORWARD, threadID, getHairParticlesEnabled() && getHairParticleAlphaCompositionEnabled(), true);
wiProfiler::GetInstance().EndRange(threadID); // Transparent Scene
}
+4 -2
View File
@@ -26,17 +26,19 @@ struct LightOutputType
#define DEFERREDLIGHT_MAKEPARAMS \
ShaderEntityType light = EntityArray[PSIn.lightIndex]; \
float3 diffuse, specular; \
float2 screenPos = float2(1, -1) * PSIn.pos2D.xy / PSIn.pos2D.w / 2.0f + 0.5f; \
float2 ScreenCoord = float2(1, -1) * PSIn.pos2D.xy / PSIn.pos2D.w * 0.5f + 0.5f; \
float depth = texture_depth[PSIn.pos.xy]; \
float4 baseColor = texture_gbuffer0[PSIn.pos.xy]; \
float4 g1 = texture_gbuffer1[PSIn.pos.xy]; \
float4 g3 = texture_gbuffer3[PSIn.pos.xy]; \
float3 N = decode(g1.xy); \
float2 velocity = g1.zw; \
float roughness = g3.x; \
float reflectance = g3.y; \
float metalness = g3.z; \
float ao = g3.w; \
float3 P = getPosition(screenPos, depth); \
float2 ReprojectedScreenCoord = ScreenCoord + velocity; \
float3 P = getPosition(ScreenCoord, depth); \
float3 V = normalize(g_xCamera_CamPos - P); \
Surface surface = CreateSurface(P, N, V, baseColor, reflectance, metalness, roughness);
+4
View File
@@ -1,5 +1,6 @@
#include "deferredLightHF.hlsli"
#define xSSR texture_9
LightOutputType main(VertexToPixel PSIn)
@@ -11,6 +12,9 @@ LightOutputType main(VertexToPixel PSIn)
specular = max(0, EnvironmentReflection_Global(surface, envMapMIP));
VoxelGI(surface, diffuse, specular, ao);
float4 ssr = xSSR.SampleLevel(sampler_linear_clamp, ReprojectedScreenCoord, 0);
specular = lerp(specular, ssr.rgb, ssr.a);
specular *= surface.F;
DEFERREDLIGHT_RETURN
+1 -1
View File
@@ -29,7 +29,7 @@ GBUFFEROutputType_Thin main(VertexToPixel input)
ForwardLighting(surface, diffuse, specular, reflection);
ApplyLighting(surface, diffuse, specular, ao, opacity, color);
ApplyLighting(surface, diffuse, specular, ao, color);
ApplyFog(dist, color);
@@ -30,7 +30,7 @@ GBUFFEROutputType_Thin main(VertexToPixel input)
TiledLighting(pixel, surface, diffuse, specular, reflection);
VoxelGI(surface, diffuse, reflection, ao);
ApplyLighting(surface, diffuse, specular, ao, opacity, color);
ApplyLighting(surface, diffuse, specular, ao, color);
ApplyFog(dist, color);
+8 -1
View File
@@ -4,6 +4,8 @@
#include "packHF.hlsli"
#include "reconstructPositionHF.hlsli"
#define xSSR texture_9
CBUFFER(DispatchParams, CBSLOT_RENDERER_DISPATCHPARAMS)
{
uint3 xDispatchParams_numThreadGroups;
@@ -478,7 +480,6 @@ void main(ComputeShaderInput IN)
iterator = o_decalCount;
// decals are not yet available here (need to r/w albedo), skip them for now...
#ifndef DISABLE_ENVMAPS
// Apply environment maps:
@@ -579,6 +580,12 @@ void main(ComputeShaderInput IN)
VoxelGI(surface, diffuse, reflection, ao);
float2 ScreenCoord = (float2)pixel * g_xWorld_ScreenWidthHeight_Inverse;
float2 velocity = g1.zw;
float2 ReprojectedScreenCoord = ScreenCoord + velocity;
float4 ssr = xSSR.SampleLevel(sampler_linear_clamp, ReprojectedScreenCoord, 0);
reflection = lerp(reflection, ssr.rgb, ssr.a);
specular += reflection * surface.F;
deferred_Diffuse[pixel] = float4(diffuse, ao);
+1 -1
View File
@@ -114,7 +114,7 @@ PixelInputType main(ConstantOutputType input, float3 uvwCoord : SV_DomainLocatio
Out.pos3D = vertexPosition.xyz;
Out.tex = vertexTex.xy;
Out.nor = normalize(vertexNormal.xyz);
Out.nor2D = mul(Out.nor.xyz, (float3x3)g_xCamera_VP).xy;
Out.nor2D = mul(Out.nor.xyz, (float3x3)g_xCamera_View).xy;
Out.ReflectionMapSamplingPos = mul(vertexPosition, g_xFrame_MainCamera_ReflVP);
+16 -11
View File
@@ -47,6 +47,7 @@ CBUFFER(MaterialCB, CBSLOT_RENDERER_MATERIAL)
// DEFINITIONS
//////////////////
// These are bound by wiRenderer (based on Material):
#define xBaseColorMap texture_0
#define xNormalMap texture_1
#define xRoughnessMap texture_2
@@ -54,6 +55,7 @@ CBUFFER(MaterialCB, CBSLOT_RENDERER_MATERIAL)
#define xMetalnessMap texture_4
#define xDisplacementMap texture_5
// These are bound by RenderableComponent (based on Render Path):
#define xReflection texture_6
#define xRefraction texture_7
#define xWaterRipples texture_8
@@ -95,7 +97,7 @@ inline GBUFFEROutputType CreateGbuffer(in float4 color, in Surface surface, in f
{
GBUFFEROutputType Out;
Out.g0 = float4(color.rgb, 1); /*FORMAT_R8G8B8A8_UNORM*/
Out.g1 = float4(encode(surface.N), velocity); /*FORMAT_R16G16B16_FLOAT*/
Out.g1 = float4(encode(surface.N), velocity); /*FORMAT_R16G16B16A16_FLOAT*/
Out.g2 = float4(0, 0, surface.sss, surface.emissive); /*FORMAT_R8G8B8A8_UNORM*/
Out.g3 = float4(surface.roughness, surface.reflectance, surface.metalness, 1); /*FORMAT_R8G8B8A8_UNORM*/
return Out;
@@ -109,8 +111,8 @@ struct GBUFFEROutputType_Thin
inline GBUFFEROutputType_Thin CreateGbuffer_Thin(in float4 color, in Surface surface, in float2 velocity)
{
GBUFFEROutputType_Thin Out;
Out.g0 = color; /*FORMAT_R16G16B16_FLOAT*/
Out.g1 = float4(encode(surface.N), velocity); /*FORMAT_R16G16B16_FLOAT*/
Out.g0 = color; /*FORMAT_R16G16B16A16_FLOAT*/
Out.g1 = float4(encode(surface.N), velocity); /*FORMAT_R16G16B16A16_FLOAT*/
return Out;
}
@@ -179,7 +181,7 @@ inline void Refraction(in float2 ScreenCoord, in float2 normal2D, in float3 bump
xRefraction.GetDimensions(0, size.x, size.y, mipLevels);
float2 perturbatedRefrTexCoords = ScreenCoord.xy + (normal2D + bumpColor.rg) * g_xMat_refractionIndex;
float4 refractiveColor = xRefraction.SampleLevel(sampler_linear_clamp, perturbatedRefrTexCoords, (g_xWorld_AdvancedRefractions ? surface.roughness * mipLevels : 0));
surface.albedo.rgb = lerp(refractiveColor.rgb, surface.albedo.rgb, color.a);
surface.albedo.rgb *= lerp(refractiveColor.rgb, 1, color.a);
color.a = 1;
}
@@ -407,9 +409,9 @@ inline void TiledLighting(in float2 pixel, inout Surface surface, inout float3 d
}
}
inline void ApplyLighting(in Surface surface, in float3 diffuse, in float3 specular, in float ao, in float opacity, inout float4 color)
inline void ApplyLighting(in Surface surface, in float3 diffuse, in float3 specular, in float ao, inout float4 color)
{
color.rgb = lerp(1, GetAmbientColor() * ao + diffuse, opacity) * surface.albedo + specular;
color.rgb = (GetAmbientColor() * ao + diffuse) * surface.albedo + specular;
}
inline void ApplyFog(in float dist, inout float4 color)
@@ -570,10 +572,6 @@ GBUFFEROutputType_Thin main(PIXELINPUT input)
#ifndef DEFERRED
#ifdef TRANSPARENT
Refraction(ScreenCoord, input.nor2D, bumpColor, surface, color);
#endif // TRANSPARENT
#ifdef FORWARD
ForwardLighting(surface, diffuse, specular, reflection);
#endif // FORWARD
@@ -592,17 +590,24 @@ GBUFFEROutputType_Thin main(PIXELINPUT input)
reflection = PlanarReflection(refUV, surface);
#endif
#ifdef TRANSPARENT
Refraction(ScreenCoord, input.nor2D, bumpColor, surface, color);
diffuse = lerp(1, diffuse, opacity);
#else
float4 ssr = xSSR.SampleLevel(sampler_linear_clamp, ReprojectedScreenCoord, 0);
reflection = lerp(reflection, ssr.rgb, ssr.a);
float ssao = xSSAO.SampleLevel(sampler_linear_clamp, ReprojectedScreenCoord, 0).r;
ao *= ssao;
#endif // TRANSPARENT
#endif // ENVMAPRENDERING
#endif // WATER
specular += reflection * surface.F;
ApplyLighting(surface, diffuse, specular, ao, opacity, color);
ApplyLighting(surface, diffuse, specular, ao, color);
#ifdef WATER
// SOFT EDGE
+1 -1
View File
@@ -28,7 +28,7 @@ PixelInputType main(Input_Object_ALL input)
Out.pos3D = surface.position.xyz;
Out.tex = surface.uv;
Out.nor = surface.normal;
Out.nor2D = mul(Out.nor.xyz, (float3x3)g_xCamera_VP).xy;
Out.nor2D = mul(Out.nor.xyz, (float3x3)g_xCamera_View).xy;
Out.ReflectionMapSamplingPos = mul(surface.position, g_xFrame_MainCamera_ReflVP);
+1 -1
View File
@@ -55,7 +55,7 @@ float4 main(PSIn input) : SV_TARGET
specular += reflection * fresnelTerm;
ApplyLighting(surface, diffuse, specular, ao, opacity, color);
ApplyLighting(surface, diffuse, specular, ao, color);
//SOFT EDGE
float fade = saturate(0.3 * abs(refDepth - lineardepth));
+1 -2
View File
@@ -22,8 +22,7 @@ float4 main(VertextoPixel input) : SV_TARGET
ALPHATEST(color.a);
float opacity = color.a;
// When opacity reaches ZERO, the multiplicative light mask will be ONE:
color.rgb = lerp(1, color.rgb, opacity);
color.rgb *= 1 - opacity;
// Use the alpha channel for refraction caustics effect:
float3 bumpColor;
+1 -1
View File
@@ -76,7 +76,7 @@ float4 main(VertexToPixelPostProcess input):SV_Target
}
float ao = 1.0 - bl * invSamples*darkness;
float ao = 1.0 - bl * invSamples/**darkness*/;
return saturate(ao.xxxx);
}
+1 -1
View File
@@ -110,6 +110,6 @@ float4 main(VertexToPixelPostProcess input) : SV_Target
float3 reflectionColor = xTexture.SampleLevel(sampler_linear_clamp, vCoords.xy, 0).rgb;
return float4(reflectionColor, reflectionIntensity);
return max(0, float4(reflectionColor, reflectionIntensity));
}
+1 -1
View File
@@ -13,7 +13,7 @@ PixelInputType main(Input_Object_POS_TEX input)
Out.pos = Out.pos2D = mul(surface.position, g_xCamera_VP);
Out.tex = surface.uv;
Out.nor = normalize(mul(surface.normal, (float3x3)WORLD));
Out.nor2D = mul(Out.nor.xyz, (float3x3)g_xCamera_VP).xy;
Out.nor2D = mul(Out.nor.xyz, (float3x3)g_xCamera_View).xy;
Out.ReflectionMapSamplingPos = mul(surface.position, g_xFrame_MainCamera_ReflVP);
+2 -35
View File
@@ -5278,8 +5278,7 @@ void wiRenderer::RenderMeshes(const XMFLOAT3& eye, const CulledCollection& culle
}
}
void wiRenderer::DrawWorld(Camera* camera, bool tessellation, GRAPHICSTHREAD threadID, SHADERTYPE shaderType,
Texture2D* refRes, Texture2D* ssaoRes, Texture2D* ssrRes, bool grass, bool occlusionCulling)
void wiRenderer::DrawWorld(Camera* camera, bool tessellation, GRAPHICSTHREAD threadID, SHADERTYPE shaderType, bool grass, bool occlusionCulling)
{
const FrameCulling& culling = frameCullings[camera];
@@ -5302,30 +5301,6 @@ void wiRenderer::DrawWorld(Camera* camera, bool tessellation, GRAPHICSTHREAD thr
if (!culledRenderer.empty() || (grass && culling.culledHairParticleSystems.empty()))
{
if (!wireRender)
{
if (refRes != nullptr)
{
GetDevice()->BindResource(PS, refRes, TEXSLOT_ONDEMAND6, threadID);
}
if (ssaoRes != nullptr)
{
GetDevice()->BindResource(PS, ssaoRes, TEXSLOT_ONDEMAND8, threadID);
}
else
{
GetDevice()->BindResource(PS, wiTextureHelper::getInstance()->getWhite(), TEXSLOT_ONDEMAND8, threadID);
}
if (ssrRes != nullptr)
{
GetDevice()->BindResource(PS, ssrRes, TEXSLOT_ONDEMAND9, threadID);
}
else
{
GetDevice()->BindResource(PS, wiTextureHelper::getInstance()->getTransparent(), TEXSLOT_ONDEMAND9, threadID);
}
}
RenderMeshes(camera->translation, culledRenderer, shaderType, RENDERTYPE_OPAQUE, threadID, tessellation, GetOcclusionCullingEnabled() && occlusionCulling);
}
@@ -5333,8 +5308,7 @@ void wiRenderer::DrawWorld(Camera* camera, bool tessellation, GRAPHICSTHREAD thr
}
void wiRenderer::DrawWorldTransparent(Camera* camera, SHADERTYPE shaderType, Texture2D* refracRes, Texture2D* refRes
, Texture2D* waterRippleNormals, GRAPHICSTHREAD threadID, bool grass, bool occlusionCulling)
void wiRenderer::DrawWorldTransparent(Camera* camera, SHADERTYPE shaderType, GRAPHICSTHREAD threadID, bool grass, bool occlusionCulling)
{
const FrameCulling& culling = frameCullings[camera];
@@ -5347,13 +5321,6 @@ void wiRenderer::DrawWorldTransparent(Camera* camera, SHADERTYPE shaderType, Tex
GetDevice()->BindResource(PS, resourceBuffers[RBTYPE_ENTITYINDEXLIST_TRANSPARENT], SBSLOT_ENTITYINDEXLIST, threadID);
}
if (!wireRender)
{
GetDevice()->BindResource(PS, refRes, TEXSLOT_ONDEMAND6, threadID);
GetDevice()->BindResource(PS, refracRes, TEXSLOT_ONDEMAND7, threadID);
GetDevice()->BindResource(PS, waterRippleNormals, TEXSLOT_ONDEMAND8, threadID);
}
if (ocean != nullptr)
{
ocean->Render(camera, renderTime, threadID);
+2 -4
View File
@@ -454,11 +454,9 @@ public:
static void RenderMeshes(const XMFLOAT3& eye, const CulledCollection& culledRenderer, SHADERTYPE shaderType, UINT renderTypeFlags, GRAPHICSTHREAD threadID, bool tessellation = false, bool occlusionCulling = false);
static void DrawSky(GRAPHICSTHREAD threadID);
static void DrawSun(GRAPHICSTHREAD threadID);
static void DrawWorld(Camera* camera, bool tessellation, GRAPHICSTHREAD threadID, SHADERTYPE shaderType,
wiGraphicsTypes::Texture2D* refRes, wiGraphicsTypes::Texture2D* ssaoRes, wiGraphicsTypes::Texture2D* ssrRes, bool grass, bool occlusionCulling);
static void DrawWorld(Camera* camera, bool tessellation, GRAPHICSTHREAD threadID, SHADERTYPE shaderType, bool grass, bool occlusionCulling);
static void DrawForShadowMap(GRAPHICSTHREAD threadID);
static void DrawWorldTransparent(Camera* camera, SHADERTYPE shaderType, wiGraphicsTypes::Texture2D* refracRes, wiGraphicsTypes::Texture2D* refRes
, wiGraphicsTypes::Texture2D* waterRippleNormals, GRAPHICSTHREAD threadID, bool grass, bool occlusionCulling);
static void DrawWorldTransparent(Camera* camera, SHADERTYPE shaderType, GRAPHICSTHREAD threadID, bool grass, bool occlusionCulling);
void DrawDebugSpheres(Camera* camera, GRAPHICSTHREAD threadID);
static void DrawDebugBoneLines(Camera* camera, GRAPHICSTHREAD threadID);
static void DrawDebugLines(Camera* camera, GRAPHICSTHREAD threadID);
+1 -1
View File
@@ -9,7 +9,7 @@ namespace wiVersion
// minor features, major updates
const int minor = 16;
// minor bug fixes, alterations, refactors, updates
const int revision = 14;
const int revision = 15;
long GetVersion()