hlsl

Vertex position relative to normal

心已入冬 提交于 2019-12-23 13:35:14
问题 In a surface shader , given the world's up axis (and the others too), a world space position and a normal in world space, how can we rotate the worldspace position into the space of the normal? That is, given a up vector and a non-orthogonal target-up vector, how can we transform the position by rotating its up vector? I need this so I can get the vertex position only affected by the object's rotation matrix, which I don't have access to. Here's a graphical visualization of what I want to do:

HLSL compiler optimizes strange?

守給你的承諾、 提交于 2019-12-23 05:14:25
问题 I am not an expert in HLSL compilers and how they work with branches but I have read different opinions about this issue. So to be concrete: In C/C++ it would make perfect sense to implement something like: if (factor == 0) { // Simple calculation in special case of factor=0 } else if (factor == 1) { // Simple calculation in special case of factor=1 } else { // Much more complex calculation in general case of arbitrary factor } in situations where most of the time factor is 0 or 1. Is the

How to enable Hardware Percentage Closer Filtering?

夙愿已清 提交于 2019-12-21 20:23:06
问题 I am trying to implement PCF filtering to my shaow maps, and so modified the GPU Gems article ( http://http.developer.nvidia.com/GPUGems/gpugems_ch11.html ) so that it could be run on current shaders. The modification includes replacing tex2Dproj function with Texture2D.Sample() function so it accepts Sampler States which are created in DirectX11. Then I compared the offset values with a normal shadow map comparison: float2 ShTex; ShTex.x = PSIn.ShadowMapSamplingPos.x/PSIn

understanding the basics of dFdX and dFdY

人走茶凉 提交于 2019-12-21 05:22:27
问题 I've read numerous descriptions of the behavior of dFdX(n) and dFdY(n) and do believe I still have a handle on partial derivatives from school. What I don't follow is where does 'n' come from in the simplest possible example? Reading the glsl built-in functions dFdx(n) and dFdy(n) without any context other than mathematics I would interpret them as "I have some function of x and y: f(x,y) , I take the partial derivative of that function w.r.t. x d/dx(x,y) , and I evaluate the partial

Rendering to a full 3D Render Target in one pass

寵の児 提交于 2019-12-21 02:26:26
问题 Using DirectX 11, I created a 3D volume texture that can be bound as a render target: D3D11_TEXTURE3D_DESC texDesc3d; // ... texDesc3d.Usage = D3D11_USAGE_DEFAULT; texDesc3d.BindFlags = D3D11_BIND_RENDER_TARGET; // Create volume texture and views m_dxDevice->CreateTexture3D(&texDesc3d, nullptr, &m_tex3d); m_dxDevice->CreateRenderTargetView(m_tex3d, nullptr, &m_tex3dRTView); I would now like to update the whole render target and fill it with procedural data generated in a pixel shader, similar

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

swift can not save .m3u8 file to gallery

我怕爱的太早我们不能终老 提交于 2019-12-20 03:52:20
问题 Im using this below method to download and save my video to gallery, with .mp4 it's work normally, but when change to .m3u8 it's always fail. func downloadVideoLinkAndCreateAsset(_ videoLink: String,_ fileName : String) { // use guard to make sure you have a valid url guard let videoURL = URL(string: videoLink) else { return } guard let documentsDirectoryURL = FileManager.default.urls(for: .documentDirectory, in: .userDomainMask).first else { return } let fileNameToSave = "CiviX_HistoryVideo_

HLSL 3 Can a Pixel Shader be declared alone?

我的梦境 提交于 2019-12-20 01:45:23
问题 I've been asked to split the question below into multiple questions: HLSL and Pix number of questions This is asking the first question, can I in HLSL 3 run a pixel shader without a vertex shader. In HLSL 2 I notice you can but I can't seem to find a way in 3? The shader will compile fine, I will then however get this error from Visual Studio when calling SpriteBatch Draw(). "Cannot mix shader model 3.0 with earlier shader models. If either the vertex shader or pixel shader is compiled as 3.0

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

When does the transition from clip space to screen coordinates happen?

霸气de小男生 提交于 2019-12-18 10:13:57
问题 I was studying the rendering pipeline and when I got to the clipping stage it was explained that from the view (eye or camera) space we have to pass to the clip space , also called normalized device space (NDC), that is a cubic space from -1 to 1. However, now I don't understand when the passage from this space to the screen coordinates space happens: Right after clipping and before rasterization? After rasterization and before scissor and z-test? At the end just before writing on the frame