I wonder myself if it can be coded.
Le light of sun impact all objects because shaders are coded in the mesh.fx effect file
- Code: Select all
/// ComputeLight
///
/// Computes the sun's contribution to the pixel's color given the dot product
/// of the light direction and surface normal. The dot product is precomputed
/// since other portions of the pixel shader might need it (and we need to reuse
/// as many calculations as possible.)
float3 ComputeLight( float dotLightNormal, float attenuation)
{
/// Typical L.N calculation.
float3 light = sunDiffuse * saturate( dotLightNormal ) * attenuation + sunAmbient;
/// The following will "fill in" the shadow color proportional to the absence of light.
/// This considers the absence of light due to shadows and surface normals pointing away from the light.
/// This way all dark areas match (very cool.)
return lightMultiplier * light + ( 1 - light ) * shadowFill;
}
Here is the unit with some code using sun light. We may code here others light contributions :
- Code: Select all
/// UnitFalloffPS
///
/// - Similar to unit shader, with the exception that it uses the diffuse texture alpha
/// channel to mask area's in which the view dependant lookup texture is sampled.
/// Only works in Medium and High fidelity.
///
float4 UnitFalloffPS( NORMALMAPPED_VERTEX vertex, uniform bool hiDefShadows) : COLOR0
{
if ( 1 == mirrored ) clip(vertex.depth.x);
float3x3 rotationMatrix = float3x3( vertex.binormal, vertex.tangent, vertex.normal);
float3 normal = ComputeNormal( normalsSampler, vertex.texcoord0.zw, rotationMatrix);
float dotLightNormal = dot(sunDirection,normal);
float4 diffuse = tex2D( albedoSampler, vertex.texcoord0.xy);
float4 specular = tex2D( specularSampler, vertex.texcoord0.xy);
float3 environment = texCUBE( environmentSampler, reflect( -vertex.viewDirection, normal));
// Calculate lookup into falloff ramp
float NdotV = pow(1 - saturate(dot( normalize(vertex.viewDirection), normal )), 0.6);
float4 fallOff = tex2D( falloffSampler, float2(NdotV,vertex.material.x));
// Calculate specular highlights based on current sun direction
float3 reflection = reflect( sunDirection, normal);
float specularAmount = saturate( dot( reflection, -vertex.viewDirection));
float3 phongAdditive = float3 (0.5,0.6,0.7) * pow( specularAmount, 9) * specular.g;
// Calculate environment map reflection
environment *= specular.r * fallOff.a;
// Calculate lighting and shadows
float shadow = 0; // ComputeShadow( vertex.shadow, hiDefShadows);
float3 light = sunDiffuse * saturate( dotLightNormal ) * shadow + sunAmbient;
light = light + ( 1 - light ) * shadowFill;
// Determine our final output color
float3 color = diffuse.rgb * light;
color += environment + phongAdditive;
color += (fallOff.rgb * diffuse.a);
float alpha = mirrored ? 0.5 : specular.b + glowMinimum;
return float4( color, alpha );
}
I think we can adding some code to the fx file to add some diffuse light around from any shader effect. I do not have the skill in coding shaders to do that, but i think, it's possible, and it must add a incredible stunning refresh in the 3D engine.
Ok, we may loose some fps, but supcom has been coded before 2007, some we have a bunch amount of graphic power that can be use today.
I'm on with any project that need a financial contribution to hire a professional programmer that may add this stuff (i think this student has the skill to add this feature :
http://gamedevelopment.tutsplus.com/tut ... -cms-24351)
Or maybe with some practice :
http://gamedevelopment.tutsplus.com/tutorials/a-beginners-guide-to-coding-graphics-shaders--cms-23313