Stack Exchange Network

Stack Exchange network consists of 174 Q&A communities including Stack Overflow, the largest, most trusted online community for developers to learn, share their knowledge, and build their careers.

Visit Stack Exchange

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

0
votes
2answers
37 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
20 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
25 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
57 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
98 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 ...
0
votes
0answers
49 views

2D Lighting Shader Multiple Lights

For a 2D platformer, I have a 2D lighting shader with two passes, the first one draws a shadow from the closest light to the sprite and the rest of the lights will reduce the visibility of the shadow ...
0
votes
0answers
27 views

Using a light mask overlay without lighting the sky

I'm using an overlay to create a lighting effect in a 2D game. The overlay is a grey-scale mesh and I multiply each pixel of the mesh with the pixel already written to the framebuffer. This works ...
1
vote
2answers
247 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
28 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
33 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?
0
votes
0answers
42 views

Why do I have to set the rendertarget to null explicitly in MonoGame?

I'm using shaders in MonoGame. I have the following code, which works fine. It fills a scene with ambient light, and applies a 2-pass gaussian smoothing to the lightmask. I have one thing that bothers ...
0
votes
0answers
28 views

D3D12 SV_InstanceID + dynamic indexing not working?

I'm implementing geometry instancing in my engine and I am having trouble indexing the constant buffer that's holding per-instance data using SV_InstanceID. Am I doing something wrong? Here is the ...
0
votes
0answers
102 views

Add emission to shader

I wrote a shader for a targeting system. It creates a parabola of chevron arrows which slowly scroll in the direction of the trajectory. The chevrons also fade to zero alpha at the beginning and end. ...
1
vote
0answers
20 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
0answers
85 views

Chaining Multiple Shaders Together (Unity)

this is probably a really stupid issue, but I just don't know how to do it I have shader A: This one does pixel lit sprite shading. It's a cs file that just includes a ton of cgcinc files then I have ...
0
votes
1answer
47 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
133 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
28 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
1answer
44 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
85 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) ...
0
votes
0answers
26 views

Is there another to blur a cubemap other than changing mip level for PBR?

I am working on a physically based shader and have encountered a problem of high mip levels not properly blurring environmental maps. At first I've tried to linearly interpolate between two mip ...
2
votes
1answer
1k views
0
votes
0answers
43 views

Passing in 2 arrays into HLSL pixel shader

I am in the process of learning how to use DirectX (using SharpDX). If you know DirectX they are both similar SharpDX is just a wrapper for DirectX. I was able to show a triangle using an index ...
0
votes
1answer
48 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 ...
0
votes
0answers
23 views

Setting up and using an ubershader in MonoGame

I'm creating a 2D engine with MonoGame. I initially clumped objects in the scene together based on the shader they were using; however, this caused several issues, such as layer depth not being ...
2
votes
1answer
195 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 ...
0
votes
1answer
456 views

HLSL MipMap sampling in pixel shader

Using the Texture2D.Sample function, how does the pixel shader infer the mipmap level to use? Or does it use mipmap level 0? I am using the ps_4_0 shader model. And replacing Sample, with SampleLevel(...
0
votes
0answers
183 views

Depth aware blur - Kawase

I am using this Kawase Blur, to apply blur onto my buffer. But I would like to apply this blur in an uniform way, no matter the distance of the objects from the camera. I guess that I need to use the ...
1
vote
0answers
85 views

How can I rolling plane by vertex shader?

I have plane that i wanna roll it by vertex shader like this: https://www.desmos.com/calculator/mrfrugwvm5 this is my shader: ...
1
vote
0answers
49 views

dx Shader Model 3.0 break, continue, and loop attributes not recognized

I've been stuck on this problem for just too long. Long story short, the compiler returns "syntax error: unexpected token" for break, continue, [loop], [unroll] and pretty much every other attribute. ...
0
votes
2answers
118 views

Compiled shader not working?

I did a simple pixel shader that makes the texture monochrome, and it works perfectly when it is precompiled, but not when compiled (returns E_FAIL). The effect was compiled using fxc.exe with these ...
0
votes
2answers
157 views

Why doesn't my simple HLSL shader work?

I'm using Monogame to draw 2D primitives to the screen. To do that, rather than use included structures like VertexPositionColor, I wrote my own vertex class for 2D....
1
vote
1answer
74 views

Per pixel normal mapping resulting in static on normals starting on Z axis

For the past week I've been trying to implement bump mapping in DirectX 11 using the Frank Luna's '3D Game Programming with DirectX 11' book. I got it working until I tried to add a flat 2D plane ...
1
vote
1answer
146 views

Processing large multi layered images with SharpDX

I'm currently working on an image processing project that pans and zooms on multi-layer high resolution images. The goal is colorize (including color, gain and noise) ...
0
votes
1answer
173 views

How do I write to a 16-bit depth buffer using Monogame and HLSL?

I'm working on shadow mapping. Part of the implementation involves drawing 3D models to a depth buffer with recommended 16-bit depth. To that end, I'm first creating a render target as follows: ...
0
votes
1answer
37 views

about register reserved word or sementic in HLSL

I'm studying HLSL cookbook. In that sample code, author used a lot of register sementic. like this ...
0
votes
1answer
70 views

Shader Resource Binding

Im trying to set a constant buffer in my shader with a value. But getting nothing, no results. Code in shader ...
0
votes
1answer
1k views

Is there an HLSL equivalent to GLSL's “map” function?

Google has not helped me in this area. Here is the GLSL shader: ...
4
votes
1answer
116 views

How is “resolution scaling” done?

Lots of new games use Resolution Scaling as an option. At first I thought it was just Super-sampling but it does not appear to remove aliasing so I'm assuming there is more to it than that. I guess ...
0
votes
2answers
75 views

MonoGame EffectPass.Apply() doesn't work

Currently I'm doing the following: ...
0
votes
1answer
40 views

Get VertexSize of Instance in VertexShader

I'm using Unitys DrawProceduralIndirect function to directly render the content of a ComputeShader. I setup the argumentBuffer for this function as follows: <...
2
votes
1answer
44 views

Why aren't my 2D primitives visible using a custom effect?

I'm working with Monogame and rendering a triangle using the following code. ...
0
votes
0answers
226 views

Convert HLSL texture-sampling function from DX9 to DX11

How can I convert the clamp function from DX9 TO DX11? On this line clamp(TEXTURE(Texture, input.uv) * scale, 0.0, 1.0); I'm getting the error ...
0
votes
0answers
52 views

What is the most optimal way of choosing a value from an array, in HLSL?

I'm creating a HLSL DirectX 11 Uber Shader. The shader has a series of "generator" functions, where the Float outputs are mapped to Float4 components. The shader exposes which function is mapped to ...
0
votes
1answer
139 views

Sprite masking with multiple, non-equally dimensioned textures in XNA

I know this question's been asked many times before, but I can't seem to get sprite masking to work in XNA/Monogame no matter if I try the stencil method, or the shader method. Considering I'm having ...
0
votes
1answer
347 views

MonoGame HLSL fx using Multiple Textures

I'm converting an old XNA title to MonoGame and one of the HLSL fx files uses two textures. But no matter what I do, it only ever uses the screen texture while rendering the effect in MonoGame, or ...
0
votes
1answer
92 views

Why does my triangle ray intersection test always return -1.0f?

I'm trying to get the mouse click position on a terrain geometry, but multiple times in each frame; doing it on the CPU was way too slow, so I'm trying to do it with a compute shader. I can't seem to ...
1
vote
0answers
33 views

Can sampling an input texture in shader return values updated in same pass?

In my hlsl, (I am using Direct2D helpers which I guess just call tex2D), can D2DSampleInputAtOffset() return a pixel value that was only updated in that same pass ...
1
vote
4answers
600 views

Output pixel to different position from pixel shader?

Is it possible to output a pixel processed by my pixel shader to a different position? For example if SV_POSITION of the pixel is 14,26, can I change it to 14,27? I see there are only two possible ...
3
votes
1answer
211 views

Reading depth buffer result in only two values

I am attempting to add an SSAO post processing shader to my deferred rendering engine. I am running into problems with reading from the depth buffer. In the images linked below you can see the depth ...