public override void Set(Effect effect, RenderContext context, Matrix transform) { const int NUM_LIGHTS = 1; DirLight[] dirLight = new DirLight[NUM_LIGHTS]; dirLight[0] = new DirLight(); Actor caster = GameResources.ActorManager.GetActorById(context.SceneResources.ShadowCasterActorId); TransformComponent casterTransform = caster.GetComponent <TransformComponent>(ActorComponent.ComponentType.Transform); dirLight[0].Direction = Vector3.Transform(Vector3.Forward, casterTransform.Orientation); dirLight[0].Ambient = Vector4.Zero; dirLight[0].Diffuse = new Vector4(0.65f, 0.65f, 0.6f, 1.0f); dirLight[0].Specular = new Vector4(0.05f, 0.05f, 0.05f, 1.0f); dirLight[0].Energy = 1.0f; EffectRegistry.Params[effect][EffectRegistry.NUMLIGHTS_PARAM_NAME].SetValue(NUM_LIGHTS); for (int i = 0; i < NUM_LIGHTS; i++) { EffectRegistry.Params[effect][EffectRegistry.DIRLIGHT_STRUCT_NAME + EffectRegistry.AMBIENT_PARAM_NAME + i.ToString()].SetValue(dirLight[i].Ambient); EffectRegistry.Params[effect][EffectRegistry.DIRLIGHT_STRUCT_NAME + EffectRegistry.DIFFUSE_PARAM_NAME + i.ToString()].SetValue(dirLight[i].Diffuse); EffectRegistry.Params[effect][EffectRegistry.DIRLIGHT_STRUCT_NAME + EffectRegistry.SPECULAR_PARAM_NAME + i.ToString()].SetValue(dirLight[i].Specular); EffectRegistry.Params[effect][EffectRegistry.DIRLIGHT_STRUCT_NAME + EffectRegistry.DIRECTION_PARAM_NAME + i.ToString()].SetValue(dirLight[i].Direction); EffectRegistry.Params[effect][EffectRegistry.DIRLIGHT_STRUCT_NAME + EffectRegistry.ENERGY_PARAM_NAME + i.ToString()].SetValue(dirLight[i].Energy); } }
public override void Set(Effect effect, RenderContext context, Matrix transform) { const int NUM_LIGHTS = 1; DirLight[] dirLight = new DirLight[NUM_LIGHTS]; dirLight[0] = new DirLight(); Actor caster = GameResources.ActorManager.GetActorById(context.SceneResources.ShadowCasterActorId); TransformComponent casterTransform = caster.GetComponent<TransformComponent>(ActorComponent.ComponentType.Transform); dirLight[0].Direction = Vector3.Transform(Vector3.Forward, casterTransform.Orientation); dirLight[0].Ambient = Vector4.Zero; dirLight[0].Diffuse = new Vector4(0.65f, 0.65f, 0.6f, 1.0f); dirLight[0].Specular = new Vector4(0.05f, 0.05f, 0.05f, 1.0f); dirLight[0].Energy = 1.0f; EffectRegistry.Params[effect][EffectRegistry.NUMLIGHTS_PARAM_NAME].SetValue(NUM_LIGHTS); for (int i = 0; i < NUM_LIGHTS; i++) { EffectRegistry.Params[effect][EffectRegistry.DIRLIGHT_STRUCT_NAME + EffectRegistry.AMBIENT_PARAM_NAME + i.ToString()].SetValue(dirLight[i].Ambient); EffectRegistry.Params[effect][EffectRegistry.DIRLIGHT_STRUCT_NAME + EffectRegistry.DIFFUSE_PARAM_NAME + i.ToString()].SetValue(dirLight[i].Diffuse); EffectRegistry.Params[effect][EffectRegistry.DIRLIGHT_STRUCT_NAME + EffectRegistry.SPECULAR_PARAM_NAME + i.ToString()].SetValue(dirLight[i].Specular); EffectRegistry.Params[effect][EffectRegistry.DIRLIGHT_STRUCT_NAME + EffectRegistry.DIRECTION_PARAM_NAME + i.ToString()].SetValue(dirLight[i].Direction); EffectRegistry.Params[effect][EffectRegistry.DIRLIGHT_STRUCT_NAME + EffectRegistry.ENERGY_PARAM_NAME + i.ToString()].SetValue(dirLight[i].Energy); } }