Questions tagged [hlsl]

A proprietary shading language developed by Microsoft for use with the Microsoft Direct3D API.

Filter by
Sorted by
Tagged with
0
votes
1answer
54 views

Strange diagonal line artifact in simple ripple shader

I have a simple shader, converted from GLSL to HLSL. This is the original: https://www.shadertoy.com/view/tdKSWG The problem is that there is a very visible diagonal line artifact going from UV(1,1) ...
0
votes
0answers
42 views

Reconstructing Position from Depth - Inverted Y?

I am currently trying to understand the following wierd result. This is basically from deferred shading in monogame/XNA. For Comparison I also write the ViewSpace Position in a Buffer and the ...
0
votes
1answer
35 views

Recalculating normals on a tesselated cubed sphere with heightmap applied

I'm learning about the graphics pipeline using C++, HLSL and DirectX 11 for my course. I'm currently tesselating a cubed sphere with an applied height map. My issue is figuring out how to recalculate ...
1
vote
0answers
34 views

How can I unpack texture data following a 16 * 8-bit pattern?

Is possible to unpack texture data following a specific bit packing scheme? I have read that texture data in HLSL can be read in as 4 floats of 32 bits each totaling 128 bits. The packing scheme I'm ...
0
votes
0answers
51 views

Simple water reflection is going wrong

i added simple code to my water shader that should add reflections of objects above the water line. The problem is that the reflection is only correct when the camera is in a certain angle to the ...
0
votes
1answer
67 views

Shaders and Distortion Effect (Monogame)

I am building a top down 2D space shooter game with sandbox elements. I am working on the shield for the spaceship now and am not having luck. I am attempting to make a distortion effect shader, but ...
0
votes
1answer
38 views

Writing Hull shader in directx

hey i am studying different types of shaders in directx. and it comes to hull shader. so i write hlsl codes for both constant hull shader and control point hull shader in same file in visual studio ...
0
votes
2answers
42 views

How to write properly shader with gradient based on vertex-color?

I took 4 squares with the outer corners painted in black, and the other ones in white. For some reason, they have a different gradient. ...
0
votes
2answers
95 views

HLSL - Shore fading in a water shader

in my desperation while trying to achieve this (I am a HLSL noob) i try to ask my question here. I am modifying an old water shader for the game "MTA San Andreas" (the multiplayer modification). MTA ...
1
vote
1answer
60 views

Problems implementing shadow maps in directx

I am trying to implement shadow maps in my Dx11 rendering engine. I created a shadow map texture2d, a shader resource view, a depth stencil, a viewport, and a rasterizer state, as recommended by ...
0
votes
0answers
32 views

Pixel Shader Displacement and Lighting

I'm doing some displacement mapping on a grid. Ambient light works well as seen in the picture but I cannot get the directional light working. When adding directional light, grid is yellow in color. ...
0
votes
0answers
55 views

Shader code not working

While compiling the following code. I get a error ...
0
votes
1answer
46 views

Rotate mesh to normal

I have some instanced geometry (basic tube meshes) laid out in a grid, and I have a noise texture (normal map) that I want to use to rotate my instances with. So head pixel in my texture is a normal ...
1
vote
1answer
58 views

Rendering colors from a texcoord output

I'm trying to implement a faster alternative to super-sampling for my isometric 2d monogame game (for when the view is zoomed out). The idea was that I would render the texture coordinates to the ...
0
votes
0answers
31 views

HLSL Texture Sampling Instability

I'm having some very strange behavior trying to calculate gradients in a shader. In both snippets, uv is the texture coordinate, duv is a float3 proportional to (1/width,1/height,0), c is tex2D(...
0
votes
1answer
28 views

Sampled texture from bitmap font produces blue glow

I'm creating a texture is DirectX 11 from bitmap fonts. I realize that I can use DXTK, but this is an exercise for me, not in learning another library. My sample code looks like this. ...
0
votes
0answers
33 views

Lighting abnormal when calculating in tangent space. Probably something wrong with coordinate transformation matrix

