A proprietary shading language developed by Microsoft for use with the Microsoft Direct3D API.

learn more… | top users | synonyms

0
votes
0answers
19 views

Sample() returns (0, 0, 0) for normal map 90% of frames

I'm having some trouble reading the values from my Normal map in my lighting fragment shader. The relevant part of the shader code is as follows: Texture2D NormalGB : register(t0); Texture2D ...
0
votes
1answer
82 views

Shader - Color blending

I would like to know how to blend colors in a specific way. Let's imagine that I have a color (A) and an other color (B). I would like to blend them in such a way that if I choose white for the (B) ...
0
votes
0answers
16 views

How to sample png heightmap in HLSL

I am working on simple parallax shader and I have problem with sampling height texture for value. My aproach amples texture and give me RGB values of picture: tex2D(TextureHeightSampler, ...
1
vote
1answer
49 views

Shader - Convert vector into scalar

I am trying to convert a half3 as a simple half but I am facing an issue. As for an example half3(1, 0, 0) give me white but half3(0, 1, 0) gives me black. How can I convert properly a half3 to a ...
0
votes
0answers
38 views

tex2Dlod to limit max mip level to use for a texture (atlas)

I'm developing a 3D multitexturing terrain engine in C# on Monogame (XNA) plateform. I would like my engine works on Windows XP or upper, so on DirectX 9c minimum. Monogame allow me to build a DirectX ...
1
vote
1answer
51 views

3D GUI Shader Problem

So I want to create one of these in my directX11 project. The little axis there that shows you the direction. I have a nice 3d shader for my world geometry that I tweaked from Frank D. Luna (He ...
0
votes
1answer
25 views

When does DirectX convert a vertex/pixel's depth from range Near-Far to 0-1?

When I output a vertex from a vertex shader, it seems to have a world-space-ish mapping. Vertices about 1 unit away have about 1 unit as their Z value. When we input into the pixel shader, the depth ...
0
votes
2answers
96 views

Draw many flashlights' focused lights' “circles” on a voxel engine map (and other objects)

So, I've been searching the internet for a while and I still didn't understand how to create a flashlight's "circle" in front of the camera over other objects. I found the following links: using ...
0
votes
0answers
35 views

How can I avoid transposing matrices and still use more efficient dp4's instead of a mul and 3 mad's?

I'm using the 'correct' matrix-vector multiplication form (M*v) as recommended here. All my matrices in shaders are prefixed with 'column_major'. This line of HLSL code: hPos = mul( ...
0
votes
1answer
46 views

DirectX11 Shader issue

I am currently having issues with HLSL shaders. I am trying to implement point lights but I am getting unusual data when debugging the shader in Visual Studio. I have read on several sites that say ...
0
votes
1answer
24 views

HLSL Shader Optimilation with MAD(m,a,d)

I understand that the expression x = m*a+d is most efficiently written as x = mad(m,a,d) because at the assembly level only one instruction is needed rather than a multiply and add separately. My ...
0
votes
1answer
37 views

Input Assembler - Vertex Shader linkage error

I'm new to HLSL and have been struggling with this problem for a while and I can't figure it out. I'm getting the below error a number of times in the debug window: D3D11 ERROR: ...
0
votes
2answers
24 views

Update single variable in DirectX Shader

I am trying to update a single variable within a CBuffer but I am unsure of how to do this. I have a LightingBuffer which is passed to the GPU containing, ambient color, diffuse color etc and I want ...
0
votes
0answers
16 views

DirectX 11 Compute Shader Thread Order

I want to implement a simple blurring method using multiple texture taps using a compute shader. The shader simply assigns a pixel color based on several near-by pixels in another texture. I would ...
2
votes
1answer
57 views

HLSL Pixel Shader for Depth Only Pass

I'm using DirectX 11 and shader model 5. There are many tutorials online for writing engines and shaders for shadow mapping. I have found an issue which seems to have a hard to find answer. Typical ...
0
votes
0answers
21 views

converting HSLS gives error

I'm using the following parser: https://github.com/unknownworlds/hlslparser I also have the following code: /* * Bo Sun, Columbia University, All rights reserved * ...
1
vote
1answer
87 views

How can I test if one point can “see” another point. (XNA)

I want to test if my enemy can see the player, however I want this to be pixel-perfect. I already have all of the solid objects drawing into a separate render state. It should be noted that every ...
0
votes
0answers
75 views

DirectX Compute shader (HLSL) makes texture black

Hello this is my first question on this forum :) When using compute shader in directx to change the color to blue the texture only gets black. I really don't understand what the problem could be and I ...
0
votes
1answer
62 views

XNA Distortion Shader problem

So I came up with a distortion pixel shader in hlsl, but it has some issues. First of all, here is how it works: The shader uses another texture generated by the program as a distortion "map" (if ...
0
votes
0answers
16 views

Multisampled Nearest Filtering in PS 2.0 is it possible?

My game involves blocky, pixelated 3D textures. When using nearest neighbor filtering with a texture sampler, I get the desired result of nicely pixelated textures -- with the caveat that hard lines ...
2
votes
1answer
59 views

What will happen if the argument of mix() or clamp() is above 1 or below 0?

There's two magnificent intrisincs: mix() in GLSL and clamp() in HLSL, which are used to implement linear interpolation. Let's say we have a variable: float v = ?; // where ? can be [-FLOAT_MAX, ...
0
votes
1answer
49 views

Binding an Instance Matrix with an InputLayout

If I want to bind an instance matrix to a vertex shader, how do I go about it? For example, here is a super-simple VS input: struct VS_IN { float4 Position : POSITION; row_major float4x4 ...
0
votes
0answers
65 views

Multi-textured terrain XNA-monogame

I'm developing a TerrainEngine for my project and I have some issues with the multi-texturing part. I already tried some techniques but it doesn't match with my TerrainEngine's conception. My ...
0
votes
1answer
60 views

Normalizing a homogeneous 3d point

As I've seen corruption in geometry, why is it a bad idea to normalize a homogeneous (divide by w) the vertex position returned from vertex shader? Update Vertex shader: // float4 pos : ...
-1
votes
1answer
116 views

FXC: Error X3501: 'main': entrypoint not found

I am trying to compile a vertex shader using VS2013, but every time I try, FXC returns the following error: Error error X3501: 'main': entrypoint not found I've reduced the vertex shader to its ...
2
votes
1answer
93 views

VS2013: Compiling Shaders with Shader Model 5.0

When I try to compile two HLSL files included in my project, the compilation fails with an error: Error error X4502: invalid vs_2_0 input semantic 'INSTANCE' However, I notice it's trying to use ...
0
votes
1answer
57 views

What are .fxo and .cod files for?

I've been reading about shaders and looking at code. I found this in the code I'm looking at and it obviously has "Basic.fxo" there. BasicFX = new BasicEffect(device, L"FX/Basic.fxo"); Now my ...
1
vote
1answer
172 views

D3D11/C++ Inaccuracies in uv interpolation in pixel shader. How to avoid?

I'm trying to draw a quad with a texture onto the screen such that texels and pixels perfectly align. Sounds pretty easy. I draw 2 triangles (as TRIANGLE_LIST, so 6 vertices) using these shaders: ...
0
votes
0answers
34 views

Encoding Floats to RGBA and Blending causing artifacts

I am using float packing to encode a float value inside a RGBA texture because I don't have access to float texture unfortunately. Here are the function I am using for encoding and decoding. inline ...
0
votes
0answers
61 views

How can I add sphere falloff to my specular lighting implementation?

I'm using point light in my game and tried to add specular lighting. It looks good but when standing close to wall player can clearly see where lights end. Image from front: Image when near wall: ...
0
votes
1answer
73 views

Encoding Float to RG/RGBA and Blending

Encoding a float value inside a RG or RGBA texture is very interesting and useful but it is also become quite useless when you use blending as the result and the values might be altered because of ...
0
votes
1answer
53 views

How is this particular HLSL condition treated with respect to compile- or run-time evaluation?

Let's say I have this very simple pixel shader (cbuffers and other stuff omitted) float4 PS(VertexOut pin, uniform bool useLighting) : SV_Target { float4 retColor = gDiffuseMap.Sample( sampler0, ...
0
votes
2answers
138 views

Can someone explain to me how setting shader parameters aren't a bottleneck?

I am trying to understand this. So I have a bunch of models that need to be rendered. Each model most likely has various "sub meshes" with their own diffuse, specular, etc textures. So for each of ...
1
vote
0answers
53 views

Blending Lightmaps and Dynamic Texture Shadows in HLSL

I'm using Gile[s] as my lightmapper and my engine can execute HLSL scripts with DirectX 9. I would like to accomplish something like this for performance reasons. I was told that this technique can ...
0
votes
1answer
58 views

Need help creating points in an array

I'm creating a lightning geometry shader using hlsl that creates an array of points based on an arbitrary number of generations. The gist of what I want to accomplish is here: ...
2
votes
1answer
53 views

The way of avoiding branching for textured and not-textured objects

I know that branching is an expensive operation on GPU (not as much as it used to be, but still). The most common situation where I use branching is when I have both textured and non-textured ...
0
votes
0answers
129 views

HLSL 5.0 assembly shows tons of ieq / add / or instructions for array indexing in loop

First of all, I have to apologize for the long code samples, but their content is not so important. Besides they are really simple and I tried to comment as much as possible. I'm working on a pixel ...
1
vote
3answers
186 views

2D HLSL World position

I'm trying to get world position from my vertex shader to my pixel shader so that I can disable the shader once a preset X coordinate has been passed (no shading once I'm over X). Getting the screen ...
0
votes
1answer
153 views

Directx: HLSL Texture based height map. (Shader 5.0)

I'm trying to implement a GPU based height map the simplest (and fastest) way that I know how. I passed a (.png, D3DX11CreateShaderResourceViewFromFile()) texture into the shader, and I'm attempting ...
1
vote
0answers
165 views

Screen Space Decals Normal Mapping [closed]

I'm trying to implement screen space decals with normal mapping support. Up to this point I'm able to project decals into my scene. I'm even able to sample from the normal map in decal space. I ...
1
vote
1answer
92 views

How to diagnose the problem when the input assembler and the vertex shader look correrct, but the Output Merger is wrong? [closed]

I'm porting some OpenGL code to Direct X 11. I ended up with nothing being drawn on the screen. I reverted to a simple program, which I am writing about here. I'm now trying to use the Graphics ...
0
votes
1answer
114 views

Compiling a shader with fxc results in invalid ps_5_0 output semantic 'COLOR0'

I'm attempting to compile a shader at the command prompt. What am I doing wrong that would make it generate this error? fxc /Od /Zi /T ps_5_0 /E "ps_main" /Fo "basic.pso" "basic.ps" Here is the ...
-2
votes
1answer
96 views

SharpDx Custom effect in SpriteBatch

I'm trying to port a blur effect from an XNA project over to SharpDx, and I get a "Null Reference Exception" wich I'm unable to find the reason for. private void blurShadow(RenderTarget2D to, ...
1
vote
2answers
100 views

Dynamic Flow Control in HLSL with Array References

I'm trying to do lighting calculations for an array of point lights in HLSL. I simply want to pass light direction vectors from the vertex shader to the pixel shader. Here is sample code: static ...
0
votes
2answers
106 views

Transparency using HLSL in XNA

I currently working on Depth Data on Kinect SDK v1.8 on XNA and I wanna show an Image Inside the Depth view of Human body. the image below is just an example of what I wanna do : ...
1
vote
0answers
99 views

Geometry shader: Dynamic output?

I'm currently using a geometry shader to generate grass blades out of single root points that are layed out in a grid. For each root point, I generate a grass blade with, right now, a constant number ...
0
votes
0answers
56 views

Very subtle HLSL syntax change causes compliation error

The following HLSL works and compiles: texture2D renderTarget; float h; // declared here sampler GetRenderTarget = sampler_state { texture = <renderTarget>; }; float3 GetHsvFromRgb(float3 ...
2
votes
1answer
76 views

HLSL compiled code

I've been using RenderDoc for debugging my shaders, and one thing that struck me as odd is that sometimes, after stepping through the debugger, I notice some vector attributes are interchanged, for ...
0
votes
1answer
131 views

Fullscreen triangle pass and texcoords

So I have a fullscreen triangle shader like this: #ifndef FULLSCREEN_TRIANGLE_VERTEX_HLSL #define FULLSCREEN_TRIANGLE_VERTEX_HLSL // Variation on Timothy Lottes FXAA vertex shader, for CCW frontface ...
1
vote
1answer
429 views

How does Direct3D know if a constant buffer is for the vertex or pixel shader?

I have a question about constant buffers in directX 11. They really confuse me and after searching on google most sites simply supply sample code without explaining how it works. I am probably ...