示例#1
0
        private void Form02OrderIndependentTransparency_Load(object sender, EventArgs e)
        {
            {
                var camera = new Camera(CameraType.Perspecitive, this.glCanvas1.Width, this.glCanvas1.Height);
                camera.Position = new vec3(0, 0, 5);
                camera.Target   = new vec3(0, 0, 0);
                camera.UpVector = new vec3(0, 1, 0);
                var rotator = new SatelliteRotator(camera);
                this.camera  = camera;
                this.rotator = rotator;
            }
            {
                var shaderCodes = new ShaderCode[2];
                shaderCodes[0] = new ShaderCode(File.ReadAllText(@"12Billboard\Cube.vert"), ShaderType.VertexShader);
                shaderCodes[1] = new ShaderCode(File.ReadAllText(@"12Billboard\Cube.frag"), ShaderType.FragmentShader);
                var map = new PropertyNameMap();
                map.Add("in_Position", "position");
                map.Add("in_Color", "color");
                var cubeRenderer = new PickableRenderer(new Cube(), shaderCodes, map, "position");
                cubeRenderer.Initialize();
                this.cubeRenderer = cubeRenderer;
            }
            {
                var shaderCodes = new ShaderCode[2];
                shaderCodes[0] = new ShaderCode(File.ReadAllText(@"12Billboard\billboard.vert"), ShaderType.VertexShader);
                shaderCodes[1] = new ShaderCode(File.ReadAllText(@"12Billboard\billboard.frag"), ShaderType.FragmentShader);
                var map = new PropertyNameMap();
                map.Add("squareVertices", "position");
                var billboardRenderer = new Renderer(new BillboardModel(), shaderCodes, map);
                billboardRenderer.Initialize();
                var texture = new sampler2D();
                var bitmap  = new Bitmap(@"12Billboard\ExampleBillboard.png");
                texture.Initialize(bitmap);
                bitmap.Dispose();
                billboardRenderer.SetUniform("myTextureSampler", new samplerValue(BindTextureTarget.Texture2D, texture.Id, OpenGL.GL_TEXTURE0));

                this.billboardRenderer = billboardRenderer;
            }
            {
                var UIRoot = new GLControl(this.glCanvas1.Size, -100, 100);
                UIRoot.Initialize();
                this.uiRoot = UIRoot;

                var glAxis = new GLAxis(AnchorStyles.Right | AnchorStyles.Bottom,
                                        new Padding(3, 3, 3, 3), new Size(70, 70), -100, 100);
                glAxis.Initialize();
                this.glAxis = glAxis;

                UIRoot.Controls.Add(glAxis);
            }
            {
                var frmPropertyGrid = new FormProperyGrid();
                frmPropertyGrid.DisplayObject(this.glAxis);
                frmPropertyGrid.Show();
                this.formPropertyGrid = frmPropertyGrid;
            }
        }
示例#2
0
        public sampler2D GetTexture2D(Bitmap bitmap)
        {
            sampler2D result;

            if (!this.dict.TryGetValue(bitmap, out result))
            {
                result = new sampler2D();
                result.Initialize(bitmap);
                this.dict.Add(bitmap, result);
            }

            return(result);
        }
示例#3
0
 protected override void DoInitialize()
 {
     {
         // This is the texture that the compute program will write into
         sampler2D texture = new sampler2D();
         var       bitmap  = new System.Drawing.Bitmap(@"Images\star.png");
         texture.Initialize(bitmap);
         bitmap.Dispose();
         this.sprite_texture[0] = texture.Id;
     }
     base.DoInitialize();
     this.SetUniform("sprite_texture", new samplerValue(
                         BindTextureTarget.Texture2D, this.sprite_texture[0], OpenGL.GL_TEXTURE0));
     this.SetUniform("factor", 25000.0f);
 }
示例#4
0
        internal void UpdateTexture(string filename)
        {
            // This is the texture that the compute program will write into
            sampler2D texture = new sampler2D();
            var       bitmap  = new System.Drawing.Bitmap(filename);

            texture.Initialize(bitmap);
            bitmap.Dispose();
            var old = new uint[1];

            old[0] = this.sprite_texture[0];
            this.sprite_texture[0] = texture.Id;
            this.SetUniform("sprite_texture", new samplerValue(
                                BindTextureTarget.Texture2D, this.sprite_texture[0], OpenGL.GL_TEXTURE0));

            OpenGL.DeleteTextures(1, old);
        }
