env probe visualizers added

This commit is contained in:
turanszkij
2016-06-17 00:38:45 +02:00
parent 5b19efa775
commit d6cb3d4482
11 changed files with 3001 additions and 7 deletions
@@ -224,6 +224,7 @@ void DeferredRenderableComponent::RenderScene(GRAPHICSTHREAD threadID){
, getSSAOEnabled() ? rtSSAO.back().GetTexture() : wiTextureHelper::getInstance()->getWhite()
, threadID, STENCILREF_DEFAULT);
wiRenderer::DrawSky(threadID);
wiRenderer::DrawDebugEnvProbes(wiRenderer::getCamera(), threadID);
wiRenderer::DrawDebugBoneLines(wiRenderer::getCamera(), threadID);
wiRenderer::DrawDebugLines(wiRenderer::getCamera(), threadID);
wiRenderer::DrawDebugBoxes(wiRenderer::getCamera(), threadID);
@@ -81,6 +81,7 @@ void ForwardRenderableComponent::RenderScene(GRAPHICSTHREAD threadID)
, false, SHADERTYPE_FORWARD
, nullptr, true, GRAPHICSTHREAD_SCENE);
wiRenderer::DrawSky(threadID);
wiRenderer::DrawDebugEnvProbes(wiRenderer::getCamera(), threadID);
wiRenderer::DrawDebugBoneLines(wiRenderer::getCamera(), threadID);
wiRenderer::DrawDebugLines(wiRenderer::getCamera(), threadID);
wiRenderer::DrawDebugBoxes(wiRenderer::getCamera(), threadID);
@@ -42,6 +42,7 @@
<None Include="sOHF.hlsli" />
<None Include="spotLightHF.hlsli" />
<None Include="tangentComputeHF.hlsli" />
<None Include="uvsphere.hlsli" />
<None Include="volumeLightHF.hlsli" />
<None Include="windHF.hlsli" />
</ItemGroup>
@@ -66,6 +67,10 @@
<ShaderType Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">Pixel</ShaderType>
<ShaderType Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">Pixel</ShaderType>
</FxCompile>
<FxCompile Include="cubeMapPS.hlsl">
<ShaderType Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">Pixel</ShaderType>
<ShaderType Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">Pixel</ShaderType>
</FxCompile>
<FxCompile Include="cubeShadowGS.hlsl">
<ShaderType Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">Geometry</ShaderType>
<ShaderType Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">Geometry</ShaderType>
@@ -350,6 +355,10 @@
<ShaderType Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">Vertex</ShaderType>
<ShaderType Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">Vertex</ShaderType>
</FxCompile>
<FxCompile Include="sphereVS.hlsl">
<ShaderType Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">Vertex</ShaderType>
<ShaderType Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">Vertex</ShaderType>
</FxCompile>
<FxCompile Include="spotLightPS.hlsl">
<ShaderType Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">Pixel</ShaderType>
<ShaderType Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">Pixel</ShaderType>
@@ -100,6 +100,9 @@
<None Include="envReflectionHF.hlsli">
<Filter>HF</Filter>
</None>
<None Include="uvsphere.hlsli">
<Filter>HF</Filter>
</None>
</ItemGroup>
<ItemGroup>
<FxCompile Include="objectHS.hlsl">
@@ -378,6 +381,12 @@
<FxCompile Include="objectPS_forward_dirlight_transparent.hlsl">
<Filter>PS</Filter>
</FxCompile>
<FxCompile Include="cubeMapPS.hlsl">
<Filter>PS</Filter>
</FxCompile>
<FxCompile Include="sphereVS.hlsl">
<Filter>VS</Filter>
</FxCompile>
</ItemGroup>
<ItemGroup>
<Filter Include="PS">
+16
View File
@@ -0,0 +1,16 @@
#include "globals.hlsli"
struct VSOut_Sphere
{
float4 pos : SV_POSITION;
float3 nor : TEXCOORD0;
float3 pos3D : TEXCOORD1;
};
float4 main(VSOut_Sphere input) : SV_TARGET
{
float3 P = input.pos3D;
float3 N = normalize(input.nor);
float3 V = normalize(g_xCamera_CamPos - P);
return texture_env0.Sample(sampler_linear_clamp,-reflect(V, N));
}
+20
View File
@@ -0,0 +1,20 @@
#include "globals.hlsli"
#include "uvsphere.hlsli"
struct VSOut_Sphere
{
float4 pos : SV_POSITION;
float3 nor : TEXCOORD0;
float3 pos3D : TEXCOORD1;
};
VSOut_Sphere main( uint vID : SV_VERTEXID )
{
VSOut_Sphere o = (VSOut_Sphere)0;
o.pos = float4(UVSPHERE[vID],1);
o.nor = o.pos.xyz;
o.pos = mul(o.pos, g_xTransform);
o.pos3D = o.pos.xyz;
o.pos = mul(o.pos, g_xCamera_VP);
return o;
}
File diff suppressed because it is too large Load Diff
+2
View File
@@ -95,6 +95,7 @@ enum VSTYPES
VSTYPE_DECAL,
VSTYPE_ENVMAP,
VSTYPE_ENVMAP_SKY,
VSTYPE_SPHERE,
VSTYPE_LAST
};
// pixel shaders
@@ -125,6 +126,7 @@ enum PSTYPES
PSTYPE_SUN,
PSTYPE_ENVMAP,
PSTYPE_ENVMAP_SKY,
PSTYPE_CUBEMAP,
PSTYPE_LAST
};
// geometry shaders
+52 -2
View File
@@ -44,7 +44,8 @@ GPUBuffer *wiRenderer::resourceBuffers[RBTYPE_LAST];
int wiRenderer::SHADOWMAPRES=1024,wiRenderer::SOFTSHADOW=2
,wiRenderer::POINTLIGHTSHADOW=2,wiRenderer::POINTLIGHTSHADOWRES=256, wiRenderer::SPOTLIGHTSHADOW=2, wiRenderer::SPOTLIGHTSHADOWRES=512;
bool wiRenderer::HAIRPARTICLEENABLED=true,wiRenderer::EMITTERSENABLED=true;
bool wiRenderer::wireRender = false, wiRenderer::debugSpheres = false, wiRenderer::debugBoneLines = false, wiRenderer::debugBoxes = false;
bool wiRenderer::wireRender = false, wiRenderer::debugSpheres = false, wiRenderer::debugBoneLines = false, wiRenderer::debugBoxes = false
, wiRenderer::debugEnvProbes = false;
Texture2D* wiRenderer::enviroMap,*wiRenderer::colorGrading;
float wiRenderer::GameSpeed=1,wiRenderer::overrideGameSpeed=1;
@@ -688,6 +689,15 @@ void wiRenderer::LoadLineShaders()
pixelShaders[PSTYPE_LINE] = static_cast<PixelShader*>(wiResourceManager::GetShaderManager()->add(SHADERPATH + "linesPS.cso", wiResourceManager::PIXELSHADER));
VertexShaderInfo* vsinfoSphere = static_cast<VertexShaderInfo*>(wiResourceManager::GetShaderManager()->add(SHADERPATH + "sphereVS.cso", wiResourceManager::VERTEXSHADER));
if (vsinfoSphere != nullptr) {
vertexShaders[VSTYPE_SPHERE] = vsinfoSphere->vertexShader;
}
pixelShaders[PSTYPE_CUBEMAP] = static_cast<PixelShader*>(wiResourceManager::GetShaderManager()->add(SHADERPATH + "cubemapPS.cso", wiResourceManager::PIXELSHADER));
}
void wiRenderer::LoadTessShaders()
{
@@ -1680,6 +1690,46 @@ void wiRenderer::DrawTranslators(Camera* camera, GRAPHICSTHREAD threadID)
renderableTranslators.clear();
}
}
void wiRenderer::DrawDebugEnvProbes(Camera* camera, GRAPHICSTHREAD threadID)
{
if (debugEnvProbes && !GetScene().environmentProbes.empty()) {
GetDevice()->EventBegin(L"Debug EnvProbes", threadID);
GetDevice()->BindPrimitiveTopology(TRIANGLELIST, threadID);
GetDevice()->BindRasterizerState(rasterizers[RSTYPE_FRONT], threadID);
GetDevice()->BindVertexLayout(nullptr, threadID);
GetDevice()->BindDepthStencilState(depthStencils[DSSTYPE_DEFAULT], STENCILREF_DEFAULT, threadID);
GetDevice()->BindBlendState(blendStates[BSTYPE_OPAQUE], threadID);
GetDevice()->BindPS(pixelShaders[PSTYPE_CUBEMAP], threadID);
GetDevice()->BindVS(vertexShaders[VSTYPE_SPHERE], threadID);
GetDevice()->BindVertexBuffer(nullptr, 0, 0, threadID);
GetDevice()->BindIndexBuffer(nullptr, threadID);
XMMATRIX VP = camera->GetViewProjection();
MiscCB sb;
for (auto& x : GetScene().environmentProbes)
{
float dist = wiMath::Distance(x->translation, camera->translation) * 0.09f;
sb.mTransform = XMMatrixTranspose(XMMatrixScaling(dist, dist, dist)*x->getMatrix());
sb.mColor = XMFLOAT4(1, 1, 1, 1);
GetDevice()->UpdateBuffer(constantBuffers[CBTYPE_MISC], &sb, threadID);
GetDevice()->BindResourcePS(x->cubeMap.GetTexture(), TEXSLOT_ENV0, threadID);
GetDevice()->Draw(2880, threadID);
}
GetDevice()->EventEnd(threadID);
renderableTranslators.clear();
}
}
void wiRenderer::DrawSoftParticles(Camera* camera, GRAPHICSTHREAD threadID, bool dark)
{
@@ -3689,7 +3739,7 @@ void wiRenderer::PutEnvProbe(const XMFLOAT3& position, int resolution)
GetDevice()->GenerateMips(probe->cubeMap.GetTexture(), threadID);
enviroMap = probe->cubeMap.GetTexture();
//enviroMap = probe->cubeMap.GetTexture();
scene->environmentProbes.push_back(probe);
+8 -4
View File
@@ -280,7 +280,7 @@ protected:
static bool wireRender, debugSpheres, debugBoneLines, debugBoxes;
static bool wireRender, debugSpheres, debugBoneLines, debugBoxes, debugEnvProbes;
static wiGraphicsTypes::Texture2D* enviroMap,*colorGrading;
@@ -330,10 +330,13 @@ public:
static bool GetRasterizer(){return wireRender;};
static void ToggleDebugSpheres(){debugSpheres=!debugSpheres;}
static void SetToDrawDebugSpheres(bool param){debugSpheres=param;}
static void SetToDrawDebugBoneLines(bool param){ debugBoneLines = param; }
static void SetToDrawDebugBoneLines(bool param) { debugBoneLines = param; }
static bool GetToDrawDebugBoneLines() { return debugBoneLines; }
static void SetToDrawDebugBoxes(bool param){debugBoxes=param;}
static bool GetToDrawDebugSpheres(){return debugSpheres;};
static bool GetToDrawDebugBoxes(){return debugBoxes;};
static bool GetToDrawDebugSpheres(){return debugSpheres;}
static bool GetToDrawDebugBoxes(){return debugBoxes;}
static bool GetToDrawDebugEnvProbes() { return debugEnvProbes; }
static void SetToDrawDebugEnvProbes(bool value) { debugEnvProbes = value; }
static wiGraphicsTypes::Texture2D* GetColorGrading(){return colorGrading;};
static void SetColorGrading(wiGraphicsTypes::Texture2D* tex){colorGrading=tex;};
static void SetEnviromentMap(wiGraphicsTypes::Texture2D* tex){ enviroMap = tex; }
@@ -381,6 +384,7 @@ public:
static void DrawDebugLines(Camera* camera, GRAPHICSTHREAD threadID);
static void DrawDebugBoxes(Camera* camera, GRAPHICSTHREAD threadID);
static void DrawTranslators(Camera* camera, GRAPHICSTHREAD threadID);
static void DrawDebugEnvProbes(Camera* camera, GRAPHICSTHREAD threadID);
static void DrawSoftParticles(Camera* camera, GRAPHICSTHREAD threadID, bool dark = false);
static void DrawSoftPremulParticles(Camera* camera, GRAPHICSTHREAD threadID, bool dark = false);
static void DrawTrails(GRAPHICSTHREAD threadID, wiGraphicsTypes::Texture2D* refracRes);
+1 -1
View File
@@ -7,7 +7,7 @@ namespace wiVersion
// minor features, major bug fixes
const int minor = 8;
// minor bug fixes, alterations, refactors
const int revision = 9;
const int revision = 10;
long GetVersion()