问题标签 [rendertarget]

For questions regarding programming in ECMAScript (JavaScript/JS) and its various dialects/implementations (excluding ActionScript). Note JavaScript is NOT the same as Java! Please include all relevant tags on your question; e.g., [node.js], [jquery], [json], [reactjs], [angular], [ember.js], [vue.js], [typescript], [svelte], etc.

0 投票
1 回答
324 浏览

alpha - Monogame: making SOME pixels of a RenderTarget semi-transparent

this is a very difficult problem to describe (I'm using MonoGame, Windows 8).

I want to be able to render a semi-transparent 'sprite' image, such as a .png, not onto the screen but onto a clear image, do this several times to in effect create a new sprite image by blending together various images... then, I want to be able to render this new sprite image to the screen with the areas that I haven't drawn to remaining transparent (i.e. around the edge mainly).

Sure, I can load in a semi-transparent 'sprite' .png image and 'paste' it onto the RenderTarget; I can do this several times and the 'sprites' will blend nicely. I can then 'paste' (i.e. draw/render) that composite image, the RenderTarget, onto the screen.

The problem is, when the RenderTarget is drawn onto the screen, it has a solid block around it.

Presumably, the default alpha value for each pixel in the RenderTarget is solid. Any pixel that I don't draw to, I want to remain fully transparent, just as if you grabbed a paintbrush and painted not onto paper but onto glass. If you then placed that sheet of glass on, say, your swirly carpet, everywhere that doesn't have paint you would see swirly carpet. But that's not what I see, I just see black, as though I'd 'painted onto black paper' rather than 'painted onto glass'.

If I could render an image onto another image directly there wouldn't be a problem (can this be done?): I'd create an 'empty' .png image, perhaps in PhotoShop, i.e. not draw anything then save it with transparency enabled, and I'd render my images onto that, then save the result. But a RenderTarget seems to be already opaque.

I hope the above is clear. I've searched and found lots of answers on manipulating the alpha of Texture2D objects, but I can't find anything on manipulating the alpha of a RenderTarget2D.

Thanks for any help!

0 投票
1 回答
1190 浏览

directx - 无法创建 DX11 渲染目标视图

我正在尝试开始使用 DirectX 11 游戏编程,但由于某种原因,我根本无法使用 ID3D11Device::CreateRenderTargetView() 创建渲染目标视图。

(顺便说一句,我使用 VS for Desktop 2013,我的 GPU 支持的最高功能级别是 11_0。我正在运行 Windows 8.1。)

这是我认为相关的代码:

0 投票
1 回答
2603 浏览

three.js - 如何访问 WebGLRenderTarget 纹理内容

所以我将场景渲染为纹理,然后我需要在 js 中处理纹理并修改内容或从值数组制作新纹理。

似乎我需要获取 WebGL 上下文并直接与 WebGL 交互来完成此操作。有人知道最好的方法吗?

0 投票
2 回答
269 浏览

xna-4.0 - XNA 4.0 Spritbatch - 不得在设备上设置渲染目标

我正在将 XNA 3.0 云效果转换为 XNA 4.0,但出现错误

它发生在这一行的第二个循环中:

代码:

如果它已经设置为渲染目标,我似乎无法在 XNA 4.0 中将纹理设置为效果参数。但我不知道如何将其转换为在 XNA 4.0 中工作:(

0 投票
1 回答
1478 浏览

javascript - THREE.js 渲染目标纹理不会在不同的场景中绘制

因此,如果任何 THREE.js 专业人士能够理解为什么我不能让 WebGLRenderTarget 用作另一个场景中飞机的材料,我会非常高兴。

现在它的工作原理是我使用透视相机创建一个场景,该相机渲染一个简单的平面。这发生在 Application 对象中。

我还有一个 WaveMap 对象,它使用另一个场景和一个正交相机,并使用片段着色器在另一个占据整个屏幕的四边形上绘制 cos(x) * sin(y) 函数。我将其渲染为纹理,然后创建使用此纹理的材质。

然后我传递要在应用程序对象中使用的材质,以在我提到的第一个平面上绘制纹理。

问题是由于某种原因,我可以让它在 WaveMap 对象内使用正交相机的场景中工作,但在传递材质后,不能在 Application 对象中使用透视相机的场景中工作。:(

我尝试过简单地传递具有纯色的简单材质并且有效,但是当我尝试传递使用 WebGLRenderTarget 作为纹理的材质时,它不再显示。

https://github.com/ArminTaheri/rendertotexture-threejs

0 投票
0 回答
99 浏览

mfc - CHwndRenderTarget 大小错误

这个虫子快把我逼疯了。我有一个带有窗口的 MFC 应用程序,我可以在其中进行绘图和交互。问题是 的大小CHwndRenderTarget与窗口的实际大小不匹配(我使用CRectget from进行比较GetClientRect())。这导致所有交互都偏离了我的鼠标指针实际所在的位置(不理想)。我尝试ReSize()使用CHwndRenderTarget正确的值,但它总是返回 false。为什么会CHwndRenderTarget是错误的尺寸?

这是我用来检查尺寸的代码:

0 投票
0 回答
210 浏览

c# - WPF:使用sharpDX将视觉对象保存为位图

我是 DirectX 的新手,我需要使用 DirectX (sharpDX) 将 WPF-Canvas 保存为位图。

我使用以下代码来处理我的画布:

如何使用sharpDX 将我的WPF-Canvas 保存为位图(通过设备上下文句柄)。(最快的方式)

0 投票
1 回答
683 浏览

javascript - 三个 JS 像素化渲染目标?

我试图让一个基本的渲染目标工作,我渲染到 1 个场景,然后将其用作纹理来渲染四边形。我有一个基本的演示,但是当我运行它时,结果都是像素化的,就好像它被渲染到一个小屏幕上然后被拉伸到四边形一样。

这是我的代码:

有任何想法吗?

0 投票
1 回答
44 浏览

textures - Retaining data across GLSL shader calls

I'm struggling to understand a concept and I was hoping somebody could set me straight on it.

I'm trying to build GLSL simulations that will retain data across each draw call, but I want it all to be done on the GPU so it's quick and efficient. I understand that you do this by rendering the data you want to a texture and then reading from that texture.

I have a simple demo where I have a rendertarget which I'm drawing a color to and each draw call I want to increase the value of the color by 0.01 by reading in the current color and adding 0.01 to it, however I get the error:

#xA;

Which makes me think I've misunderstood this concept entirely because I get the impression you can't pass the current rendertarget in as a texture. Could someone clear this up for me because I feel pretty confused right now

0 投票
2 回答
302 浏览

opengl - 渲染到 FBO,采样失败

我正在尝试渲染到 FBO,然后在 OpenGL / LWJGL 中进行筛选,结果很奇怪。

如果直接渲染到帧缓冲区,我的场景工作得很好,看起来像这样:

1

但是,当我渲染到 FBO,然后渲染到默认帧缓冲区上的四边形时,我得到了这个:

2

看起来图像中的所有颜色都以单一颜色平均,就好像用那个颜色清除了屏幕一样。

我的猜测是,四边形上的纹理采样有问题,但我无法弄清楚。

当我看到 glPolymode - GL_LINE 的边缘时,四边形显然就在那里。此外,当我移动游戏摄像机时,四边形上的单一颜色会发生变化,并且不知何故也反映了屏幕上最突出的颜色。所以也许你可以指出我可能显而易见的解决方案?我将在本文末尾放置一些我认为相关的代码。


这就是我设置小队顶点和 uv 坐标的方式。我对多维数据集使用相同的方法和父类,所以我知道这是可行的:

这就是我将它们绑定到vbos的方式:

这就是我在着色器中为四边形绑定属性位置的方式:

这就是我渲染屏幕四边形的方式:

这是我的顶点和片段着色器:顶点:

分段:

最后,这是我的渲染过程:prepare(); 绘制场景();展示();

使用这些功能:

编辑:也许我应该添加我如何设置 FBO: