コード例 #1
0
 /// <summary>
 /// Конструктор
 /// </summary>
 public MorphMeshShader() : base()
 {
     if (firstVertexAttrib == null)
     {
         firstVertexAttrib = new VertexAttribute("inFirstPosition");
         attribs.Add(firstVertexAttrib);
     }
     if (secondVertexAttrib == null)
     {
         secondVertexAttrib = new VertexAttribute("inSecondPosition");
         attribs.Add(secondVertexAttrib);
     }
     if (firstNormalAttrib == null)
     {
         firstNormalAttrib = new VertexAttribute("inFirstNormal");
         attribs.Add(firstNormalAttrib);
     }
     if (secondNormalAttrib == null)
     {
         secondNormalAttrib = new VertexAttribute("inSecondNormal");
         attribs.Add(secondNormalAttrib);
     }
     if (deltaUniform == null)
     {
         deltaUniform = new FloatUniform("delta");
         uniforms.Add(deltaUniform);
     }
 }
コード例 #2
0
 public void SetShadingUniforms(ShaderProgram shader)
 {
     this.ambientLightColorUniform = new Vector3Uniform("ambientLightColor", this.SceneLight.Color);
     this.ambientLightColorUniform.Set(shader);
     this.ambientLightStrengthUniform = new FloatUniform("ambientLightStrength", this.SceneLight.Strength);
     this.ambientLightStrengthUniform.Set(shader);
 }
コード例 #3
0
 private BulletBatch(VertexArray vao, ArrayBuffer ivbo, ShaderProgram program, FloatUniform timeUniform, FloatUniform scaleUniform)
 {
     this.vao          = vao;
     this.ivbo         = ivbo;
     this.program      = program;
     this.timeUniform  = timeUniform;
     this.scaleUniform = scaleUniform;
 }
コード例 #4
0
ファイル: ShipBatch.cs プロジェクト: LorenzJ/PureEcsPrototype
 public ShipBatch(ShaderProgram program, ArrayBuffer ivbo, VertexArray vao, FloatUniform timeUniform, FloatUniform scaleUniform)
 {
     this.program      = program;
     this.ivbo         = ivbo;
     this.vao          = vao;
     this.timeUniform  = timeUniform;
     this.scaleUniform = scaleUniform;
 }
コード例 #5
0
    public void SetRenderUniforms(Material Mat)
    {
        foreach (var field in typeof(RenderUniforms).GetFields())
        {
            FloatUniform u = (FloatUniform)field.GetValue(renderUniforms);

            Mat.SetFloat(field.Name, u.value);
        }
    }
コード例 #6
0
    public void resetRenderUniforms()
    {
        foreach (var field in typeof(RenderUniforms).GetFields())
        {
            FloatUniform u = (FloatUniform)field.GetValue(renderUniforms);
            u.value = u.og;

            field.SetValue(renderUniforms, u);
        }
    }
コード例 #7
0
ファイル: SurfaceManager.cs プロジェクト: amulware/yatl
 private void initOverlay(ShaderManager shaders)
 {
     this.Overlay = new PostProcessSurface();
     this.Overlay.AddSettings(
         SurfaceBlendSetting.PremultipliedAlpha,
         this.overlayFadePercentage = new FloatUniform("fadePercentage"),
         this.overlayColor          = new Vector4Uniform("color")
         );
     shaders.Overlay.UseOnSurface(this.Overlay);
 }
