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

DirectX10 Only one rendertarget is drawn to

So I have added MRT to my program. The Problem: My two textures (normalMap and positionMap) are empty (only filled with the clearcolor).. I use them like this: Inside of my header: ID3D10RenderTargetView** m_ppBuffer; ID3D10Texture**…
PuRe
  • 179
  • 2
  • 13
0
votes
1 answer

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 question regards optimally writing this expression: x…
Russell Trahan
  • 783
  • 4
  • 34
0
votes
2 answers

SetMatrix() does not copy all values to HLSL

I want to use the contents of a vector of D3DXMatrices to my shader. m_pLightMatrices->SetMatrixArray(¤tLightMatrices[0].m[0][0],0,numLights); As we know the internals of a vector this poses no problems (as it is just a dynamic array). Now…
Tili
  • 163
  • 4
0
votes
2 answers

How do I send information to an HLSL effect in DirectX 10?

I'd like to send my view vector to an ID3D10Effect variable in order to calculate specular lighting. How do I send a vector or even just scalar values to the HLSL from the running DirectX program? I want to do something like render() { //do…
pypmannetjies
  • 25,734
  • 7
  • 39
  • 49
0
votes
0 answers

Using constant buffer data as index when returning from a shader

So I have a pixelshader that blends different textures using a blend map, but I am attempting to make the blending an option. So my solution was that I calculate 3 different float3 which are in an array (0 is no blend, 1 is blend between two…
Gamewolf3000
  • 63
  • 2
  • 8
0
votes
2 answers

How does the reversebits function of HLSL SM5 work?

I am trying to implement an inverse FFT in a HLSL compute shader and don't understand how the new inversebits function works. The shader is run under Unity3D, but that shouldn't make a difference. The problem is, that the resulting texture remains…
0
votes
1 answer

Directional per-face lighting using Geometry Shader?

Because of limitations I have to calculate vertex normals inside my geometry shader. Because of this limitation the normals are per-face instead of interpolated between faces on the vertex, meaning per-pixel directional lighting is just a waste.…
ManIkWeet
  • 1,298
  • 1
  • 15
  • 36
0
votes
1 answer

Efficient way to generate normal map (from height) for all 360 degrees of a rotated image

I already have a shader that generates a normal map from a height map. Now I need to apply the effect to all 360 degrees of the rotated heightmap. Of coarse I could just apply the effect 360 times to each heighmap, but if I have already done it once…
Deniz Cetinalp
  • 901
  • 1
  • 18
  • 34
0
votes
1 answer

Use pixel shaders for textures in Direct3D9

I'm trying to use a pixel shader to display an image. I've searched around for information on how to do this, and I found this: https://msdn.microsoft.com/en-us/library/windows/desktop/bb219690%28v=vs.85%29.aspx Here is the hlsl script from there:…
NickLokarno
  • 300
  • 6
  • 20
0
votes
1 answer

CPU face flipping vs GPU face flipping?

Assuming the following shader code, would it be more efficient to generate the other side of a triangle on the CPU: letting the GPU translate double the amount of vertices by the instance/worldmatrix, or to generate it on the GPU: copying the…
ManIkWeet
  • 1,298
  • 1
  • 15
  • 36
0
votes
3 answers

How do I use/apply transparency on a pixel using a shader.fx?

I'm not sure if I'm not using the right SpriteBatch parameters or if my shader is not coded properly, but, to be simple, I'm trying to make a shader that sets the alpha of all pixels to 128. However, there seems to be only 2 possible 'alphas'.…
0
votes
2 answers

Can't get texture.Sample to work, although I can get texture.Load to work fine in Direct 3d 11 shader

In my HLSL for Direct3d 11 app, I'm having a problem where the texture.Sample intrinsic always return 0. I know my data and parameters are correct because if I use texture.Load instead of Sample the value returned is correct. Here are my…
antlersoft
  • 14,636
  • 4
  • 35
  • 55
0
votes
1 answer

Tiled fractal noise

Could someone help me with creating a fragment shader producing a tiled fractal noise. currently I'm using random noise texture and sample it with diferent resolution and sum the result. What I have to add to make it tileable. uniform float time;…
0
votes
1 answer

Draw effect XNA with multiple texture

In Xna I would like to draw my model with a custom effect.. SO I would like to get the textures from the mesh. foreach (ModelMesh mesh in model.Meshes) { foreach (ModelMeshPart part in mesh.MeshParts) …
lopata
  • 1,325
  • 1
  • 10
  • 23
0
votes
3 answers

How to wrap texture coordinates manually?

I am using C++ and HLSL and need to have my texture coordinates wrap so that the texture is tiled across a triangle. After the coordinates are "wrapped" into 0-1 range they will be rotated, so I can't simply use the texture sampler AddressU and…
Frobot
  • 1,224
  • 3
  • 16
  • 33