Пример #1
0
 public void setShader()
 {
     if (!parameters.Directional)
     {
         shader.SetTechnique("Billboard");
     }
     else
     {
         shader.SetTechnique("DirectionalBillboard");
         shader.Effect.GetVariableByName("startPosition").AsVector().Set(parameters.position);
     }
     shader.Effect.GetVariableByName("world").AsMatrix().SetMatrix(Matrix.Identity);
     shader.Effect.GetVariableByName("viewProjection").AsMatrix().SetMatrix(Matrix.Identity);
     shader.Effect.GetVariableByName("viewInverse").AsMatrix().SetMatrix(Matrix.Identity);
     shader.Effect.GetVariableByName("txDiffuse").AsResource().SetResource(texturePool.LoadTexture(parameters.texture));
     shader.Effect.GetVariableByName("size").AsScalar().Set(parameters.size);
     //effect parameter
     shader.Effect.GetVariableByName("timeTexture").AsResource().SetResource(timeTextureRSV);
     shader.Effect.GetVariableByName("width").AsScalar().Set(parameters.particleWidth);
     shader.Effect.GetVariableByName("height").AsScalar().Set(parameters.particleHeight);
     shader.Effect.GetVariableByName("widthEnd").AsScalar().Set(parameters.particleWidthEnd);
     shader.Effect.GetVariableByName("heightEnd").AsScalar().Set(parameters.particleHeightEnd);
     shader.Effect.GetVariableByName("startColor").AsVector().Set(new Color4(StartColor.ToVector3() * parameters.darkScale));
     shader.Effect.GetVariableByName("endColor").AsVector().Set(new Color4(EndColor.ToVector3() * parameters.darkScale));
     shader.Effect.GetVariableByName("oneOverTotalLifeTime").AsScalar().Set(1 / (parameters.MaxLifeTime));
     shader.Effect.GetVariableByName("uvStart").AsVector().Set(parameters.UvStart);
     shader.Effect.GetVariableByName("uvSize").AsVector().Set(parameters.UvSize);
     shader.Apply();
 }