protected override Number4 GetLinear( SamplerState samplerState, ITextureMipMap mipMap, ref Number4 texCoords) { int intTexelX = (int) texCoords.Float0; int intTexelY = (int) texCoords.Float1; float fracX = texCoords.Float0 - intTexelX; float fracY = texCoords.Float1 - intTexelY; texCoords.Int0 = intTexelX; texCoords.Int1 = intTexelY; var c00 = GetColor(samplerState, mipMap, ref texCoords); texCoords.Int0 = intTexelX + 1; texCoords.Int1 = intTexelY; var c10 = GetColor(samplerState, mipMap, ref texCoords); texCoords.Int0 = intTexelX; texCoords.Int1 = intTexelY + 1; var c01 = GetColor(samplerState, mipMap, ref texCoords); texCoords.Int0 = intTexelX + 1; texCoords.Int1 = intTexelY + 1; var c11 = GetColor(samplerState, mipMap, ref texCoords); var cMinV = Number4.Lerp(ref c00, ref c10, fracX); var cMaxV = Number4.Lerp(ref c01, ref c11, fracX); return Number4.Lerp(ref cMinV, ref cMaxV, fracY); }
protected override Number4 GetLinear( SamplerState samplerState, ITextureMipMap mipMap, ref Number4 texCoords) { int intTexelX = (int)texCoords.Float0; int intTexelY = (int)texCoords.Float1; float fracX = texCoords.Float0 - intTexelX; float fracY = texCoords.Float1 - intTexelY; texCoords.Int0 = intTexelX; texCoords.Int1 = intTexelY; var c00 = GetColor(samplerState, mipMap, ref texCoords); texCoords.Int0 = intTexelX + 1; texCoords.Int1 = intTexelY; var c10 = GetColor(samplerState, mipMap, ref texCoords); texCoords.Int0 = intTexelX; texCoords.Int1 = intTexelY + 1; var c01 = GetColor(samplerState, mipMap, ref texCoords); texCoords.Int0 = intTexelX + 1; texCoords.Int1 = intTexelY + 1; var c11 = GetColor(samplerState, mipMap, ref texCoords); var cMinV = Number4.Lerp(ref c00, ref c10, fracX); var cMaxV = Number4.Lerp(ref c01, ref c11, fracX); return(Number4.Lerp(ref cMinV, ref cMaxV, fracY)); }
protected override Number4 GetNearestNeighbor( SamplerState samplerState, ITextureMipMap mipMap, ref Number4 texCoords) { texCoords.Int0 = MathUtility.Floor(texCoords.Float0); texCoords.Int1 = MathUtility.Floor(texCoords.Float1); return GetColor(samplerState, mipMap, ref texCoords); }
protected override Number4 GetNearestNeighbor( SamplerState samplerState, ITextureMipMap mipMap, ref Number4 texCoords) { texCoords.Int0 = MathUtility.Floor(texCoords.Float0); texCoords.Int1 = MathUtility.Floor(texCoords.Float1); return(GetColor(samplerState, mipMap, ref texCoords)); }
private static Number4 GetColor(SamplerState samplerState, ITextureMipMap mipMap, ref Number4 texCoords) { if (!GetTextureAddress(texCoords.Int0, mipMap.Width, samplerState.AddressU, out texCoords.Int0)) return samplerState.BorderColor; if (!GetTextureAddress(texCoords.Int1, mipMap.Height, samplerState.AddressV, out texCoords.Int1)) return samplerState.BorderColor; return mipMap.GetData(ref texCoords); }
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); }
private static Number4 GetColor(SamplerState samplerState, ITextureMipMap mipMap, ref Number4 texCoords) { if (!GetTextureAddress(texCoords.Int0, mipMap.Width, samplerState.AddressU, out texCoords.Int0)) { return(samplerState.BorderColor); } if (!GetTextureAddress(texCoords.Int1, mipMap.Height, samplerState.AddressV, out texCoords.Int1)) { return(samplerState.BorderColor); } return(mipMap.GetData(ref texCoords)); }
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; }
protected abstract Number4 GetLinear( SamplerState samplerState, ITextureMipMap mipMap, ref Number4 texCoords);
protected abstract void GetMipMapAndTransformedCoordinates( ITexture texture, ref Number4 location, int level, out ITextureMipMap mipMap, out Number4 textureCoordinates);
protected abstract Number4 GetNearestNeighbor( SamplerState samplerState, ITextureMipMap mipMap, ref Number4 texCoords);