SetPixelShaderConstant() public method

public SetPixelShaderConstant ( float data, int startRegister ) : void
data float
startRegister int
return void
Example #1
0
        void OnShaderSet(MaterialRendererServices services, int userData)
        {
            if (userData == 2 || userData == 3) //All DirectX Shaders
            {
                Matrix4 worldViewProj;
                worldViewProj = _driver.GetTransform(TransformationState.Projection);
                worldViewProj *= _driver.GetTransform(TransformationState.View);
                worldViewProj *= _driver.GetTransform(TransformationState.World);
                services.SetVertexShaderConstant("mWorldViewProj", worldViewProj.ToShader());
            }
            if (userData == 1 || userData == 3) //Clamp Shaders
            {
                if (userData == 1) //OpenGL Clamp Shader
                {
                    services.SetPixelShaderConstant("DiffuseMap", 0f);
                    services.SetPixelShaderConstant("DetailMap", 1f);
                }
                services.SetPixelShaderConstant("WaterPositionY", WaterNode.Position.Y);
                return;
            }
            //Water Shaders
            float time = (float)((DateTime.Now.TimeOfDay.TotalMilliseconds));
            services.SetVertexShaderConstant("Time", time);
            services.SetVertexShaderConstant("WaveHeight", WaveHeight);
            services.SetVertexShaderConstant("WaveLength", WaveLength);
            services.SetVertexShaderConstant("WaveSpeed", WaveSpeed);

            services.SetPixelShaderConstant("AddedColor", AddedColor.ToShader());
            services.SetPixelShaderConstant("MultiColor", MultiColor.ToShader());
            services.SetPixelShaderConstant("WaveDisplacement", WaveDisplacement);
            services.SetPixelShaderConstant("WaveRepetition", WaveRepetition);
            services.SetPixelShaderConstant("RefractionFactor", RefractionFactor);
            services.SetPixelShaderConstant("UnderWater", IsUnderwater(_scene.ActiveCamera) ? 1.0f : 0.0f);
        }
Example #2
0
        public override void ShaderEvent(MaterialRendererServices services, int userData)
        {
            IrrlichtNETCP.VideoDriver driver = services.VideoDriver;

            // *****************************************
            // VERTEX SHADER CONSTANTS
            // *****************************************
            Matrix4 worldViewProj = driver.GetTransform(TransformationState.Projection);
            worldViewProj *= driver.GetTransform(TransformationState.View);
            worldViewProj *= driver.GetTransform(TransformationState.World);
            services.SetVertexShaderConstant("WorldViewProj", worldViewProj.ToShader(), 16);

            Matrix4 worldReflectionViewProj = driver.GetTransform(TransformationState.Projection);
            worldReflectionViewProj *= Camera.ViewMatrix;
            worldReflectionViewProj *= driver.GetTransform(TransformationState.World);
            services.SetVertexShaderConstant("WorldReflectionViewProj", worldReflectionViewProj.ToShader(), 16);

            services.SetVertexShaderConstant("WaveLength", 0.01f);   // 0.1

            float time = Reference.Device.Timer.Time / 1000000.0f;
            services.SetVertexShaderConstant("Time", time);

            services.SetVertexShaderConstant("WindForce", WindForce);
            services.SetVertexShaderConstant("WindDirection", WindDirection.ToShader(), 2);

            // *****************************************
            // PIXEL SHADER CONSTANTS
            // *****************************************
            Vector3D cameraPos = Reference.SceneManager.ActiveCamera.Position;
            services.SetPixelShaderConstant("CameraPosition", cameraPos.ToShader());
            services.SetPixelShaderConstant("WaveHeight", WaveHeight);
            services.SetPixelShaderConstant("WaterColor", WaterColor.ToShader());
            services.SetPixelShaderConstant("SpecularColor", SpecularColor.ToShader());
            services.SetPixelShaderConstant("Specular", Specular);
            services.SetPixelShaderConstant("ColorBlendFactor", ColorBlendFactor);

            base.ShaderEvent(services, userData);
        }