I'm trying to calculate lighting in tangent space. But I just keep getting abnormal results. I was modifying the book's demo code and I wander if there maybe something wrong with the transformation ...
1
vote
0answers
69 views

HLSL DXGI_FORMAT_A8_UNORM Texture - dark colors appear less opaque than white

I am trying to render a DXGI_FORMAT_A8_UNORM texture (precisely, a font bitmap) in multiple colors by specifying the color per vertex and then apply the alpha value ...
1
vote
1answer
81 views

how are semantics used when declaring a struct?

I don't understand how semantics are used in shaders. While reading Unity's shader tutorials, I come across this ...
0
votes
0answers
52 views

Calculating UV Coordinates in domain shader

Dears, I was trying to implement the terrain tutorial in Introduction to game programming by frank luna. I succeeded to implement it using the effect file. When I try to separate the Vertex, hull, ...
0
votes
2answers
203 views

Raymarching signed distance function resulting in holes on surface - step size required?

I've been learning about raymarching and signed distance functions, and I implemented a raymarching fragment shader in Unity. It works fine for geometric shapes such as cubes and spheres, but when I ...
1
vote
1answer
97 views

HLSL equivilant to “Object” data from “Texture Coordinate” node in Blender

I mocked up a shader how I wanted it with the node editor in Blender. Now I'm trying to write it in HLSL. In Blender there is a node group called "Texture Coordinate". If I use the "uv" node from the ...
1
vote
0answers
62 views

Alpha is not working in diffuse light shader

I am following this tutorials series on rastertek.com and I got a bit stuck on the Diffuse Lighting Tutorial. Particulary, the part that does not work for me is alpha channel of the light color. Here ...
0
votes
1answer
48 views

Steering constantly turning in circles

I've been working on a fish system in a compute shader but bugs have been drowning me. The latest bug had me strip almost all the functionality to track down: Fish keep turning in circles. It starts ...
13
votes
1answer
545 views

How can I make outline shader like “Life is Strange”?

I want to make sketch shader like life strange. shader has two part: 1.animated dashed line 2.noisy outline I like to know how can I make noisy outline? see outline of objects First I tried to ...
1
vote
0answers
163 views

Hard coded triangle in HLSL geometry shader doesn't show on screen

In Unity I'm planning on using a geometry shader for processing points into quads and can't quite figure out why I'm not getting output from my geometry shader. I've edited it down to a minimum ...
3
votes
0answers
115 views

Trying to get Vertexshader to work Monogame 2D

If I don't use the vertex shader, it gives me white textures which is what the default color is. Once I add the vertex shader, the screen is black. I figure it is something wrong with the Matrices I ...
0
votes
1answer
249 views

Texture Atlas and HLSL Shader for sprite tiling

I am trying to create a shader that allows to tile a specific region of a texture. This seem to be a common need however I can't seem to find any information about how to get this effect done. The ...
0
votes
1answer
43 views

Combination Lighting Shader?

I am currently working on writing a shader for combination lighting. The idea behind it is to apply directional light, point light, and spot light in a single pass. I believe I can do this by: ...
0
votes
1answer
47 views

Typical Point Light Flow?

A Quick Note This question assumes you have some knowledge about the overall rendering process and do not need clarification on rendering objects with HLSL and a <...
0
votes
1answer
61 views

Why does order matter in constant buffers?

I have a rather peculiar question remaining after solving most of my own question on StackOverflow. When creating the constant buffers used by my shaders, I've learned that the order of variables ...
0
votes
1answer
228 views

HLSL Manual Alpha Blending

I'm trying to do alpha blending manually because I only want to apply alpha blending on certain pixels. Underlying is the texture I'm writing to. This is what I got so far, but it doesn't give the ...
0
votes
1answer
210 views

DirectX 11 Compute Shader error DXGI_ERROR_DEVICE_HUNG

I am trying to use a compute shader for ray picking technology. My shader accepts: vertex buffer of all models index buffer of all models a buffer of transformation matrices of all models Offset ...
0
votes
2answers
85 views

