mirror of
https://github.com/TorqueGameEngines/Torque3D.git
synced 2026-02-18 06:03:48 +00:00
Shifted the rest of the probe render code to hook into the array'd uniforms, made the reflection probe shader definition refer to the array shader.
This commit is contained in:
parent
1f38bb6d2d
commit
f5da79b39f
5 changed files with 159 additions and 77 deletions
|
|
@ -309,7 +309,7 @@ void LightManager::_update4LightConsts( const SceneData &sgData,
|
||||||
GFXShaderConstHandle *lightInvRadiusSqSC,
|
GFXShaderConstHandle *lightInvRadiusSqSC,
|
||||||
GFXShaderConstHandle *lightSpotDirSC,
|
GFXShaderConstHandle *lightSpotDirSC,
|
||||||
GFXShaderConstHandle *lightSpotAngleSC,
|
GFXShaderConstHandle *lightSpotAngleSC,
|
||||||
GFXShaderConstHandle *lightSpotFalloffSC,
|
GFXShaderConstHandle *lightSpotFalloffSC,
|
||||||
GFXShaderConstBuffer *shaderConsts )
|
GFXShaderConstBuffer *shaderConsts )
|
||||||
{
|
{
|
||||||
PROFILE_SCOPE( LightManager_Update4LightConsts );
|
PROFILE_SCOPE( LightManager_Update4LightConsts );
|
||||||
|
|
@ -324,12 +324,12 @@ void LightManager::_update4LightConsts( const SceneData &sgData,
|
||||||
{
|
{
|
||||||
PROFILE_SCOPE( LightManager_Update4LightConsts_setLights );
|
PROFILE_SCOPE( LightManager_Update4LightConsts_setLights );
|
||||||
|
|
||||||
static AlignedArray<Point4F> lightPositions( 3, sizeof( Point4F ) );
|
static AlignedArray<Point4F> lightPositions( 3, sizeof( Point4F ) );
|
||||||
static AlignedArray<Point4F> lightSpotDirs( 3, sizeof( Point4F ) );
|
static AlignedArray<Point4F> lightSpotDirs( 3, sizeof( Point4F ) );
|
||||||
static AlignedArray<Point4F> lightColors( 4, sizeof( Point4F ) );
|
static AlignedArray<Point4F> lightColors( 4, sizeof( Point4F ) );
|
||||||
static Point4F lightInvRadiusSq;
|
static Point4F lightInvRadiusSq;
|
||||||
static Point4F lightSpotAngle;
|
static Point4F lightSpotAngle;
|
||||||
static Point4F lightSpotFalloff;
|
static Point4F lightSpotFalloff;
|
||||||
F32 range;
|
F32 range;
|
||||||
|
|
||||||
// Need to clear the buffers so that we don't leak
|
// Need to clear the buffers so that we don't leak
|
||||||
|
|
|
||||||
|
|
@ -295,12 +295,28 @@ void RenderProbeMgr::render( SceneRenderState *state )
|
||||||
//Array rendering
|
//Array rendering
|
||||||
static U32 MAXPROBECOUNT = 50;
|
static U32 MAXPROBECOUNT = 50;
|
||||||
|
|
||||||
U32 probeCount = PROBEMGR->mRegisteredProbes.size();
|
U32 probeCount = ProbeRenderInst::all.size();
|
||||||
|
|
||||||
if (probeCount != 0)
|
if (probeCount != 0)
|
||||||
{
|
{
|
||||||
|
MatrixF trans = MatrixF::Identity;
|
||||||
|
sgData.objTrans = &trans;
|
||||||
|
|
||||||
AlignedArray<Point3F> probePositions(MAXPROBECOUNT, sizeof(Point3F));
|
AlignedArray<Point3F> probePositions(MAXPROBECOUNT, sizeof(Point3F));
|
||||||
|
Vector<MatrixF> probeWorldToObj;
|
||||||
|
AlignedArray<Point3F> probeBBMin(MAXPROBECOUNT, sizeof(Point3F));
|
||||||
|
AlignedArray<Point3F> probeBBMax(MAXPROBECOUNT, sizeof(Point3F));
|
||||||
|
AlignedArray<float> probeUseSphereMode(MAXPROBECOUNT, sizeof(float));
|
||||||
|
AlignedArray<float> probeRadius(MAXPROBECOUNT, sizeof(float));
|
||||||
|
AlignedArray<float> probeAttenuation(MAXPROBECOUNT, sizeof(float));
|
||||||
|
|
||||||
dMemset(probePositions.getBuffer(), 0, probePositions.getBufferSize());
|
dMemset(probePositions.getBuffer(), 0, probePositions.getBufferSize());
|
||||||
|
probeWorldToObj.setSize(MAXPROBECOUNT);
|
||||||
|
dMemset(probeBBMin.getBuffer(), 0, probeBBMin.getBufferSize());
|
||||||
|
dMemset(probeBBMax.getBuffer(), 0, probeBBMax.getBufferSize());
|
||||||
|
dMemset(probeUseSphereMode.getBuffer(), 0, probeUseSphereMode.getBufferSize());
|
||||||
|
dMemset(probeRadius.getBuffer(), 0, probeRadius.getBufferSize());
|
||||||
|
dMemset(probeAttenuation.getBuffer(), 0, probeAttenuation.getBufferSize());
|
||||||
|
|
||||||
if (reflProbeMat && reflProbeMat->matInstance)
|
if (reflProbeMat && reflProbeMat->matInstance)
|
||||||
{
|
{
|
||||||
|
|
@ -309,12 +325,13 @@ void RenderProbeMgr::render( SceneRenderState *state )
|
||||||
MaterialParameterHandle *numProbesSC = reflProbeMat->matInstance->getMaterialParameterHandle("$numProbes");
|
MaterialParameterHandle *numProbesSC = reflProbeMat->matInstance->getMaterialParameterHandle("$numProbes");
|
||||||
matParams->setSafe(numProbesSC, (float)probeCount);
|
matParams->setSafe(numProbesSC, (float)probeCount);
|
||||||
|
|
||||||
//ProcessedShaderMaterial* processedMat = reflProbeMat->matInstance->getProcessedShaderMaterial();
|
|
||||||
//GFXShaderConstBuffer* shaderConsts = processedMat->_getShaderConstBuffer(0);
|
|
||||||
|
|
||||||
//ProbeShaderConstants *psc = PROBEMGR->getProbeShaderConstants(shaderConsts);
|
|
||||||
|
|
||||||
MaterialParameterHandle *probePositionSC = reflProbeMat->matInstance->getMaterialParameterHandle("$inProbePosArray");
|
MaterialParameterHandle *probePositionSC = reflProbeMat->matInstance->getMaterialParameterHandle("$inProbePosArray");
|
||||||
|
MaterialParameterHandle *probeWorldToObjSC = reflProbeMat->matInstance->getMaterialParameterHandle("$worldToObjArray");
|
||||||
|
MaterialParameterHandle *probeBBMinSC = reflProbeMat->matInstance->getMaterialParameterHandle("$bbMinArrayy");
|
||||||
|
MaterialParameterHandle *probeBBMaxSC = reflProbeMat->matInstance->getMaterialParameterHandle("$bbMaxArray");
|
||||||
|
MaterialParameterHandle *probeUseSphereModeSC = reflProbeMat->matInstance->getMaterialParameterHandle("$useSphereMode");
|
||||||
|
MaterialParameterHandle *probeRadiusSC = reflProbeMat->matInstance->getMaterialParameterHandle("$radius");
|
||||||
|
MaterialParameterHandle *probeAttenuationSC = reflProbeMat->matInstance->getMaterialParameterHandle("$attenuation");
|
||||||
|
|
||||||
U32 effectiveProbeCount = 0;
|
U32 effectiveProbeCount = 0;
|
||||||
|
|
||||||
|
|
@ -323,57 +340,34 @@ void RenderProbeMgr::render( SceneRenderState *state )
|
||||||
if (effectiveProbeCount >= MAXPROBECOUNT)
|
if (effectiveProbeCount >= MAXPROBECOUNT)
|
||||||
break;
|
break;
|
||||||
|
|
||||||
ProbeRenderInst* curEntry = ProbeRenderInst::all[PROBEMGR->mRegisteredProbes[i]];
|
ProbeRenderInst* curEntry = ProbeRenderInst::all[i];
|
||||||
|
|
||||||
/*if (!curEntry->mIsEnabled)
|
//Setup
|
||||||
continue;
|
|
||||||
|
|
||||||
if (curEntry->numPrims == 0)
|
|
||||||
continue;
|
|
||||||
|
|
||||||
if (curEntry->mIsSkylight && (!skylightMat || !skylightMat->matInstance))
|
|
||||||
continue;
|
|
||||||
|
|
||||||
if (!curEntry->mIsSkylight && (!reflProbeMat || !reflProbeMat->matInstance))
|
|
||||||
break;*/
|
|
||||||
|
|
||||||
//Setup
|
|
||||||
const Point3F &probePos = curEntry->getPosition();
|
const Point3F &probePos = curEntry->getPosition();
|
||||||
probePositions[i].x = probePos.x;
|
probePositions[i] = probePos + curEntry->mProbePosOffset;
|
||||||
probePositions[i].y = probePos.y;
|
|
||||||
probePositions[i].z = probePos.z;
|
|
||||||
|
|
||||||
Point3F test = probePositions[i];
|
probeWorldToObj[i] = curEntry->getTransform();
|
||||||
|
|
||||||
MatrixF probeTrans = curEntry->getTransform();
|
probeBBMin[i] = curEntry->mBounds.minExtents;
|
||||||
|
probeBBMax[i] = curEntry->mBounds.maxExtents;
|
||||||
|
|
||||||
//if (!curEntry->mIsSkylight)
|
probeUseSphereMode[i] = curEntry->mProbeShapeType == ProbeRenderInst::Sphere ? 1 : 0;
|
||||||
{
|
|
||||||
//if (curEntry->mProbeShapeType == ProbeRenderInst::Sphere)
|
|
||||||
// probeTrans.scale(curEntry->mRadius * 1.01f);
|
|
||||||
|
|
||||||
sgData.objTrans = &probeTrans;
|
probeRadius[i] = curEntry->mRadius;
|
||||||
|
probeAttenuation[i] = 1;
|
||||||
reflProbeMat->setProbeParameters(curEntry, state, worldToCameraXfm);
|
|
||||||
}
|
|
||||||
|
|
||||||
effectiveProbeCount++;
|
effectiveProbeCount++;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (effectiveProbeCount != 0)
|
if (effectiveProbeCount != 0)
|
||||||
{
|
{
|
||||||
//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);
|
|
||||||
|
|
||||||
bool tasadfh = true;
|
|
||||||
}
|
|
||||||
|
|
||||||
matParams->set(probePositionSC, probePositions);
|
matParams->set(probePositionSC, probePositions);
|
||||||
|
matParams->set(probeWorldToObjSC, probeWorldToObj.address(), probeWorldToObj.size());
|
||||||
|
matParams->set(probeBBMinSC, probeBBMin);
|
||||||
|
matParams->set(probeBBMaxSC, probeBBMax);
|
||||||
|
matParams->set(probeUseSphereModeSC, probeUseSphereMode);
|
||||||
|
matParams->set(probeRadiusSC, probeRadius);
|
||||||
|
matParams->set(probeAttenuationSC, probeAttenuation);
|
||||||
|
|
||||||
// Set geometry
|
// Set geometry
|
||||||
GFX->setVertexBuffer(mFarFrustumQuadVerts);
|
GFX->setVertexBuffer(mFarFrustumQuadVerts);
|
||||||
|
|
@ -437,7 +431,7 @@ void RenderProbeMgr::render( SceneRenderState *state )
|
||||||
GFX->popActiveRenderTarget();
|
GFX->popActiveRenderTarget();
|
||||||
|
|
||||||
//PROBEMGR->unregisterAllProbes();
|
//PROBEMGR->unregisterAllProbes();
|
||||||
PROBEMGR->mRegisteredProbes.clear();
|
//PROBEMGR->mRegisteredProbes.clear();
|
||||||
|
|
||||||
PROFILE_END();
|
PROFILE_END();
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -280,12 +280,25 @@ new CustomMaterial( AL_ParticlePointLightMaterial )
|
||||||
//Reflection probe Specular
|
//Reflection probe Specular
|
||||||
new ShaderData( ReflectionProbeShader )
|
new ShaderData( ReflectionProbeShader )
|
||||||
{
|
{
|
||||||
DXVertexShaderFile = "shaders/common/lighting/advanced/convexGeometryV.hlsl";
|
/*DXVertexShaderFile = "shaders/common/lighting/advanced/convexGeometryV.hlsl";
|
||||||
DXPixelShaderFile = "shaders/common/lighting/advanced/reflectionProbeP.hlsl";
|
DXPixelShaderFile = "shaders/common/lighting/advanced/reflectionProbeP.hlsl";
|
||||||
|
|
||||||
OGLVertexShaderFile = "shaders/common/lighting/advanced/gl/convexGeometryV.glsl";
|
OGLVertexShaderFile = "shaders/common/lighting/advanced/gl/convexGeometryV.glsl";
|
||||||
OGLPixelShaderFile = "shaders/common/lighting/advanced/gl/reflectionProbeP.glsl";
|
OGLPixelShaderFile = "shaders/common/lighting/advanced/gl/reflectionProbeP.glsl";
|
||||||
|
|
||||||
|
samplerNames[0] = "$deferredBuffer";
|
||||||
|
samplerNames[1] = "$colorBuffer";
|
||||||
|
samplerNames[2] = "$matInfoBuffer";
|
||||||
|
samplerNames[3] = "$cubeMap";
|
||||||
|
samplerNames[4] = "$irradianceCubemap";
|
||||||
|
samplerNames[5] = "$BRDFTexture";*/
|
||||||
|
|
||||||
|
DXVertexShaderFile = "shaders/common/lighting/advanced/convexGeometryV.hlsl";
|
||||||
|
DXPixelShaderFile = "shaders/common/lighting/advanced/reflectionProbeArrayP.hlsl";
|
||||||
|
|
||||||
|
OGLVertexShaderFile = "shaders/common/lighting/advanced/gl/convexGeometryV.glsl";
|
||||||
|
OGLPixelShaderFile = "shaders/common/lighting/advanced/gl/reflectionProbeArrayP.glsl";
|
||||||
|
|
||||||
samplerNames[0] = "$deferredBuffer";
|
samplerNames[0] = "$deferredBuffer";
|
||||||
samplerNames[1] = "$colorBuffer";
|
samplerNames[1] = "$colorBuffer";
|
||||||
samplerNames[2] = "$matInfoBuffer";
|
samplerNames[2] = "$matInfoBuffer";
|
||||||
|
|
|
||||||
|
|
@ -134,7 +134,7 @@ new SimGroup(MissionGroup) {
|
||||||
ReflectionMode = "Baked Cubemap";
|
ReflectionMode = "Baked Cubemap";
|
||||||
reflectionPath = "levels/probeTest/probes/";
|
reflectionPath = "levels/probeTest/probes/";
|
||||||
Bake = "0";
|
Bake = "0";
|
||||||
position = "0 0.0825528 4.53387";
|
position = "0 0.0825528 2.18272";
|
||||||
rotation = "1 0 0 0";
|
rotation = "1 0 0 0";
|
||||||
scale = "5 5 5";
|
scale = "5 5 5";
|
||||||
canSave = "1";
|
canSave = "1";
|
||||||
|
|
@ -156,7 +156,7 @@ new SimGroup(MissionGroup) {
|
||||||
|
|
||||||
surface = "0 0 0 1 0 0 0.5";
|
surface = "0 0 0 1 0 0 0.5";
|
||||||
surface = "0 1 0 0 0 0 -0.5";
|
surface = "0 1 0 0 0 0 -0.5";
|
||||||
surface = "0.707107 0 0 0.707107 0 0.5 0";
|
surface = "0.707107 0 0 0.707106 0 0.5 0";
|
||||||
surface = "0 0.707107 -0.707107 0 0 -0.5 -2.84217e-14";
|
surface = "0 0.707107 -0.707107 0 0 -0.5 -2.84217e-14";
|
||||||
surface = "0.5 0.5 -0.5 0.5 -0.5 0 -9.93411e-08";
|
surface = "0.5 0.5 -0.5 0.5 -0.5 0 -9.93411e-08";
|
||||||
surface = "0.5 -0.5 0.5 0.5 0.5 0 -9.93411e-08";
|
surface = "0.5 -0.5 0.5 0.5 0.5 0 -9.93411e-08";
|
||||||
|
|
@ -171,7 +171,7 @@ new SimGroup(MissionGroup) {
|
||||||
|
|
||||||
surface = "0 0 0 1 0 0 0.5";
|
surface = "0 0 0 1 0 0 0.5";
|
||||||
surface = "0 1 0 0 0 0 -0.5";
|
surface = "0 1 0 0 0 0 -0.5";
|
||||||
surface = "0.707107 0 0 0.707107 0 0.5 0";
|
surface = "0.707107 0 0 0.707106 0 0.5 0";
|
||||||
surface = "0 0.707107 -0.707107 0 0 -0.5 -2.84217e-14";
|
surface = "0 0.707107 -0.707107 0 0 -0.5 -2.84217e-14";
|
||||||
surface = "0.5 0.5 -0.5 0.5 -0.5 0 -9.93411e-08";
|
surface = "0.5 0.5 -0.5 0.5 -0.5 0 -9.93411e-08";
|
||||||
surface = "0.5 -0.5 0.5 0.5 0.5 0 -9.93411e-08";
|
surface = "0.5 -0.5 0.5 0.5 0.5 0 -9.93411e-08";
|
||||||
|
|
@ -186,7 +186,7 @@ new SimGroup(MissionGroup) {
|
||||||
|
|
||||||
surface = "0 0 0 1 0 0 0.5";
|
surface = "0 0 0 1 0 0 0.5";
|
||||||
surface = "0 1 0 0 0 0 -0.5";
|
surface = "0 1 0 0 0 0 -0.5";
|
||||||
surface = "0.707107 0 0 0.707106 0 0.5 0";
|
surface = "0.707107 0 0 0.707107 0 0.5 0";
|
||||||
surface = "0 0.707107 -0.707107 0 0 -0.5 -2.84217e-14";
|
surface = "0 0.707107 -0.707107 0 0 -0.5 -2.84217e-14";
|
||||||
surface = "0.5 0.5 -0.5 0.5 -0.5 0 -9.93411e-08";
|
surface = "0.5 0.5 -0.5 0.5 -0.5 0 -9.93411e-08";
|
||||||
surface = "0.5 -0.5 0.5 0.5 0.5 0 -9.93411e-08";
|
surface = "0.5 -0.5 0.5 0.5 0.5 0 -9.93411e-08";
|
||||||
|
|
@ -201,7 +201,7 @@ new SimGroup(MissionGroup) {
|
||||||
|
|
||||||
surface = "0 0 0 1 0 0 0.5";
|
surface = "0 0 0 1 0 0 0.5";
|
||||||
surface = "0 1 0 0 0 0 -0.5";
|
surface = "0 1 0 0 0 0 -0.5";
|
||||||
surface = "0.707107 0 0 0.707106 0 0.5 0";
|
surface = "0.707107 0 0 0.707107 0 0.5 0";
|
||||||
surface = "0 0.707107 -0.707107 0 0 -0.5 -2.84217e-14";
|
surface = "0 0.707107 -0.707107 0 0 -0.5 -2.84217e-14";
|
||||||
surface = "0.5 0.5 -0.5 0.5 -0.5 0 -9.93411e-08";
|
surface = "0.5 0.5 -0.5 0.5 -0.5 0 -9.93411e-08";
|
||||||
surface = "0.5 -0.5 0.5 0.5 0.5 0 -9.93411e-08";
|
surface = "0.5 -0.5 0.5 0.5 0.5 0 -9.93411e-08";
|
||||||
|
|
@ -216,7 +216,7 @@ new SimGroup(MissionGroup) {
|
||||||
|
|
||||||
surface = "0 0 0 1 0 0 0.5";
|
surface = "0 0 0 1 0 0 0.5";
|
||||||
surface = "0 1 0 0 0 0 -0.5";
|
surface = "0 1 0 0 0 0 -0.5";
|
||||||
surface = "0.707107 0 0 0.707106 0 0.5 0";
|
surface = "0.707107 0 0 0.707107 0 0.5 0";
|
||||||
surface = "0 0.707107 -0.707107 0 0 -0.5 -2.84217e-14";
|
surface = "0 0.707107 -0.707107 0 0 -0.5 -2.84217e-14";
|
||||||
surface = "0.5 0.5 -0.5 0.5 -0.5 0 -9.93411e-08";
|
surface = "0.5 0.5 -0.5 0.5 -0.5 0 -9.93411e-08";
|
||||||
surface = "0.5 -0.5 0.5 0.5 0.5 0 -9.93411e-08";
|
surface = "0.5 -0.5 0.5 0.5 0.5 0 -9.93411e-08";
|
||||||
|
|
@ -231,7 +231,7 @@ new SimGroup(MissionGroup) {
|
||||||
|
|
||||||
surface = "0 0 0 1 0 0 0.5";
|
surface = "0 0 0 1 0 0 0.5";
|
||||||
surface = "0 1 0 0 0 0 -0.5";
|
surface = "0 1 0 0 0 0 -0.5";
|
||||||
surface = "0.707107 0 0 0.707107 0 0.5 0";
|
surface = "0.707107 0 0 0.707106 0 0.5 0";
|
||||||
surface = "0 0.707107 -0.707107 0 0 -0.5 -2.84217e-14";
|
surface = "0 0.707107 -0.707107 0 0 -0.5 -2.84217e-14";
|
||||||
surface = "0.5 0.5 -0.5 0.5 -0.5 0 -9.93411e-08";
|
surface = "0.5 0.5 -0.5 0.5 -0.5 0 -9.93411e-08";
|
||||||
surface = "0.5 -0.5 0.5 0.5 0.5 0 -9.93411e-08";
|
surface = "0.5 -0.5 0.5 0.5 0.5 0 -9.93411e-08";
|
||||||
|
|
@ -246,7 +246,7 @@ new SimGroup(MissionGroup) {
|
||||||
|
|
||||||
surface = "0 0 0 1 0 0 0.5";
|
surface = "0 0 0 1 0 0 0.5";
|
||||||
surface = "0 1 0 0 0 0 -0.5";
|
surface = "0 1 0 0 0 0 -0.5";
|
||||||
surface = "0.707107 0 0 0.707106 0 0.5 0";
|
surface = "0.707107 0 0 0.707107 0 0.5 0";
|
||||||
surface = "0 0.707107 -0.707107 0 0 -0.5 -2.84217e-14";
|
surface = "0 0.707107 -0.707107 0 0 -0.5 -2.84217e-14";
|
||||||
surface = "0.5 0.5 -0.5 0.5 -0.5 0 -9.93411e-08";
|
surface = "0.5 0.5 -0.5 0.5 -0.5 0 -9.93411e-08";
|
||||||
surface = "0.5 -0.5 0.5 0.5 0.5 0 -9.93411e-08";
|
surface = "0.5 -0.5 0.5 0.5 0.5 0 -9.93411e-08";
|
||||||
|
|
@ -313,5 +313,65 @@ new SimGroup(MissionGroup) {
|
||||||
canSave = "1";
|
canSave = "1";
|
||||||
canSaveDynamicFields = "1";
|
canSaveDynamicFields = "1";
|
||||||
};
|
};
|
||||||
|
new ReflectionProbe() {
|
||||||
|
enabled = "1";
|
||||||
|
ProbeShape = "Box";
|
||||||
|
radius = "5";
|
||||||
|
posOffset = "0 0 0";
|
||||||
|
ReflectionMode = "Baked Cubemap";
|
||||||
|
reflectionPath = "levels/probeTest/probes/";
|
||||||
|
Bake = "0";
|
||||||
|
position = "-8.24487 0.0825528 2.5031";
|
||||||
|
rotation = "1 0 0 0";
|
||||||
|
scale = "5 5 5";
|
||||||
|
canSave = "1";
|
||||||
|
canSaveDynamicFields = "1";
|
||||||
|
persistentId = "e9c2eed2-1ae9-11e9-9c9a-df9135416cc7";
|
||||||
|
GroundColor = "0.8 0.7 0.5 1";
|
||||||
|
IndirectLight = "1 1 1 1";
|
||||||
|
IndirectLightMode = "Spherical Harmonics";
|
||||||
|
Intensity = "1";
|
||||||
|
SkyColor = "0.5 0.5 1 1";
|
||||||
|
};
|
||||||
|
new ReflectionProbe() {
|
||||||
|
enabled = "1";
|
||||||
|
ProbeShape = "Box";
|
||||||
|
radius = "5";
|
||||||
|
posOffset = "0 0 0";
|
||||||
|
ReflectionMode = "Baked Cubemap";
|
||||||
|
reflectionPath = "levels/probeTest/probes/";
|
||||||
|
Bake = "0";
|
||||||
|
position = "-8.24487 3.18253 2.18272";
|
||||||
|
rotation = "1 0 0 0";
|
||||||
|
scale = "5 5 5";
|
||||||
|
canSave = "1";
|
||||||
|
canSaveDynamicFields = "1";
|
||||||
|
persistentId = "f281a5ff-1ae9-11e9-9c9a-df9135416cc7";
|
||||||
|
GroundColor = "0.8 0.7 0.5 1";
|
||||||
|
IndirectLight = "1 1 1 1";
|
||||||
|
IndirectLightMode = "Spherical Harmonics";
|
||||||
|
Intensity = "1";
|
||||||
|
SkyColor = "0.5 0.5 1 1";
|
||||||
|
};
|
||||||
|
new ReflectionProbe() {
|
||||||
|
enabled = "1";
|
||||||
|
ProbeShape = "Box";
|
||||||
|
radius = "5";
|
||||||
|
posOffset = "0 0 0";
|
||||||
|
ReflectionMode = "Baked Cubemap";
|
||||||
|
reflectionPath = "levels/probeTest/probes/";
|
||||||
|
Bake = "0";
|
||||||
|
position = "-8.24487 -3.37372 2.18272";
|
||||||
|
rotation = "1 0 0 0";
|
||||||
|
scale = "5 5 5";
|
||||||
|
canSave = "1";
|
||||||
|
canSaveDynamicFields = "1";
|
||||||
|
persistentId = "f4db4dde-1ae9-11e9-9c9a-df9135416cc7";
|
||||||
|
GroundColor = "0.8 0.7 0.5 1";
|
||||||
|
IndirectLight = "1 1 1 1";
|
||||||
|
IndirectLightMode = "Spherical Harmonics";
|
||||||
|
Intensity = "1";
|
||||||
|
SkyColor = "0.5 0.5 1 1";
|
||||||
|
};
|
||||||
};
|
};
|
||||||
//--- OBJECT WRITE END ---
|
//--- OBJECT WRITE END ---
|
||||||
|
|
|
||||||
|
|
@ -4,11 +4,19 @@
|
||||||
#include "../../lighting.hlsl"
|
#include "../../lighting.hlsl"
|
||||||
#include "../../torque.hlsl"
|
#include "../../torque.hlsl"
|
||||||
|
|
||||||
struct ConvexConnectP
|
/*struct ConvexConnectP
|
||||||
{
|
{
|
||||||
float4 pos : TORQUE_POSITION;
|
float4 pos : TORQUE_POSITION;
|
||||||
float4 uv0 : TEXCOORD1;
|
float4 uv0 : TEXCOORD1;
|
||||||
float4 vsEyeDir : TEXCOORD2;
|
float4 vsEyeDir : TEXCOORD2;
|
||||||
|
};*/
|
||||||
|
|
||||||
|
struct ConvexConnectP
|
||||||
|
{
|
||||||
|
float4 pos : TORQUE_POSITION;
|
||||||
|
float4 wsEyeDir : TEXCOORD0;
|
||||||
|
float4 ssPos : TEXCOORD1;
|
||||||
|
float4 vsEyeDir : TEXCOORD2;
|
||||||
};
|
};
|
||||||
|
|
||||||
TORQUE_UNIFORM_SAMPLER2D(deferredBuffer, 0);
|
TORQUE_UNIFORM_SAMPLER2D(deferredBuffer, 0);
|
||||||
|
|
@ -57,7 +65,8 @@ float3 iblBoxDiffuse( Surface surface, int id)
|
||||||
{
|
{
|
||||||
float3 cubeN = boxProject(surface.P, surface.N, inProbePosArray[id], bbMinArray[id], bbMaxArray[id]);
|
float3 cubeN = boxProject(surface.P, surface.N, inProbePosArray[id], bbMinArray[id], bbMaxArray[id]);
|
||||||
cubeN.z *=-1;
|
cubeN.z *=-1;
|
||||||
return TORQUE_TEXCUBEARRAYLOD(irradianceCubemap,cubeN,id,0).xyz;
|
//return TORQUE_TEXCUBEARRAYLOD(irradianceCubemap,cubeN,id,0).xyz;
|
||||||
|
return float3(1,1,1);
|
||||||
}
|
}
|
||||||
|
|
||||||
float3 iblBoxSpecular(Surface surface, float3 surfToEye, TORQUE_SAMPLER2D(brdfTexture), int id)
|
float3 iblBoxSpecular(Surface surface, float3 surfToEye, TORQUE_SAMPLER2D(brdfTexture), int id)
|
||||||
|
|
@ -73,7 +82,8 @@ float3 iblBoxSpecular(Surface surface, float3 surfToEye, TORQUE_SAMPLER2D(brdfTe
|
||||||
float3 cubeR = normalize(r);
|
float3 cubeR = normalize(r);
|
||||||
cubeR = boxProject(surface.P, surface.N, inProbePosArray[id], bbMinArray[id], bbMaxArray[id]);
|
cubeR = boxProject(surface.P, surface.N, inProbePosArray[id], bbMinArray[id], bbMaxArray[id]);
|
||||||
|
|
||||||
float3 radiance = TORQUE_TEXCUBEARRAYLOD(cubeMap,cubeR,id,lod).xyz * (brdf.x + brdf.y);
|
//float3 radiance = TORQUE_TEXCUBEARRAYLOD(cubeMap,cubeR,id,lod).xyz * (brdf.x + brdf.y);
|
||||||
|
float3 radiance = float3(1,1,1);
|
||||||
|
|
||||||
return radiance;
|
return radiance;
|
||||||
}
|
}
|
||||||
|
|
@ -97,16 +107,20 @@ float defineBoxSpaceInfluence(Surface surface, int id)
|
||||||
|
|
||||||
float4 main( ConvexConnectP IN ) : SV_TARGET
|
float4 main( ConvexConnectP IN ) : SV_TARGET
|
||||||
{
|
{
|
||||||
|
// Compute scene UV
|
||||||
|
float3 ssPos = IN.ssPos.xyz / IN.ssPos.w;
|
||||||
|
float2 uvScene = getUVFromSSPos( ssPos, rtParams0 );
|
||||||
|
|
||||||
//eye ray WS/LS
|
//eye ray WS/LS
|
||||||
float3 vsEyeRay = getDistanceVectorToPlane( -vsFarPlane.w, IN.vsEyeDir.xyz, vsFarPlane );
|
float3 vsEyeRay = getDistanceVectorToPlane( -vsFarPlane.w, IN.vsEyeDir.xyz, vsFarPlane );
|
||||||
float3 wsEyeRay = mul(cameraToWorld, float4(vsEyeRay, 0)).xyz;
|
float3 wsEyeRay = mul(cameraToWorld, float4(vsEyeRay, 0)).xyz;
|
||||||
|
|
||||||
//unpack normal and linear depth
|
//unpack normal and linear depth
|
||||||
float4 normDepth = TORQUE_DEFERRED_UNCONDITION(deferredBuffer, IN.uv0.xy);
|
float4 normDepth = TORQUE_DEFERRED_UNCONDITION(deferredBuffer, uvScene);
|
||||||
|
|
||||||
//create surface
|
//create surface
|
||||||
Surface surface = createSurface( normDepth, TORQUE_SAMPLER2D_MAKEARG(colorBuffer),TORQUE_SAMPLER2D_MAKEARG(matInfoBuffer),
|
Surface surface = createSurface( normDepth, TORQUE_SAMPLER2D_MAKEARG(colorBuffer),TORQUE_SAMPLER2D_MAKEARG(matInfoBuffer),
|
||||||
IN.uv0.xy, eyePosWorld, wsEyeRay, cameraToWorld);
|
uvScene, eyePosWorld, wsEyeRay, cameraToWorld);
|
||||||
//early out if emissive
|
//early out if emissive
|
||||||
if (getFlag(surface.matFlag, 0))
|
if (getFlag(surface.matFlag, 0))
|
||||||
{
|
{
|
||||||
|
|
@ -121,22 +135,22 @@ float4 main( ConvexConnectP IN ) : SV_TARGET
|
||||||
|
|
||||||
for(i=0; i < numProbes; i++)
|
for(i=0; i < numProbes; i++)
|
||||||
{
|
{
|
||||||
float3 probeWS = inProbePosArray[i];
|
float3 probeWS = inProbePosArray[i];
|
||||||
float3 L = probeWS - surface.P;
|
float3 L = probeWS - surface.P;
|
||||||
|
|
||||||
if(useSphereMode[i])
|
if(useSphereMode[i])
|
||||||
{
|
{
|
||||||
float3 L = inProbePosArray[i] - surface.P;
|
float3 L = inProbePosArray[i] - surface.P;
|
||||||
blendVal[i] = 1.0-length(L)/radius[i];
|
blendVal[i] = 1.0-length(L)/radius[i];
|
||||||
blendVal[i] = max(0,blendVal[i]);
|
blendVal[i] = max(0,blendVal[i]);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
blendVal[i] = defineBoxSpaceInfluence(surface, i);
|
blendVal[i] = defineBoxSpaceInfluence(surface, i);
|
||||||
blendVal[i] = max(0,blendVal[i]);
|
blendVal[i] = max(0,blendVal[i]);
|
||||||
}
|
}
|
||||||
blendSum += blendVal[i];
|
blendSum += blendVal[i];
|
||||||
invBlendSum +=(1.0f - blendVal[i]);
|
invBlendSum +=(1.0f - blendVal[i]);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Weight0 = normalized NDF, inverted to have 1 at center, 0 at boundary.
|
// Weight0 = normalized NDF, inverted to have 1 at center, 0 at boundary.
|
||||||
|
|
@ -166,6 +180,7 @@ float4 main( ConvexConnectP IN ) : SV_TARGET
|
||||||
float3 irradiance = float3(0,0,0);
|
float3 irradiance = float3(0,0,0);
|
||||||
float3 specular = float3(0,0,0);
|
float3 specular = float3(0,0,0);
|
||||||
float3 F = FresnelSchlickRoughness(surface.NdotV, surface.f0, surface.roughness);
|
float3 F = FresnelSchlickRoughness(surface.NdotV, surface.f0, surface.roughness);
|
||||||
|
|
||||||
//energy conservation
|
//energy conservation
|
||||||
float3 kD = 1.0.xxx - F;
|
float3 kD = 1.0.xxx - F;
|
||||||
kD *= 1.0 - surface.metalness;
|
kD *= 1.0 - surface.metalness;
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue