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
3
votes
1 answer

Projection matrix causing inaccuracy in clip-space depth calculation?

Currently working with SlimDX's Direct3D 11 bindings and having significant difficulty with my shader, the source of which follows: /* * * * * * * * * * PARAM STRUCTS * * * * * * * * * */ struct VSPointIn { float3 pos : POSITION; …
Dave K
  • 56
  • 4
3
votes
1 answer

HLSL color bleeding when using a texture atlas

I'm making a game in C# / XNA. I'm currently working on the shader I'll be using for the terrain. I'm using a texture atlas for speed and efficiency but I'm experiencing texture/color bleeding between tiles: https://i.stack.imgur.com/249Ha.png I get…
user2002287
  • 51
  • 1
  • 6
3
votes
1 answer

Bind Texture2D and TextureCube

I need to pass both a Texture2D and a TextureCube to my pixel shader at the same time. I was previously sending an array of texture's but found that I was not able to send a textureCube as well as this. This question mentions something called…
Questioning
  • 1,903
  • 1
  • 29
  • 50
3
votes
1 answer

Using VS2012 Shader Designer to create XNA shader

I created a shader that seems to work nicely in the VS2012 shader designer. It saves it in DGSL format, which I then exported to HLSL. I thought I'd be able to use this in an XNA project, but there are two things that are very new to me and I'm…
Dave
  • 1,521
  • 17
  • 31
3
votes
2 answers

HLSL 3 Can a Pixel Shader be declared alone?

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

Direct3D 11 CreatePixelShader (E_INVLIDARGS)

I am using fxc.exe utility from directx sdk to compile my shaders and then load them as byte array in my application (with this code): inline std::vector ReadToByteArray(char* filename) { std::ifstream file; …
acrilige
  • 2,436
  • 20
  • 30
3
votes
1 answer

HLSL (.fx file) Syntax Highlighting in VS2010?

Is there any way to get syntax highlighting (and maybe something like "Format Document") for fx files in visual studio 2010 ? It is quite hard to debug more complex HLSL shader code without it. I know I could use fx composer but I would rather not…
ares_games
  • 1,019
  • 2
  • 15
  • 32
3
votes
1 answer

Rendering a circle with a pixel shader in DirectX

I would like to render a circle on to a triangle pair using a pixel shader written in HLSL. There is some pseudocode for this here, but I am running in to one problem after another while implementing it. This will be running on Windows RT, so I am…
Justin R.
  • 23,435
  • 23
  • 108
  • 157
3
votes
2 answers

How to write the header file if I want to compile HLSL at build time to header files,

MSDN says you can compile your .hlsl files into byte arrays that are defined in header files. And this is the code they give. #include "PixelShader.h" ComPtr m_pPixelShader; hr = pDevice->CreatePixelShader(g_psshader,…
user955249
3
votes
2 answers

Undesired regular Perlin noise

I'm trying to implement fBm onto a sphere for a planet. To create my sphere, I convert it to such from a cube. Unfortunately, the fBm that gets generated appears as mirrored patches. In addition, it only does it on 2 faces (wrapping the values for…
Skully
  • 31
  • 1
3
votes
1 answer

Omnidirectional Shadow Mapping Spot Lights

I was implementing omnidirectional shadow mapping in a deferred renderer but am having trouble solving this problem: Here is a picture: This is what happened when I just position six spot lights pointing along each axis in positive and negative…
3
votes
1 answer

fullscreen quad in pixel shader has screen coordinates?

i have a 640x480 rendertarget (its the main backbuffer). im passing a fullscreen quad to the vertex shader, the fullscreen quad has coordinates between [-1,1] for both X and Y, that means that i only pass the coordinates into the pixel shader with…
sap
  • 1,188
  • 1
  • 14
  • 25
3
votes
2 answers

HLSL getting values from texture position

I have mapped some values into my texture on my alpha channel. Actually I use my texture as 2Darray. What I need is a way to read the alpha value of the map at position e.g. [4][5] (representing x and y) I need the returned value available in my…
marius
  • 1,118
  • 1
  • 18
  • 38
3
votes
1 answer

hlsl dot function

I was looking over an effect file I found in the DirectX SDK , and the only part that really threw me was the Dot() function. That led me to a Wikipedia page about dot products that made no sense to me. What is a dot product?
Code Monkey
  • 889
  • 3
  • 11
  • 27
3
votes
2 answers

How do you count instructions in HLSL?

When I use the following code: #define MAX_RADIUS 55 #define KERNEL_SIZE (MAX_RADIUS * 2 + 1) ... float[] kernel[KERNEL_RADIUS]; ... float4 PS_GaussianBlur(float2 texCoord : TEXCOORD) : COLOR0 { float4 color = float4(0.0f, 0.0f, 0.0f, 0.0f); …
Darkhydro
  • 1,992
  • 4
  • 24
  • 43