/usr/share/libwildmagic/Data/CgShaders/LightPointPerPixel.fx is in libwildmagic-common 5.13-1ubuntu3.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 | void v_LightPointPerPixel
(
in float3 modelPosition : POSITION,
in float3 modelNormal : TEXCOORD1,
out float4 clipPosition : POSITION,
out float3 vertexPosition : TEXCOORD0,
out float3 vertexNormal : TEXCOORD1,
uniform float4x4 PVWMatrix
)
{
clipPosition = mul(PVWMatrix, float4(modelPosition,1.0f));
vertexPosition = modelPosition;
vertexNormal = modelNormal;
}
void p_LightPointPerPixel
(
in float3 vertexPosition : TEXCOORD0,
in float3 vertexNormal : TEXCOORD1,
out float4 pixelColor : COLOR,
uniform float4x4 WMatrix,
uniform float3 CameraModelPosition,
uniform float3 MaterialEmissive,
uniform float3 MaterialAmbient,
uniform float4 MaterialDiffuse,
uniform float4 MaterialSpecular,
uniform float3 LightModelPosition,
uniform float3 LightAmbient,
uniform float3 LightDiffuse,
uniform float3 LightSpecular,
uniform float4 LightAttenuation
)
{
// Compute the lighting factors.
float3 normal = normalize(vertexNormal);
float3 vertexLightDiff = vertexPosition - LightModelPosition;
float3 vertexDirection = normalize(vertexLightDiff);
float NDotL = -dot(normal, vertexDirection);
float3 viewVector = normalize(CameraModelPosition - vertexPosition);
float3 halfVector = normalize(viewVector - vertexDirection);
float NDotH = dot(normal, halfVector);
float4 lighting = lit(NDotL, NDotH, MaterialSpecular.a);
// Compute the distance-based attenuation.
float3 worldLightDiff = mul((float3x3)WMatrix, vertexLightDiff);
float distance = length(worldLightDiff);
float attenuation = LightAttenuation.w/(LightAttenuation.x + distance *
(LightAttenuation.y + distance*LightAttenuation.z));
// Compute the lighting color.
float3 color = MaterialAmbient*LightAmbient
+ lighting.y*MaterialDiffuse.rgb*LightDiffuse
+ lighting.z*MaterialSpecular.rgb*LightSpecular;
// Compute the pixel color.
pixelColor.rgb = MaterialEmissive + attenuation*color;
pixelColor.a = MaterialDiffuse.a;
}
|