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:
Areloch 2019-01-19 00:31:42 -06:00
parent 1f38bb6d2d
commit f5da79b39f
5 changed files with 159 additions and 77 deletions

View file

@ -280,12 +280,25 @@ new CustomMaterial( AL_ParticlePointLightMaterial )
//Reflection probe Specular
new ShaderData( ReflectionProbeShader )
{
DXVertexShaderFile = "shaders/common/lighting/advanced/convexGeometryV.hlsl";
/*DXVertexShaderFile = "shaders/common/lighting/advanced/convexGeometryV.hlsl";
DXPixelShaderFile = "shaders/common/lighting/advanced/reflectionProbeP.hlsl";
OGLVertexShaderFile = "shaders/common/lighting/advanced/gl/convexGeometryV.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[1] = "$colorBuffer";
samplerNames[2] = "$matInfoBuffer";

View file

@ -134,7 +134,7 @@ new SimGroup(MissionGroup) {
ReflectionMode = "Baked Cubemap";
reflectionPath = "levels/probeTest/probes/";
Bake = "0";
position = "0 0.0825528 4.53387";
position = "0 0.0825528 2.18272";
rotation = "1 0 0 0";
scale = "5 5 5";
canSave = "1";
@ -156,7 +156,7 @@ new SimGroup(MissionGroup) {
surface = "0 0 0 1 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.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 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.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 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.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 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.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 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.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 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.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 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.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";
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 ---

View file

@ -4,11 +4,19 @@
#include "../../lighting.hlsl"
#include "../../torque.hlsl"
struct ConvexConnectP
/*struct ConvexConnectP
{
float4 pos : TORQUE_POSITION;
float4 uv0 : TEXCOORD1;
float4 vsEyeDir : TEXCOORD2;
};*/
struct ConvexConnectP
{
float4 pos : TORQUE_POSITION;
float4 wsEyeDir : TEXCOORD0;
float4 ssPos : TEXCOORD1;
float4 vsEyeDir : TEXCOORD2;
};
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]);
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)
@ -73,7 +82,8 @@ float3 iblBoxSpecular(Surface surface, float3 surfToEye, TORQUE_SAMPLER2D(brdfTe
float3 cubeR = normalize(r);
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;
}
@ -97,16 +107,20 @@ float defineBoxSpaceInfluence(Surface surface, int id)
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
float3 vsEyeRay = getDistanceVectorToPlane( -vsFarPlane.w, IN.vsEyeDir.xyz, vsFarPlane );
float3 wsEyeRay = mul(cameraToWorld, float4(vsEyeRay, 0)).xyz;
//unpack normal and linear depth
float4 normDepth = TORQUE_DEFERRED_UNCONDITION(deferredBuffer, IN.uv0.xy);
float4 normDepth = TORQUE_DEFERRED_UNCONDITION(deferredBuffer, uvScene);
//create surface
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
if (getFlag(surface.matFlag, 0))
{
@ -121,22 +135,22 @@ float4 main( ConvexConnectP IN ) : SV_TARGET
for(i=0; i < numProbes; i++)
{
float3 probeWS = inProbePosArray[i];
float3 L = probeWS - surface.P;
float3 probeWS = inProbePosArray[i];
float3 L = probeWS - surface.P;
if(useSphereMode[i])
{
float3 L = inProbePosArray[i] - surface.P;
blendVal[i] = 1.0-length(L)/radius[i];
blendVal[i] = max(0,blendVal[i]);
}
else
{
blendVal[i] = defineBoxSpaceInfluence(surface, i);
blendVal[i] = max(0,blendVal[i]);
}
if(useSphereMode[i])
{
float3 L = inProbePosArray[i] - surface.P;
blendVal[i] = 1.0-length(L)/radius[i];
blendVal[i] = max(0,blendVal[i]);
}
else
{
blendVal[i] = defineBoxSpaceInfluence(surface, i);
blendVal[i] = max(0,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.
@ -166,6 +180,7 @@ float4 main( ConvexConnectP IN ) : SV_TARGET
float3 irradiance = float3(0,0,0);
float3 specular = float3(0,0,0);
float3 F = FresnelSchlickRoughness(surface.NdotV, surface.f0, surface.roughness);
//energy conservation
float3 kD = 1.0.xxx - F;
kD *= 1.0 - surface.metalness;