Survivalcraft API 1.8.2.3 v1.8.2.3
Survivalcraft 2.4
载入中...
搜索中...
未找到
SkyShader.cs
浏览该文件的文档.
1namespace Engine.Graphics {
2 public class SkyShader : TransformedShader {
4
6
8
10
12
14 set => m_textureParameter.SetValue(value);
15 }
16
18 set => m_samplerStateParameter.SetValue(value);
19 }
20
21 public Vector4 Color {
22 set => m_colorParameter.SetValue(value);
23 }
24
25 public float AlphaThreshold {
26 set => m_alphaThresholdParameter.SetValue(value);
27 }
28
29 public SkyShader(string vsc, string psc, bool useVertexColor, bool useTexture, bool useAlphaThreshold) : base(
30 vsc,
31 psc,
32 1,
33 PrepareShaderMacros(useVertexColor, useTexture, useAlphaThreshold)
34 ) {
37 }
38
39 public SkyShader(string vsc, string psc, bool useVertexColor, bool useTexture, bool useAlphaThreshold, ShaderMacro[] shaderMacros = null) :
40 base(vsc, psc, 1, PrepareShaderMacros(useVertexColor, useTexture, useAlphaThreshold, shaderMacros)) {
43 }
44
45 public virtual void SetParameter() {
46 m_worldViewProjectionMatrixParameter = base.GetParameter("u_worldViewProjectionMatrix", true);
47 m_textureParameter = base.GetParameter("u_texture", true);
48 m_samplerStateParameter = base.GetParameter("u_samplerState", true);
49 m_colorParameter = base.GetParameter("u_color", true);
50 m_alphaThresholdParameter = base.GetParameter("u_alphaThreshold", true);
51 }
52
53 public override void PrepareForDrawingOverride() {
54 Transforms.UpdateMatrices(1, false, false, true);
55 m_worldViewProjectionMatrixParameter.SetValue(Transforms.WorldViewProjection, 1);
56 }
57
58 public static ShaderMacro[] PrepareShaderMacros(bool useVertexColor,
59 bool useTexture,
60 bool useAlphaThreshold,
61 ShaderMacro[] shaderMacros = null) {
62 List<ShaderMacro> list = [];
63 if (useVertexColor) {
64 list.Add(new ShaderMacro("USE_VERTEXCOLOR"));
65 }
66 if (useTexture) {
67 list.Add(new ShaderMacro("USE_TEXTURE"));
68 }
69 if (useAlphaThreshold) {
70 list.Add(new ShaderMacro("USE_ALPHATHRESHOLD"));
71 }
72 if (shaderMacros != null
73 && shaderMacros.Length > 0) {
74 foreach (ShaderMacro shaderMacro in shaderMacros) {
75 list.Add(shaderMacro);
76 }
77 }
78 return list.ToArray();
79 }
80 }
81}
static ShaderMacro[] PrepareShaderMacros(bool useVertexColor, bool useTexture, bool useAlphaThreshold, ShaderMacro[] shaderMacros=null)
ShaderParameter m_alphaThresholdParameter
SkyShader(string vsc, string psc, bool useVertexColor, bool useTexture, bool useAlphaThreshold, ShaderMacro[] shaderMacros=null)
ShaderParameter m_textureParameter
ShaderParameter m_samplerStateParameter
SkyShader(string vsc, string psc, bool useVertexColor, bool useTexture, bool useAlphaThreshold)
ShaderParameter m_colorParameter
ShaderParameter m_worldViewProjectionMatrixParameter
override void PrepareForDrawingOverride()
static readonly Vector4 One