pixel-shader

Passing colors through a pixel shader in HLSL

ぃ、小莉子 提交于 2019-12-10 14:35:37
问题 I have have a pixel shader that should simply pass the input color through, but instead I am getting a constant result. I think my syntax might be the problem. Here is the shader: struct PixelShaderInput { float3 color : COLOR; }; struct PixelShaderOutput { float4 color : SV_TARGET0; }; PixelShaderOutput main(PixelShaderInput input) { PixelShaderOutput output; output.color.rgba = float4(input.color, 1.0f); // input.color is 0.5, 0.5, 0.5; output is black // output.color.rgba = float4(0.5f, 0

How to modify/displace pixel position in a Cg fragment shader?

左心房为你撑大大i 提交于 2019-12-08 06:05:21
问题 Is it possible to modify pixel coordinates in a fragment (pixel) shader using Cg? I'm sure such functionality became available in 2nd/3rd-generation shaders but I don't know what profiles exactly, or how to do it. 回答1: No, it is not possible. The only coordinate you can modify in a fragment shader is the Z, going into the Z-buffer. And even that has performance implications, as it defeats some optimizations (like Hierarchical Z). the X and Y positions are set before the fragment shader is

How to unset texture data in XNA 4.0

不羁的心 提交于 2019-12-08 01:28:24
问题 I need to communicate some constantly changing data to my pixel shader. I have a texture2d that I am passing to my pixel shader via a texture parameter. Before I call the shader I need to update the data in the texture. emittingPositions.SetData(emittingPositionsBuffer); //Set the data on the texture animationEffect.Parameters["emittersMap"].SetValue(emittingPositions); //Tell the shader about the texture data //go on to do the actual drawing calls to use the pixel shader The problem is that

Can't render pixel shader to RenderTargetBitmap! Please help!

眉间皱痕 提交于 2019-12-07 21:43:15
问题 I wrote a very simple WPF application to test the ability to render a control that has an associated pixel shader to a RenderTargetBitmap. I then write the bitmap to file (jpeg). The control is rendered onto the bitmap, however the pixel shader effect is not applied to the control. The code and the XAML is below: namespace TestPixelShader { /// <summary> /// Interaction logic for MainWindow.xaml /// </summary> public partial class MainWindow : Window { public MainWindow() {

How wrap image around cylinder in Silverlight

我的未来我决定 提交于 2019-12-07 06:36:39
问题 I am trying wrap image around cylinder in silverlight. I looked a lot in Google but don't found anything. As I know it can be done with pixel shader, but don't know how. Is it possible? Thanks. 回答1: It's not a complete wrap onto cylinder, but you will get a starting idea/example: (code is in GLSL, not in HLSL, but i think it will be not hard to convert it) uniform sampler2D tex; void main() { vec2 cen = vec2(0.5,gl_TexCoord[0].y)-gl_TexCoord[0].xy; cen = vec2(pow(cen.x,1.7),pow(cen.y,2.2));

How to modify/displace pixel position in a Cg fragment shader?

房东的猫 提交于 2019-12-07 03:11:27
Is it possible to modify pixel coordinates in a fragment (pixel) shader using Cg? I'm sure such functionality became available in 2nd/3rd-generation shaders but I don't know what profiles exactly, or how to do it. No, it is not possible. The only coordinate you can modify in a fragment shader is the Z, going into the Z-buffer. And even that has performance implications, as it defeats some optimizations (like Hierarchical Z). the X and Y positions are set before the fragment shader is ever executed (in the Rasterizer ). Typical rasterizers actually generate at the very least 2x2 chunks of

How to unset texture data in XNA 4.0

穿精又带淫゛_ 提交于 2019-12-06 10:43:15
I need to communicate some constantly changing data to my pixel shader. I have a texture2d that I am passing to my pixel shader via a texture parameter. Before I call the shader I need to update the data in the texture. emittingPositions.SetData(emittingPositionsBuffer); //Set the data on the texture animationEffect.Parameters["emittersMap"].SetValue(emittingPositions); //Tell the shader about the texture data //go on to do the actual drawing calls to use the pixel shader The problem is that when I do this I get an exception: "You may not call SetData on a resource while it is actively set on

Unity 3d Sprite Shader (How do I limit Max Brightness to 1 with Multiple Lights Hitting)

杀马特。学长 韩版系。学妹 提交于 2019-12-06 08:43:30
I am creating a videogame in Unity. Every sprite is rendered with a Sprite Renderer with a Material that has the CornucopiaShader.shader. The problem I have is I want to limit the max brightness (or color) of the sprite to just be a normal image of the sprite regardless of the power of how many point lights are hitting it, the intensity of the lights, and also the ambient light in the unity scene. When the intensity of the lights hitting the sprite is below that max brightness level I want it to act like a normal lit sprite and be black if no lights are hitting it, and be half lit up if an

Can't render pixel shader to RenderTargetBitmap! Please help!

不问归期 提交于 2019-12-06 08:05:47
I wrote a very simple WPF application to test the ability to render a control that has an associated pixel shader to a RenderTargetBitmap. I then write the bitmap to file (jpeg). The control is rendered onto the bitmap, however the pixel shader effect is not applied to the control. The code and the XAML is below: namespace TestPixelShader { /// <summary> /// Interaction logic for MainWindow.xaml /// </summary> public partial class MainWindow : Window { public MainWindow() { InitializeComponent(); } private void OnSaveSnapshot(object sender, RoutedEventArgs e) { SaveFileDialog dlg = new

Floyd–Steinberg dithering alternatives for pixel shader

≯℡__Kan透↙ 提交于 2019-12-05 00:47:05
I know that Floyd–Steinberg dithering algorithm can't be implemented with pixel shader, because that algorithm is strictly sequential. But maybe there exist some higly parallel dithering algorithm which by it's visual output is similar to Floyd-Steinberg algorithm ? So the question is - What are dithering algorithms which are suitable to implement on pixel shader (preferably GLSL) and with output quality (very) similar to Floyd-Steinberg dithering ? BTW. Multi-pass algorithms are allowed until there are not more than 2 passes and CPU overhead between those passes is small. Any ideas ? EDIT: I