public override void Use(RenderState rstate, IVertexType vertextype, ref Lighting lights) { if (Camera == null) { return; } ShaderCaps caps = ShaderCaps.None; if (VertexLighting) { caps |= ShaderCaps.VertexLighting; } if (HasSpotlight(ref lights)) { caps |= ShaderCaps.Spotlight; } if (EtEnabled) { caps |= ShaderCaps.EtEnabled; } if (Fade) { caps |= ShaderCaps.FadeEnabled; } var dxt1 = GetDxt1(); if (dxt1) { caps |= ShaderCaps.AlphaTestEnabled; //Shitty way of dealing with alpha_mask //FL has a lot of DXT1 textures that aren't part of alpha_mask //so this brings overall performance down. //Don't change any of this stuff unless you can verify it works //in all places! (Check Li01 shipyards, Bw10 tradelanes) } var shader = GetShader(vertextype, caps); lastShader = shader; shader.SetWorld(World); shader.SetView(Camera); shader.SetViewProjection(Camera); //Dt shader.SetDtSampler(0); BindTexture(rstate, 0, DtSampler, 0, DtFlags, ResourceManager.WhiteTextureName); //Dc shader.SetDc(Dc); //Oc shader.SetOc(Oc); if (AlphaEnabled || Fade || OcEnabled || dxt1) { rstate.BlendMode = BlendMode.Normal; } else { rstate.BlendMode = BlendMode.Opaque; //TODO: Maybe I can just leave this out? } //Fade if (Fade) { shader.SetFadeRange(new Vector2(FadeNear, FadeFar)); } //MaterialAnim if (MaterialAnim != null) { shader.SetMaterialAnim(new Vector4( MaterialAnim.UOffset, MaterialAnim.VOffset, MaterialAnim.UScale, MaterialAnim.VScale )); } else { shader.SetMaterialAnim(new Vector4(0, 0, 1, 1)); } shader.SetFlipNormal(FlipNormals); if (Bones != null && vertextype is DfmVertex) { shader.Shader.UniformBlockBinding("Bones", 1); shader.SetSkinningEnabled(true); Bones.BindTo(1, BufferOffset, 200); } else { shader.SetSkinningEnabled(false); } //Ec shader.SetEc(Ec); //EtSampler if (EtEnabled) { shader.SetEtSampler(1); BindTexture(rstate, 1, EtSampler, 1, EtFlags, ResourceManager.NullTextureName); } //Set lights SetLights(shader, ref lights); shader.UseProgram(); }