// Original authored MilkyWayPlane. Actual VS alias is resolved by the five
// uint shader keys, not by a matching signature or a nearby shader name.
cbuffer OriginalPlaneCamera:register(b9) {
float4 planeEyeFocal,planeRightWidth,planeUpHeight,planeForwardNear;
float4 planeOutput,planeMaterial0,planeMaterial1,planeQuaternion;
}
Texture2D<float4> originalPlaneTexture:register(t18);
SamplerState originalPlaneSampler:register(s3);
struct OriginalPlaneVertex {float3 position:POSITION;float3 normal:NORMAL;float2 uv:TEXCOORD0;};
struct OriginalPlanePixel {float3 normal:TEXCOORD0;float3 ray:TEXCOORD1;float2 uv:TEXCOORD2;float4 position:SV_POSITION;};
float3 RotateOriginalPlane(float3 value) {
float3 q=planeQuaternion.xyz;float w=planeQuaternion.w;
// Exact original unified-model VS formula, preserving source packed-u16
// quantisation (the quaternion is deliberately not renormalised here).
return (2*w*w-1)*value+2*q*dot(q,value)+2*w*cross(q,value);
}
OriginalPlanePixel VSOriginalPlane(OriginalPlaneVertex vertex) {
OriginalPlanePixel pixel;
float3 world=RotateOriginalPlane(vertex.position)*100000+float3(50000,40955,50000);
pixel.ray=world-planeEyeFocal.xyz;pixel.normal=RotateOriginalPlane(vertex.normal);pixel.uv=vertex.uv;
float depth=dot(pixel.ray,planeForwardNear.xyz);
pixel.position=float4(dot(pixel.ray,planeRightWidth.xyz)*planeEyeFocal.w*2/planeRightWidth.w,
dot(pixel.ray,planeUpHeight.xyz)*planeEyeFocal.w*2/planeUpHeight.w,planeForwardNear.w,depth);
return pixel;
}
float4 PSOriginalPlane(OriginalPlanePixel pixel):SV_TARGET {
float facing=pow(abs(dot(-normalize(pixel.ray),normalize(pixel.normal))),planeMaterial0.w);
float nearFade=saturate((dot(planeForwardNear.xyz,pixel.ray)-planeMaterial1.y)/planeMaterial1.x);
float4 value=originalPlaneTexture.Sample(originalPlaneSampler,pixel.uv);
return float4(value.rgb*planeMaterial0.x*planeOutput.x,value.a*facing*nearFade);
}
// Original authored MilkyWayPlane. Actual VS alias is resolved by the five
// uint shader keys, not by a matching signature or a nearby shader name.
cbuffer OriginalPlaneCamera:register(b9) {
float4 planeEyeFocal,planeRightWidth,planeUpHeight,planeForwardNear;
float4 planeOutput,planeMaterial0,planeMaterial1,planeQuaternion;
}
Texture2D<float4> originalPlaneTexture:register(t18);
SamplerState originalPlaneSampler:register(s3);
struct OriginalPlaneVertex {float3 position:POSITION;float3 normal:NORMAL;float2 uv:TEXCOORD0;};
struct OriginalPlanePixel {float3 normal:TEXCOORD0;float3 ray:TEXCOORD1;float2 uv:TEXCOORD2;float4 position:SV_POSITION;};
float3 RotateOriginalPlane(float3 value) {
float3 q=planeQuaternion.xyz;float w=planeQuaternion.w;
// Exact original unified-model VS formula, preserving source packed-u16
// quantisation (the quaternion is deliberately not renormalised here).
return (2*w*w-1)*value+2*q*dot(q,value)+2*w*cross(q,value);
}
OriginalPlanePixel VSOriginalPlane(OriginalPlaneVertex vertex) {
OriginalPlanePixel pixel;
float3 world=RotateOriginalPlane(vertex.position)*100000+float3(50000,40955,50000);
pixel.ray=world-planeEyeFocal.xyz;pixel.normal=RotateOriginalPlane(vertex.normal);pixel.uv=vertex.uv;
float depth=dot(pixel.ray,planeForwardNear.xyz);
pixel.position=float4(dot(pixel.ray,planeRightWidth.xyz)*planeEyeFocal.w*2/planeRightWidth.w,
dot(pixel.ray,planeUpHeight.xyz)*planeEyeFocal.w*2/planeUpHeight.w,planeForwardNear.w,depth);
return pixel;
}
float4 PSOriginalPlane(OriginalPlanePixel pixel):SV_TARGET {
float facing=pow(abs(dot(-normalize(pixel.ray),normalize(pixel.normal))),planeMaterial0.w);
float nearFade=saturate((dot(planeForwardNear.xyz,pixel.ray)-planeMaterial1.y)/planeMaterial1.x);
float4 value=originalPlaneTexture.Sample(originalPlaneSampler,pixel.uv);
return float4(value.rgb*planeMaterial0.x*planeOutput.x,value.a*facing*nearFade);
}