Extracting individual components of a vector in the Source Shader Editor

I'm using the Source Shader editor and would like to mask a vector output to one or two values, yet there is no existing mask node, as far as I can see. What HLSL code should I use to output what I ...
1
vote
1answer
108 views

What does vertex:disp and tessellate:tessEdge mean? [Shader] [Unity]

I came across the following declaration on unity tutorial #pragma surface surf BlinnPhong addshadow fullforwardshadows vertex:disp tessellate:tessEdge nolightmap ...
0
votes
1answer
132 views

Difference between texture.Load and texture.Sample(PointSampler,..) in HLSL/Dx

Conceptually, I understand the difference between load and sample but I want to know if essentially point sampling and load do the same thing when it comes to selecting a texture value (ignoring an ...
1
vote
0answers
168 views

Is there a quick-reference card for HLSL (DX9 or DX11)?

Does anyone know of a DX9 or DX11 counterpart to the GLSL quick-reference card from Khronos? The GLSL card is pages 8-11 here, and lists preprocessor directives, operators, types, and builtin ...
0
votes
1answer
366 views

HLSL float bitfield

In HLSL I want to store a bitfield for each color in a texture. Specifically spanning 3 floats (RGB, not alpha). Since each float has to be between 0 and 1 I can only use the significand/mantissa of ...
1
vote
2answers
782 views

2D Blizzard/Snowstorm Effect

How can I implement a blizzard/snowstorm effect in a 2D platformer? I have a particle system for snow particles, but I need some kind of windblown texture similar to this as well: How do I create this ...
0
votes
1answer
148 views

Using multiple textures in Monogame HLSL Effect shader?

My Monogame HLSL shaders only successfully sample one texture (besides the screen). Any additional textures I try to sample end up with the same texture data as the screen. I've found people with ...
0
votes
2answers
88 views

2D Camera Movement Temporal Reprojection

Having an Orthographic Camera with its View Projection Matrix given from the current and last frame, how to reproject the previous frame to the new one?
1
vote
0answers
37 views

Effective way of transferring data to HLSL shader in MonoGame and storing it

I'm toying around with HLSL shaders in monogame. Lets say I want to use a structure in my shader which is like this: ...
0
votes
1answer
73 views

Difficulty with Texture Alphas - HLSL

UPDATE 3: I have fixed the issue by reordering my effects (see my answer for details.) Anyone who wants to post more information based on that answer (either in an answer or in the comments) would be ...
0
votes
1answer
654 views

HLSL registers and slots

I'm learning DirectX11 and since I'm beginning to write some shader code I don't understand the difference between binding slots and HLSL registers. The shader model 5.0 introduced the keyword ...
0
votes
0answers
49 views

Projective texturing in DirectX11

I'm trying to implement reflections on flat surfaces and render a simple scene with a reflection. So I'm rendering the scene from the point of view of a camera symmetrical to the reflection plane and ...
0
votes
2answers
83 views

Alpha Blending older Images

I am working on re-writing an old game, and have faced some issues with the older images that were used, the first thing we done was convert all the old images and set the alpha channel on black ...
0
votes
1answer
207 views

Specular light for DirectX11

I illumine model through model illumine of Phong. Ambient and diffuse light’s constituent work well, but specular works wrong. Under this message I sent screenshoots: 1) ambient and diffuse 2) ...
2
votes
1answer
2k views

How does the following code generate a full screen quad?

How does this ...
0
votes
1answer
178 views

What does declaring a const float within a function do? (CGFX)

I've been working with this piece of code to get the mip map level that I should sample for a texture that I got off a forum somewhere. I noticed that they use a const float. Now from what I ...
2
votes
1answer
1k views

Why do these DirectXMath functions seem like they return column-major matrics?

I know these questions have been asked a million times in various formats, but I'm getting weirdly skeptical about some of the row-major vs. column-major claims about the DirectXMath library. If I ...