示例#5
0
 protected override void DoInitialize()
 {
     {
         // This is the texture that the compute program will write into
         OpenGL.GenTextures(1, sprite_texture);
         OpenGL.BindTexture(OpenGL.GL_TEXTURE_2D, sprite_texture[0]);
         OpenGL.TexStorage2D(TexStorage2DTarget.Texture2D, 8, OpenGL.GL_RGBA32F, 256, 256);
         OpenGL.BindTexture(OpenGL.GL_TEXTURE_2D, 0);
         sampler2D texture = new sampler2D();
         var bitmap = new System.Drawing.Bitmap(@"07Billboard\star.png");
         texture.Initialize(bitmap);
         this.sprite_texture[0] = texture.Id;
         bitmap.Dispose();
     }
     base.DoInitialize();
     this.SetUniform("sprite_texture", new samplerValue(
           BindTextureTarget.Texture2D, this.sprite_texture[0], OpenGL.GL_TEXTURE0));
     this.SetUniform("factor", 100.0f);
 }
示例#6
0
 protected extern vec4 textureProjGradOffset(sampler2D sampler, vec4 p, vec2 dPdx, vec2 dPdy, ivec2 offset);
 /// <summary>Do a texture lookup with both explicit gradient and offset, as described in textureGrad and textureOffset. </summary>
 protected static vec4 textureGradOffset(sampler2D sampler, vec2 P, vec2 dPdx, vec2 dPdy, ivec2 offset)
 {
     throw _invalidAccess;
 }
示例#8
0
 protected float4 Texture2D(sampler2D sampler, float2 coord)
 {
     return(new float4(1, 1, 1, 1));
 }
示例#9
0
 public static vec4 texture(sampler2D texture, vec2 uv)
 {
     return(null);
 }
示例#10
0
 public override void Begin()
 {
     base.Begin();
     PermSampler2D = BindTexture(_perm2D).ToSampler();
     PermGradSampler = BindTexture(_permGrad3).ToSampler();
 }
 protected vec4 texture2DProjLod(sampler2D sampler, vec4 coord, float lod) { throw new NotImplementedException(); }
示例#12
0
 public override void Begin()
 {
     base.Begin();
     PermSampler2D   = BindTexture(_perm2D).ToSampler();
     PermGradSampler = BindTexture(_permGrad3).ToSampler();
 }
 protected vec4 texture2DProj(sampler2D sampler, vec3 coord, float bias)
 {
     throw new NotImplementedException();
 }
示例#14
0
 protected extern vec4 textureLod(sampler2D sampler, vec2 p, float lod);
示例#15
0
 protected extern vec4 textureProjLodOffset(sampler2D sampler, vec4 p, float lod, ivec2 offset);
示例#16
0
 protected extern vec4 textureProj(sampler2D sampler, vec4 p, float bias         = 0);
示例#17
0
 protected extern ivec2 textureSize(sampler2D sampler, int lod);
示例#18
0
 protected extern vec4 texture(sampler2D sampler, vec2 p, float bias              = 0);
 /// <summary>  Do an offset texture lookup with explicit LOD. See textureLod and textureOffset.</summary>
 protected static vec4 textureLodOffset(sampler2D sampler, vec2 P, float lod, ivec2 offset)
 {
     throw _invalidAccess;
 }
 /// <summary>Do a texture lookup with projection. The texture coordinates consumed from P,
 /// not including the last component of P, are divided by the last component of P. 
 /// After these values are computed,texture lookup proceeds as in texture.</summary>
 protected internal static vec4 TextureProj(sampler2D sampler, vec4 P)
 {
     throw _invalidAccess;
 }
