- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
所以我有一个流体模拟,我正在尝试应用双边过滤器,以便在保留边缘的同时模糊表面。我的方法基于此演示文稿(特别是幻灯片 26)http://developer.download.nvidia.com/presentations/2010/gdc/Direct3D_Effects.pdf
我遇到的问题是根本没有保留我的边缘。即使我渲染出单个粒子,它也会被模糊,正如您在下图中看到的那样,模糊是不正确的。
此外,如 pdf 中所述,虽然分离双边过滤器通常是 Not Acceptable ,但在流体的情况下这样做是合理的,因为只有轻微的伪影。这就是下面两个 pass 的原因,但这不应该导致边缘模糊。
模糊着色器:
#version 400
in vec2 coord;
uniform sampler2D depthMap;
uniform vec2 screenSize;
uniform mat4 projection;
uniform vec2 blurDir;
const float filterRadius = 10;
const float blurScale = .1;
const float blurDepthFalloff = 1000;
void main() {
float depth = texture(depthMap, coord).x;
float sum = 0.0f;
float wsum = 0.0f;
for (float x = -filterRadius; x <= filterRadius; x += 1.0f) {
float s = texture(depthMap, coord + x*blurDir).x;
float r = x * blurScale;
float w = exp(-r*r);
float r2 = (s - depth) * blurDepthFalloff;
float g = exp(-r2*r2);
sum += s * w * g;
wsum += w * g;
}
if (wsum > 0.0f) {
sum /= wsum;
}
gl_FragDepth = sum;
}
绘图代码:
//--------------------Particle Blur-------------------------
{
glUseProgram(blurShader.program);
//Vertical blur
glBindFramebuffer(GL_FRAMEBUFFER, blurShader.fboV);
glDrawBuffer(GL_NONE);
glReadBuffer(GL_NONE);
glClear(GL_DEPTH_BUFFER_BIT);
blurShader.blurDepthVAO();
glActiveTexture(GL_TEXTURE0);
glBindTexture(GL_TEXTURE_2D, depthShader.tex);
glUniform1i(blurShader.depthMap, 0);
RenderUtility.setVector2(blurShader, screenSize, "screenSize");
RenderUtility.setMatrix(blurShader, projection, "projection");
RenderUtility.setVector2(blurShader, new Vector2(0.0f, 1.0f / screenSize.y), "blurDir");
glEnable(GL_DEPTH_TEST);
glBindVertexArray(blurShader.vao);
glDrawArrays(GL_TRIANGLE_STRIP, 0, 4);
//Horizontal Blur
glBindFramebuffer(GL_FRAMEBUFFER, blurShader.fboH);
glDrawBuffer(GL_NONE);
glReadBuffer(GL_NONE);
glClear(GL_DEPTH_BUFFER_BIT);
glActiveTexture(GL_TEXTURE0);
glBindTexture(GL_TEXTURE_2D, blurShader.texV);
glUniform1i(blurShader.depthMap, 0);
RenderUtility.setVector2(blurShader, screenSize, "screenSize");
RenderUtility.setMatrix(blurShader, projection, "projection");
RenderUtility.setVector2(blurShader, new Vector2(1.0f / screenSize.x, 0.0f), "blurDir");
glEnable(GL_DEPTH_TEST);
glBindVertexArray(blurShader.vao);
glDrawArrays(GL_TRIANGLE_STRIP, 0, 4);
}
当前状态图:
最佳答案
终于明白了。缺少的部分是深度大于 .9999(或其他最大深度数)的像素需要被丢弃,这样您就不会试图模糊不属于模拟的像素。回想起来很明显,但我花了很长时间才意识到。
因此正确的着色器如下所示:
uniform sampler2D depthMap;
uniform vec2 screenSize;
uniform mat4 projection;
uniform vec2 blurDir;
const float filterRadius = 10;
const float blurScale = .1;
const float blurDepthFalloff = 1000;
void main() {
float depth = texture(depthMap, coord).x;
if (depth == 1.0f) {
discard;
}
float sum = 0.0f;
float wsum = 0.0f;
for (float x = -filterRadius; x <= filterRadius; x += 1.0f) {
float s = texture(depthMap, coord + x*blurDir).x;
float r = x * blurScale;
float w = exp(-r*r);
float r2 = (s - depth) * blurDepthFalloff;
float g = exp(-r2*r2);
sum += s * w * g;
wsum += w * g;
}
if (wsum > 0.0f) {
sum /= wsum;
}
gl_FragDepth = sum;
}
关于java - 用于流体模拟的双边滤波器,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/27662477/
.mid{ margin:0 auto; max-width:10em; min-width:5em; border:1px solid red; } ... 此代码创
我想用 制作 4 列元素: 第1列的宽度需要固定为200px。 其他 3 列需要动态划分它们之间的剩余宽度。 Column 1 Fixed 200px Column 2 Fluid Column 3
好的,我看到了 static , fluid , static 布局,但现在我的设计需要fluid, static, fluid 布局。 如: +---------------------------
我有以下 2 列 div 布局。左列需要有 75px 的宽度以容纳图像,但右列需要流入其所有父容器。 这个网格位于一个用户控件中,该控件被添加到多个站点/页面,每个站点/页面都有不同的布局,因此父容器
在此fiddle ,我在 dark-blue 的包装器中有一个图像,我希望它相对于它的包装器水平和垂直对齐 70%。 我尝试使用 table-cell,但它似乎不起作用。 HTML:
在 CSS 中获得此布局的最佳方法是什么?想象一下,我有三个 div,两个 div 在另一个里面。在两个内部 div 中,第一个具有特定的宽度集,第二个 div 预计会占用剩余空间。 通常我会在第二列
我对流体有点陌生,我想在流体中创建以下 php 语句。 if ($var == 'something') { // do something } elseif ($other-var == 's
仅当属性值 fileEn 时,我才尝试输出我的元素为 NULL ( fileEn => NULL ) {file} 然而,这也向我展示了 fileEn 不是 NULL 的元素! 最佳答案
简短的版本:我有一个元素,我需要定义一个 DIV,它将水平重复,然后在空间不足时换行到下一行(类似表格的网格)。我见过提到 jQuery.GridLayout,但演示/主页是 404,所以我不知道这是
我想不通 - 但我相信有人可以...我正在研究将新的流体宽度设置为 100%,并为内容包装器设置最小和最大宽度。 当页眉区域未设置为 overflow:hidden 时会出现问题 - 会出现一个大的水
我正在为一部即将上映的电影设计一个网站,但在让它适应所有浏览器窗口大小和屏幕大小方面遇到了一些问题。本质上,例如初始页面的标记在页面顶部有电影 Logo ,在其下方有一个视频(电影预告片),然后是一个
我正在构建一个由 50% 宽度的 div 和 25% 宽度的 div 组成的流动网站,我遇到的问题是对齐问题,尤其是与 Chrome。 我已经在这里上传了代码:http://tekulated.com
我正在尝试使用 twitter bootstrap 为我的网站做一个垂直的双色调背景(使用 css 渐变),这样渐变在连续流体的跨度之间的排水沟的中心结束。我已经有了渐变代码(如下所示),并且正在尝试
最近开始使用bootstrap,遇到如下问题:出现水平滚动条应该早得多。下面屏幕截图中的红色方 block 显示了表格旁边的空白区域没有填充任何信息,隐藏表/div。 HTML
我正在努力让这个布局稍微流畅一些。我希望#logo 位于#infobot 的右下角,其大小由我想随浏览器窗口缩放的图片决定。 #white 应该只是掩盖#logo 左侧的区域。如何让#white 和#
我们收到了一位客户的奇怪请求。他们想要一个特别的 的内容以图标为中心。居中本身不是问题,图标也不是。 问题是我找不到将 居中的方法s 的宽度可变,图标没有左对齐。 所以我们正在努力实现您在 http
我的网站有后台问题。我们的想法是不使用任何媒体查询,而是将所有内容都设置在 % 上,以便它始终可以在任何设备上查看。 我的问题是,背景图像确实具有适用于 with 的正确 css,但高度由 div 中
我正在对这个站点进行一些样式调整 http://neondataskills.org/ 我添加了一个顶部栏图像,现在,当您调整页面大小时,顶部栏图形如果太宽就会与导航重叠。我想强制图像将导航栏向下推。
我创建了一个带有面板和面板主体的容器。当我在桌面上查看该站点时,它看起来还不错。但是我在手机上看的时候,右边好像有一个很大的空间,什么也没有。 描述问题的图片 http://snag.gy/ApnWS
我有这样的布局: /*Sidebar*/ /*Column1*/ /*Column2*/ /*Column3*/ /*Sidebar*/ 所以现在我想做一个流畅的布局,在台式电脑上看起来不错,但在缩小
我是一名优秀的程序员,十分优秀!