pixel-shader

Are there DirectX guidelines for binding and unbinding resources between draw calls?

我怕爱的太早我们不能终老 提交于 2019-12-21 05:21:35
问题 All DirectX books and tutorials strongly recommend reducing resource allocations between draw calls to a minimum – yet I can’t find any guidelines that get more into details. Reviewing a lot of sample code found in the web, I have concluded that programmers have completely different coding principles regarding this subject. Some even set and unset VS/PS VS/PS ResourceViews RasterizerStage DepthStencilState PrimitiveTopology ... before and after every draw call (although the setup remains

HLSL and Pix number of questions

僤鯓⒐⒋嵵緔 提交于 2019-12-20 05:58:22
问题 I'm having a number of isses with HLSL and Pix. 1) Can you in HLSL 3, declare a Pixel shader alone without a Vertex Shader? If not, what can I do to get around this? 2) Why does Pix skip code? I have a reasonably long shader method but Pix seems to stop me from debugging until half way through the method and then skips the rest of the block. I set Pix to gather information when F12 is hit and check the DISABLE D3DX analysis checkbox. I have to do this because I'm using XNA. 3) Can I debug the

Pixel Shader Effect Examples

荒凉一梦 提交于 2019-12-18 11:31:44
问题 I've seen a number of pixel-shader effect examples, stuff like swirl on an image. But I'm wondering if anyone knows of any examples or tutorials for more practical uses of shader effects? I'm not saying that a swirl effect doesn't have it's uses, it's just that many of the examples I've found have the basic effect explained and don't go into how it might be used subtly with another effect or transition to produce a wonderful effect. There's a video here, that outlines all the WPF Effects

HLSL for getting cylinder effect

帅比萌擦擦* 提交于 2019-12-18 07:14:53
问题 I need to write an application with Silverlight 4 and need to show images like wrapped on cylinder. I need some HLSL code, as I wont to do that with Effects of Silverlight. I don't wont to do that with 3D libarries for silverlight. I only need HLSL code for changing pixels. I need for my image to look like this Thanks. 回答1: This seems to be the effect you want, you may wish to change the 0.2 value to increase or decrease the effect or make this adjustable in your shader but that's a simple

GLSL shader to boost the color

只愿长相守 提交于 2019-12-13 11:11:25
问题 Is their any GLSL shader that can help me to "boost" the color of a texture ? How to write such shader ? I would like to do something like the picture below : 回答1: It seems they are mostly boosting saturation here, so that's what you'd need to do in your fragment shader. To boost saturation, you need to take your data from the RVB color space to the HSL (hue saturation lightness) space. you then need to do: hslColor = vec3(hslCOlor.x, hslColor.y * **boost**, hslCOlor.z); Of course to do that

How to avoid int->float conversion when passing data to pixel shader?

大兔子大兔子 提交于 2019-12-13 00:44:13
问题 I have a pixel shader: varying vec2 f_texcoord; uniform vec4 mycolor_mult; uniform sampler2D mytexture; void main(void) { gl_FragColor = (texture2D(mytexture, f_texcoord) * mycolor_mult); }; and corresponding C++ code: GLint m_attr = glGetUniformLocation(m_program, "mycolor_mult"); // ... unsigned int myColor = ...; // 0xAARRGGBB format float a = (myColor >> 24) / 255.f; float r = ((myColor >> 16) & 0xFF) / 255.f; float g = ((myColor >> 8) & 0xFF) / 255.f; float b = (myColor & 0xFF) / 255.f;

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

送分小仙女□ 提交于 2019-12-12 10:09:23
问题 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

DirectX 11, Combining pixel shaders to prevent bottlenecks

岁酱吖の 提交于 2019-12-11 19:26:45
问题 I'm trying to implement one complex algorithm using GPU. The only problem is HW limitations and maximum available feature level is 9_3. Algorithm is basically "stereo matching"-like algorithm for two images. Because of mentioned limitations all calculations has to be performed in Vertex/Pixel shaders only (there is no computation API available). Vertex shaders are rather useless here so I considered them as pass-through vertex shaders. Let me shortly describe the algorithm: Take two images

Rendering a line into a 1x1 RenderTarget2D does not change the target's pixel color

人盡茶涼 提交于 2019-12-11 14:58:53
问题 What I am trying to achieve is the following: my pass will return a huge array with several unique numbers repeating over and over, which I need to retrieve and process on CPU. I tried rendering into a 2000x1 texture and then sampled it on the CPU with RenderTarget2d.GetData<>() and a foreach loop. It was awfully slow :). So I sidestepped my problem, the idea now is to render to a 1x1 texture multiple times. Inbetween passes I will extend a parameter array in my shader to include the numbers

Transparency on two rectangles in DirectX, one behind another - I see the background of window instead the second texture

放肆的年华 提交于 2019-12-11 13:55:56
问题 I have an DirectX 11 C++ application that displays two rectangles with textures and some text. Both textures are taken from TGA resources (with alpha channel added). When I run the program, I get the result: What's wrong? Take a closer look: The corners of the rectangles are transparent (and they should be). The rest of textures are set to be 30% opacity (and it works well too). But, when one texture (let's call it texture1 ) is over another ( texture2 ): The corners of texture1 are