hlsl

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

How to create Photoshop Stamp filter analog in any pixel shading language?

夙愿已清 提交于 2019-12-11 09:49:25
问题 How to create Photoshop Stamp filter analog in any pixel shading language? (I need at least filter algorithm...) 回答1: I've look at the Stamp Filter in Photoshop and it looks like a Threshold and a strong Blur added together. I've used the HorizontalGaussianBlur kernel found Pixel Bender Basics Article on Devnet and just added a cheap threshold. Here is how my kernel looks like: <languageVersion : 1.0;> kernel stamp < namespace : "toMaterial"; vendor : "George Profenza"; version : 1;

Why is this 128Bit Color Format being converted to 32Bit

我的未来我决定 提交于 2019-12-11 09:18:34
问题 I am trying to write an HLSL pixel shader for a project I am working on. Basically want I want to do is if a texture has a pixel with a float value of 0.52 (on scale of 0-255 is 132.6) I want to output 133 60% of the time and output 132 40% of the time. Write now I am just trying to output the fractional remainder of the RGB value (i.e. the chance to bump the pixel up) however I always get a value of zero) I think this is because the colors are getting quantized to a 0-255 scale before they

Combining Two Shaders into One Shader

僤鯓⒐⒋嵵緔 提交于 2019-12-11 08:03:22
问题 Unity Project, Want to combine these two shaders into one shader to get both of their functionality. One shader is for lighting, the other shader is for rendering better. How do I combine? Shader "Transparent/Cutout/Lit3dSprite" { Properties{ _MainCol("Main Tint", Color) = (1,1,1,1) _MainTex("Main Texture", 2D) = "white" {} _Cutoff("Alpha cutoff", Range(0,1)) = 0.5 } SubShader{ Tags {"Queue" = "AlphaTest" "IgnoreProjector" = "True" "RenderType" = "TransparentCutout" "PreviewType" = "Plane"}

How to apply a SharpDX.Toolkit.Graphics.Effect directly?

孤者浪人 提交于 2019-12-11 07:54:32
问题 I'm creating an image editor for Windows Phone 8 / Windows 8 using SharpDX api and trying to apply a custom effect (SharpDX.Toolkit.Graphics.Effect) to a WriteableBitmap. The effect itself is applied, but the result looks strange. Seems to me that the texture was reduced and inverted. The code to apply the effect is written below. private void ApplyEffect() { GraphicsDevice graphicsDevice = GraphicsDevice.New(); RenderTarget2D renderTarget = RenderTarget2D.New( graphicsDevice, _originalBitmap

How to use a huge array in HLSL (error X4505)

瘦欲@ 提交于 2019-12-11 03:27:10
问题 When I try to compile I get the error: X4505: sum of temp register and indexable temp registers exceeds limit of 4096. However my shader does work in FX Composer . The reason it crashes is probably because I use a very large array since I'm using marching cubes. const static int edgeTable[256] = ... const static int triTable[256][16] = ... How should I go about using these arrays? (D11) 回答1: https://msdn.microsoft.com/en-us/library/windows/desktop/ff476898(v=vs.85).aspx#Shader_Constant_Buffer

Marshalling C# Structs into DX11 cbuffers

泄露秘密 提交于 2019-12-10 21:44:55
问题 I'm having some issues with (i think) the packing of my structure in C# and passing them through to cbuffers i have registered in HLSL. When i pack my struct in one manner the information seems to be able to pass to the shader: [StructLayout(LayoutKind.Explicit, Size = 16)] internal struct TestStruct { [FieldOffset(0)] public Vector3 mEyePosition; [FieldOffset(12)] public int type; } When i create this struct and set it as my constant buffer in C# it seems to work just fine. I get what

Strange smeared edges pattern using HLSL for YUV to RGB conversion

拥有回忆 提交于 2019-12-10 20:39:54
问题 I'm trying to write a YUV to RGB shader in HLSL. Specifically, it converts the Yuv420p format which consists of an N M plane of Y values, followed by an (N/2) (M/2) plane of U values and then an (N/2)*(M/2) plane of V values. For example this 1280x720 picture: looks like this in YUV format interpreted as an 8-bit, 1280x1080 texture: In Direct3D11, I'm loading this as a Texture2D with format R8_UNorm and dimensions 1280x1080. The tricky part is reconstituting the U and V planes, because as you

How to find the distance between a point and a parabola in code

跟風遠走 提交于 2019-12-10 19:28:13
问题 I am trying to find the closest point on a parabola to an arbitrary point in 2d, for a DirectX pixel shader. A great amount of googling has revealed to me that this is a common pre-calculus homework problem. Unfortunately, the hundreds of relevant answers all say things like "Once you have this equation, use your graphing calculator's minimum function and it will tell you the answer is 6." I confess that I recall nothing of pre-calculus. I recognize that the equation I seek is probably

Pix, A couple of issues I'm not understanding

試著忘記壹切 提交于 2019-12-10 17:07:09
问题 I've been asked to split questions which I asked here: HLSL and Pix number of questions I thought two and three would both fit in the same question as a solution of one may help resolve the other. I'm trying to debug a shader and seem to be running into issues. Firstly Pix seems to be skipping a large amount of code when I'm running analyse mode. This is analysing an experiment with F12 captures and with D3DX analysis turned off. I have to turn it off as I'm using XNA. The shader code in