1using System.Globalization;
3using System.Reflection;
113 set =>
m_time.SetValue(value);
121 throw new InvalidOperationException(
"Invalid instances count.");
130 bool useEmissionColor,
134 bool useAlphaThreshold,
135 int maxInstancesCount = 1) : base(
150 || lightsCount > 3) {
151 throw new ArgumentException(
"lightsCount");
153 if (maxInstancesCount < 0
154 || maxInstancesCount > 32) {
155 throw new ArgumentException(
"maxInstancesCount");
180 if (useEmissionColor) {
183 if (lightsCount >= 1) {
188 if (lightsCount >= 2) {
192 if (lightsCount >= 3) {
202 bool useEmissionColor,
206 bool useAlphaThreshold,
207 int maxInstancesCount = 1) : base(
222 || lightsCount > 3) {
223 throw new ArgumentException(
"lightsCount");
225 if (maxInstancesCount < 0
226 || maxInstancesCount > 32) {
227 throw new ArgumentException(
"maxInstancesCount");
251 if (useEmissionColor) {
254 if (lightsCount >= 1) {
259 if (lightsCount >= 2) {
263 if (lightsCount >= 3) {
276 Stream stream = typeof(
Shader).GetTypeInfo().Assembly.GetManifestResourceStream(
"Engine.Resources.Lit.vsh");
278 ArgumentNullException.ThrowIfNull(stream);
279 return new StreamReader(stream).ReadToEnd();
286 Stream stream = typeof(
Shader).GetTypeInfo().Assembly.GetManifestResourceStream(
"Engine.Resources.Lit.psh");
288 ArgumentNullException.ThrowIfNull(stream);
289 return new StreamReader(stream).ReadToEnd();
304 bool useEmissionColor,
308 bool useAlphaThreshold,
309 int maxInstancesCount) {
310 List<ShaderMacro> list = [];
311 if (lightsCount > 0) {
314 if (lightsCount == 1) {
317 if (lightsCount == 2) {
320 if (lightsCount == 3) {
323 if (useEmissionColor) {
326 if (useVertexColor) {
335 if (useAlphaThreshold) {
338 if (maxInstancesCount > 1) {
341 list.Add(
new ShaderMacro(
"MAX_INSTANCES_COUNT", maxInstancesCount.ToString(CultureInfo.InvariantCulture)));
342 return list.ToArray();
static string GetLitVshString()
LitShader(int lightsCount, bool useEmissionColor, bool useVertexColor, bool useTexture, bool useFog, bool useAlphaThreshold, int maxInstancesCount=1)
Vector3 DiffuseLightColor1
ShaderParameter m_ambientLightColorParameter
ShaderParameter m_worldViewMatrixParameter
Vector3 DiffuseLightColor2
ShaderParameter m_diffuseLightColor2Parameter
ShaderParameter m_samplerStateParameter
ShaderParameter m_materialColorParameter
ShaderParameter m_diffuseLightColor1Parameter
ShaderParameter m_textureParameter
Vector3 AmbientLightColor
ShaderParameter m_directionToLight2Parameter
static ShaderMacro[] PrepareShaderMacros(int lightsCount, bool useEmissionColor, bool useVertexColor, bool useTexture, bool useFog, bool useAlphaThreshold, int maxInstancesCount)
SamplerState SamplerState
Vector3 DiffuseLightColor3
ShaderParameter m_fogLengthParameter
ShaderParameter m_alphaThresholdParameter
ShaderParameter m_fogColorParameter
ShaderParameter m_worldMatrixParameter
ShaderParameter m_worldViewProjectionMatrixParameter
ShaderParameter m_directionToLight1Parameter
static string GetLitPshString()
ShaderParameter m_fogStartParameter
ShaderParameter m_emissionColorParameter
ShaderParameter m_diffuseLightColor3Parameter
LitShader(string vsc, string psc, int lightsCount, bool useEmissionColor, bool useVertexColor, bool useTexture, bool useFog, bool useAlphaThreshold, int maxInstancesCount=1)
ShaderParameter m_directionToLight3Parameter
override void PrepareForDrawingOverride()
virtual ShaderParameter GetParameter(string name, bool allowNull=false)
static Stream OpenFile(string path, OpenFileMode openFileMode)
static Vector3 Normalize(Vector3 v)
static readonly Vector4 One
static readonly Vector4 Zero