Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- float4x4 wvp : register( c0 );
- float4x4 world : register( c5 );
- #ifdef USE_LIGHTING
- float3 lightPosition : register( c10 );
- float3 lightColor : register( c11 );
- float lightRange : register( c12 );
- float3 ambientColor : register( c13 );
- #endif
- struct VS_INPUT {
- float4 position : POSITION;
- float2 texcoord : TEXCOORD0;
- float4 color : COLOR0;
- };
- struct VS_OUTPUT {
- float4 position : POSITION;
- float2 texcoord : TEXCOORD0;
- float4 color : TEXCOORD1;
- };
- VS_OUTPUT main( VS_INPUT input ) {
- VS_OUTPUT output;
- output.position = mul( wvp, input.position );
- output.texcoord = input.texcoord;
- #ifdef USE_LIGHTING
- float4 worldPos = mul( world, input.position );
- float distance = length( worldPos - lightPosition );
- float attenuation = lightRange * 1.25f / ( 1 + distance * distance );
- output.color = float4( lightColor.xyz * input.color.xyz * attenuation + ambientColor.xyz, 1.0f ) ;
- #else
- output.color = input.color;
- #endif
- return output;
- };
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement