// Port of hash-pinned BackgroundBlackHole_Forward0 VS/PS. These are the actual
// 52B source fields; instance RGBA is white, array layer0, half(styleSize).
cbuffer BlackHoleCamera:register(b9) {
float4 bhEyeFocal;float4 bhRightWidth;float4 bhUpHeight;float4 bhForwardNear;
float4 bhMaterial;float4 bhOutput;
}
Texture2DArray<float4> blackHoleTexture:register(t18);
SamplerState blackHoleSampler:register(s0);
struct BlackHoleInput {
float3 world:POSITION0;float4 weightsLayer:POSITION2;
float4 parameters:TEXCOORD3;float4 colour:POSITION4;
};
struct BlackHolePixel {
float4 centreSize:TEXCOORD0;float3 colour:TEXCOORD1;float3 world:TEXCOORD2;
float2 weights:TEXCOORD4;float3 uvLayer:TEXCOORD5;float4 position:SV_POSITION;
};
BlackHolePixel VSOriginalBlackHole(BlackHoleInput input,uint vertex:SV_VertexID) {
const float4 quad[6]={float4(0,1,-1,-1),float4(0,0,-1,1),float4(1,0,1,1),float4(1,0,1,1),float4(1,1,1,-1),float4(0,1,-1,-1)};
float4 q=quad[vertex];BlackHolePixel p;
p.centreSize=float4(input.world,input.parameters.z);
p.colour=pow(input.colour.rgb,bhMaterial.x);
p.world=input.world+bhRightWidth.xyz*(q.z*input.parameters.z)+bhUpHeight.xyz*(q.w*input.parameters.z);
p.weights=input.weightsLayer.xy;p.uvLayer=float3(q.xy,input.weightsLayer.w);
float3 relative=p.world-bhEyeFocal.xyz;float depth=dot(relative,bhForwardNear.xyz);
p.position=float4(dot(relative,bhRightWidth.xyz)*bhEyeFocal.w/(bhRightWidth.w*.5),
dot(relative,bhUpHeight.xyz)*bhEyeFocal.w/(bhUpHeight.w*.5),bhForwardNear.w,depth);
return p;
}
float4 PSOriginalBlackHole(BlackHolePixel p):SV_TARGET {
float normalizedRadius=length(p.world-p.centreSize.xyz)/(p.centreSize.w*bhMaterial.z);
float radial=bhMaterial.y-normalizedRadius+1;
float3 mask=blackHoleTexture.SampleBias(blackHoleSampler,p.uvLayer,-1).rgb*float3(1,p.weights);
mask=pow(mask,1.2);
float3 colour=clamp((radial*mask*bhMaterial.w+mask*(1-saturate(bhMaterial.w)))*p.colour,0,100);
// Preserve negative RGB and unclamped alpha exactly as the original PS.
// The actual named publisher supplies SourceAlpha/One; its signed source
// therefore darkens the scene, unlike a normal positive stellar glow.
return float4((1-colour)*bhOutput.x,length(colour)*.3333333333333333);
}
// Port of hash-pinned BackgroundBlackHole_Forward0 VS/PS. These are the actual
// 52B source fields; instance RGBA is white, array layer0, half(styleSize).
cbuffer BlackHoleCamera:register(b9) {
float4 bhEyeFocal;float4 bhRightWidth;float4 bhUpHeight;float4 bhForwardNear;
float4 bhMaterial;float4 bhOutput;
}
Texture2DArray<float4> blackHoleTexture:register(t18);
SamplerState blackHoleSampler:register(s0);
struct BlackHoleInput {
float3 world:POSITION0;float4 weightsLayer:POSITION2;
float4 parameters:TEXCOORD3;float4 colour:POSITION4;
};
struct BlackHolePixel {
float4 centreSize:TEXCOORD0;float3 colour:TEXCOORD1;float3 world:TEXCOORD2;
float2 weights:TEXCOORD4;float3 uvLayer:TEXCOORD5;float4 position:SV_POSITION;
};
BlackHolePixel VSOriginalBlackHole(BlackHoleInput input,uint vertex:SV_VertexID) {
const float4 quad[6]={float4(0,1,-1,-1),float4(0,0,-1,1),float4(1,0,1,1),float4(1,0,1,1),float4(1,1,1,-1),float4(0,1,-1,-1)};
float4 q=quad[vertex];BlackHolePixel p;
p.centreSize=float4(input.world,input.parameters.z);
p.colour=pow(input.colour.rgb,bhMaterial.x);
p.world=input.world+bhRightWidth.xyz*(q.z*input.parameters.z)+bhUpHeight.xyz*(q.w*input.parameters.z);
p.weights=input.weightsLayer.xy;p.uvLayer=float3(q.xy,input.weightsLayer.w);
float3 relative=p.world-bhEyeFocal.xyz;float depth=dot(relative,bhForwardNear.xyz);
p.position=float4(dot(relative,bhRightWidth.xyz)*bhEyeFocal.w/(bhRightWidth.w*.5),
dot(relative,bhUpHeight.xyz)*bhEyeFocal.w/(bhUpHeight.w*.5),bhForwardNear.w,depth);
return p;
}
float4 PSOriginalBlackHole(BlackHolePixel p):SV_TARGET {
float normalizedRadius=length(p.world-p.centreSize.xyz)/(p.centreSize.w*bhMaterial.z);
float radial=bhMaterial.y-normalizedRadius+1;
float3 mask=blackHoleTexture.SampleBias(blackHoleSampler,p.uvLayer,-1).rgb*float3(1,p.weights);
mask=pow(mask,1.2);
float3 colour=clamp((radial*mask*bhMaterial.w+mask*(1-saturate(bhMaterial.w)))*p.colour,0,100);
// Preserve negative RGB and unclamped alpha exactly as the original PS.
// The actual named publisher supplies SourceAlpha/One; its signed source
// therefore darkens the scene, unlike a normal positive stellar glow.
return float4((1-colour)*bhOutput.x,length(colour)*.3333333333333333);
}