- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我正在使用 HTML5 Canvas API 为像素艺术游戏绘制瓷砖 map 。渲染的瓦片 map 由许多较小的图像组成,这些图像是从称为瓦片表的单个源图像中剪切出来的。我正在使用 drawImage(src_img, sx, sy, sw, sh, dx, dy, dw, dh)
从源图像中切出单个图块并将它们绘制到目标 Canvas 上。我正在使用 setTransform(sx, 0, 0, sy, tx, ty)
将缩放和平移应用于最终渲染的图像。
我需要修复的颜色“出血”问题是由采样器引起的,它在缩放操作期间使用插值来混合颜色,以使事物看起来不会像素化。这对于缩放数码照片非常有用,但不适用于像素艺术。虽然这不会对图块的中心造成太大的视觉损害,但采样器会沿着源图像中相邻图块的边缘混合颜色,从而在渲染的图块 map 中产生意想不到的颜色。而不是仅使用传递给 drawImage
的源矩形内的颜色,采样器从其边界之外混合颜色,导致瓷砖之间出现间隙。
下面是我的瓷砖表的源图像。它的实际大小是 24x24 像素,但我在 GIMP 中将其放大到 96x96 像素,以便您可以看到它。我在 GIMP 的缩放工具上使用了“插值:无”设置。正如您所看到的,由于采样器没有对颜色进行插值,因此各个图块周围没有间隙或模糊的边界。即使在 imageSmoothingEnabled
时, Canvas API 的采样器显然也会插入颜色。设置为 false
.
下面是带有 imageSmoothingEnabled
的渲染图块 map 的一部分设置为 true
.左箭头指向灰色瓷砖底部的一些红色出血。这是因为红色瓷砖在瓷砖表中的灰色瓷砖正下方。采样器正在将红色混合到灰色瓷砖的底部边缘。
右侧的箭头指向绿色图块的右边缘。如您所见,没有颜色渗入其中。这是因为源图像中绿色图块的右侧没有任何东西,因此采样器没有任何东西可以混合。
下面是带有 imageSmoothingEnabled
的渲染图块 map 设置为 false
.根据比例和翻译,仍然会发生纹理渗色。左箭头指向从源图像中的红色瓷砖渗出的红色。视觉伤害减少了,但仍然存在。
右箭头指向最右侧绿色磁贴的问题,它有一条细灰色线从源图像中的灰色磁贴渗入,位于绿色磁贴的左侧。
上面的两张图片是从 Edge 截屏的。 Chrome 和 Firefox 在隐藏出血方面做得更好。 Edge 似乎在四面八方流血,但 Chrome 和 Firefox 似乎只在源矩形的右侧和底部流血。
如果有人知道如何解决这个问题,请告诉我。人们在很多论坛上询问这个问题,并得到解决以下问题的答案:
image-rendering:pixelated
缩放它,这与之前的工作基本相同。 function drawRounded(source_image, context, scale) {
var offset_x = -OFFSET.x * scale + context.canvas.width * 0.5;
var offset_y = -OFFSET.y * scale + context.canvas.height * 0.5;
var map_height = (MAP_HEIGHT * scale)|0; // Similar to Math.trunc(MAP_HEIGHT * scale);
var map_width = (MAP_WIDTH * scale)|0;
var tile_size = TILE_SIZE * scale;
var rendered_tile_size = (tile_size + 1)|0; // Similar to Math.ceil(tile_size);
var map_index = 0; // Track the tile index in the map. This increases once per draw loop.
/* Loop through all tile positions in actual coordinate space so no additional calculations based on grid index are needed. */
for (var y = 0; y < map_height; y += tile_size) { // y first so we draw rows from top to bottom
for (var x = 0; x < map_width; x += tile_size) {
var frame = FRAMES[MAP[map_index]]; // The frame is the source location of the tile in the source_image.
// We have to keep the dx, dy truncation inside the loop to ensure the highest level of accuracy possible.
context.drawImage(source_image, frame.x, frame.y, TILE_SIZE, TILE_SIZE, (offset_x + x)|0, (offset_y + y)|0, rendered_tile_size, rendered_tile_size);
map_index ++;
}
}
}
最佳答案
这是一个四舍五入的问题。
已经有 that question当上下文准确地转换为 Safari 浏览器时遇到的这个问题 n.5
, Edge 和 IE 更糟,总是以一种或另一种方式流血,MacOs 版 Chrome 在 n.5
上流血也是,但只有在绘制 时,
// First calculate the scaled translations
const scaled_offset_left = -OFFSET.x * scale + context.canvas.width * 0.5;
const scaled_offset_top = -OFFSET.y * scale + context.canvas.height * 0.5;
// when drawing each tile
const dest_x = Math.floor( scaled_offset_left + (x * scale) );
const dest_y = Math.floor( scaled_offset_top + (y * scale) );
const dest_size = Math.ceil( TILE_SIZE * scale );
context.drawImage( source_image,
frame.x, frame.y, TILE_SIZE, TILE_SIZE,
dest_x, dest_y, dest_size, dest_size,
);
/* This is the tile map. Each value is a frame index in the FRAMES array. Each frame tells drawImage where to blit the source from */
const MAP = [
0, 0, 0, 1, 1, 1, 1, 2, 2, 2,
0, 1, 0, 1, 2, 2, 1, 2, 3, 2,
0, 0, 0, 1, 1, 1, 1, 2, 2, 2,
3, 3, 3, 4, 4, 4, 4, 5, 5, 5,
3, 4, 3, 4, 5, 5, 4, 5, 6, 5,
3, 4, 3, 4, 5, 5, 4, 5, 6, 5,
3, 3, 3, 4, 4, 4, 4, 5, 5, 5,
6, 6, 6, 7, 7, 7, 7, 8, 8, 8,
6, 7, 6, 7, 8, 8, 7, 8, 0, 8,
6, 6, 6, 7, 7, 7, 7, 8, 8, 8
];
const TILE_SIZE = 8; // Each tile is 8x8 pixels
const MAP_HEIGHT = 80; // The map is 80 pixels tall by 80 pixels wide
const MAP_WIDTH = 80;
/* Each frame represents the source x, y coordinates of a tile in the source image. They are indexed according to the map values */
const FRAMES = [
{ x:0, y:0 }, // map value = 0
{ x:8, y:0 }, // map value = 1
{ x:16, y:0 }, // map value = 2
{ x:0, y:8 }, // etc.
{ x:8, y:8 },
{ x:16, y:8},
{ x:0, y:16},
{ x:8, y:16},
{ x:16, y:16}
];
/* These represent the state of the keyboard keys being used. false is up and true is down */
const KEYS = {
down: false,
left: false,
right: false,
scale_down: false, // the D key
scale_up: false, // the F key
up: false
}
/* This is the scroll offset. You can also think of it as the position of the red dot in the map. */
const OFFSET = {
x: MAP_WIDTH * 0.5,
y: MAP_HEIGHT * 0.5
}; // It starts out centered in the map.
const MAX_SCALE = 75; // Max scale is 75 times larger than the actual image size.
const MIN_SCALE = 0; // Texture bleeding seems to only occur on upscale, but min scale is 0 in case you want to try it.
var scale = 4.71; // some arbitrary number that will hopefully cause the issue in your browser
/* Get the canvas drawing context. */
var context = document.querySelector('canvas').getContext('2d', {
alpha: false,
desynchronized: true
});
/* The toggle button is the div */
var toggle = document.querySelector('div');
/* The source image is a 24x24 square with 9 tile images of various colors in it. */
var base_64_image_source = 'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABgAAAAYCAIAAABvFaqvAAAKlnpUWHRSYXcgcHJvZmlsZSB0eXBlIGV4aWYAAHjazZhpciM7DoT/8xRzBO7LcbhGzA3m+POBVZK1Ws/dLzpasqUSiwsKCSSSVPN//13qP7y891b5kHIsMWpevvhiKxdZH6+6P432+/P4cbln7tvV9YalyfHtjp85nu2Tdkt/f7b3c55Ke7iZqF4WaPc36rmAzecCZ/tlIWeOBfQ5sWqX+/Z+5XZ2iCWn20cYZ/81z4t8/Cv58DHZaOKMzWJUXMnHbHVK0STmjzkG7mPt6rbI2HCufvtbbScn3DwCBjlrpzNO85nFSnf8V/4dn8Z5+miXuD7agzvdoYCMxbePDt9a/e3rnfXq0fwT+jtor1fmTTv+VbeQR3/ecA9Ixev3y3YTLhM9QLvxu1k51uvKd+2z6nUxTd1CKP9rjbw2tjxF9REY4vlQl0fZV/TDq97tUVFHhaMjXst8y7vwzqRGJ54GwdZ4d1OMBcplvBmmmmXm/u6mY6K30yarlbW2W7cbs0u22A6swCxvs2xyxQ2XAbsTEo5We7XF7GXLXq5Lrg09DF2tYTLDkF96q590Xkvyxhidr77CLiuRZ5URNzr5pBuImHU6NWwHX96PL8HVgSAxiWezLgrHtmOKFswXnbgNtKNj4PtIZJPGOQEuYumAMcaBgI7GqWCi0cnaZAyOzABUMd2SVA0ETAh2YKT1zkXAIRuKrgxJZne1wR7NRdkKEsFFEjGDUAUs7wPxk3wmhipZ6UMIZFDIoYQaXfQxxBhTFGatySWfQooqpZRTSTW77HPIMaecc8m12OJg3lBiSSWXUmplzcrMldGVDrU221zzLbTYkmq5lVY74dN9Dz321HMvvQ473IBbRhxp5FFGnWYSStPPMONMM88y6yLUllt+BbVggpVXWfWK2gnr0/sHqJkTNbuRko7pihqtKV2mMEInQTADMetNIPuF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ZUvY9kjFEQ4qLSufrJDiEAKsjHf2wiLTgKqKROsI0o6n7afJuvG/D9FSRi0xIUE6E5n4Y7wg3x8M3xMguR65PeSLRp+bS/NAqEtB8Nw0B+e9M47r6pWkec65oiO3JJ1TYEJeMbWxQ8Wvb7yIn2lp0to9y8G4d2y2BwfXUZN8v8pLqjfjRouhM6t26rJHPoVVCpcrmiL0ki7ewSaZIdIgkuegoKsJS3Q6/yQls/E6WdtElATpGkmZIefY215ZxsKhDtO5nhFwva2h1WYbdz+1CIrHSllj367SLZgni1Osa+OjdCj9dQL1b4acLqJ8+wp/10Qjn8WDX0HnV//TIBiOMuj3I0vrp2ObdgeuKpRya6jy4UdlcT25+eHCj9Xk2s09m1M3JzYvbLw9uXh3bGPVRqt0c24xvjm3+xWNoNhO3x9DuLzqGtj85hq5/6hi6xrtj6PSXHUP7Hx1D+z90DO0fjqH133YMnX9yDB3LHzmGLnfH0OavO4Y2n4+hSa6i/g9YSF5od4J2cQAAAAZiS0dEAP8AAAAAMyd88wAAAAlwSFlzAAAuIwAALiMBeKU/dgAAAAd0SU1FB+QDDgsUN3w4Y2wAAAAbdEVYdENvbW1lbnQARnJhbmsgUG90aCB3YXMgaGVyZbBgrYoAAAA4SURBVDjLY/z//z8DVsBIkjADEwOVwKhBQ9EgFlzpoqGhEbtEfcNoYI8ahFG84CqORsujUYNIAADOzQexgePC2gAAAABJRU5ErkJggg==';
var source_image = new Image(); // This will be the source image
/* The keyboard event handler */
function keyDownUp(event) {
var state = event.type == 'keydown' ? true : false;
switch (event.keyCode) {
case 37:
KEYS.left = state;
break;
case 38:
KEYS.up = state;
break;
case 39:
KEYS.right = state;
break;
case 40:
KEYS.down = state;
break;
case 68:
KEYS.scale_down = state;
break;
case 70:
KEYS.scale_up = state;
}
}
/* This is the update and rendering loop. It handles input and draws the images. */
function loop() {
window.requestAnimationFrame(loop); // Perpetuate the loop
/* Prepare to move and scale the image with the keyboard input */
if (KEYS.left) OFFSET.x -= 0.5;
if (KEYS.right) OFFSET.x += 0.5;
if (KEYS.up) OFFSET.y -= 0.5;
if (KEYS.down) OFFSET.y += 0.5;
if (KEYS.scale_down) scale -= 0.5 * scale / MAX_SCALE;
if (KEYS.scale_up) scale += 0.5 * scale / MAX_SCALE;
/* Keep the scale size within a defined range */
if (scale > MAX_SCALE) scale = MAX_SCALE;
else if (scale < MIN_SCALE) scale = MIN_SCALE;
/* Clear the canvas to gray. */
context.setTransform(1, 0, 0, 1, 0, 0); // Set the transform back to the identity matrix
context.fillStyle = "#202830"; // Set the fill color to gray
context.fillRect(0, 0, context.canvas.width, context.canvas.height); // fill the entire canvas
/* [EDIT]
Don't set the transform, we will calculate it ourselves
// context.setTransform(scale, 0, 0, scale, -OFFSET.x * scale + context.canvas.width * 0.5, -OFFSET.y * scale + context.canvas.height * 0.5);
First step is calculating the scaled translation
*/
const scaled_offset_left = -OFFSET.x * scale + context.canvas.width * 0.5;
const scaled_offset_top = -OFFSET.y * scale + context.canvas.height * 0.5;
let map_index = 0; // Track the tile index in the map. This increases once per draw loop.
/* Loop through all tile positions in actual coordinate space so no additional calculations based on grid index are needed. */
for (let y = 0; y < MAP_HEIGHT; y += TILE_SIZE) { // y first so we draw rows from top to bottom
for (let x = 0; x < MAP_WIDTH; x += TILE_SIZE) {
const frame = FRAMES[MAP[map_index]]; // The frame is the source location of the tile in the source_image.
/* [EDIT]
We transform the coordinates ourselves
We can control a uniform rounding by using floor and ceil
*/
const dest_x = Math.floor( scaled_offset_left + (x * scale) );
const dest_y = Math.floor( scaled_offset_top + (y * scale) );
const dest_size = Math.ceil(TILE_SIZE * scale);
context.drawImage( source_image,
frame.x, frame.y, TILE_SIZE, TILE_SIZE,
dest_x, dest_y, dest_size, dest_size
);
map_index++;
}
}
/* Draw the red dot in the center of the screen. */
context.fillStyle = "#ff0000";
/* [EDIT]
Do the same kind of calculations for the "dot" if you don't want antialiasing
// const dot_x = Math.floor( scaled_offset_left + ((OFFSET.x - 0.5) * scale) );
// const dot_y = Math.floor( scaled_offset_top + ((OFFSET.y - 0.5) * scale) );
// const dot_size = Math.ceil( scale );
// context.fillRect( dot_x, dot_y, dot_size, dot_size ); // center on the dot
But if you do want antialiasing for the dot, then just set the transformation for this drawing
*/
context.setTransform(scale, 0, 0, scale, scaled_offset_left, scaled_offset_top);
context.fillRect( (OFFSET.x - 0.5), (OFFSET.y - 0.5), 1, 1 ); // center on the dot
var smoothing = context.imageSmoothingEnabled; // Get the current smoothing value because we are going to ignore it briefly.
/* Draw the source image in the top left corner for reference. */
context.setTransform(4, 0, 0, 4, 0, 0); // Zoom in on it so it's visible.
context.imageSmoothingEnabled = false; // Set smoothing to false so we get a crisp source image representation (the real source image is not scaled at all).
context.drawImage( source_image, 0, 0 );
context.imageSmoothingEnabled = smoothing; // Set smoothing back the way it was according to the toggle choice.
}
/* Turn image smoothing on and off when you press the toggle. */
function toggleSmoothing(event) {
context.imageSmoothingEnabled = !context.imageSmoothingEnabled;
if (context.imageSmoothingEnabled) toggle.innerText = 'Smoothing Enabled'; // Make sure the button has appropriate text in it.
else toggle.innerText = 'Smoothing Disabled';
}
/* The main loop will start after the source image is loaded to ensure there is something to draw. */
source_image.addEventListener('load', (event) => {
window.requestAnimationFrame(loop); // Start the loop
}, { once: true });
/* Add the toggle smoothing click handler to the div. */
toggle.addEventListener('click', toggleSmoothing);
/* Add keyboard input */
window.addEventListener('keydown', keyDownUp);
window.addEventListener('keyup', keyDownUp);
/* Resize the canvas. */
context.canvas.width = 480;
context.canvas.height = 480;
toggleSmoothing(); // Set imageSmoothingEnabled
/* Load the source image from the base64 string. */
source_image.setAttribute('src', base_64_image_source);
* {
box-sizing: border-box;
margin: 0;
overflow: hidden;
padding: 0;
user-select: none;
}
body,
html {
background-color: #202830;
color: #ffffff;
height: 100%;
width: 100%;
}
body {
align-items: center;
display: grid;
justify-items: center;
}
p {
max-width: 640px;
}
div {
border: #ffffff 2px solid;
bottom: 4px;
cursor: pointer;
padding: 8px;
position: fixed;
right: 4px
}
<div>Smoothing Disabled</div>
<p>Use the arrow keys to scroll and the D and F keys to scale. The source image is represented on the top left. Notice the vertical and horizontal lines that appear between tiles as you scroll and scale. They are the color of the tile's neighbor in the source
image. This may be due to color sampling that occurs during scaling. Click the toggle to set imageSmoothingEnabled on the drawing context.</p>
<canvas></canvas>
关于javascript - 使用 drawImage 从 Tile Sheet、Sprite Sheet 或 Texture Atlas 绘制多个图像时,如何防止纹理出血?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/60684359/
我创建了一个类来保存我的模型信息。我必须正确渲染模型并正确包裹纹理,但出于某种原因,如果我有多个模型,它会将我的所有模型纹理化为仅 1 个纹理,如您在此图像中所见:http://imgur.com/d
是否有可能,如果有,如何在 OpenGL4.x 中的不同 channel 上创建和读取具有不同压缩算法的 RGBA 纹理: 没有实际意义的例子A: RG channel 存储以 3Dc 编码的法线贴图
我需要将浮点数据提供给计算着色器。 我看到的 3 种方法是: 着色器存储缓冲区对象 缓冲纹理 “经典”纹理(使用 PBO 将数据上传到 GPU,然后使用 glTexSubImage2D 将数据复制到纹
我会保持简单:本文末尾列出的代码在我的项目中按从上到下的顺序排列。我有一个 OGLES2.0 框架,可以完美渲染除纹理之外的所有内容。渲染单个纹理时,我看到的只是一个尺寸正确的黑盒子。 这是我已验证的
我在 Android 平台上编码。我正在尝试为三角形使用纹理(从 Assets 文件夹加载图像)。当我的应用程序运行时,它只是三角形中的空白白色(不是我想要的纹理)。 我读过一些其他资料,说图像必须是
我有道路的纹理。具有此纹理的线(由三角形条表示)如下所示: 当然,道路可以与其他道路重叠。在这种情况下,我想隐藏道路边界。道路边界具有 alpha 0.6,同时道路具有 alpha 1。那么当它们与具
我正在画一个到 webgl Canvas 上。我可以在 Chrome 和 Firefox 中使用它,但 IE11 似乎会抛出错误。错误指出: drawElements: The texture is
我想使用自定义着色器将纹理渲染到平面上。这个纹理有一个“偏移”属性集,当我使用标准的 threejs Material 时它可以正常工作。但是,我不知道如何在我的自定义片段着色器中访问这些偏移量。它只
导入项目后,Unity 中不断出现此错误。 这是代码: public static void CameraFadeSwap(Texture2D texture){ if(cameraFade)
这就是我在片段着色器中渲染画笔的方式: gl_FragColor.rgb = Color.rgb; gl_FragColor.a = Texture.a * Color.a; 在 (0, 0, 0,
我目前正在尝试在 Android 上开发视频播放器,但在颜色格式方面遇到困难。 上下文:我通过 MediaExtractor/MediaCodec 的标准组合提取和解码视频。因为我需要将提取的帧用作
在 Xcode 13 beta 中运行模拟器,我遇到了崩溃,我该怎么办? _validateTextureView:557: failed assertion `Texture View Valida
在我目前制作的游戏中,我有两个着色器: 一个用于纹理图集上的 Sprite 一个单独加载的粒子形状纹理。 (我决定将此纹理保留在图集之外,因为我的生成器中的粒子是 GL_POINTS)。 目前,我将其
我正在创建两个渲染目标,两者都必须共享后台缓冲区的深度缓冲区,因此我将它们设置为具有相同的多重采样参数很重要,但是 pDevice->CreateTexture(..) 没有给出任何参数设置多重采样类
如何在 POV-Ray 中创建一个看起来像地球的球体?据推测,答案将涉及获取某种地球 map 并以某种方式将其包裹在球体周围作为纹理。谷歌搜索让我找到了http://www.physics.sfasu
是否可以从 中的纹理读取顶点带 WebGL 的着色器? 我写了一个 WebGL page (只是为了尝试一下)并使用 Chrome 7 对其进行测试。一旦我升级到 Chrome 8,它就停止工作。我仔
我正在为一个模型的多个网格渲染不同的纹理,但是我对程序没有太多的了解。有人建议为每个网格创建自己的描述符集,并调用vkCmdBindDescriptorSets()和vkCmdDrawIndexed(
我有一个简单的 Vulkan 设置,它加载了一个相当大的网格文件(女性)并应用了漫反射和法线贴图纹理。 顶点着色器: #version 450 core layout (set = 0, bindin
Apple 现在在其许多产品中都使用了这种纹理: 仔细看看: 您可以看到它不仅仅是一堆线条:它具有随机性元素。一般来说,如何才能做到这一点?我对实现不像对概念那么感兴趣。我在网上看过,但找不到任何提示
我知道这是一个非常常见的问题。我收到无法从未定义中读取属性“纹理”的消息。抱歉,我对 javascript 还很陌生。 我的代码的javascript部分如下 this.createTexture=f
我是一名优秀的程序员,十分优秀!