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

HLSL - How can I set sampler Min/Mag/Mip filters to disable all filtering/anti-aliasing?

I have a tex2D sampler I want to only return precisely those colours that are present on my texture. I am using Shader Model 3, so cannot use load. In the event of a texel overlapping multiple colours, I want it to pick one and have the whole texel…
RJFalconer
  • 10,890
  • 5
  • 51
  • 66
0
votes
1 answer

HLSL TextureSampler Color returning white

I was following a tutorial to build a basic effect texture in XNA/Monogame. Everything seems to be working but if Percentage = 0 it will always return the color as white. I am having a hard time wrapping my head around why this would be happening.…
servvs
  • 100
  • 1
  • 9
0
votes
0 answers

What is proper input element description for this structure in direct3d 11 to input assembler state?

I have this following struct which I use to describe vertexes to input assembler stage: struct Vertex3D { XMFLOAT3 Position; // position x, y, z XMFLOAT4 Color; // color r, g, b, a }; I know I could use {"POSITION", 0,…
The amateur programmer
  • 1,238
  • 3
  • 18
  • 38
0
votes
2 answers

How can I optimise an SM3 HLSL pixel shader by only executing complex code for some pixels?

I have a really complex HLSL shader doing tons of texture reads, using shader model 3 in Direct3D9. The complex code is only used at some pixels so I put an if-statement around that block of code. To my surprise this gives no performance gain at…
Oogst
  • 358
  • 2
  • 14
0
votes
0 answers

Color in floating-point texture of HLSL

In the HLSL Pixel Shader, the code is as follows: float Exposure_Level; sampler Environment; float4 ps_main(float3 dir: TEXCOORD0) : COLOR { // Read texture and determine HDR color based on alpha // channel and exposure level float4 color…
Noah
  • 135
  • 3
  • 11
0
votes
1 answer

Gradient-generating shader with arbitrary color components

The task is: shader takes in a constant color, then generates pixel colors according to their positions by replacing two of four color components (RGBA) with texture coordinates. With hardcoded component set it will be like: float4 inputColor :…
Pavel Tupitsyn
  • 8,393
  • 3
  • 22
  • 44
0
votes
1 answer

Custom HLSL shader making weird patterns across icosphere

really hoping that someone can help me here - I rarely can't resolve bugs in C# since I have a fair amount of experience in it but I don't have a lot to go on with HLSL. The picture linked to below is of the same model (programmatically generated on…
0
votes
1 answer

SharpDX D3D11 VertexElement Format Mismatch?

I have a shader that no longer draws correctly. It was working in XNA, but had to be rewritten for DX11 and SharpDX and now uses shader model 5. There are no exceptions and the shader effect compiles fine, no debug-layer messages from the device…
selkathguy
  • 1,171
  • 7
  • 17
0
votes
1 answer

issues converting HLSL shader to shaderLab

I've been working on a project which involves me working with shader coding something I'm not familiar with. I've been provided some HLSL code from another team member and have been trying to implement in unity. Not being able to use the provided…
David Parsonson
  • 585
  • 6
  • 23
0
votes
1 answer

Shadow Mapping Issue with DirectX9 and HLSL

I am attempting to teach myself shadow mapping to integrate it into my game, and I am currently using this tutorial (without the soft shaders for…
Carradine
  • 41
  • 2
  • 9
0
votes
1 answer

How do you find the Y position of a point between four vertices? HLSL

Let's say there is a grid terrain for a game composed of tiles made of two triangles - made from four vertices. How would we find the Y (up) position of a point between the four vertices? I have tried this: float diffZ1 = lerp(heights[0],…
Obi-Dan
  • 113
  • 1
  • 8
0
votes
1 answer

HLSL Pixel Shader 5.0 NdotL lighting sample

I am going through a tutorial for Pixel Shader 5.0 using directX. I was doing fine until I got to the fourth lesson, which has me create a PixelShader.hlsl file with the following code: cbuffer ConstantBuffer : register( b0 ) { matrix World; …
Flopdong
  • 259
  • 1
  • 3
  • 15
0
votes
2 answers

Whats Wrong With This HLSL Shader ?

What am I Doing Wrong ? if I Compile This Get an Error cbuffer MatrixBuffer { matrix worldM; matrix viewM; matrix projectionM; }; struct VertexInput { float4 position : POSITION; float4 color : COLOR; }; struct PixelInput { …
user3460574
0
votes
0 answers

DirectX11 Terrain Smoothing Technique

I have a terrain system set up which utilizes a quad tree and a gray scale height map to draw the terrain. I create one 64x64 flat triangulated grid, which is then drawn at various scales based on the quad tree node selection. In the vertex shader,…
Ben Trapani
  • 271
  • 1
  • 4
  • 11
0
votes
2 answers

unity3d shaders level of detail

Maybe questions seems strange , but , please take a look at the summarized shader code listed below : Shader "AngryBots/PlanarRealtimeReflection" { Properties { ... } SubShader { LOD 400 Tags {…
S.A.Parkhid
  • 2,772
  • 6
  • 28
  • 58