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

learn more… | top users | synonyms

1
vote
0answers
31 views

Grid patter appear over bloom when resolution is lower than 1366x768

The bloom post process in our engine is done via consecutive downscaling of the treshhold texture down to 1/64x1/64 of the main size. Every texture we use is R16G16B16A16 FP16. Afterwards, we ...
3
votes
0answers
79 views

HLSL - Voxel texturing

I'm currently trying to develop a Voxel Engine using Direct3D 9 and C++. To keep the memory usage low, i'm only passing the position, the orientation and the offset of the current voxels texture in ...
3
votes
0answers
32 views

Problem building a color grading map

I am trying to build a default color grading map into a 1024x32 RenderTarget. Here is my shader code: VertexShaderOutput VertexShaderFunction(VertexShaderInput input) { VertexShaderOutput output; ...
3
votes
1answer
45 views

Calculating normals after displacement mapping

I'm using C++, DX11 and tessellation. After tessellating a triangle I apply displacement mapping to the new vertices. But they still have the original triangle's normal so the lighting calculation ...
3
votes
0answers
68 views

Creating a black light (ultraviolet) shader?

I am interested in the algorithm for color picking that would ideally allow to choose what color range will be highlighted and what color range will be faded. I can sort-of understand how to make it ...
0
votes
0answers
54 views

Implementing Exponential Shadow Mapping

I've been following the tutorials (link1) and (link2) to implement Shadow Mapping. However, I'm getting shadowing artifacts which are quite ugly. I've done some research, and found that ESM ...
34
votes
1answer
3k views

How AAA games use this texture in the tone-mapping shader?

I found that Battlefield 3 as well as Saint's Row the Third use this texture in their final tone-mapping stage. Can anyone share a link to an article about how this texture is used? UPDATE: As ...
0
votes
2answers
32 views

InputAssembler and emtpy/incomplete buffers

I was wondering what the InputAssembler does if the size of the bound buffers does not match the vertex count of the Draw() call. I've seen the example at ...
0
votes
1answer
90 views

Converting Projected Vertex Positions to Normalized Device Coordinates

I'm using directx 9 and vertex shaders to rasterize triangles...I have vertex shader input structs like this: struct VS_INPUT_Quad { float4 Position : POSITION; float2 UV : TEXCOORD0; }; and ...
2
votes
1answer
112 views

HLSL float4 addition returning all 0.0f vector, unexpected result

Edit: Added images at the bottom to show the current issue. I have the following few lines in my hlsl pixel shader where color and specular are both float4. color = color * textureColor; // Add ...
1
vote
0answers
75 views

How do i define array in shader's constant buffer with C#?

I am using SharpDX to render 3D graphics and i cannot get to work constant buffer in my shader since it contains an array. Currently it looks like this: cbuffer cb0 : register(b0) { matrix ...
2
votes
1answer
40 views

Compare world space distance to shadow map depth

I am rendering shadow maps to cubemaps (just rendering raw depth buffer) then projecting them to the scene to do omni-directional shadow mapping. The cubemap is sampled by the light direction vector ...
1
vote
1answer
31 views

Proper Directional light on multiple models

I've been trying to implement a Directional light into an XNA game I'm working on, but for what ever reason, I cannot seem to get the directional light to be a true directional light. Instead, I am ...
1
vote
1answer
94 views

How to set shader global variable in sharpdx without using Effect class

I am working with SharpDX, i thinking to try using (uniform) global variables for HLSL constants instead of constant buffers. But, in my code SharpDX's Effect class is not used: i use PixelShader ...
2
votes
1answer
52 views

Do the predefined HLSL semantics carry any meaning?

I'd say there are 3 kinds of HLSL semantics: SV_* group - these are "system value" semantics which DO carry special meanings (e.g. assign special input/output data to/from shader stages) predefined ...
0
votes
1answer
39 views

Easiest way to smoothen coarse mesh with HLSL?

I've browsed through a couple of presentations and papers about DX11 tessellation and they all say that one of the most common usages of tessellation is to take a coarse (low poly) mesh, smoothen it ...
2
votes
1answer
40 views

What does the hull shader attribute “patchsize” do?

What does the hull shader attribute [patchsize(12)] do? MSDN fails to mention it. Do I have to use it? Should I use it?
0
votes
1answer
60 views

XNA and HLSL shaders - Instancing using World Matrix array

I have posted this question on StackOverflow and was directed here, so I'll just copy the question: I am attempting to improvise some sort of hardware instancing in my game. I wish to draw multiple ...
1
vote
1answer
29 views

How do I render into a sub-region of a texture atlas with XNA / HLSL?

Is it possible to render into a texture atlas? I've been wondering how to reduce the number of textures required for shadow-mapping, and came across a blog post here about rendering up to sixteen ...
3
votes
2answers
109 views

HLSL: using “?” operator in Technique section produces branches?

I recently found that you can do this: int AnotherShaderConstant = 0; float4 PixShader(VSOUT input, uniform bool Direction) { float4 color; if (Direction) color = GoLeft(); else ...
3
votes
1answer
59 views

Why does my PixelShader ignore color but respond to alpha changes?

I started teaching myself some DirectX a short time ago and found something I'm confused about. For some reason, I can only get the color of the model I'm drawing to vary between black and white, ...
0
votes
1answer
107 views

Using Appendbuffers in unity for terrain generation

Like many others I figured I would try and make the most of the monster processing power of the GPU but I'm having trouble getting the basics in place. CPU code: using UnityEngine; using ...
0
votes
1answer
65 views

Geometry Shader input vertices order

MSDN specifies (link) that when using triangleadj type of input to the GS, it should provide me with 6 vertices in specific order: 1st vertex of the triangle processed, vertex of an adjacent triangle, ...
1
vote
1answer
47 views

SetFloat() in HLSL shader (effect) has no effect - variables stay at 0

I have a problem wherein I'm trying to set two simple float variables in my shader. I have a dozen other shaders in this project where it works fine, but for some reason, I've got a bug in this one ...
3
votes
1answer
191 views

Issue with interpolation on a burn shader (lerp and smoothstep)

I'm trying to create a simple burn shader. See here for more info on the method I'm using. However, I don't get why replacing the smoothstep with a lerp results in completely different results. Am I ...
0
votes
1answer
145 views

Instancing with the SharpDX toolkit

I am starting on the graphical portion of my project and before I begin I need to get Instancing working. I can do instancing with SharpDX, but not with the Toolkit Models. The main reason I want to ...
0
votes
2answers
162 views

How to mix pixel colors in Shader?

I have a pixel that have a colour RGB. This color is calculated by the shader and can be anything. How can I override this color by a colour I choose. If my pixel is white it's simple, I can do this: ...
1
vote
1answer
78 views

What does [dynamic] do in HLSL

Here's an example (this if() is inside of a for loop, which itself has the [unroll] attribute): [dynamic] if (n.x > 1.0f || n.x < -1.0f || n.y > 1.0f || n.y < -1.0f || n.z < 0.0f || ...
0
votes
1answer
88 views

How to share matrix in HLSL?

I am trying to share this across multiple effect files: matrix worldMatrix : register(vs_4_0, b0); If I set this from one effect file, will it effect every effect file which has the same type of ...
8
votes
3answers
517 views

How can I create a glitter effect?

I am trying to create a glittering effect for my realtime shader but I don't know how. Here is one example, and another example. What technique can I use to implement this?
1
vote
1answer
76 views

Is it possible to compile both VS and PS in a single file in VS2012?

VS2012 has a built-in option for compiling *.hlsl files at compile time (e.g. to check for errors). But from what I've seen it requires me to provide the entry point (function) name for each file. ...
0
votes
0answers
184 views

How does this bezier curve rendering shader determine if a curve is concave or convex?

I have read an article about rendering quadratic splines on a GPU with a shader. The algorithm is explained like this: For each quadratic Bézier curve we use Bézier control points of the curve to ...
0
votes
1answer
102 views

Rendering Textured Terrain With SharpDX Toolkit [closed]

So i recently moved from XNA to SharpDX Toolkit and started with some basics. The 2d part was easy since nearly nothing has changed but im really struggeling with the 3d part. For example i wanted to ...
0
votes
1answer
65 views

Why would I lose the D3D device during an HLSL unroll?

I have a pixel shader that downsamples a texture from one size to another. The downsample shader uses a nested 'for' loop to traverse the uv coordinates. When the for loop executes more than four ...
0
votes
1answer
147 views

How to get pixel coordinates between 0,1 from SV_POSITION [duplicate]

I am new to HLSL and Directx. I was trying to write a simple gradient Shader by modifying one of Microsoft samples. 1.I can not understand why SV_POSITION is float4? If it is pixel coordinates ...
1
vote
1answer
72 views

XNA Render Targets Depth Testing

I imagine this is a problem that gets asked quite often, but reading up on it I can't seem to get a definitive answer on how to solve it. I've got two HLSL shaders (I've simplified them in the ...
1
vote
1answer
73 views

rrr subcsript for float type

I'm a little confused with this construction: float sdcolor = MyColor.r; // MyColor has float4 type float rcolor = sdcolor.rrr; // .ggg or .bbb isn't working return float4(rcolor , rcolor , rcolor , ...
0
votes
1answer
53 views

Multiplying matrices in HLSL

I have code that calculates a position like this in HLSL: output.ShadowPos = input.VertexPos; output.ShadowPos = mul(output.ShadowPos, gWorld); output.ShadowPos = mul(output.ShadowPos, ...
0
votes
3answers
265 views

Encode two integers into colour values and compare them in a HLSL shader

I am writing a 2D point and click adventure game in Monogame, and I'd like to be able to create an image mask for every room which defines which parts of the background a character can walk behind, ...
0
votes
1answer
59 views

Using tex2Dlod to determine the appropriate size of the texture

We have a top-down game with fixed camera position. We also use orthographic projection so every model in the game will always be viewed from the very same angle and from the very same distance. The ...
0
votes
1answer
67 views

Glow with forward rendering without two passes/MRT?

I am trying to implement controllable bloom. By controllable I mean bloom that can be requested even for non-bright pixels by adding the bloom value into a model's texture channel. To do this I need ...
3
votes
1answer
131 views

Is multipass rendering possible with SpriteBatch?

I'm trying to implement a bloom effect. This requires three shader passes: a brightness threshold, a horizontal blur, and a vertical blur. It also requires resizes, but these are irrelevant to the ...
1
vote
1answer
92 views

How do I draw an isoline in a shader with a triangle topology?

I have some problems with my displacment. So I would like to have a simple little isoline starting in every triangles face center of the mash pointing in the direction of the corresponding faces ...
0
votes
1answer
106 views

HLSL postprocessing for day to night (DTN)

I am trying to implement a "day-to-night"-filter (as commonly used in cinema) for a 2D game (XNA) by using a full screen HLSL pixel shader. The aim is to transform any bright and colorful image into a ...
3
votes
3answers
194 views

Does passing uniform constants from technique into shader cause branches?

I am trying to find a way to organize my evergrowing number of shader techniques/functions (I am coding in sm_3.0). One way is to do this: float4 PS_Crossroads(PS_INPUT input, uniform bool ...
0
votes
3answers
74 views

how do I modify Texture2DArray values in shader

I'm using HLSL Shader Model 5.0. I'm using a Texture2D with the vertex positions for a mesh. In the Shader I'm trying to displace patchepositions along the normal of the patches I'd like to actualize ...
1
vote
1answer
137 views

How does HLSL handle clip(vector)?

My goal is to convert clip() to GLSL, version 1.5. I'm currently doing a basic: if (x < 0) discard; But if x is not a scalar, obviously I can't use the "<" operator. So I'm wanting to ...
2
votes
1answer
242 views

Is this GLSL equivalent to this HLSL?

I was wondering if the both shader codes are equivalent. So the question is, is this GLSL vNormal = mat3(FUSEE_ITMV[0].xyz, FUSEE_ITMV[1].xyz, FUSEE_ITMV[2].xyz) * fuNormal; Equivalent to this ...
1
vote
1answer
114 views

Does HLSL implement Shader Model LOD instruction?

The DX Shader Model 5.0 has a lod instruction. It returns "the LOD (level of detail) that would be used for texture filtering". Does HLSL have a built-in intrinsic that can do the same? I know I ...
0
votes
0answers
26 views

Skip the first RenderTarget when writing to MRT with Opaque blending

I am writing to three rendertargets and whant to know how to tell a GPU not to write to the first RT. When you write a shader you can simply output less data than you have RTs (like output a single ...