示例#21
0
文件: Access.cs 项目: h3tch/ProtoFX
 public static vec4 texture(Location location, sampler2D sampler, vec2 P, float bias = 0)
 {
     return(texturef(location, sampler.i, P.x, P.y, 0, 0, GetPName.TextureBinding2D));
 }
 /// <summary>Do a texture lookup projectively and with explicit gradient as described in TextureProjGrad,
 /// as well as with offset, as described in TextureOffset.</summary>
 protected internal static vec4 TextureProjGradOffset(sampler2D sampler, vec4 P, vec2 dPdx, vec2 dPdy, ivec2 offset)
 {
     throw _invalidAccess;
 }
 protected vec4 texture2D(sampler2D sampler, vec2 coord)
 {
     throw new NotImplementedException();
 }
 /// <summary>  Do an offset texture lookup with explicit LOD. See TextureLod and TextureOffset.</summary>
 protected internal static vec4 TextureProjLod(sampler2D sampler, vec3 P, float lod)
 {
     throw _invalidAccess;
 }
示例#25
0
 public override void Begin()
 {
     base.Begin();
     WangTiles = BindTexture(Tiles).ToSampler();
     WangMap = BindTexture(WangTable).ToSampler(); ;
 }
 /// <summary>  Do an offset texture lookup with explicit LOD. See TextureLod and TextureOffset.</summary>
 protected internal static vec4 TextureProjLodOffset(sampler2D sampler, vec4 P, float lod, ivec2 offset)
 {
     throw _invalidAccess;
 }
示例#27
0
 public static vec4 texture(sampler2D tex, vec2 coord)
 {
     throw new NotImplementedException();
 }
 /// <summary>  Do a projective texture lookup as described in TextureProj offset by offset as described in TextureOffset. </summary>
 protected internal static vec4 TextureProjOffset(sampler2D sampler, vec4 P, ivec2 offset, float bias)
 {
     throw _invalidAccess;
 }
示例#29
0
 protected extern vec4 textureProjLod(sampler2D sampler, vec4 p, float lod);
 /// <summary>
 /// Returns the mipmap array(s) that would be accessed in the x component of the return value.
 /// Returns the computed level of detail relative to the base level in the y component of the return value.
 /// If called on an incomplete texture, the results are undefined.
 /// </summary>
 protected internal static vec2 TextureQueryLod(sampler2D sampler, vec2 P)
 {
     throw _invalidAccess;
 }
示例#31
0
 protected extern vec4 textureLodOffset(sampler2D sampler, vec2 p, int lod, ivec2 offset);
 protected internal static ivec2 TextureSize(sampler2D sampler, int lod)
 {
     throw _invalidAccess;
 }
 protected static vec4 texture2D(sampler2D sampler, vec2 st, float bias)
 {
     throw _invalidAccess;
 }
 /// <summary>Use the texture coordinate P to do a texture lookup in the texture currently bound to sampler.</summary>
 protected internal static vec4 Texture(sampler2D sampler, vec2 P, float bias)
 {
     throw _invalidAccess;
 }
 /// <summary>
 /// Use integer texture coordinate P to lookup a single texel from sampler. 
 /// The level-ofdetail lod is as described in sections 2.11.8 “Shader Execution” 
 /// under Texel Fetches and 3.8 “Texturing” of the OpenGL GraphicsSystem Specification.
 /// </summary>
 protected static vec4 texelFetch(sampler2D sampler, ivec2 P, int lod)
 {
     throw _invalidAccess;
 }
 /// <summary> Do a texture lookup as in texture but with offset added to the (u,v,w) texel coordinates before looking up each texel.
 /// The offset value must be a constant expression. A limited range of offset values are supported; 
 /// the minimum and maximum offset values are implementation-dependent and given by MIN_PROGRAM_TEXEL_OFFSET and MAX_PROGRAM_TEXEL_OFFSET, respectively.
 /// Note that offset does not apply to the layer coordinate for texture arrays. This is explained in detail in section 3.8.11
 /// “Texture Minification” of the OpenGL Graphics System Specification, where offset is (∂u ,∂v ,∂w).
 /// </summary>
 protected internal static vec4 TextureOffset(sampler2D sampler, vec2 P, ivec2 offset)
 {
     throw _invalidAccess;
 }
 /// <summary> Do a texture lookup as in texture but with offset added to the (u,v,w) texel coordinates before looking up each texel.
 /// The offset value must be a constant expression. A limited range of offset values are supported; 
 /// the minimum and maximum offset values are implementation-dependent and given by MIN_PROGRAM_TEXEL_OFFSET and MAX_PROGRAM_TEXEL_OFFSET, respectively.
 /// Note that offset does not apply to the layer coordinate for texture arrays. This is explained in detail in section 3.8.11
 /// “Texture Minification” of the OpenGL Graphics System Specification, where offset is (∂u ,∂v ,∂w).
 /// </summary>
 protected static vec4 textureOffset(sampler2D sampler, vec2 P, ivec2 offset, float bias)
 {
     throw _invalidAccess;
 }
 /// <summary>Do a texture lookup with projection. The texture coordinates consumed from P,
 /// not including the last component of P, are divided by the last component of P. 
 /// After these values are computed,texture lookup proceeds as in texture.</summary>
 protected static vec4 textureProj(sampler2D sampler, vec3 P)
 {
     throw _invalidAccess;
 }