コード例 #8
0
ファイル: MtlReader.cs プロジェクト: aalmada/bonsai
        internal static void ReadMaterial(MaterialConfiguration material, string fileName)
        {
            foreach (var line in File.ReadAllLines(fileName))
            {
                var values = line.Split(new[] { ' ' }, StringSplitOptions.RemoveEmptyEntries);
                if (values.Length < 2)
                {
                    continue;
                }

                var uniformName = values[0];
                if (uniformName == "newmtl" || uniformName.StartsWith("#"))
                {
                    continue;
                }
                if (uniformName.StartsWith("map_"))
                {
                    var textureBinding = new TextureBindingConfiguration();
                    textureBinding.Name        = uniformName;
                    textureBinding.TextureName = Path.GetFileNameWithoutExtension(values[1]);
                    textureBinding.TextureSlot = TextureUnit.Texture0 + material.BufferBindings.Count;
                    material.BufferBindings.Add(textureBinding);
                }
                else
                {
                    UniformConfiguration uniform;
                    var uniformValues = ParseValues(values);
                    switch (uniformValues.Length)
                    {
                    case 1: uniform = new FloatUniform {
                            Value = uniformValues[0]
                    }; break;

                    case 2: uniform = new Vec2Uniform {
                            Value = new Vector2(uniformValues[0], uniformValues[1])
                    }; break;

                    case 3: uniform = new Vec3Uniform {
                            Value = new Vector3(uniformValues[0], uniformValues[1], uniformValues[2])
                    }; break;

                    case 4: uniform = new Vec4Uniform {
                            Value = new Vector4(uniformValues[0], uniformValues[1], uniformValues[2], uniformValues[3])
                    }; break;

                    default: throw new InvalidOperationException("Unsupported number of values in the configuration of uniform " + uniformName + ".");
                    }
                    uniform.Name = uniformName;
                    material.ShaderUniforms.Add(uniform);
                }
            }
        }
コード例 #9
0
 // Конструктор
 protected MeshShader() : base()
 {
     if (vertexAttrib == null)
     {
         vertexAttrib = new VertexAttribute("inPosition");
         attribs.Add(vertexAttrib);
     }
     if (normalAttrib == null)
     {
         normalAttrib = new VertexAttribute("inNormal");
         attribs.Add(normalAttrib);
     }
     if (texCoordAttrib == null)
     {
         texCoordAttrib = new VertexAttribute("inTexCoord");
         attribs.Add(texCoordAttrib);
     }
     if (textureUniform == null)
     {
         textureUniform = new TextureUniform("texture");
         uniforms.Add(textureUniform);
     }
     if (diffuseColor == null)
     {
         diffuseColor = new ColorUniform("diffuseColor");
         uniforms.Add(diffuseColor);
     }
     if (alphaPass == null)
     {
         alphaPass = new BoolUniform("discardPass");
         uniforms.Add(alphaPass);
     }
     if (lightMultiplier == null)
     {
         lightMultiplier = new FloatUniform("lightMult");
         uniforms.Add(lightMultiplier);
     }
     if (textureMatrix == null)
     {
         textureMatrix = new MatrixUniform("textureMatrix");
         uniforms.Add(textureMatrix);
     }
 }
コード例 #10
0
    public void updateInterfaceValues()
    {
        foreach (var field in typeof(ComputeUniforms).GetFields())
        {
            if (ComputeSliders[field.Name] != null)
            {
                FloatUniform u      = (FloatUniform)field.GetValue(computeUniforms);
                GameObject   slider = (GameObject)ComputeSliders[field.Name];

                float v     = slider.GetComponent <Slider>().Value;
                float final = v * (u.high - u.low) + u.low;

                u.value = final;


                field.SetValue(computeUniforms, u);
            }
            else
            {
            }
        }

        foreach (var field in typeof(RenderUniforms).GetFields())
        {
            if (RenderSliders[field.Name] != null)
            {
                FloatUniform u      = (FloatUniform)field.GetValue(renderUniforms);
                GameObject   slider = (GameObject)RenderSliders[field.Name];

                float v     = slider.GetComponent <Slider>().Value;
                float final = v * (u.high - u.low) + u.low;

                u.value = final;


                field.SetValue(renderUniforms, u);
            }
            else
            {
            }
        }
    }
