Fixed texture bug, optimized window function

Fixed texture bug, optimized window function