示例#39
0
文件: Access.cs 项目: h3tch/ProtoFX
 public static vec4 texelFetch(Location location, sampler2D sampler, ivec2 P, int lod)
 {
     return(Shader.TraceFunction(location, new vec4(texelFetch <float>(location, sampler.i, P.x, P.y, 0, lod, GetPName.TextureBinding2D)), "texelFetch"));
 }
 /// <summary>Do a texture lookup with projection. The texture coordinates consumed from P,
 /// not including the last component of P, are divided by the last component of P. 
 /// After these values are computed,texture lookup proceeds as in texture.</summary>
 protected static vec4 textureProj(sampler2D sampler, vec4 P, float bias)
 {
     throw _invalidAccess;
 }
 protected vec4 texture2DProjLod(sampler2D sampler, vec4 coord, float lod)
 {
     throw new NotImplementedException();
 }
 /// <summary>Do a texture lookup both projectively, as described in textureProj, and with explicit gradient as 
 /// described in textureGrad. The partial derivatives dPdx and dPdy are assumed to be already projected.</summary>
 protected static vec4 textureProjGrad(sampler2D sampler, vec4 P, vec2 dPdx, vec2 dPdy)
 {
     throw _invalidAccess;
 }
示例#43
0
        void FormMain_Load(object sender, EventArgs e)
        {
            {
                var camera = new Camera(
                    new vec3(0, 0, (float)(Earth.revolutionRadius * 1.1)),
                    new vec3(0, 0, 0),
                    new vec3(0, 1, 0),
                    CameraType.Perspecitive, this.glCanvas1.Width, this.glCanvas1.Height);

                IPerspectiveViewCamera perspecitve = camera;
                perspecitve.Near = 1;
                perspecitve.Far  = Earth.revolutionRadius * 5;
                var rotator = new SatelliteRotator(camera);
                this.camera  = camera;
                this.rotator = rotator;
            }
            {
                const int   latitude         = 180;                     //从南到北,纬度共有180°
                const int   hour             = 24;                      //24小时,24个时区
                const int   longitudePerHour = 15;                      // 每个时区占有的经度为15°
                const int   longitude        = hour * longitudePerHour; // 从东到西,经度共有360°
                IBufferable bufferable       = new CelestialBody(1, latitude, longitude);
                var         shaderCodes      = new ShaderCode[2];
                shaderCodes[0] = new ShaderCode(File.ReadAllText(@"shaders\CelestialBody.vert"), ShaderType.VertexShader);
                shaderCodes[1] = new ShaderCode(File.ReadAllText(@"shaders\CelestialBody.frag"), ShaderType.FragmentShader);
                var map = new PropertyNameMap();
                map.Add("inPosition", CelestialBody.strPosition);
                map.Add("inUV", CelestialBody.strUV);
                var earthRenderer = new PickableRenderer(bufferable, shaderCodes, map, CelestialBody.strPosition);
                earthRenderer.Initialize();
                earthRenderer.Name = "Earth 地球";
                this.earthRenderer = earthRenderer;
            }
            {
                // Ecliptic: 黄道
                IBufferable bufferable  = new Circle((float)Earth.revolutionRadius);
                var         shaderCodes = new ShaderCode[2];
                shaderCodes[0] = new ShaderCode(File.ReadAllText(@"shaders\Circle.vert"), ShaderType.VertexShader);
                shaderCodes[1] = new ShaderCode(File.ReadAllText(@"shaders\Circle.frag"), ShaderType.FragmentShader);
                var map = new PropertyNameMap();
                map.Add("inPosition", Circle.strPosition);
                var eclipticRenderer = new Renderer(bufferable, shaderCodes, map);
                eclipticRenderer.Initialize();
                eclipticRenderer.Name = "Ecliptic 黄道";
                this.eclipticRenderer = eclipticRenderer;
            }
            {
                const int   latitude         = 180;                     //从南到北,纬度共有180°
                const int   hour             = 24;                      //24小时,24个时区
                const int   longitudePerHour = 15;                      // 每个时区占有的经度为15°
                const int   longitude        = hour * longitudePerHour; // 从东到西,经度共有360°
                IBufferable bufferable       = new CelestialBody((float)Sun.radius, latitude, longitude);
                var         shaderCodes      = new ShaderCode[2];
                shaderCodes[0] = new ShaderCode(File.ReadAllText(@"shaders\Sun.vert"), ShaderType.VertexShader);
                shaderCodes[1] = new ShaderCode(File.ReadAllText(@"shaders\Sun.frag"), ShaderType.FragmentShader);
                var map = new PropertyNameMap();
                map.Add("inPosition", CelestialBody.strPosition);
                var sunRenderer = new PickableRenderer(bufferable, shaderCodes, map, CelestialBody.strPosition);
                sunRenderer.Initialize();
                sunRenderer.Name = "Sun 太阳";
                this.sunRenderer = sunRenderer;
            }
            {
                var sunshineRenderer = new SunshineRenderer();
                this.sunshineRenderer = sunshineRenderer;
            }
            {
                var backgroundStars = new BackgroundStarsRenderer(2000, Earth.revolutionRadius);
                backgroundStars.Initialize();
                backgroundStars.Name = "stars 星星";
                this.backgroundStars = backgroundStars;
            }
            {
                var glAxis = new GLAxis(AnchorStyles.Left | AnchorStyles.Bottom,
                                        new Padding(5, 5, 5, 5), new Size(100, 100), -100, 100);
                glAxis.Initialize();
                this.glAxis = glAxis;
            }
            {
                var uiRoot = new GLControl(this.glCanvas1.Size, -100, 100);
                uiRoot.Initialize();
                this.uiRoot = uiRoot;
            }
            {
                this.uiRoot.Controls.Add(this.glAxis);
            }
            {
                var earthColorTexture = new sampler2D();
                var bitmap            = new Bitmap(@"Images\earth-color-map-10800-5400.jpg");
                earthColorTexture.Initialize(bitmap);
                bitmap.Dispose();
                this.earthColorTexture = earthColorTexture;
            }
            {
                this.eclipticRenderer.SetUniform("color", new vec4(1.0f, 1.0f, 0.0f, 0.1f));
                this.eclipticRenderer.SwitchList.Add(new PolygonModeSwitch(PolygonModes.Points));
            }
            {
                this.earthRenderer.SetUniform("colorTexture", new samplerValue(BindTextureTarget.Texture2D, this.earthColorTexture.Id, OpenGL.GL_TEXTURE0));
                //this.earthRenderer.SwitchList.Add(new CullFaceSwitch());
                //this.sunRenderer.SwitchList.Add(new CullFaceSwitch());
            }
            {
                var earth = new Earth();
                this.earth = earth;
                this.thingList.Add(earth);
            }
            {
                var sun = new Sun();
                this.sun = sun;
                this.thingList.Add(sun);
            }
            {
                var tracer = new CameraTracer(this.camera, this.earth, this.sun);
                this.tracer = tracer;
                this.thingList.Add(tracer);
            }
            {
                var frmPropertyGrid = new FormProperyGrid();
                frmPropertyGrid.DisplayObject(this);
                frmPropertyGrid.Show();
            }
            {
                var frmPropertyGrid = new FormProperyGrid();
                frmPropertyGrid.DisplayObject(this.earthRenderer);
                frmPropertyGrid.Show();
            }
            {
                var frmPropertyGrid = new FormProperyGrid();
                frmPropertyGrid.DisplayObject(this.sunRenderer);
                frmPropertyGrid.Show();
            }
            {
                var frmPropertyGrid = new FormProperyGrid();
                frmPropertyGrid.DisplayObject(this.eclipticRenderer);
                frmPropertyGrid.Show();
            }
            {
                var frmPropertyGrid = new FormProperyGrid();
                frmPropertyGrid.DisplayObject(this.tracer);
                frmPropertyGrid.Show();
            }
            {
                this.TimeSpeed = 14400;
            }
        }
 /// <summary>Use the texture coordinate P to do a texture lookup in the texture currently bound to sampler.</summary>
 protected internal static vec4 texture(sampler2D sampler, vec2 P)
 {
     throw _invalidAccess;
 }
