Questions tagged [hlsl]

HLSL(High Level Shader Language) is a proprietary shading language developed by Microsoft for use with the Microsoft Direct3D API

HLSL is a C-like language developed by Microsoft and it's used in Direct3D API to define shaders. HLSL is used by Direct3D 9, and is required by the unified shader model in Direct3D 10+.

HLSL can be used to define pixel shaders, vertex shaders, geometry shaders, compute shaders, tessellation shaders, raytracing shaders and mesh shaders. It is analogous to for OpenGL.

Vulkan SDK and DirectX Shader Compiler also supports compiling HLSL shaders into SPIR-V, enabling its use in Vulkan applications.

Resources

1642 questions
4
votes
2 answers

Advanced moiré a pattern reduction in HLSL / GLSL procedural textures shader - antialiasing

I am working on a procedural texture, it looks fine, except very far away, the small texture pixels disintegrate into noise and moiré patterns. I have set out to find a solution to average and quantise the scale of the pattern far away and close…
bandybabboon
  • 2,210
  • 1
  • 23
  • 33
4
votes
2 answers

How can I feed compute shader results into vertex shader w/o using a vertex buffer?

Before I go into details I want outline the problem: I use RWStructuredBuffers to store the output of my compute shaders (CS). Since vertex and pixel shaders can’t read from RWStructuredBuffers, I map a StructuredBuffer onto the same slot (u0/t0)…
4
votes
1 answer

Specifying the target layer of a 3D rendertarget in vertex shader? [HLSL]

When working in HLSL/Directx11 I see there are two methods for binding a 3D rendertarget: either you bind the entire target or you bind it while specifying a layer. If you bind the entire target how does one specify the layer in HLSL code to which…
James
  • 1,973
  • 1
  • 18
  • 32
4
votes
2 answers

Two constant buffers with same elements

Suppose i have a following HLSL vertex shader fragment with constant buffers: cbuffer matrixBuffer { matrix worldMatrix; matrix viewMatrix; matrix projectionMatrix; }; cbuffer matrixBuffer2 { matrix worldMatrix2; matrix…
user1387886
  • 122
  • 1
  • 7
4
votes
2 answers

How to enable Hardware Percentage Closer Filtering?

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…
4
votes
1 answer

HLSL: Getting texture dimensions in a pixel shader

I have a texture and I need to know its dimensions within a pixel shader. This seems like a job for GetDimensions. Here's the code: Texture2D t: register(t4); ... float w; float h; t.GetDimensions(w, h); However, this results in an error: X4532:…
Justin R.
  • 23,435
  • 23
  • 108
  • 157
4
votes
3 answers

Vertex shader world transform, why do we use 4 dimensional vectors?

From this site: http://www.toymaker.info/Games/html/vertex_shaders.html We have the following code snippet: // transformations provided by the app, constant Uniform data float4x4 matWorldViewProj: WORLDVIEWPROJECTION; // the format of our vertex…
meds
  • 21,699
  • 37
  • 163
  • 314
4
votes
1 answer

Pix, A couple of issues I'm not understanding

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…
Bushes
  • 1,010
  • 1
  • 18
  • 37
4
votes
1 answer

loading from RWTexture2D in a compute shader

I understand there's a limitation in HLSL shader model 5.0 where one cannot load data from a non-scalar typed RWTexture2D resource. That is to say, the following is illegal: RWTexture2D __color; float4 c = __color[PixelCoord]; //…
Fooberman
  • 626
  • 5
  • 14
4
votes
1 answer

Vim regex fails matching square brackets on start of line

I'm writting a syntax file for Direct3D and I have a problem with the attributes: [unroll] for(int i = 0...) Here, "unroll" is an attribute. I'm using a regex to find some keywords inside square brackets to identify them as attributes. The regex…
Marc Costa
  • 95
  • 6
4
votes
4 answers

HLSL Pixel Shader - Change Image Color For Specific Hue

I'd like to write a pixel shader that takes an input image, and converts all of the colors of one Hue range (i.e. HSV) into another Hue Range. My motivation is simple: I want to color a bunch of different textures differently, but i don't want to…
Mark P Neyer
  • 1,009
  • 2
  • 8
  • 19
4
votes
1 answer

DirectX Shader not working right?

Okay so I have this shader for ambient occlusion. It loads to world correctly, but it just shows all the models as being white. I do not know why. I am just running the shader while the model is rendering, is that correct? or do I need to make a…
dvds414
  • 143
  • 1
  • 9
4
votes
0 answers

DGSL (Directed Graph Shader Language) editor in Visual Studio 2012

I'm using the DGSL (Directed Graph Shader Language) editor in VS 2012 to create shader that I wish to export to HLSL and then load in MAYA http://msdn.microsoft.com/en-us/library/hh315733.aspx At this stage I cannot for the life of me figure out to…
Jamie
  • 271
  • 1
  • 2
  • 11
4
votes
2 answers

Is fmod equivalient to the % operator in HLSL

The following statement is valid HLSL: float3(300.0f,200.0f,100.0f) % 256.0f Apparently te % operator works on floating point numbers? How is that different from fmod? Is the following statement equivalent? fmod(float3(300.0f,200.0f,100.0f),…
Johan
  • 660
  • 1
  • 6
  • 13
4
votes
1 answer

Fill clipped area with color

I'd like to achieve an effect in XNA where I move a clipping plane through an object, and the object gradually disappears WHILE the clipped area is filled with a custom color or texture. This is what I was able to achieve via HLSL: And this is what…
theAdam
  • 65
  • 12