Beispiel #1
0
        protected override void DoInitialize()
        {
            base.DoInitialize();

            // Create the atomic counter buffer
            {
                const int           length = 1;
                AtomicCounterBuffer buffer = AtomicCounterBuffer.Create(typeof(uint), length, BufferUsage.DynamicCopy);
                // another way to do this:
                //uint data = 1;
                //AtomicCounterBuffer buffer = data.GenAtomicCounterBuffer(BufferUsage.DynamicCopy);
                // Reset atomic counter
                IntPtr data = buffer.MapBuffer(MapBufferAccess.WriteOnly);
                unsafe
                {
                    var array = (uint *)data.ToPointer();
                    array[0] = 0;
                }
                buffer.UnmapBuffer();

                this.atomicCounterBuffer = buffer;
            }

            {
                this.depthTestState = new DepthTestSwitch(false);                   // disable depth test.
                this.cullFaceState  = new CullFaceSwitch(CullFaceMode.Back, false); // disable cull face.
            }
        }
Beispiel #2
0
 public OrderIndependentTransparencyRenderer(IBufferable model, vec3 lengths,
                                             string positionName, string normalName)
 {
     {
         var map = new AttributeMap();
         map.Add("position", positionName);
         map.Add("normal", normalName);
         var build_lists = new ShaderCode[2];
         build_lists[0]          = new ShaderCode(File.ReadAllText(@"shaders\OIT\build_lists.vert"), ShaderType.VertexShader);
         build_lists[1]          = new ShaderCode(File.ReadAllText(@"shaders\OIT\build_lists.frag"), ShaderType.FragmentShader);
         this.buildListsRenderer = new PickableRenderer(model, build_lists, map, positionName);
     }
     {
         var map = new AttributeMap();
         map.Add("position", positionName);
         var resolve_lists = new ShaderCode[2];
         resolve_lists[0]   = new ShaderCode(File.ReadAllText(@"shaders\OIT\resolve_lists.vert"), ShaderType.VertexShader);
         resolve_lists[1]   = new ShaderCode(File.ReadAllText(@"shaders\OIT\resolve_lists.frag"), ShaderType.FragmentShader);
         this.resolve_lists = new PickableRenderer(model, resolve_lists, map, positionName);
     }
     {
         this.depthTestSwitch = new DepthTestSwitch(false);
         this.cullFaceSwitch  = new CullFaceSwitch(false);
     }
     this.Lengths = lengths;
 }
 public OrderIndependentTransparencyRenderer(IBufferable model,
     string positionName, string normalName)
 {
     {
         var map = new PropertyNameMap();
         map.Add("position", positionName);
         map.Add("normal", normalName);
         var build_lists = new ShaderCode[2];
         build_lists[0] = new ShaderCode(File.ReadAllText(@"shaders\build_lists.vert"), ShaderType.VertexShader);
         build_lists[1] = new ShaderCode(File.ReadAllText(@"shaders\build_lists.frag"), ShaderType.FragmentShader);
         this.buildListsRenderer =new PickableRenderer(model, build_lists, map, positionName);
     }
     {
         var map = new PropertyNameMap();
         map.Add("position", positionName);
         var resolve_lists = new ShaderCode[2];
         resolve_lists[0] = new ShaderCode(File.ReadAllText(@"shaders\resolve_lists.vert"), ShaderType.VertexShader);
         resolve_lists[1] = new ShaderCode(File.ReadAllText(@"shaders\resolve_lists.frag"), ShaderType.FragmentShader);
         this.resolve_lists = new PickableRenderer(model, resolve_lists, map, positionName);
     }
     {
         this.depthTestSwitch = new DepthTestSwitch(false);
         this.cullFaceSwitch = new CullFaceSwitch(false);
     }
 }
Beispiel #4
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="totalBmp"></param>
        /// <returns></returns>
        public static SkyboxNode Create(Bitmap[] bitmaps)
        {
            var vs       = new VertexShader(vertexCode);
            var fs       = new FragmentShader(fragmentCode);
            var provider = new ShaderArray(vs, fs);
            var map      = new AttributeMap();

            map.Add(inPosition, Skybox.strPosition);
            var cullface = new CullFaceSwitch(CullFaceMode.Back);// display back faces only.
            var builder  = new RenderMethodBuilder(provider, map, cullface);
            var model    = new Skybox();
            var node     = new SkyboxNode(model, Skybox.strPosition, bitmaps, builder);

            node.EnablePicking = TwoFlags.Children;// sky box should not take part in picking.
            node.Initialize();

            return(node);
        }