From 4d3d800051c02e31f4135cebf8091d7a781765c3 Mon Sep 17 00:00:00 2001 From: Azaezel Date: Tue, 8 Jan 2019 11:16:05 -0600 Subject: [PATCH] skylights do actually have a position. 0,0,0. so we can include those without messing with things. and we'll want to sum/count for blending purposes down the line. not render over each other --- Engine/source/renderInstance/renderProbeMgr.cpp | 6 +++--- .../common/lighting/advanced/reflectionProbeP.hlsl | 14 ++++++++++---- 2 files changed, 13 insertions(+), 7 deletions(-) diff --git a/Engine/source/renderInstance/renderProbeMgr.cpp b/Engine/source/renderInstance/renderProbeMgr.cpp index d1f308634..ad712ecf2 100644 --- a/Engine/source/renderInstance/renderProbeMgr.cpp +++ b/Engine/source/renderInstance/renderProbeMgr.cpp @@ -347,7 +347,7 @@ void RenderProbeMgr::render( SceneRenderState *state ) MatrixF probeTrans = curEntry->getTransform(); - if (!curEntry->mIsSkylight) + //if (!curEntry->mIsSkylight) { //if (curEntry->mProbeShapeType == ProbeRenderInst::Sphere) // probeTrans.scale(curEntry->mRadius * 1.01f); @@ -362,13 +362,13 @@ void RenderProbeMgr::render( SceneRenderState *state ) if (effectiveProbeCount != 0) { - Con::printf("Probe aligned position count: %i", probeCount); + //Con::printf("Probe aligned position count: %i", probeCount); for (U32 p = 0; p < probeCount; p++) { Point3F prb = probePositions[p]; - Con::printf("Probe %i aligned position is: %g %g %g", p, prb.x, prb.y, prb.z); + //Con::printf("Probe %i aligned position is: %g %g %g", p, prb.x, prb.y, prb.z); bool tasadfh = true; } diff --git a/Templates/Full/game/shaders/common/lighting/advanced/reflectionProbeP.hlsl b/Templates/Full/game/shaders/common/lighting/advanced/reflectionProbeP.hlsl index 89125a7b6..2288fc078 100644 --- a/Templates/Full/game/shaders/common/lighting/advanced/reflectionProbeP.hlsl +++ b/Templates/Full/game/shaders/common/lighting/advanced/reflectionProbeP.hlsl @@ -137,18 +137,24 @@ float4 main( ConvexConnectP IN ) : SV_TARGET float3 specular = iblBoxSpecular(surface.N, surface.P, surface.roughness, surfToEye, TORQUE_SAMPLER2D_MAKEARG(BRDFTexture), TORQUE_SAMPLERCUBE_MAKEARG(cubeMap), probeWSPos, bbMin, bbMax); int i; + irradiance = float3(0,0,0); + float blendSum = 0.00001; for(i=0; i < numProbes; i++) { float3 probeWS = inProbePosArray[i]; float3 L = probeWS - surface.P; blendVal = 1.0-length(L)/radius; - //clip(blendVal); + blendVal = max(0,blendVal); - irradiance = float3(blendVal,blendVal,blendVal); + irradiance += float3(blendVal,blendVal,blendVal); specular = irradiance; + blendSum += blendVal; } - + //irradiance /= blendSum; + //specular /= blendSum; + blendSum /= numProbes; + //render into the bound space defined above // //float3 irradiance = TORQUE_TEXCUBELOD(irradianceCubemap, float4(surface.N,0)).xyz; @@ -161,5 +167,5 @@ float4 main( ConvexConnectP IN ) : SV_TARGET //final diffuse color float3 diffuse = kD * irradiance * surface.baseColor.rgb; - return float4(diffuse + specular * surface.ao, blendVal); + return float4(diffuse + specular * surface.ao, blendSum); }