-
-
Notifications
You must be signed in to change notification settings - Fork 4.2k
Solari indirect specular support #21355
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
…i.e. is non-metallic)
Split the uncontroversial stuff off into a separate PR since this one needs some work #21391 |
Simplify and fix recursive traces
let depth = textureLoad(depth_buffer, global_id.xy, 0); | ||
if depth == 0.0 { | ||
textureStore(diffuse_albedo, pixel_id, vec4(0.0)); | ||
textureStore(diffuse_albedo, pixel_id, vec4(0.5)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should this be specular_albedo
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Whoops yes, thanks for catching!
let B = TBN[1]; | ||
let N = TBN[2]; | ||
let wo = -wi; | ||
let wo_tangent = vec3(dot(wo, T), dot(wo, B), dot(wo, N)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
isnt this just a matmul
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, but the rest of bevy does it this way so we keep doing it this way.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yep
var bias = dot(M1 * X.xy, Y.xy) / dot(M2 * X.xyw, Y.xyw); | ||
let scale = dot(M3 * X.xy, Y.xy) / dot(M4 * X.xzw, Y.xyw); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
are the swizzles right here? .xyw .xyw on the first line and .xzw .xyz on the second
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
From the DLSS RR integration guide,
float3 EnvBRDFApprox2(float3 SpecularColor, float alpha, float NoV)
{
NoV = abs(NoV);
// [Ray Tracing Gems, Chapter 32]
float4 X;
X.x = 1.f;
X.y = NoV;
X.z = NoV * NoV;
X.w = NoV * X.z;
float4 Y;
Y.x = 1.f;
Y.y = alpha;
Y.z = alpha * alpha;
Y.w = alpha * Y.z;
float2x2 M1 = float2x2(0.99044f, -1.28514f, 1.29678f, -0.755907f);
float3x3 M2 = float3x3(1.f, 2.92338f, 59.4188f, 20.3225f, -27.0302f,
222.592f, 121.563f, 626.13f, 316.627f);
float2x2 M3 = float2x2(0.0365463f, 3.32707, 9.0632f, -9.04756);
float3x3 M4 = float3x3(1.f, 3.59685f, -1.36772f, 9.04401f, -16.3174f,
9.22949f, 5.56589f, 19.7886f, -20.2123f);
float bias = dot(mul(M1, X.xy), Y.xy) * rcp(dot(mul(M2, X.xyw), Y.xyw));
float scale = dot(mul(M3, X.xy), Y.xy) * rcp(dot(mul(M4, X.xzw), Y.xyw));
// This is a hack for specular reflectance of 0
bias *= saturate(SpecularColor.g * 50);
return mad(SpecularColor, max(0, scale), max(0, bias));
}
outSpecularAlbedo = EnvBRDFApprox2( GBuffer.SpecularAlbedo, GBuffer.fRoughness
* GBuffer.fRoughness, NdotV );
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yep it's correct
Objective
Solution
specular_gi
Future
Showcase
Before

After
