mirror of
https://github.com/TorqueGameEngines/Torque3D.git
synced 2026-02-28 02:53:49 +00:00
Corrected probe init'ing so they don't fight for the cubemap idx order
Also correct deleting behavior so it updates indicies when a probe is removed Updated forward lighting to utilize the same math as deferred
This commit is contained in:
parent
a2aa241c92
commit
e87dc787ee
18 changed files with 426 additions and 375 deletions
|
|
@ -388,10 +388,9 @@ void AdvancedLightManager::setLightInfo( ProcessedMaterial *pmat,
|
|||
lsc->mLightPositionSC,
|
||||
lsc->mLightDiffuseSC,
|
||||
lsc->mLightAmbientSC,
|
||||
lsc->mLightInvRadiusSqSC,
|
||||
lsc->mLightConfigDataSC,
|
||||
lsc->mLightSpotDirSC,
|
||||
lsc->mLightSpotAngleSC,
|
||||
lsc->mLightSpotFalloffSC,
|
||||
lsc->mLightSpotParamsSC,
|
||||
shaderConsts );
|
||||
|
||||
// Static
|
||||
|
|
|
|||
|
|
@ -304,10 +304,9 @@ BasicLightManager::LightingShaderConstants::LightingShaderConstants()
|
|||
mLightPosition( NULL ),
|
||||
mLightDiffuse( NULL ),
|
||||
mLightAmbient( NULL ),
|
||||
mLightInvRadiusSq( NULL ),
|
||||
mLightConfigDataSC( NULL ),
|
||||
mLightSpotDir( NULL ),
|
||||
mLightSpotAngle( NULL ),
|
||||
mLightSpotFalloff( NULL )
|
||||
mLightSpotParamsSC( NULL )
|
||||
{
|
||||
}
|
||||
|
||||
|
|
@ -333,11 +332,10 @@ void BasicLightManager::LightingShaderConstants::init(GFXShader* shader)
|
|||
|
||||
mLightPosition = shader->getShaderConstHandle( ShaderGenVars::lightPosition );
|
||||
mLightDiffuse = shader->getShaderConstHandle( ShaderGenVars::lightDiffuse);
|
||||
mLightInvRadiusSq = shader->getShaderConstHandle( ShaderGenVars::lightInvRadiusSq );
|
||||
mLightConfigDataSC = shader->getShaderConstHandle( ShaderGenVars::lightConfigData );
|
||||
mLightAmbient = shader->getShaderConstHandle( ShaderGenVars::lightAmbient );
|
||||
mLightSpotDir = shader->getShaderConstHandle( ShaderGenVars::lightSpotDir );
|
||||
mLightSpotAngle = shader->getShaderConstHandle( ShaderGenVars::lightSpotAngle );
|
||||
mLightSpotFalloff = shader->getShaderConstHandle( ShaderGenVars::lightSpotFalloff );
|
||||
mLightSpotParamsSC = shader->getShaderConstHandle( ShaderGenVars::lightSpotParams );
|
||||
|
||||
mInit = true;
|
||||
}
|
||||
|
|
@ -399,9 +397,8 @@ void BasicLightManager::setLightInfo( ProcessedMaterial* pmat,
|
|||
mLastConstants->mLightPosition,
|
||||
mLastConstants->mLightDiffuse,
|
||||
mLastConstants->mLightAmbient,
|
||||
mLastConstants->mLightInvRadiusSq,
|
||||
mLastConstants->mLightConfigDataSC,
|
||||
mLastConstants->mLightSpotDir,
|
||||
mLastConstants->mLightSpotAngle,
|
||||
mLastConstants->mLightSpotFalloff,
|
||||
mLastConstants->mLightSpotParamsSC,
|
||||
shaderConsts );
|
||||
}
|
||||
|
|
|
|||
|
|
@ -88,10 +88,9 @@ protected:
|
|||
GFXShaderConstHandle *mLightPosition;
|
||||
GFXShaderConstHandle *mLightDiffuse;
|
||||
GFXShaderConstHandle *mLightAmbient;
|
||||
GFXShaderConstHandle *mLightInvRadiusSq;
|
||||
GFXShaderConstHandle *mLightConfigDataSC;
|
||||
GFXShaderConstHandle *mLightSpotDir;
|
||||
GFXShaderConstHandle *mLightSpotAngle;
|
||||
GFXShaderConstHandle *mLightSpotFalloff;
|
||||
GFXShaderConstHandle *mLightSpotParamsSC;
|
||||
|
||||
LightingShaderConstants();
|
||||
~LightingShaderConstants();
|
||||
|
|
|
|||
|
|
@ -306,10 +306,9 @@ void LightManager::_update4LightConsts( const SceneData &sgData,
|
|||
GFXShaderConstHandle *lightPositionSC,
|
||||
GFXShaderConstHandle *lightDiffuseSC,
|
||||
GFXShaderConstHandle *lightAmbientSC,
|
||||
GFXShaderConstHandle *lightInvRadiusSqSC,
|
||||
GFXShaderConstHandle *lightConfigDataSC,
|
||||
GFXShaderConstHandle *lightSpotDirSC,
|
||||
GFXShaderConstHandle *lightSpotAngleSC,
|
||||
GFXShaderConstHandle *lightSpotFalloffSC,
|
||||
GFXShaderConstHandle *lightSpotParamsSC,
|
||||
GFXShaderConstBuffer *shaderConsts )
|
||||
{
|
||||
PROFILE_SCOPE( LightManager_Update4LightConsts );
|
||||
|
|
@ -317,14 +316,110 @@ void LightManager::_update4LightConsts( const SceneData &sgData,
|
|||
// Skip over gathering lights if we don't have to!
|
||||
if ( lightPositionSC->isValid() ||
|
||||
lightDiffuseSC->isValid() ||
|
||||
lightInvRadiusSqSC->isValid() ||
|
||||
lightConfigDataSC->isValid() ||
|
||||
lightSpotDirSC->isValid() ||
|
||||
lightSpotAngleSC->isValid() ||
|
||||
lightSpotFalloffSC->isValid() )
|
||||
lightSpotParamsSC->isValid() )
|
||||
{
|
||||
PROFILE_SCOPE( LightManager_Update4LightConsts_setLights );
|
||||
|
||||
static AlignedArray<Point4F> lightPositions( 3, sizeof( Point4F ) );
|
||||
//new setup
|
||||
const U32 MAX_FORWARD_LIGHTS = 4;
|
||||
|
||||
static AlignedArray<Point4F> lightPositions(MAX_FORWARD_LIGHTS, sizeof(Point4F));
|
||||
static AlignedArray<Point4F> lightSpotDirs(MAX_FORWARD_LIGHTS, sizeof(Point4F));
|
||||
static AlignedArray<Point4F> lightColors(MAX_FORWARD_LIGHTS, sizeof(Point4F));
|
||||
static AlignedArray<Point4F> lightConfigData(MAX_FORWARD_LIGHTS, sizeof(Point4F)); //type, brightness, range, invSqrRange : rgba
|
||||
static AlignedArray<Point4F> lightSpotParams(MAX_FORWARD_LIGHTS, sizeof(Point4F));
|
||||
|
||||
dMemset(lightPositions.getBuffer(), 0, lightPositions.getBufferSize());
|
||||
dMemset(lightSpotDirs.getBuffer(), 0, lightSpotDirs.getBufferSize());
|
||||
dMemset(lightColors.getBuffer(), 0, lightColors.getBufferSize());
|
||||
dMemset(lightConfigData.getBuffer(), 0, lightConfigData.getBufferSize());
|
||||
dMemset(lightSpotParams.getBuffer(), 0, lightSpotParams.getBufferSize());
|
||||
|
||||
//sun-only
|
||||
F32 vectorLightBrightness;
|
||||
static Point4F vectorLightDirection;
|
||||
static Point4F vectorLightColor;
|
||||
static Point4F vectorLightAmbientColor;
|
||||
int hasVectorLight = 0;
|
||||
|
||||
vectorLightBrightness = 0;
|
||||
vectorLightDirection = Point4F::Zero;
|
||||
vectorLightColor = Point4F::Zero;
|
||||
vectorLightAmbientColor = Point4F::Zero;
|
||||
|
||||
// Gather the data for the first 4 lights.
|
||||
const LightInfo* light;
|
||||
for (U32 i = 0; i < MAX_FORWARD_LIGHTS; i++)
|
||||
{
|
||||
light = sgData.lights[i];
|
||||
if (!light)
|
||||
break;
|
||||
|
||||
if (light->getType() == LightInfo::Vector)
|
||||
{
|
||||
if (hasVectorLight != 0)
|
||||
continue;
|
||||
|
||||
vectorLightBrightness = light->getBrightness();
|
||||
vectorLightDirection = light->getDirection();
|
||||
vectorLightColor = Point4F(light->getColor());
|
||||
vectorLightAmbientColor = Point4F(light->getAmbient());
|
||||
hasVectorLight = 1;
|
||||
continue;
|
||||
}
|
||||
|
||||
// The light positions and spot directions are
|
||||
// in SoA order to make optimal use of the GPU.
|
||||
const Point3F& lightPos = light->getPosition();
|
||||
lightPositions[i].x = lightPos.x;
|
||||
lightPositions[i].y = lightPos.y;
|
||||
lightPositions[i].z = lightPos.z;
|
||||
lightPositions[i].w = 0;
|
||||
|
||||
const VectorF& lightDir = light->getDirection();
|
||||
lightSpotDirs[i].x = lightDir.x;
|
||||
lightSpotDirs[i].y = lightDir.y;
|
||||
lightSpotDirs[i].z = lightDir.z;
|
||||
lightSpotDirs[i].w = 0;
|
||||
|
||||
lightColors[i] = Point4F(light->getColor());
|
||||
|
||||
if (light->getType() == LightInfo::Point)
|
||||
{
|
||||
lightConfigData[i].x = 0;
|
||||
}
|
||||
else if (light->getType() == LightInfo::Spot)
|
||||
{
|
||||
lightConfigData[i].x = 1;
|
||||
|
||||
const F32 outerCone = light->getOuterConeAngle();
|
||||
const F32 innerCone = getMin(light->getInnerConeAngle(), outerCone);
|
||||
const F32 outerCos = mCos(mDegToRad(outerCone / 2.0f));
|
||||
const F32 innerCos = mCos(mDegToRad(innerCone / 2.0f));
|
||||
Point2F spotParams(outerCos, innerCos - outerCos);
|
||||
|
||||
lightSpotParams[i].x = spotParams.x;
|
||||
lightSpotParams[i].y = spotParams.y;
|
||||
}
|
||||
|
||||
lightConfigData[i].y = light->getBrightness();
|
||||
|
||||
F32 range = light->getRange().x;
|
||||
lightConfigData[i].z = range;
|
||||
lightConfigData[i].w = 1.0f / (range * range);
|
||||
}
|
||||
|
||||
shaderConsts->setSafe(lightPositionSC, lightPositions);
|
||||
shaderConsts->setSafe(lightDiffuseSC, lightColors);
|
||||
shaderConsts->setSafe(lightSpotDirSC, lightSpotDirs);
|
||||
shaderConsts->setSafe(lightConfigDataSC, lightConfigData);
|
||||
shaderConsts->setSafe(lightSpotParamsSC, lightSpotParams);
|
||||
|
||||
//================================================================
|
||||
//old setup
|
||||
/*static AlignedArray<Point4F> lightPositions( 3, sizeof( Point4F ) );
|
||||
static AlignedArray<Point4F> lightSpotDirs( 3, sizeof( Point4F ) );
|
||||
static AlignedArray<Point4F> lightColors( 4, sizeof( Point4F ) );
|
||||
static Point4F lightInvRadiusSq;
|
||||
|
|
@ -343,7 +438,7 @@ void LightManager::_update4LightConsts( const SceneData &sgData,
|
|||
|
||||
// Gather the data for the first 4 lights.
|
||||
const LightInfo *light;
|
||||
for ( U32 i=0; i < 4; i++ )
|
||||
for ( U32 i=0; i < MAX_FORWARD_LIGHTS; i++ )
|
||||
{
|
||||
light = sgData.lights[i];
|
||||
if ( !light )
|
||||
|
|
@ -382,7 +477,7 @@ void LightManager::_update4LightConsts( const SceneData &sgData,
|
|||
|
||||
shaderConsts->setSafe( lightSpotDirSC, lightSpotDirs );
|
||||
shaderConsts->setSafe( lightSpotAngleSC, lightSpotAngle );
|
||||
shaderConsts->setSafe( lightSpotFalloffSC, lightSpotFalloff );
|
||||
shaderConsts->setSafe( lightSpotFalloffSC, lightSpotFalloff );*/
|
||||
}
|
||||
|
||||
// Setup the ambient lighting from the first
|
||||
|
|
|
|||
|
|
@ -177,8 +177,7 @@ protected:
|
|||
GFXShaderConstHandle *lightAmbientSC,
|
||||
GFXShaderConstHandle *lightInvRadiusSqSC,
|
||||
GFXShaderConstHandle *lightSpotDirSC,
|
||||
GFXShaderConstHandle *lightSpotAngleSC,
|
||||
GFXShaderConstHandle *lightSpotFalloffSC,
|
||||
GFXShaderConstHandle * lightSpotParamsSC,
|
||||
GFXShaderConstBuffer *shaderConsts );
|
||||
|
||||
/// A dummy default light used when no lights
|
||||
|
|
|
|||
|
|
@ -460,10 +460,8 @@ LightingShaderConstants::LightingShaderConstants()
|
|||
mLightPositionSC(NULL),
|
||||
mLightDiffuseSC(NULL),
|
||||
mLightAmbientSC(NULL),
|
||||
mLightInvRadiusSqSC(NULL),
|
||||
mLightConfigDataSC(NULL),
|
||||
mLightSpotDirSC(NULL),
|
||||
mLightSpotAngleSC(NULL),
|
||||
mLightSpotFalloffSC(NULL),
|
||||
mShadowMapSC(NULL),
|
||||
mDynamicShadowMapSC(NULL),
|
||||
mShadowMapSizeSC(NULL),
|
||||
|
|
@ -524,10 +522,8 @@ void LightingShaderConstants::init(GFXShader* shader)
|
|||
mLightPositionSC = shader->getShaderConstHandle( ShaderGenVars::lightPosition );
|
||||
mLightDiffuseSC = shader->getShaderConstHandle( ShaderGenVars::lightDiffuse );
|
||||
mLightAmbientSC = shader->getShaderConstHandle( ShaderGenVars::lightAmbient );
|
||||
mLightInvRadiusSqSC = shader->getShaderConstHandle( ShaderGenVars::lightInvRadiusSq );
|
||||
mLightConfigDataSC = shader->getShaderConstHandle( ShaderGenVars::lightConfigData);
|
||||
mLightSpotDirSC = shader->getShaderConstHandle( ShaderGenVars::lightSpotDir );
|
||||
mLightSpotAngleSC = shader->getShaderConstHandle( ShaderGenVars::lightSpotAngle );
|
||||
mLightSpotFalloffSC = shader->getShaderConstHandle( ShaderGenVars::lightSpotFalloff );
|
||||
|
||||
mShadowMapSC = shader->getShaderConstHandle("$shadowMap");
|
||||
mDynamicShadowMapSC = shader->getShaderConstHandle("$dynamicShadowMap");
|
||||
|
|
|
|||
|
|
@ -87,10 +87,8 @@ struct LightingShaderConstants
|
|||
GFXShaderConstHandle *mLightPositionSC;
|
||||
GFXShaderConstHandle *mLightDiffuseSC;
|
||||
GFXShaderConstHandle *mLightAmbientSC;
|
||||
GFXShaderConstHandle *mLightInvRadiusSqSC;
|
||||
GFXShaderConstHandle *mLightConfigDataSC;
|
||||
GFXShaderConstHandle *mLightSpotDirSC;
|
||||
GFXShaderConstHandle *mLightSpotAngleSC;
|
||||
GFXShaderConstHandle *mLightSpotFalloffSC;
|
||||
|
||||
GFXShaderConstHandle* mShadowMapSC;
|
||||
GFXShaderConstHandle* mDynamicShadowMapSC;
|
||||
|
|
|
|||
|
|
@ -317,10 +317,10 @@ void RenderProbeMgr::addElement(RenderInst *inst)
|
|||
|
||||
ProbeRenderInst* RenderProbeMgr::registerProbe()
|
||||
{
|
||||
ProbeRenderInst newProbe;
|
||||
mRegisteredProbes.increment();
|
||||
ProbeRenderInst* newProbe = &mRegisteredProbes.last();
|
||||
|
||||
mRegisteredProbes.push_back(newProbe);
|
||||
newProbe.mProbeIdx = mRegisteredProbes.size();
|
||||
newProbe->mProbeIdx = mRegisteredProbes.size() - 1;
|
||||
|
||||
const U32 cubeIndex = _findNextEmptyCubeSlot();
|
||||
if (cubeIndex == INVALID_CUBE_SLOT)
|
||||
|
|
@ -349,18 +349,18 @@ ProbeRenderInst* RenderProbeMgr::registerProbe()
|
|||
mCubeSlotCount += PROBE_ARRAY_SLOT_BUFFER_SIZE;
|
||||
}
|
||||
|
||||
newProbe.mCubemapIndex = cubeIndex;
|
||||
newProbe->mCubemapIndex = cubeIndex;
|
||||
//mark cubemap slot as taken
|
||||
mCubeMapSlots[cubeIndex] = true;
|
||||
mCubeMapCount++;
|
||||
|
||||
#ifdef TORQUE_DEBUG
|
||||
Con::warnf("RenderProbeMgr::registerProbe: Registered probe %u to cubeIndex %u", newProbe.mProbeIdx, cubeIndex);
|
||||
Con::warnf("RenderProbeMgr::registerProbe: Registered probe %u to cubeIndex %u", newProbe->mProbeIdx, cubeIndex);
|
||||
#endif
|
||||
|
||||
mProbesDirty = true;
|
||||
|
||||
return &mRegisteredProbes.last();
|
||||
return newProbe;
|
||||
}
|
||||
|
||||
void RenderProbeMgr::unregisterProbe(U32 probeIdx)
|
||||
|
|
@ -378,6 +378,12 @@ void RenderProbeMgr::unregisterProbe(U32 probeIdx)
|
|||
|
||||
mRegisteredProbes.erase(probeIdx);
|
||||
|
||||
//recalculate all the probe's indicies just to be sure
|
||||
for (U32 i = 0; i < mRegisteredProbes.size(); i++)
|
||||
{
|
||||
mRegisteredProbes[i].mProbeIdx == i;
|
||||
}
|
||||
|
||||
//rebuild our probe data
|
||||
mProbesDirty = true;
|
||||
}
|
||||
|
|
@ -750,7 +756,7 @@ void RenderProbeMgr::render( SceneRenderState *state )
|
|||
mProbeArrayEffect->setCubemapArrayTexture(5, mIrradianceArray);
|
||||
|
||||
mProbeArrayEffect->setShaderConst("$numProbes", (S32)mEffectiveProbeCount);
|
||||
mProbeArrayEffect->setShaderConst("$skylightCubemapIdx", mSkylightCubemapIdx);
|
||||
mProbeArrayEffect->setShaderConst("$skylightCubemapIdx", (S32)mSkylightCubemapIdx);
|
||||
|
||||
mProbeArrayEffect->setShaderConst("$cubeMips", (float)mMipCount);
|
||||
|
||||
|
|
|
|||
|
|
@ -818,6 +818,74 @@ Var* ShaderFeatureHLSL::addOutDetailTexCoord( Vector<ShaderComponent*> &compon
|
|||
return outTex;
|
||||
}
|
||||
|
||||
Var* ShaderFeatureHLSL::getSurface(Vector<ShaderComponent*>& componentList, MultiLine* meta)
|
||||
{
|
||||
ShaderConnector* connectComp = dynamic_cast<ShaderConnector*>(componentList[C_CONNECTOR]);
|
||||
|
||||
Var* diffuseColor = (Var*)LangElement::find(getOutputTargetVarName(ShaderFeature::DefaultTarget));
|
||||
|
||||
Var* matinfo = (Var*)LangElement::find("PBRConfig");
|
||||
if (!matinfo)
|
||||
{
|
||||
Var* metalness = (Var*)LangElement::find("metalness");
|
||||
if (!metalness)
|
||||
{
|
||||
metalness = new Var("metalness", "float");
|
||||
metalness->uniform = true;
|
||||
metalness->constSortPos = cspPotentialPrimitive;
|
||||
}
|
||||
|
||||
Var* smoothness = (Var*)LangElement::find("smoothness");
|
||||
if (!smoothness)
|
||||
{
|
||||
smoothness = new Var("smoothness", "float");
|
||||
smoothness->uniform = true;
|
||||
smoothness->constSortPos = cspPotentialPrimitive;
|
||||
}
|
||||
|
||||
matinfo = new Var("PBRConfig", "float4");
|
||||
LangElement* colorDecl = new DecOp(matinfo);
|
||||
meta->addStatement(new GenOp(" @ = float4(0.0,1.0,@,@);\r\n", colorDecl, smoothness, metalness)); //reconstruct matinfo, no ao darkening
|
||||
}
|
||||
|
||||
Var* inTex = getInTexCoord("texCoord", "float2", componentList);
|
||||
if (!inTex)
|
||||
return nullptr;
|
||||
|
||||
Var* wsNormal = (Var*)LangElement::find("wsNormal");
|
||||
if (!wsNormal)
|
||||
{
|
||||
wsNormal = connectComp->getElement(RT_TEXCOORD);
|
||||
wsNormal->setName("wsNormal");
|
||||
wsNormal->setStructName("IN");
|
||||
wsNormal->setType("float3");
|
||||
|
||||
// If we loaded the normal its our responsibility
|
||||
// to normalize it... the interpolators won't.
|
||||
//
|
||||
// Note we cast to half here to get partial precision
|
||||
// optimized code which is an acceptable loss of
|
||||
// precision for normals and performs much better
|
||||
// on older Geforce cards.
|
||||
//
|
||||
meta->addStatement(new GenOp(" @ = normalize( half3( @ ) );\r\n", wsNormal, wsNormal));
|
||||
}
|
||||
|
||||
Var* wsEyePos = (Var*)LangElement::find("eyePosWorld");
|
||||
Var* wsPosition = getInWsPosition(componentList);
|
||||
Var* wsView = getWsView(wsPosition, meta);
|
||||
|
||||
Var* surface = (Var*)LangElement::find("surface");
|
||||
|
||||
if (!surface)
|
||||
{
|
||||
surface = new Var("surface", "Surface");
|
||||
meta->addStatement(new GenOp(" @ = createForwardSurface(@,@,@,@,@,@,@);\r\n\n", new DecOp(surface), diffuseColor, wsNormal, matinfo,
|
||||
inTex, wsPosition, wsEyePos, wsView));
|
||||
}
|
||||
|
||||
return surface;
|
||||
}
|
||||
//****************************************************************************
|
||||
// Base Texture
|
||||
//****************************************************************************
|
||||
|
|
@ -2157,10 +2225,10 @@ void RTLightingFeatHLSL::processPix( Vector<ShaderComponent*> &componentList,
|
|||
Var *wsView = getWsView( wsPosition, meta );
|
||||
|
||||
// Create temporaries to hold results of lighting.
|
||||
Var *rtShading = new Var( "rtShading", "float4" );
|
||||
Var *specular = new Var( "specular", "float4" );
|
||||
meta->addStatement( new GenOp( " @; @;\r\n",
|
||||
new DecOp( rtShading ), new DecOp( specular ) ) );
|
||||
//Var *rtShading = new Var( "rtShading", "float4" );
|
||||
//Var *specular = new Var( "specular", "float4" );
|
||||
//meta->addStatement( new GenOp( " @; @;\r\n",
|
||||
// new DecOp( rtShading ), new DecOp( specular ) ) );
|
||||
|
||||
// Look for a light mask generated from a previous
|
||||
// feature (this is done for BL terrain lightmaps).
|
||||
|
|
@ -2171,12 +2239,13 @@ void RTLightingFeatHLSL::processPix( Vector<ShaderComponent*> &componentList,
|
|||
// Get all the light constants.
|
||||
Var *inLightPos = new Var( "inLightPos", "float4" );
|
||||
inLightPos->uniform = true;
|
||||
inLightPos->arraySize = 3;
|
||||
inLightPos->arraySize = 4;
|
||||
inLightPos->constSortPos = cspPotentialPrimitive;
|
||||
|
||||
Var *inLightInvRadiusSq = new Var( "inLightInvRadiusSq", "float4" );
|
||||
inLightInvRadiusSq->uniform = true;
|
||||
inLightInvRadiusSq->constSortPos = cspPotentialPrimitive;
|
||||
Var * inLightConfigData = new Var( "inLightConfigData", "float4" );
|
||||
inLightConfigData->uniform = true;
|
||||
inLightConfigData->arraySize = 4;
|
||||
inLightConfigData->constSortPos = cspPotentialPrimitive;
|
||||
|
||||
Var *inLightColor = new Var( "inLightColor", "float4" );
|
||||
inLightColor->uniform = true;
|
||||
|
|
@ -2185,19 +2254,23 @@ void RTLightingFeatHLSL::processPix( Vector<ShaderComponent*> &componentList,
|
|||
|
||||
Var *inLightSpotDir = new Var( "inLightSpotDir", "float4" );
|
||||
inLightSpotDir->uniform = true;
|
||||
inLightSpotDir->arraySize = 3;
|
||||
inLightSpotDir->arraySize = 4;
|
||||
inLightSpotDir->constSortPos = cspPotentialPrimitive;
|
||||
|
||||
Var *inLightSpotAngle = new Var( "inLightSpotAngle", "float4" );
|
||||
inLightSpotAngle->uniform = true;
|
||||
inLightSpotAngle->constSortPos = cspPotentialPrimitive;
|
||||
Var * lightSpotParams = new Var( "lightSpotParams", "float4" );
|
||||
lightSpotParams->uniform = true;
|
||||
lightSpotParams->arraySize = 4;
|
||||
lightSpotParams->constSortPos = cspPotentialPrimitive;
|
||||
|
||||
Var *lightSpotFalloff = new Var( "inLightSpotFalloff", "float4" );
|
||||
lightSpotFalloff->uniform = true;
|
||||
lightSpotFalloff->constSortPos = cspPotentialPrimitive;
|
||||
Var* surface = getSurface(componentList, meta);
|
||||
if (!surface)
|
||||
{
|
||||
Con::errorf("ShaderGen::RTLightingFeatHLSL() - failed to generate surface!");
|
||||
return;
|
||||
}
|
||||
|
||||
Var *smoothness = (Var*)LangElement::find("smoothness");
|
||||
if (!fd.features[MFT_SpecularMap])
|
||||
/*if (!fd.features[MFT_SpecularMap])
|
||||
{
|
||||
if (!smoothness)
|
||||
{
|
||||
|
|
@ -2205,10 +2278,10 @@ void RTLightingFeatHLSL::processPix( Vector<ShaderComponent*> &componentList,
|
|||
smoothness->uniform = true;
|
||||
smoothness->constSortPos = cspPotentialPrimitive;
|
||||
}
|
||||
}
|
||||
}*/
|
||||
|
||||
Var *metalness = (Var*)LangElement::find("metalness");
|
||||
if (!fd.features[MFT_SpecularMap])
|
||||
/*if (!fd.features[MFT_SpecularMap])
|
||||
{
|
||||
if (!metalness)
|
||||
{
|
||||
|
|
@ -2216,7 +2289,7 @@ void RTLightingFeatHLSL::processPix( Vector<ShaderComponent*> &componentList,
|
|||
metalness->uniform = true;
|
||||
metalness->constSortPos = cspPotentialPrimitive;
|
||||
}
|
||||
}
|
||||
}*/
|
||||
|
||||
Var *albedo = (Var*)LangElement::find(getOutputTargetVarName(ShaderFeature::DefaultTarget));
|
||||
|
||||
|
|
@ -2225,16 +2298,24 @@ void RTLightingFeatHLSL::processPix( Vector<ShaderComponent*> &componentList,
|
|||
ambient->constSortPos = cspPass;
|
||||
|
||||
// Calculate the diffuse shading and specular powers.
|
||||
meta->addStatement( new GenOp( " compute4Lights( @, @, @, @,\r\n"
|
||||
/*meta->addStatement( new GenOp( " compute4Lights( @, @, @, @,\r\n"
|
||||
" @, @, @, @, @, @, @, @, @,\r\n"
|
||||
" @, @ );\r\n",
|
||||
wsView, wsPosition, wsNormal, lightMask,
|
||||
inLightPos, inLightInvRadiusSq, inLightColor, inLightSpotDir, inLightSpotAngle, lightSpotFalloff, smoothness, metalness, albedo,
|
||||
inLightPos, inLightConfigData, inLightColor, inLightSpotDir, inLightSpotAngle, lightSpotFalloff, smoothness, metalness, albedo,
|
||||
rtShading, specular ) );
|
||||
|
||||
// Apply the lighting to the diffuse color.
|
||||
LangElement *lighting = new GenOp( "float4( @.rgb + @.rgb, 1 )", rtShading, ambient );
|
||||
meta->addStatement( new GenOp( " @;\r\n", assignColor( lighting, Material::Mul ) ) );
|
||||
meta->addStatement( new GenOp( " @;\r\n", assignColor( lighting, Material::Mul ) ) );*/
|
||||
|
||||
Var* lighting = new Var("lighting", "float4");
|
||||
meta->addStatement(new GenOp(" @ = compute4Lights( @, @, @, @,\r\n"
|
||||
" @, @, @);\r\n",
|
||||
new DecOp(lighting), surface, lightMask, inLightPos, inLightConfigData, inLightColor, inLightSpotDir, lightSpotParams));
|
||||
|
||||
meta->addStatement(new GenOp(" @;\r\n", assignColor(lighting, Material::Add)));
|
||||
|
||||
output = meta;
|
||||
}
|
||||
|
||||
|
|
@ -3051,6 +3132,14 @@ void ReflectionProbeFeatHLSL::processPix(Vector<ShaderComponent*> &componentList
|
|||
irradianceCubemapARTex->uniform = true;
|
||||
irradianceCubemapARTex->texture = true;
|
||||
irradianceCubemapARTex->constNum = irradianceCubemapAR->constNum;
|
||||
|
||||
Var* surface = getSurface(componentList, meta);
|
||||
|
||||
if (!surface)
|
||||
{
|
||||
Con::errorf("ShaderGen::ReflectionProbeFeatHLSL() - failed to generate surface!");
|
||||
return;
|
||||
}
|
||||
|
||||
Var *inTex = getInTexCoord("texCoord", "float2", componentList);
|
||||
if (!inTex)
|
||||
|
|
@ -3059,55 +3148,15 @@ void ReflectionProbeFeatHLSL::processPix(Vector<ShaderComponent*> &componentList
|
|||
Var *diffuseColor = (Var*)LangElement::find(getOutputTargetVarName(ShaderFeature::DefaultTarget));
|
||||
|
||||
Var *matinfo = (Var*)LangElement::find("PBRConfig");
|
||||
if (!matinfo)
|
||||
{
|
||||
Var* metalness = (Var*)LangElement::find("metalness");
|
||||
if (!metalness)
|
||||
{
|
||||
metalness = new Var("metalness", "float");
|
||||
metalness->uniform = true;
|
||||
metalness->constSortPos = cspPotentialPrimitive;
|
||||
}
|
||||
|
||||
Var* smoothness = (Var*)LangElement::find("smoothness");
|
||||
if (!smoothness)
|
||||
{
|
||||
smoothness = new Var("smoothness", "float");
|
||||
smoothness->uniform = true;
|
||||
smoothness->constSortPos = cspPotentialPrimitive;
|
||||
}
|
||||
|
||||
matinfo = new Var("PBRConfig", "float4");
|
||||
LangElement* colorDecl = new DecOp(matinfo);
|
||||
meta->addStatement(new GenOp(" @ = float4(0.0,1.0,@,@);\r\n", colorDecl, smoothness, metalness)); //reconstruct matinfo, no ao darkening
|
||||
}
|
||||
Var* metalness = (Var*)LangElement::find("metalness");
|
||||
Var* smoothness = (Var*)LangElement::find("smoothness");
|
||||
|
||||
Var* wsEyePos = (Var*)LangElement::find("eyePosWorld");
|
||||
Var* worldToTangent = getInWorldToTangent(componentList);
|
||||
|
||||
Var* wsNormal = (Var*)LangElement::find("wsNormal");
|
||||
if (!wsNormal)
|
||||
{
|
||||
wsNormal = connectComp->getElement(RT_TEXCOORD);
|
||||
wsNormal->setName("wsNormal");
|
||||
wsNormal->setStructName("IN");
|
||||
wsNormal->setType("float3");
|
||||
|
||||
// If we loaded the normal its our responsibility
|
||||
// to normalize it... the interpolators won't.
|
||||
//
|
||||
// Note we cast to half here to get partial precision
|
||||
// optimized code which is an acceptable loss of
|
||||
// precision for normals and performs much better
|
||||
// on older Geforce cards.
|
||||
//
|
||||
meta->addStatement(new GenOp(" @ = normalize( half3( @ ) );\r\n", wsNormal, wsNormal));
|
||||
}
|
||||
|
||||
//Reflection vec
|
||||
Var* surface = new Var("surface", "Surface");
|
||||
meta->addStatement(new GenOp(" @ = createForwardSurface(@,@,@,@,@,@,@);\r\n\n", new DecOp(surface), diffuseColor, wsNormal, matinfo,
|
||||
inTex, wsPosition, wsEyePos, wsView));
|
||||
String computeForwardProbes = String::String(" @.rgb = computeForwardProbes(@,@,@,@,@,@,@,@,@,\r\n\t\t");
|
||||
computeForwardProbes += String::String("@,TORQUE_SAMPLER2D_MAKEARG(@),\r\n\t\t");
|
||||
computeForwardProbes += String::String("TORQUE_SAMPLERCUBEARRAY_MAKEARG(@),TORQUE_SAMPLERCUBEARRAY_MAKEARG(@)).rgb; \r\n");
|
||||
|
|
|
|||
|
|
@ -135,6 +135,8 @@ public:
|
|||
bool useInstancing,
|
||||
MultiLine *meta );
|
||||
|
||||
Var* getSurface(Vector<ShaderComponent*>& componentList, MultiLine* meta);
|
||||
|
||||
// ShaderFeature
|
||||
Var* getVertTexCoord( const String &name );
|
||||
LangElement* setupTexSpaceMat( Vector<ShaderComponent*> &componentList, Var **texSpaceMat );
|
||||
|
|
|
|||
|
|
@ -61,10 +61,9 @@ const String ShaderGenVars::oneOverTargetSize("$oneOverTargetSize");
|
|||
const String ShaderGenVars::lightPosition("$inLightPos");
|
||||
const String ShaderGenVars::lightDiffuse("$inLightColor");
|
||||
const String ShaderGenVars::lightAmbient("$ambient");
|
||||
const String ShaderGenVars::lightInvRadiusSq("$inLightInvRadiusSq");
|
||||
const String ShaderGenVars::lightConfigData("$inLightConfigData");
|
||||
const String ShaderGenVars::lightSpotDir("$inLightSpotDir");
|
||||
const String ShaderGenVars::lightSpotAngle("$inLightSpotAngle");
|
||||
const String ShaderGenVars::lightSpotFalloff("$inLightSpotFalloff");
|
||||
const String ShaderGenVars::lightSpotParams("$lightSpotParams");
|
||||
const String ShaderGenVars::specularColor("$specularColor");
|
||||
const String ShaderGenVars::smoothness("$smoothness");
|
||||
const String ShaderGenVars::metalness("$metalness");
|
||||
|
|
|
|||
|
|
@ -74,10 +74,9 @@ struct ShaderGenVars
|
|||
const static String lightPosition;
|
||||
const static String lightDiffuse;
|
||||
const static String lightAmbient;
|
||||
const static String lightInvRadiusSq;
|
||||
const static String lightConfigData;
|
||||
const static String lightSpotDir;
|
||||
const static String lightSpotAngle;
|
||||
const static String lightSpotFalloff;
|
||||
const static String lightSpotParams;
|
||||
const static String specularColor;
|
||||
const static String smoothness;
|
||||
const static String metalness;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue