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
0
votes
3 answers

Algorithm for the Winding Number of a Closed Contour

Let's say I have a contour shape defined by two functions x(p) and y(p), where p is the distance traveled along the perimeter of the shape, normalized between 0 and 1. For example, a unit circle about the origin would be defined as x(p) = sin(2 *…
NmdMystery
  • 2,778
  • 3
  • 32
  • 60
0
votes
1 answer

Building an HLSL shader with FXC.exe, what's the simplest way to get the byte code itself in a binary file?

For example, let's say I have "HLSLStructureTest.hlsl", and I want to have a binary file "HLSLStructureTestBytecode.bin" which contains the byte code for my compiled shader. Is there maybe an option I can include when running FXC.exe to get that? …
MNagy
  • 423
  • 7
  • 20
0
votes
1 answer

HLSL Primitive type size issue

I was under the impression that the type float2x4 would occupy 32 bytes, however when I declare the following float2x4 varname[100], it occupies 64*100 bytes, not 32*100 bytes as expected. How come? Perhaps I'm not seeing something related to the…
Miguel P
  • 1,262
  • 6
  • 23
  • 48
0
votes
0 answers

Nondeterministic artifacts in HLSL shader

I have a HLSL shader (compiled using fxc and ps_2_b) that is giving me flickering artifacts. First I need to establish that all the variables seem to be constant, and their values with the following shader: float4 src_rect : register(c0); float4…
dsffsd
  • 1
  • 1
0
votes
2 answers

Shader value remap - Blend Falloff

I would like to know if there's a way to remap a value that goes from 0 to 1 constantly like this. Into those values (those are examples). This might be some function transformation but I can't find the way to do that. I've tried using a lookup…
MaT
  • 1,556
  • 3
  • 28
  • 64
0
votes
1 answer

While loop in compute shader is crashing my video card driver

I am trying to implement a Binary Search in a compute shader with HLSL. It's not a classic Binary Search as the search key as well as the array values are float. If there is no matching array value to the search key, the search is supposed to return…
dnlbschff
  • 21
  • 4
0
votes
1 answer

Strange way of declaring variables in hlsl

I found this example of implementing Phong lightning in hlsl. It is first snippet where I see that strange syntax where you declare variables in hlsl like here: float3 materialEmissive : EMISSIVE; float3 materialAmbient : AMBIENT; In usual instead…
bartosz.baczek
  • 1,567
  • 1
  • 17
  • 32
0
votes
1 answer

Error 'overlapping register semantics not yet implemented' in VertexShader

I am trying to perform diffuse reflection in hlsl. Currently I am working on vertex shader. Unfortunatelly I get following error, when trying to compile with fxc.exe: C:\Users\BBaczek\Projects\MyApp\VertexShader.vs.hlsl(2,10-25) : error X4500:…
bartosz.baczek
  • 1,567
  • 1
  • 17
  • 32
0
votes
1 answer

C# XNA EffectPass.Apply() not doing anything

What I would like to do is to be able to draw a specific set of sprites within a spriteBatch with additive blending. The problem is that the draw order that they're drawn in needs to be preserved and I can't draw everything else in the SpriteBatch…
Darthmarshie
  • 87
  • 1
  • 11
0
votes
1 answer

Invisible edges when applying pixel shader to model

I am currently working on a simple shader in hlsl. What I am trying to achieve is 'highlight' effect when cursor is placed on the object in my screen. My issue is that, the pixel shader doesn't work correctly: In the picture number 1 there is an…
bartosz.baczek
  • 1,567
  • 1
  • 17
  • 32
0
votes
1 answer

HLSL: Cut a texture radially

I'm currently having a pixel shader: float4 PixelShaderFunction(float2 coords: TEXCOORD0) : COLOR0 { float4 color = tex2D(Sampler0,coords); float dx = coords.x - 0.5f; float dy = coords.y - 0.5f; float tpos = dx * dx + dy * dy; if(tpos <= 0.25f…
0
votes
1 answer

Reading HLSL semantics & annonations with DirectX 11 API?

I have an shader (in .fx file) that has parts like that (which are using SAS): cbuffer UpdatePerObject : register(b1) { float4x4 worldViewIT : WorldViewInverseTranspose < string UIWidget = "MyName"; >; float4x4 world : World < string…
PolGraphic
  • 3,233
  • 11
  • 51
  • 108
0
votes
0 answers

What is the correct sampler state to fit a texture to my polygons?

I have a "line" shader which draws lines using two triangles (bisect the line). That all works. Today I thought I'd draw star trails and add a texture to it: My problem, however, is that they render like this: So they do not appear to get…
Dave
  • 1,521
  • 17
  • 31
0
votes
2 answers

Setting both a constant and variable buffer in a shader

My vertex shader has both a constant buffer and a variable buffer. When I go to Map() and set their data, however, I have no idea how to tell the two buffers apart. My code is as follows, and you can see that I'm using "Subresource 1" which is NOT…
Dave
  • 1,521
  • 17
  • 31
0
votes
1 answer

What blend mode do I want so that two 0.2 alphas add up to a 0.4 alpha on a pixel?

Pretty basic: If I draw two polygons (lines in appearance, but they're triangulated quads for the lines) with 0.2f in the Alpha, I'd like them to be brighter where they overlap. Currently, no matter what blending op I've tried, the results vary but…
Dave
  • 1,521
  • 17
  • 31