コード例 #11
0
    public void SetRenderInterface()
    {
        foreach (var field in typeof(RenderUniforms).GetFields())
        {
            if (RenderSliders[field.Name] != null)
            {
                FloatUniform u      = (FloatUniform)field.GetValue(renderUniforms);
                GameObject   slider = (GameObject)RenderSliders[field.Name];

                float final = (u.value - u.low) / (u.high - u.low);// + u.low;

                //Wfinal = 1.0f;
                slider.GetComponent <Slider>().SetValue(final);
            }
            else
            {
                print("NO SLIDERSSS");
            }
        }
    }
コード例 #12
0
    public void SetComputeUniforms(ComputeShader Mat)
    {
        //print(computeUniforms._Dampening.value);

        // Mat.SetFloat( "_LengthOfConnectionSprings"    , u._LengthOfConnectionSprings);

        foreach (var field in typeof(ComputeUniforms).GetFields())
        {
            FloatUniform u = (FloatUniform)field.GetValue(computeUniforms);

            Mat.SetFloat(field.Name, u.value);
        }

        //Mat.SetFloat( "_MaxVel"                       , computeUniforms._MaxVel.value                    );
        //Mat.SetFloat( "_MaxForce"                     , computeUniforms._MaxForce.value                  );
        //Mat.SetFloat( "_ForceMultiplier"              , computeUniforms._ForceMultiplier.value           );
        //Mat.SetFloat( "_Dampening"                    , computeUniforms._Dampening.value                 );
        //Mat.SetFloat( "_HandRepelRadius"              , computeUniforms._HandRepelRadius.value           );
        //Mat.SetFloat( "_HandRepelStrength"            , computeUniforms._HandRepelStrength.value         );
        //Mat.SetFloat( "_ReturnSpringStrength"         , computeUniforms._ReturnSpringStrength.value      );
        //Mat.SetFloat( "_DistanceToAudioHit"           , computeUniforms._DistanceToAudioHit.value        );
        //Mat.SetFloat( "_AudioHitMultiplier"           , computeUniforms._AudioHitMultiplier.value        );
    }
コード例 #13
0
    public void resetComputeUniforms()
    {
        foreach (var field in typeof(ComputeUniforms).GetFields())
        {
            FloatUniform u = (FloatUniform)field.GetValue(computeUniforms);
            u.value = u.og;

            field.SetValue(renderUniforms, u);
        }


        //computeUniforms._LengthOfConnectionSprings  = 0.001f;
        //computeUniforms._LengthOfConnectionSprings.value  = computeUniforms._LengthOfConnectionSprings.og ;
        //computeUniforms._ConnectionSpringStrength.value   = computeUniforms._ConnectionSpringStrength.og  ;
        //computeUniforms._MaxVel.value                     = computeUniforms._MaxVel.og                    ;
        //computeUniforms._MaxForce.value                   = computeUniforms._MaxForce.og                  ;
        //computeUniforms._ForceMultiplier.value            = computeUniforms._ForceMultiplier.og           ;
        //computeUniforms._Dampening.value                  = computeUniforms._Dampening.og                 ;
        //computeUniforms._HandRepelRadius.value            = computeUniforms._HandRepelRadius.og           ;
        //computeUniforms._HandRepelStrength.value          = computeUniforms._HandRepelStrength.og         ;
        //computeUniforms._ReturnSpringStrength.value       = computeUniforms._ReturnSpringStrength.og      ;
        //computeUniforms._DistanceToAudioHit.value         = computeUniforms._DistanceToAudioHit.og        ;
        //computeUniforms._AudioHitMultiplier.value         = computeUniforms._AudioHitMultiplier.og        ;
    }
コード例 #14
0
 public FloatUniformViewModel(FloatUniform uniform)
     : base(uniform)
 {
 }
コード例 #15
0
 public static void Set(this ShaderProgram @this, FloatUniform uniform, float value)
 => Gl.ProgramUniform1(@this.Handle, uniform.Location, value);