mirror of
https://github.com/TorqueGameEngines/Torque3D.git
synced 2026-01-19 20:24:49 +00:00
random testing bits trying to isolate remaining forward issues.
This commit is contained in:
parent
093f50bd9d
commit
6db975e81c
|
|
@ -354,15 +354,15 @@ void GFXGLCubemapArray::init(GFXCubemapHandle *cubemaps, const U32 cubemapCount)
|
|||
|
||||
glBindTexture(GL_TEXTURE_CUBE_MAP_ARRAY, mCubemap);
|
||||
const U32 mipSize = getMax(U32(1), mSize >> currentMip);
|
||||
/*if (isCompressed)
|
||||
if (isCompressed)
|
||||
{
|
||||
const U32 mipDataSize = getCompressedSurfaceSize(mFormat, mSize, mSize, currentMip);
|
||||
glCompressedTexImage3D(GL_TEXTURE_CUBE_MAP_ARRAY, currentMip, GFXGLTextureInternalFormat[mFormat], mipSize, mipSize, 0, mipDataSize, pixelData);
|
||||
glCompressedTexImage3D(GL_TEXTURE_CUBE_MAP_ARRAY, currentMip, GFXGLTextureInternalFormat[mFormat], 0, 0, i * 6 + face, 0, mipDataSize, pixelData);
|
||||
}
|
||||
else
|
||||
{*/
|
||||
glTexSubImage3D(GL_TEXTURE_CUBE_MAP_ARRAY, currentMip, 0, 0, i * 6 + face, mipSize, mipSize, 1, GFXGLTextureFormat[mFormat], GFXGLTextureType[mFormat], pixelData);
|
||||
//}
|
||||
{
|
||||
glTexSubImage3D(GL_TEXTURE_CUBE_MAP_ARRAY, currentMip, 0, 0, i * 6 + face, mipSize, mipSize, 1, GFXGLTextureFormat[mFormat], GFXGLTextureType[mFormat], pixelData);
|
||||
}
|
||||
glBindTexture(GL_TEXTURE_CUBE_MAP_ARRAY, 0);
|
||||
|
||||
delete[] pixelData;
|
||||
|
|
@ -415,15 +415,15 @@ void GFXGLCubemapArray::updateTexture(const GFXCubemapHandle &cubemap, const U32
|
|||
|
||||
glBindTexture(GL_TEXTURE_CUBE_MAP_ARRAY, mCubemap);
|
||||
const U32 mipSize = getMax(U32(1), mSize >> currentMip);
|
||||
/*if (isCompressed)
|
||||
if (isCompressed)
|
||||
{
|
||||
const U32 mipDataSize = getCompressedSurfaceSize(mFormat, mSize, mSize, currentMip);
|
||||
glCompressedTexImage3D(GL_TEXTURE_CUBE_MAP_ARRAY, currentMip, GFXGLTextureInternalFormat[mFormat], mipSize, mipSize, 0, mipDataSize, pixelData);
|
||||
glCompressedTexImage3D(GL_TEXTURE_CUBE_MAP_ARRAY, currentMip, GFXGLTextureInternalFormat[mFormat], 0, 0, slot * 6 + face, 0, mipDataSize, pixelData);
|
||||
}
|
||||
else
|
||||
{*/
|
||||
{
|
||||
glTexSubImage3D(GL_TEXTURE_CUBE_MAP_ARRAY, currentMip, 0, 0, slot * 6 + face, mipSize, mipSize, 1, GFXGLTextureFormat[mFormat], GFXGLTextureType[mFormat], pixelData);
|
||||
//}
|
||||
}
|
||||
glBindTexture(GL_TEXTURE_CUBE_MAP_ARRAY, 0);
|
||||
|
||||
delete[] pixelData;
|
||||
|
|
|
|||
|
|
@ -171,6 +171,19 @@ void ProbeShaderConstants::init(GFXShader* shader)
|
|||
mInit = true;
|
||||
}
|
||||
|
||||
bool ProbeShaderConstants::isValid()
|
||||
{
|
||||
if (mProbePositionSC->isValid() ||
|
||||
mProbeConfigDataSC->isValid() ||
|
||||
mProbeBoxMinSC->isValid() ||
|
||||
mProbeBoxMaxSC->isValid() ||
|
||||
mProbeSpecularCubemapSC->isValid() ||
|
||||
mProbeIrradianceCubemapSC->isValid())
|
||||
return true;
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
void ProbeShaderConstants::_onShaderReload()
|
||||
{
|
||||
if (mShader.isValid())
|
||||
|
|
@ -536,12 +549,7 @@ void RenderProbeMgr::_update4ProbeConsts(const SceneData &sgData,
|
|||
PROFILE_SCOPE(ProbeManager_Update4ProbeConsts);
|
||||
|
||||
// Skip over gathering lights if we don't have to!
|
||||
if (probeShaderConsts->mProbePositionSC->isValid() ||
|
||||
probeShaderConsts->mProbeConfigDataSC->isValid() ||
|
||||
probeShaderConsts->mProbeBoxMinSC->isValid() ||
|
||||
probeShaderConsts->mProbeBoxMaxSC->isValid() ||
|
||||
probeShaderConsts->mProbeSpecularCubemapSC->isValid() ||
|
||||
probeShaderConsts->mProbeIrradianceCubemapSC->isValid()/* && (!ProbeRenderInst::all.empty())*/)
|
||||
if (probeShaderConsts->isValid())
|
||||
{
|
||||
PROFILE_SCOPE(ProbeManager_Update4ProbeConsts_setProbes);
|
||||
|
||||
|
|
@ -653,7 +661,7 @@ void RenderProbeMgr::_update4ProbeConsts(const SceneData &sgData,
|
|||
if (!curEntry.mIsEnabled)
|
||||
continue;
|
||||
|
||||
if (curEntry.mIsSkylight)
|
||||
/*if (curEntry.mIsSkylight)
|
||||
{
|
||||
if (curEntry.mPrefilterCubemap.isValid() && curEntry.mPrefilterCubemap.isValid())
|
||||
{
|
||||
|
|
@ -664,8 +672,8 @@ void RenderProbeMgr::_update4ProbeConsts(const SceneData &sgData,
|
|||
hasSkylight = true;
|
||||
continue;
|
||||
}
|
||||
}
|
||||
else
|
||||
}*/
|
||||
if(!curEntry.mIsSkylight)
|
||||
{
|
||||
/*probePositions[effectiveProbeCount] = curEntry.getPosition();
|
||||
probeRefPositions[effectiveProbeCount] = curEntry.mProbeRefOffset;
|
||||
|
|
@ -694,6 +702,39 @@ void RenderProbeMgr::_update4ProbeConsts(const SceneData &sgData,
|
|||
//GFX->setCubeArrayTexture(probeShaderConsts->mProbeSpecularCubemapSC->getSamplerRegister(), mPrefilterArray);
|
||||
//GFX->setCubeArrayTexture(probeShaderConsts->mProbeIrradianceCubemapSC->getSamplerRegister(), mIrradianceArray);
|
||||
|
||||
//if (!hasSkylight)
|
||||
// shaderConsts->setSafe(probeShaderConsts->mHasSkylight, 0.0f);
|
||||
}
|
||||
|
||||
//check for skylight action
|
||||
if (probeShaderConsts->mHasSkylight->isValid()
|
||||
&& probeShaderConsts->mSkylightIrradMap->isValid()
|
||||
&& probeShaderConsts->mSkylightSpecularMap->isValid())
|
||||
{
|
||||
//Array rendering
|
||||
U32 probeCount = ProbeRenderInst::all.size();
|
||||
|
||||
bool hasSkylight = false;
|
||||
for (U32 i = 0; i < probeCount; i++)
|
||||
{
|
||||
const ProbeRenderInst& curEntry = *ProbeRenderInst::all[i];
|
||||
if (!curEntry.mIsEnabled)
|
||||
continue;
|
||||
|
||||
if (curEntry.mIsSkylight)
|
||||
{
|
||||
if (curEntry.mPrefilterCubemap.isValid() && curEntry.mPrefilterCubemap.isValid())
|
||||
{
|
||||
GFX->setCubeTexture(probeShaderConsts->mSkylightSpecularMap->getSamplerRegister(), curEntry.mPrefilterCubemap);
|
||||
GFX->setCubeTexture(probeShaderConsts->mSkylightIrradMap->getSamplerRegister(), curEntry.mIrradianceCubemap);
|
||||
|
||||
shaderConsts->setSafe(probeShaderConsts->mHasSkylight, 1.0f);
|
||||
hasSkylight = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (!hasSkylight)
|
||||
shaderConsts->setSafe(probeShaderConsts->mHasSkylight, 0.0f);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -152,6 +152,8 @@ struct ProbeShaderConstants
|
|||
|
||||
void init(GFXShader* buffer);
|
||||
|
||||
bool isValid();
|
||||
|
||||
void _onShaderReload();
|
||||
};
|
||||
|
||||
|
|
|
|||
|
|
@ -3134,7 +3134,11 @@ void ReflectionProbeFeatHLSL::processPix(Vector<ShaderComponent*> &componentList
|
|||
|
||||
Var *wsEyePos = (Var*)LangElement::find("eyePosWorld");
|
||||
|
||||
Var *worldToCamera = (Var*)LangElement::find("worldToCamera");
|
||||
Var *worldToTangent = (Var*)LangElement::find("worldToTangent");
|
||||
if (!worldToTangent)
|
||||
return;
|
||||
|
||||
/*Var *worldToCamera = (Var*)LangElement::find("worldToCamera");
|
||||
if (!worldToCamera)
|
||||
{
|
||||
worldToCamera = new Var;
|
||||
|
|
@ -3142,13 +3146,13 @@ void ReflectionProbeFeatHLSL::processPix(Vector<ShaderComponent*> &componentList
|
|||
worldToCamera->setName("worldToCamera");
|
||||
worldToCamera->uniform = true;
|
||||
worldToCamera->constSortPos = cspPass;
|
||||
}
|
||||
}*/
|
||||
|
||||
//Reflection vec
|
||||
Var *surface = new Var("surface", "Surface");
|
||||
meta->addStatement(new GenOp(" @ = createForwardSurface(@,@,@,@,@,@,@,@);\r\n\n", new DecOp(surface), diffuseColor, bumpNormal, matinfo,
|
||||
inTex, wsPosition, wsEyePos, wsView, worldToCamera));
|
||||
String computeForwardProbes = String::String(" @.rgb += computeForwardProbes(@,@,@,@,@,@,@,@,@,\r\n\t\t");
|
||||
inTex, wsPosition, wsEyePos, wsView, worldToTangent));
|
||||
String computeForwardProbes = String::String(" @.rgb = computeForwardProbes(@,@,@,@,@,@,@,@,@,\r\n\t\t");
|
||||
computeForwardProbes += String::String("@,TORQUE_SAMPLER2D_MAKEARG(@),\r\n\t\t");
|
||||
computeForwardProbes += String::String("TORQUE_SAMPLERCUBE_MAKEARG(@), TORQUE_SAMPLERCUBE_MAKEARG(@), \r\n\t\t");
|
||||
computeForwardProbes += String::String("TORQUE_SAMPLERCUBEARRAY_MAKEARG(@),TORQUE_SAMPLERCUBEARRAY_MAKEARG(@)).rgb; \r\n");
|
||||
|
|
|
|||
|
|
@ -148,17 +148,18 @@ inline Surface createSurface(float4 gbuffer0, TORQUE_SAMPLER2D(gbufferTex1), TOR
|
|||
return surface;
|
||||
}
|
||||
|
||||
inline Surface createForwardSurface(float4 baseColor, float4 normal, float4 pbrProperties, in float2 uv, in float3 wsPosition, in float3 wsEyePos, in float3 wsEyeRay, in float4x4 invView)
|
||||
inline Surface createForwardSurface(float4 baseColor, float4 normal, float4 pbrProperties, in float2 uv,
|
||||
in float3 wsPosition, in float3 wsEyePos, in float3 wsEyeRay, in float3x3 worldToTangent)
|
||||
{
|
||||
Surface surface = (Surface)0;
|
||||
|
||||
surface.depth = 0;
|
||||
surface.P = wsPosition;
|
||||
surface.N = mul(invView, float4(normal.xyz,0)).xyz; //TODO move t3d to use WS normals
|
||||
surface.N = normalize( mul( normal.xyz, worldToTangent ) );
|
||||
surface.V = normalize(wsEyePos - surface.P);
|
||||
surface.baseColor = baseColor;
|
||||
const float minRoughness=1e-4;
|
||||
surface.roughness = clamp(1.0 - pbrProperties.b, minRoughness, 1.0); //t3d uses smoothness, so we convert to roughness.
|
||||
surface.roughness = clamp(1.0 - pbrProperties.b, minRoughness, 1); //t3d uses smoothness, so we convert to roughness.
|
||||
surface.roughness_brdf = surface.roughness * surface.roughness;
|
||||
surface.metalness = pbrProperties.a;
|
||||
surface.ao = pbrProperties.g;
|
||||
|
|
@ -372,7 +373,7 @@ float4 computeForwardProbes(Surface surface,
|
|||
float lod = surface.roughness*cubeMips;
|
||||
|
||||
float alpha = 1;
|
||||
for (i = 0; i < numProbes; ++i)
|
||||
/*for (i = 0; i < numProbes; ++i)
|
||||
{
|
||||
float contrib = contribution[i];
|
||||
if (contrib != 0)
|
||||
|
|
@ -384,7 +385,7 @@ float4 computeForwardProbes(Surface surface,
|
|||
specular += TORQUE_TEXCUBEARRAYLOD(specularCubemapAR, dir, cubemapIdx, lod).xyz * contrib;
|
||||
alpha -= contrib;
|
||||
}
|
||||
}
|
||||
}*/
|
||||
|
||||
if (hasSkylight && alpha > 0.001)
|
||||
{
|
||||
|
|
@ -396,7 +397,7 @@ float4 computeForwardProbes(Surface surface,
|
|||
|
||||
//energy conservation
|
||||
float3 kD = 1.0.xxx - F;
|
||||
kD *= 1.0 - surface.metalness;
|
||||
kD *= clamp(1.0 - surface.metalness, 0.1, 1);
|
||||
|
||||
//apply brdf
|
||||
//Do it once to save on texture samples
|
||||
|
|
@ -407,5 +408,6 @@ float4 computeForwardProbes(Surface surface,
|
|||
float3 diffuse = kD * irradiance * surface.baseColor.rgb;
|
||||
float4 finalColor = float4(diffuse + specular * surface.ao, 1.0);
|
||||
|
||||
finalColor = float4(specular,1);
|
||||
return finalColor;
|
||||
}
|
||||
Loading…
Reference in a new issue