Ejemplo n.º 1
0
 protected override void GetMipMapAndTransformedCoordinates(
     ITexture texture, ref Number4 location,
     int level, out ITextureMipMap mipMap,
     out Number4 textureCoordinates)
 {
     mipMap             = texture.GetMipMap(0, level);
     textureCoordinates = new Number4(
         location.Float0 * mipMap.Width,
         location.Float1 * mipMap.Height,
         0, 0);
 }
Ejemplo n.º 2
0
        protected override void GetMipMapAndTransformedCoordinates(
            ITexture texture, ref Number4 location, 
			int level, out ITextureMipMap mipMap,
            out Number4 textureCoordinates)
        {
            mipMap = texture.GetMipMap(0, level);
            textureCoordinates = new Number4(
                location.Float0 * mipMap.Width,
                location.Float1 * mipMap.Height,
                0, 0);
        }
		protected override void GetMipMapAndTransformedCoordinates(
			ITexture texture, ref Number4 location,
			int level, out ITextureMipMap mipMap,
			out Number4 textureCoordinates)
		{
			var arraySlice = MathUtility.Round(location.Float2);
			mipMap = texture.GetMipMap(arraySlice, level);
			textureCoordinates = new Number4(
				location.Float0 * mipMap.Width,
				location.Float1 * mipMap.Height,
				0, 0);
		}
        protected override void GetMipMapAndTransformedCoordinates(
            ITexture texture, ref Number4 location,
            int level, out ITextureMipMap mipMap,
            out Number4 textureCoordinates)
        {
            var arraySlice = MathUtility.Round(location.Float2);

            mipMap             = texture.GetMipMap(arraySlice, level);
            textureCoordinates = new Number4(
                location.Float0 * mipMap.Width,
                location.Float1 * mipMap.Height,
                0, 0);
        }
Ejemplo n.º 5
0
		protected override void GetMipMapAndTransformedCoordinates(
			ITexture texture, ref Number4 location,
			int level, out ITextureMipMap mipMap,
			out Number4 textureCoordinates)
		{
			int arrayIndex;
			CubeMapUtility.GetCubeMapCoordinates(ref location,
				out arrayIndex, out textureCoordinates);

			mipMap = texture.GetMipMap(arrayIndex, level);

			textureCoordinates.X *= mipMap.Width;
			textureCoordinates.Y *= mipMap.Height;
		}
Ejemplo n.º 6
0
        protected override void GetMipMapAndTransformedCoordinates(
            ITexture texture, ref Number4 location,
            int level, out ITextureMipMap mipMap,
            out Number4 textureCoordinates)
        {
            int arrayIndex;

            CubeMapUtility.GetCubeMapCoordinates(ref location,
                                                 out arrayIndex, out textureCoordinates);

            mipMap = texture.GetMipMap(arrayIndex, level);

            textureCoordinates.X *= mipMap.Width;
            textureCoordinates.Y *= mipMap.Height;
        }
Ejemplo n.º 7
0
        public override float CalculateLevelOfDetail(
            ITexture texture, SamplerState samplerState, 
            ref Number4 ddx, ref Number4 ddy)
        {
            var mostDetailedMipMap = texture.GetMipMap(0, 0);
            int width = mostDetailedMipMap.Width;
            int height = mostDetailedMipMap.Height;
            float xBound2 = width * width;
            float yBound2 = height * height;

            float dudx2 = ddx.Float0 * ddx.Float0 * xBound2;
            float dvdx2 = ddx.Float1 * ddx.Float1 * yBound2;
            float dudy2 = ddy.Float0 * ddy.Float0 * xBound2;
            float dvdy2 = ddy.Float1 * ddy.Float1 * yBound2;

            // Proportional to the amount of a texel on display in a single pixel
            float pixelSizeTexelRatio2 = Math.Max(dudx2 + dvdx2, dudy2 + dvdy2);

            // Uses formula for p410 of Essential Mathematics for Games and Interactive Applications
            float result = 0.5f * MathUtility.Log2(pixelSizeTexelRatio2);

            // Clamp to >= 0.
            return Math.Max(result, 0.0f);
        }
Ejemplo n.º 8
0
        public override float CalculateLevelOfDetail(
            ITexture texture, SamplerState samplerState,
            ref Number4 ddx, ref Number4 ddy)
        {
            var   mostDetailedMipMap = texture.GetMipMap(0, 0);
            int   width   = mostDetailedMipMap.Width;
            int   height  = mostDetailedMipMap.Height;
            float xBound2 = width * width;
            float yBound2 = height * height;

            float dudx2 = ddx.Float0 * ddx.Float0 * xBound2;
            float dvdx2 = ddx.Float1 * ddx.Float1 * yBound2;
            float dudy2 = ddy.Float0 * ddy.Float0 * xBound2;
            float dvdy2 = ddy.Float1 * ddy.Float1 * yBound2;

            // Proportional to the amount of a texel on display in a single pixel
            float pixelSizeTexelRatio2 = Math.Max(dudx2 + dvdx2, dudy2 + dvdy2);

            // Uses formula for p410 of Essential Mathematics for Games and Interactive Applications
            float result = 0.5f * MathUtility.Log2(pixelSizeTexelRatio2);

            // Clamp to >= 0.
            return(Math.Max(result, 0.0f));
        }