示例#45
0
        public static vec4 texture(sampler2D sampler, vec2 coord)
        {
            return(((SoftwareSampler2D)sampler).GetTexel(coord));

            // return Program.GetTexturePixel(coord);
        }
 /// <summary> Fetch a single texel as in texelFetch offset by offset as described in textureOffset. </summary>
 protected static vec4 texelFetchOffset(sampler2D sampler, ivec2 P, int lod, ivec2 offset)
 {
     throw _invalidAccess;
 }
 protected vec4 texture2DProj(sampler2D sampler, vec3 coord, float bias) { throw new NotImplementedException(); }
 /// <summary>  Do an offset texture lookup with explicit LOD. See textureLod and textureOffset.</summary>
 protected static vec4 textureProjLod(sampler2D sampler, vec4 P, float lod)
 {
     throw _invalidAccess;
 }
 protected vec4 texture2D(sampler2D sampler, vec2 coord) { throw new NotImplementedException(); }
 /// <summary>  Do a projective texture lookup as described in textureProj offset by offset as described in textureOffset. </summary>
 protected static vec4 textureProjOffset(sampler2D sampler, vec4 P, ivec2 offset)
 {
     throw _invalidAccess;
 }
示例#51
0
 protected float4 Texture2DProjLod(sampler2D sampler, float4 coord, float lod)
 {
     return(new float4(1, 1, 1, 1));
 }
 /// <summary>
 /// Returns the mipmap array(s) that would be accessed in the x component of the return value.
 /// Returns the computed level of detail relative to the base level in the y component of the return value.
 /// If called on an incomplete texture, the results are undefined.
 /// </summary>
 protected static vec2 textureQueryLod(sampler2D sampler, vec2 P)
 {
     throw _invalidAccess;
 }
