Soften PMREM background sampling
This commit is contained in:
parent
52c9ae76a6
commit
2f10b02172
3 changed files with 42 additions and 5 deletions
|
|
@ -47,7 +47,9 @@ static const float GRID_HEIGHT_TEXEL_COUNT = 128.0;
|
|||
static const int BODY_LIGHT_COUNT = 8;
|
||||
static const float STUDIO_PMREM_MAX_LOD = 8.0;
|
||||
static const float STUDIO_PMREM_SPECULAR_INTENSITY = 0.34;
|
||||
static const float GRID_FLAT_REFLECTION_MAX_LOD = 5.2;
|
||||
static const float GRID_FLAT_REFLECTION_MAX_LOD = 3.0;
|
||||
static const float BACKGROUND_PMREM_LOD = 3.0;
|
||||
static const float BACKGROUND_PMREM_CONE = 0.16;
|
||||
static const float GRID_FLAT_SLOPE_START = 0.018;
|
||||
static const float GRID_FLAT_SLOPE_END = 0.16;
|
||||
|
||||
|
|
@ -437,6 +439,35 @@ float3 studioPmremDirection(float3 worldDirection)
|
|||
return normalize(float3(worldDirection.x, worldDirection.z, worldDirection.y));
|
||||
}
|
||||
|
||||
void directionBasis(float3 direction, out float3 tangent, out float3 bitangent)
|
||||
{
|
||||
float3 up = abs(direction.z) > 0.94 ? float3(0.0, 1.0, 0.0) : float3(0.0, 0.0, 1.0);
|
||||
tangent = normalize(cross(up, direction));
|
||||
bitangent = cross(direction, tangent);
|
||||
}
|
||||
|
||||
float3 studioPmremSample(float3 worldDirection, float lod)
|
||||
{
|
||||
return studioPmremTexture.SampleLevel(gridSampler, studioPmremDirection(worldDirection), lod).rgb;
|
||||
}
|
||||
|
||||
float3 studioPmremConeSample(float3 worldDirection, float lod, float cone)
|
||||
{
|
||||
float3 direction = normalize(worldDirection);
|
||||
float3 tangent;
|
||||
float3 bitangent;
|
||||
directionBasis(direction, tangent, bitangent);
|
||||
|
||||
float3 sum = studioPmremSample(direction, lod) * 2.0;
|
||||
sum += studioPmremSample(normalize(direction + tangent * cone), lod);
|
||||
sum += studioPmremSample(normalize(direction - tangent * cone), lod);
|
||||
sum += studioPmremSample(normalize(direction + bitangent * cone), lod);
|
||||
sum += studioPmremSample(normalize(direction - bitangent * cone), lod);
|
||||
sum += studioPmremSample(normalize(direction + (tangent + bitangent) * (cone * 0.7071)), lod);
|
||||
sum += studioPmremSample(normalize(direction + (-tangent + bitangent) * (cone * 0.7071)), lod);
|
||||
return sum * 0.125;
|
||||
}
|
||||
|
||||
float3 gridMirrorRadiance(float3 p, float3 direction, out float3 normal)
|
||||
{
|
||||
float2 gradient = terrainGradient(p.xy);
|
||||
|
|
@ -444,13 +475,18 @@ float3 gridMirrorRadiance(float3 p, float3 direction, out float3 normal)
|
|||
float3 reflectionDirection = reflect(direction, normal);
|
||||
float flatness = 1.0 - smoothstep(GRID_FLAT_SLOPE_START, GRID_FLAT_SLOPE_END, length(gradient));
|
||||
float lod = flatness * GRID_FLAT_REFLECTION_MAX_LOD;
|
||||
return studioPmremTexture.SampleLevel(gridSampler, studioPmremDirection(reflectionDirection), lod).rgb;
|
||||
return studioPmremConeSample(reflectionDirection, lod, flatness * 0.055);
|
||||
}
|
||||
|
||||
float3 backgroundRadiance(float3 direction)
|
||||
{
|
||||
return studioPmremConeSample(direction, BACKGROUND_PMREM_LOD, BACKGROUND_PMREM_CONE);
|
||||
}
|
||||
|
||||
RayMarchResult traverseRay(float2 uv, float2 screenUv, float3 origin, float3 direction)
|
||||
{
|
||||
RayMarchResult result;
|
||||
result.color = float3(0.0, 0.0, 0.0);
|
||||
result.color = backgroundRadiance(direction);
|
||||
result.travel = farDistance + 1.0;
|
||||
result.fieldId = 0.0;
|
||||
result.normal = 0.0;
|
||||
|
|
@ -593,7 +629,7 @@ float3 studioPmremSpecularRadiance(float3 p, float3 normal, float roughness, flo
|
|||
float ndv = saturate(dot(normal, viewDirection));
|
||||
float3 reflectionDirection = reflect(-viewDirection, normal);
|
||||
float lod = saturate(roughness) * STUDIO_PMREM_MAX_LOD;
|
||||
float3 radiance = studioPmremTexture.SampleLevel(gridSampler, studioPmremDirection(reflectionDirection), lod).rgb;
|
||||
float3 radiance = studioPmremSample(reflectionDirection, lod);
|
||||
float3 fresnel = fresnelSchlickRoughness(ndv, f0, roughness);
|
||||
return radiance * fresnel * STUDIO_PMREM_SPECULAR_INTENSITY;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -11,3 +11,4 @@
|
|||
{"timestamp":"2026-05-11T07:00:00+01:00","topic":"studio2-pmrem-probe","lesson":"Active reflection probe switched to Studio2 from E:\\Projects\\Aetheria-Economy\\Assets\\Textures\\studio2.hdr. The renderer loads Assets/Textures/studio2_pmrem.dds through the existing D3D12 TextureCube PMREM path, and the unused Studio3 DDS was cut from live assets.","files":["src/Aquarium.Engine/Assets/Textures/studio2_pmrem.dds","src/Aquarium.Engine/Assets/Textures/studio3_pmrem.dds","src/Aquarium.Engine/Render/D3D12Renderer.cs","state/map.yaml","state/memory.json"],"source":"E:\\Projects\\Aetheria-Economy\\Assets\\Textures\\studio2.hdr"}
|
||||
{"timestamp":"2026-05-11T07:14:00+01:00","topic":"grid-brush-cpu-mirror","lesson":"Self's Grid gravity bowl now uses a 17-world-unit radius and an Aetheria-style radial cosine wave. The brush equation is mirrored across D3D12Grid, CPU body-light placement, D3D12Scene body centers, and D3D12Post temporal reprojection; body centers sit at Grid height plus 2x radius.","files":["src/Aquarium.Engine/Render/D3D12Renderer.cs","src/Aquarium.Engine/Render/Shaders/D3D12Grid.hlsl","src/Aquarium.Engine/Render/Shaders/D3D12Scene.hlsl","src/Aquarium.Engine/Render/Shaders/D3D12Post.hlsl","state/map.yaml","state/memory.json"],"source":"E:\\Projects\\Aetheria-Economy\\Assets\\Shaders\\Brushes\\RadialWaveBrush.shader"}
|
||||
{"timestamp":"2026-05-11T07:22:00+01:00","topic":"grid-flatness-roughness","lesson":"Grid reflection roughness is now slope-driven: flat regions sample higher Studio2 PMREM mips to avoid an over-literal HDRI mirror, while sloped or waved regions sharpen toward mip 0.","files":["src/Aquarium.Engine/Render/Shaders/D3D12Scene.hlsl","state/memory.json"]}
|
||||
{"timestamp":"2026-05-11T07:28:00+01:00","topic":"pmrem-background-mip","lesson":"Flat Grid reflection now tops out at Studio2 PMREM mip 3, and ray misses use Studio2 PMREM mip 3 as the soft background so the reflective Grid is not contrasted against black void. Low-resolution mip texels are hidden with a small multi-direction cone average rather than one magnified TextureCube sample.","files":["src/Aquarium.Engine/Render/Shaders/D3D12Scene.hlsl","state/memory.json"]}
|
||||
|
|
|
|||
|
|
@ -28,7 +28,7 @@
|
|||
],
|
||||
"rendering": [
|
||||
"Grid height is defined by the shared brush equation in CPU placement, D3D12Grid, D3D12Scene, and temporal reprojection. Self uses a 17-world-unit gravity bowl plus an Aetheria-style radial cosine wave; body centers sit at Grid height plus 2x body radius.",
|
||||
"The Grid is direct-traced as a terminating reflective surface over the scalar height field. It writes the primary surface packet with FIELD_ID_GRID, terrain normal, full coverage, and Studio2 PMREM reflection; flat regions sample rougher PMREM mips while sloped/waved regions sharpen toward mip 0.",
|
||||
"The Grid is direct-traced as a terminating reflective surface over the scalar height field. It writes the primary surface packet with FIELD_ID_GRID, terrain normal, full coverage, and Studio2 PMREM reflection; flat regions sample up to PMREM mip 3 while sloped/waved regions sharpen toward mip 0. Ray misses use a cone-averaged Studio2 PMREM mip 3 as the soft background so low-resolution mip texels do not become visible blocks.",
|
||||
"Mouse/cursor-owned SDF bodies need object-motion reprojection. Carry current and previous cursor world anchors through frame constants and reproject cursor hits from current center to previous center.",
|
||||
"The cursor locator uses the MathWorld teardrop curve profile with m=6, revolved around vertical: x=cos(t), y=sin(t)*sin^m(t/2), radius `sqrt(1 - x^2) * ((1 - x) / 2)^3`. Ripples belong in the SDF radius function. Material is brass GGX metal with brass-tinted F0, no diffuse metal term, non-emissive, and no ambient floor.",
|
||||
"Heavy/specialized SDF evaluators should not live inside generic packed-id helpers when those helpers are called repeatedly; avoid shader compiler path cloning.",
|
||||
|
|
|
|||
Loading…
Reference in a new issue