예제 #1
0
        protected internal override void Init(Renderer renderer)
        {
            base.Init(renderer);

            var vertices = new float[]
            {
                - 0.5f, - 0.5f, 0, 0, 
			      0.5f, - 0.5f, 1, 0,
			      0.5f,   0.5f, 1, 1,
			    - 0.5f,   0.5f, 0, 1
            };

            var faces = new ushort[]
                {
                    0, 1, 2,
			        0, 2, 3
                };

            vertexBuffer = GL.GenBuffer();
            elementBuffer = GL.GenBuffer();

            GL.BindBuffer(BufferTarget.ArrayBuffer, vertexBuffer);
            GL.BufferData(BufferTarget.ArrayBuffer, (IntPtr)(vertices.Length * sizeof(float)), vertices, BufferUsageHint.StaticDraw);

            GL.BindBuffer(BufferTarget.ElementArrayBuffer, elementBuffer);
            GL.BufferData(BufferTarget.ElementArrayBuffer, (IntPtr)(faces.Length * sizeof(ushort)), faces, BufferUsageHint.StaticDraw);

            program = CreateProgram();

            attributes = new Dictionary<string, int>()
        {
			{"position",GL.GetAttribLocation(program, "position")},
			{"uv",      GL.GetAttribLocation(program, "uv")}
		};

            uniforms = new Dictionary<string, int>()
        {
			{"uvOffset", GL.GetUniformLocation( program, "uvOffset")},
			{"uvScale", GL.GetUniformLocation( program, "uvScale")},
			{"rotation", GL.GetUniformLocation( program, "rotation")},
			{"scale", GL.GetUniformLocation( program, "scale")},
			{"color", GL.GetUniformLocation( program, "'color")},
			{"map", GL.GetUniformLocation( program, "map")},
			{"opacity", GL.GetUniformLocation( program, "opacity")},
			{"modelViewMatrix", GL.GetUniformLocation( program, "modelViewMatrix")},
			{"projectionMatrix", GL.GetUniformLocation( program, "projectionMatrix")},
			{"fogType", GL.GetUniformLocation( program, "fogType")},
			{"fogDensity", GL.GetUniformLocation( program, "fogDensity")},
			{"fogNear", GL.GetUniformLocation( program, "fogNear")},
			{"fogFar", GL.GetUniformLocation( program, "fogFar")},
			{"fogColor", GL.GetUniformLocation( program, "fogColor")},
			{"alphaTest", GL.GetUniformLocation( program, "alphaTest")},
		};

            texture = new Texture(8, 8, Color.White);
            texture.NeedsUpdate = true;
        }
예제 #2
0
        protected internal override void Init(GL4.Renderer renderer)
        {
            base.Init(renderer);

            var vertices = new float[]{
			-0.5f, - 0.5f, 0, 0, 
			 0.5f, - 0.5f, 1, 0,
			 0.5f,   0.5f, 1, 1,
			-0.5f,   0.5f, 0, 1
            };

		var faces = new uint[]{
			0, 1, 2,
			0, 2, 3
		};

		vertexBuffer  = GL.GenBuffer();
		elementBuffer = GL.GenBuffer();

		GL.BindBuffer(BufferTarget.ArrayBuffer, vertexBuffer );
		GL.BufferData(BufferTarget.ArrayBuffer, (IntPtr)(vertices.Length * sizeof(float)), vertices, BufferUsageHint.StaticDraw);

		GL.BindBuffer( BufferTarget.ElementArrayBuffer, elementBuffer );
		GL.BufferData( BufferTarget.ElementArrayBuffer, (IntPtr)(faces.Length * sizeof(uint)), faces, BufferUsageHint.StaticDraw);

		program = CreateProgram();

		attributes = new {
			position =			GL.GetAttribLocation(program, "position"),
            uv = GL.GetAttribLocation ( program, "uv" )
		};

		uniforms = new {
			uvOffset =			GL.GetAttribLocation( program, "uvOffset" ),
			uvScale =			GL.GetAttribLocation( program, "uvScale"),
			rotation =			GL.GetAttribLocation( program, "rotation" ),
			scale =				GL.GetAttribLocation( program, "scale" ),
			color = 			GL.GetAttribLocation( program, "color" ),
			map =				GL.GetAttribLocation( program, "map" ),
			opacity =			GL.GetAttribLocation( program, "opacity" ),
			modelViewMatrix = 	GL.GetAttribLocation( program, "modelViewMatrix" ),
			projectionMatrix =	GL.GetAttribLocation( program, "projectionMatrix"),
			fogType = 			GL.GetAttribLocation( program, "fogType" ),
			fogDensity =		GL.GetAttribLocation( program, "fogDensity" ),
			fogNear =			GL.GetAttribLocation( program, "fogNear" ),
			fogFar =			GL.GetAttribLocation( program, "fogFar" ),
			fogColor =			GL.GetAttribLocation( program, "fogColor" ),
			alphaTest =			GL.GetAttribLocation( program, "alphaTest" )
		};
		
            texture = new Texture(8,8,Color.White);
            texture.NeedsUpdate = true;
            sprites = new List<Sprite>();
        }
예제 #3
0
 private void AddFlare(Color color, Texture texture, float size = -1, float distance = 0, BlendMode blending = BlendMode.Normal, float opacity = 1)
 {
     distance = Mathf.Min(distance, Mathf.Max(0, distance));
     var lensFlareInfo = new LensFlareInfo()
     {
         Texture = texture, 			// THREE.Texture
         Size = size, 				// size in pixels (-1 = use texture.width)
         Distance = distance, 		// distance (0-1) from light source (0=at light source)
         x = 0,
         y = 0,
         Z = 0,		// screen position (-1 => 1) z = 0 is ontop z = 1 is back
         Scale = 1, 					// scale
         Rotation = 1, 				// rotation
         Opacity = opacity,			// opacity
         Color = color,				// color
         Blending = blending		// blending
     };
     lenFlareInfos.Add(lensFlareInfo);
 }
예제 #4
0
파일: Loader.cs 프로젝트: prepare/three.net
        private void CreateTexture(string texturePath, dynamic mpars, string name, string sourceFile, Vector2? repeat, Vector2? offset, WrapMode? wrapS, WrapMode? wrapT, float? anisotropy)
        {
            var fullPath = Path.GetFullPath(Path.Combine(texturePath, sourceFile));
            //var loader = Loader.Handlers.get( fullPath );

            var texture = new Texture(fullPath);

            if (repeat.HasValue)
            {
                var r = repeat.Value;
                texture.Repeat = r;
                if (r.x != 1) texture.WrapS = WrapMode.Repeat;
                if (r.y != 1) texture.WrapT = WrapMode.Repeat;
            }

            if (offset.HasValue) texture.Offset = offset.Value;

            if (wrapS.HasValue) texture.WrapS = wrapS.Value;
            if (wrapT.HasValue) texture.WrapT = wrapT.Value;

            if (anisotropy.HasValue) texture.Anisotropy = anisotropy.Value;

            mpars["name"] = texture.Name;
        }
예제 #5
0
 private void AddFlare(Texture texture, float size = -1, float distance = 0, BlendMode blending = BlendMode.Normal, float opacity = 1)
 {
     AddFlare(Color.White, texture, size, distance, blending, opacity);
 }
예제 #6
0
 public LensFlare(Texture texture, float size, float distance, BlendMode blending, Color color)
 {
     if (texture != null) AddFlare(color, texture, size, distance, blending);
 }