示例#53
0
 protected float4 Texture2DProj(sampler2D sampler, float4 coord, float bias)
 {
     return(new float4(1, 1, 1, 1));
 }
示例#54
0
 protected extern vec4 textureProjOffset(sampler2D sampler, vec4 p, ivec2 offset, float bias            = 0);
 public static vec4 texture(sampler2D texture, vec2 uv)
 {
     throw new NotNeedToImplementException();
 }
 /// <summary> Do a texture lookup as in texture but with explicit gradients. 
 /// The partial derivatives of P are with respect to window x and window y.
 /// ∂s/∂x = ∂P.s/∂x; ∂s/∂y = ∂P.s/∂y; ∂t/∂x = ∂P.t/∂x; ∂t/∂y = ∂P.t/∂y; ∂r/∂x = 0; ∂r/∂y = 0;</summary>
 protected internal static vec4 textureGrad(sampler2D sampler, vec2 P, vec2 dPdx, vec2 dPdy)
 {
     throw _invalidAccess;
 }
示例#57
0
 public static vec4 texture2D(sampler2D simplexTexture, vec2 sindex)
 {
     return(null);
 }
 /// <summary>
 /// Do a texture lookup as in texture but with explicit LOD; lod specifies λbase and sets the partial derivatives as follows. 
 /// (See section 3.8.11 “Texture Minification” and equation 3.17 in the OpenGL Graphics SystemSpecification.)
 /// ∂u/∂x = 0; ∂v/∂x = 0; ∂w/∂x = 0; ∂u/∂y = 0; ∂v/∂y = 0; ∂w/∂y = 0; 
 /// </summary>
 protected internal static vec4 textureLod(sampler2D sampler, vec2 P, float lod)
 {
     throw _invalidAccess;
 }
 protected static ivec2 textureSize(sampler2D sampler, int lod)
 {
     throw _invalidAccess;
 }
示例#60
0
 protected extern vec4 textureProGrad(sampler2D sampler, vec4 p, vec2 dPdx, vec2 dPdy);