public override void Init( FXEffect m_effect, FXConstantBuffer m_cb )
        {
            // bind the local variables with the shader
            Texture_Variable = m_effect.GetResourceByName(VariableName + "_Texture");

            // set the default values
            if (Tex != null)
                Texture_Variable.SetResource(Tex.shaderResource);
        }
 private void InitShader()
 {
     /// Texture resources
     m_TextureDiffuse = m_effect.GetResourceByName("g_TextureDiffuse");
 }
        public override void Init( FXEffect m_effect , FXConstantBuffer m_cb )
        {
            /// Bind the random Texture
            RandomTex_Variable = m_effect.GetResourceByName(VariableName + "_RandomTex");

            /// Get the variables from Constant buffer
            MinValue_Variable = m_cb.GetMemberByName<float>( VariableName + "_MinValue" );
            MaxValue_Variable = m_cb.GetMemberByName<float>( VariableName + "_MaxValue" );
            Tile_X_Variable = m_cb.GetMemberByName<float>( VariableName + "_Tile_X" );
            Tile_Y_Variable = m_cb.GetMemberByName<float>( VariableName + "_Tile_Y" );
            Loops_Variable = m_cb.GetMemberByName<int>( VariableName + "_Loops" );

            // create and set random texture
            SetRandomTex(_Seed);

            // set the values of the variables
            MinValue_Variable.Set(_MinValue);
            MaxValue_Variable.Set(_MaxValue);
            Loops_Variable.Set(_Loops);
            Tile_X_Variable.Set(_Tile_X);
            Tile_Y_Variable.Set(_Tile_Y);
        }
Exemple #4
0
        public PointCloud(List<FxMaths.Vector.FxVector3f> Points, List<FxMaths.Vector.FxVector3f> Colors)
        {
            Device dev = Engine.g_device;

            /// make a stream with the vertex to be able to insert it to the mesh
            DataStream stream = new DataStream(Marshal.SizeOf(typeof(PointCloudParticle)) * Points.Count, true, true);

            /// Init the shader
            m_shader = new Shaders.ShaderPointCloud();
            m_numParticles = Points.Count;

            m_shader.SetTexture("c://Particle.png");

            /// write the particles to the stream
            for (int i = 0; i < m_numParticles; i++)
            {
                Points[i].WriteToDataStream(stream);
                Colors[i].WriteToDataStream(stream);
            }
            /// reset the position in the stream
            stream.Position = 0;

            /// Fill the buffer with the vertices
            m_BufferParticles = ComputeShader.CreateBuffer(m_numParticles, ComputeShader.SizeOfFloat3 * 2, AccessViewType.SRV, stream);
            m_BufferParticles.DebugName = "ParticleBuffer";

            m_srvBufferParticles = FXResourceVariable.InitSRVResource(dev, m_BufferParticles);
            m_rvBufferParticles = m_shader.m_effect.GetResourceByName("particleBuffer");
            m_rvBufferParticles.SetResource(m_srvBufferParticles);

            // set the world matrix
            m_WorldMatrix = Matrix.Scaling(_scale) * Matrix.RotationYawPitchRoll(_rotation.Y, _rotation.X, _rotation.Z) * Matrix.Translation(_position);

            // close the stream
            stream.Close();
        }
        private void InitShader()
        {
            /// Bind the random Texture
            RandomTex_Variable =m_effect.GetResourceByName( "randomTex" );

            /// Bind the constant buffer with local buffer
            CB_PerlinNoise = m_effect.GetConstantBufferByName<cbPerlinNoise>( "cbPerlinNoiseVariables");

            // create and set random texture
            SetRandomTex( _Seed );
        }
 private void InitShader()
 {
     /// Texture resources
     m_TextureDiffuse = m_effect.GetResourceByName("g_TextureDiffuse");
     m_TextureBump = m_effect.GetResourceByName( "g_TextureBump");
     m_TextureNormal = m_effect.GetResourceByName( "g_TextureNormal");
     m_TextureLightmap = m_effect.GetResourceByName("g_TextureLightmap");
     m_TextureHighmap = m_effect.GetResourceByName("g_TextureHighmap");
 }