예제 #1
0
            public ArraySegment <byte> GetValue(ParameterContainer container)
            {
                //if( ValueDataPosition == -1 )
                //	Log.Fatal( "ParameterContainer: NamedParameter: GetValue: No data in byte array." );

                //!!!!check valid array size
                return(new ArraySegment <byte>(container.data, ValueDataPosition, GetTotalSizeInBytes()));
            }
예제 #2
0
        unsafe public override void Render(Component_RenderingPipeline pipeline, ViewportRenderingContext context, Component_RenderingPipeline.IFrameData frameData)
        {
            UpdateProcessedCubemaps();

            if (mesh != null)
            {
                var pass = GetMaterialPass();
                if (pass != null)
                {
                    ////!!!!
                    //CreatedCubemapUpdate();

                    //!!!!double
                    Matrix4F worldMatrix = Matrix4.FromTranslate(context.Owner.CameraSettings.Position).ToMatrix4F();

                    foreach (var item in mesh.Result.MeshData.RenderOperations)
                    {
                        ParameterContainer generalContainer = new ParameterContainer();
                        generalContainer.Set("multiplier", Multiplier.Value.ToColorValue());
                        GetRotationMatrix(out var rotation);
                        generalContainer.Set("rotation", rotation);                          // Matrix3.FromRotateByZ( Rotation.Value.InRadians() ).ToMatrix3F() );

                        Component_Image tex = null;

                        //!!!!сделать GetResultEnvironmentCubemap()?
                        //!!!!!!где еще его использовать
                        if (processedEnvironmentCubemap != null)
                        {
                            tex = processedEnvironmentCubemap;
                        }
                        //else if( AnyCubemapSideIsSpecified() )
                        //	tex = createdCubemap;
                        else
                        {
                            tex = Cubemap;
                        }
                        if (tex == null)
                        {
                            tex = ResourceUtility.BlackTextureCube;
                        }

                        if (tex.Result != null && tex.Result.TextureType == Component_Image.TypeEnum.Cube)
                        {
                            var addressingMode = TextureAddressingMode.Clamp;

                            context.BindTexture(new ViewportRenderingContext.BindTextureData(0 /*"skyboxTexture"*/, tex, addressingMode, FilterOption.Linear, FilterOption.Linear, FilterOption.Linear));

                            var containers = new List <ParameterContainer>();
                            containers.Add(generalContainer);

                            Bgfx.SetTransform((float *)&worldMatrix);
                            ((Component_RenderingPipeline_Basic)pipeline).RenderOperation(context, item, pass, containers);
                        }
                    }
                }
            }
        }
예제 #3
0
        public void BindParameterContainer(ParameterContainer container)
        {
            if (container.NamedParameters != null)
            {
                foreach (var tuple in container.NamedParameters)
                {
                    var name = tuple.Key;
                    var p    = tuple.Value;

                    if (ParameterTypeUtility.CanConvertToByteArray(p.Type))
                    {
                        //uniforms
                        SetUniform(name, p.Type, p.ElementCount, p.GetValue(container));
                    }
                    else
                    {
                        //Log.Fatal( "ViewportRenderingContext: BindParameterContainer: Is not supported named parameter." );
                    }
                    //else if( ParameterTypeUtility.IsTexture( p.Type ) )
                    //{
                    //	//textures

                    //	//!!!!текстуры в вершинах

                    //	var value = (GpuMaterialPass.TextureParameterValue)p.Value;
                    //	var index = int.Parse( p.Name );
                    //	BindTexture( index, value );
                    //}
                }
            }

            if (container.UniformParameters != null)
            {
                for (int n = 0; n < container.UniformParameters.Count; n++)
                {
                    ref var p = ref container.UniformParameters.Data[n];
                    SetUniform(p.Uniform, p.Type, p.ElementCount, p.GetValue(container));
                }
            }