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 and tessellation shaders. It is analogous to for OpenGL.

Resources

1397 questions
81
votes
2 answers

Do conditional statements slow down shaders?

I want to know if "if-statements" inside shaders (vertex / fragment / pixel...) are really slowing down the shader performance. For example: Is it better to use this: vec3 output; output = input*enable + input2*(1-enable); instead of using…
Thomas
  • 1,672
  • 2
  • 17
  • 34
35
votes
5 answers

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

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.…
StrG30
  • 630
  • 1
  • 8
  • 18
27
votes
6 answers

Normalizing from [0.5 - 1] to [0 - 1]

I'm kind of stuck here, I guess it's a bit of a brain teaser. If I have numbers in the range between 0.5 to 1 how can I normalize it to be between 0 to 1? Thanks for any help, maybe I'm just a bit slow since I've been working for the past 24 hours…
meds
  • 17,850
  • 30
  • 131
  • 265
17
votes
3 answers

How do I calculate pixel shader depth to render a circle drawn on a point sprite as a sphere that will intersect with other objects?

I am writing a shader to render spheres on point sprites, by drawing shaded circles, and need to write a depth component as well as colour in order that spheres near each other will intersect correctly. I am using code similar to that written by…
David
  • 12,749
  • 6
  • 61
  • 126
15
votes
1 answer

Glsl mod vs Hlsl fmod

I've implemented the spiral GLSL shader described in this question in HLSL, but the results are not the same. I think it's because of the mod function in GLSL that I've translated to fmod in HLSL. I suspect that this problem only happens when we…
Ivo Leitão
  • 307
  • 1
  • 4
  • 16
15
votes
3 answers

Why does HLSL have semantics?

In HLSL I must use semantics to pass info from a vertex shader to a fragment shader. In GLSL no semantics are needed. What is an objective benefit of semantics? Example: GLSL vertex shader varying vec4 foo varying vec4 bar; void main() { ... …
gman
  • 83,286
  • 25
  • 191
  • 301
13
votes
4 answers

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

I am following an example book called: Introduction to 3D Game Programming with DirectX 11 It is all written in VS2010. I would like to try using VS2013... It is an example project for Windows Desktop Program I have a program with the following in…
Jimmyt1988
  • 18,656
  • 34
  • 113
  • 210
11
votes
1 answer

Some simple XNA/HLSL questions

I've been getting into HLSL programming lately and I'm very curious as to HOW some of the things I'm doing actually work. For example, I've got this very simple shader here that shades any teal colored pixels to a red-ish color. sampler2D…
inline
  • 685
  • 1
  • 7
  • 16
11
votes
1 answer

How much performance do conditionals and unused samplers/textures add to SM2/3 pixel shaders?

We've one pixel shader in HLSL which is used for slightly different things in a few places, and as such has several conditional blocks meaning that complex functionality is omitted in some cases. As well, this means we pass textures as sampler…
Mr. Boy
  • 52,885
  • 84
  • 282
  • 517
11
votes
5 answers

VS2010 - HLSL Intellisense?

Are there any free components out there that will give highlighting and/or intellisense for HLSL? I've seen mentions of something called "InteliSense.Net," but the author's site is down and I can't find a download anywhere.
3Dave
  • 26,903
  • 17
  • 82
  • 145
11
votes
1 answer

How to implement SLERP in GLSL/HLSL

I'm attempting to SLERP from GLSL (HLSL would also be okay as I'm targeting Unity3D) I've found this page: http://www.geeks3d.com/20140205/glsl-simple-morph-target-animation-opengl-glslhacker-demo It contains the following listing: #version 150 in…
P i
  • 25,182
  • 33
  • 133
  • 229
10
votes
2 answers

Pixel Shader Effect Examples

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,…
Chris Nicol
  • 9,726
  • 6
  • 35
  • 48
10
votes
1 answer

HLSL for loop with Shader Model 2.0: Error X3511 unable to unroll loop

When compiling the following for loop in my HLSL shader under Shader Model 2.0, I'm getting Error X3511. for (int x = -5; x <= 5; x++) { for (int y = -5; y <= 5; y++) { ... The error reads as follows: unable to unroll loop, loop…
barnacleboy
  • 499
  • 8
  • 18
9
votes
1 answer

pow(0, 2.2) gives 1 in a hlsl pixel shader?

But pow(0, 2.0) gives 0 Seems that any float exponent gives 1 while integer exponents give 0. I am using DirectX 9 and hlsl compiler "D3DCompiler_43.dll". Confirmed that on Nvidia and Ati cards. I am confused! Is that some kind of known behaviour or…
Ole Dittmann
  • 1,654
  • 1
  • 12
  • 20
9
votes
2 answers

Loading a precompiled HLSL shader into memory for use with CreatePixelShader

I need to load a compiled pixel shader into memory to use with CreatePixelShader but I can't use any D3DX calls. How can I do this? (I'm using Visual Studio 2010 as my compiler and C++ as the language)
Calin Leafshade
  • 1,175
  • 1
  • 11
  • 21
1
2 3
93 94