简体   繁体   English

现有纹理的抗锯齿

[英]Antialiasing of existing texture

I have a lot of pre-generated images (same size) that consist of curved and straight lines and a colorful fill.我有很多预生成的图像(相同大小),它们由曲线和直线以及彩色填充组成。 The problem is that:问题是:

  • these lines are not smooth,这些线条不流畅,
  • straight lines are very thin.直线很细。

例子

Questions:问题:

  • a) using a shader, how to make all curves and straight lines more smoother in a given texture? a) 使用着色器,如何使给定纹理中的所有曲线和直线更平滑?
  • b) how to make thin straight lines 2, 3 or 4 times thicker? b) 如何使细直线粗 2、3 或 4 倍?

Sorry for not offering my own solution, I'm very new to shaders and haven't been able to solve this problem yet.很抱歉没有提供我自己的解决方案,我对着色器很陌生,还不能解决这个问题。 I import pictures (textures) into the shader from p5.js.我将图片(纹理)从 p5.js 导入到着色器中。

let img, theShader, pg;
function preload() {
  img = loadImage('texture.jpg');
}
   
function setup() {   
    createCanvas(600,800);
    pixelDensity(1);
    pg = createGraphics(600, 800);
    pg.pixelDensity(1);
    theShader = pg.createShader(vert, frag);
    pg.texture(img);
    **
}

function draw() {
**
pg.shader(theShader);
theShader.setUniform('u_resolution', [pg.width, pg.height]);
theShader.setUniform('u_texture', pg);  
pg.rectMode(CENTER);
pg.noStroke();
pg.rect(0, 0, pg.width, pg.height); 
image(pg, 0,0, width, height);
**
}

You can try to apply some FXAA to reduce jagged edges but you can't just change arbitrary features (like line width) in a pregenerated image without writing some rather sophisticated custom filtering.您可以尝试应用一些 FXAA 来减少锯齿状边缘,但您不能只更改预生成图像中的任意特征(如线宽)而不编写一些相当复杂的自定义过滤。 This is basically the worst step in the pipeline to try to increase image quality, if at all possible you should try to get better source material: a higher resolution render, vector image format (svg) or straight up recreate the output.这基本上是尝试提高图像质量的管道中最糟糕的一步,如果可能的话,您应该尝试获得更好的源材料:更高分辨率的渲染、矢量图像格式 (svg) 或直接重新创建 output。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM