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

learn more… | top users | synonyms

2
votes
1answer
142 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
211 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
87 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
41 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
478 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
83 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
124 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
49 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
118 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
46 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
195 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
70 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
207 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 ...
1
vote
1answer
137 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
79 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
575 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
283 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
176 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
104 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
106 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 ...
9
votes
3answers
686 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
110 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
258 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
157 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
72 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
345 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
91 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
96 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
79 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
359 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
101 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
105 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
217 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
130 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
134 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
242 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
92 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
206 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
293 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
143 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
28 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 ...
4
votes
1answer
126 views

PCF shadow shader math causing artifacts

For a while now I used PCSS for my shadow technique of choice until I discovered a type of percentage closer filtering. This method creates really smooth shadows and with hopes of improving ...
14
votes
1answer
613 views

Rendering oily/polluted water?

Any shader wizards out there have an idea of how to achieve an oily/polluted water effect, similar to this: Ideally, the water would not be uniformly oily, but instead the oil could be generated ...
1
vote
1answer
159 views

HLSL What you get when you subtract world position from InvertViewProjection.Translation?

In one of NVIDIA's Vertex shaders (the metal one) I found the following code: // transform object normals, tangents, & binormals to world-space: float4x4 WorldITXf : WorldInverseTranspose < ...
0
votes
0answers
151 views

Radiosity using a hemisphere

I'm working on a radiosity processor. I'm projecting scene geometry onto a hemisphere at a high order of tessellation during a visibility pass onto a 1024x1024 render target. The problem is that the ...
1
vote
0answers
140 views

write to depth buffer while using multiple render targets

Presently my engine is set up to use deferred shading. My pixel shader output struct is as follows: struct GBuffer { float4 Depth : DEPTH0; //depth render target float4 Normal : COLOR0; ...
1
vote
2answers
585 views

How AlphaBlend Blendstate works in XNA 4 when accumulighting light into a RenderTarget?

I am using a Deferred Rendering engine from Catalin Zima's tutorial: His lighting shader returns the color of the light in the rgb channels and the specular component in the alpha channel. Here is ...
5
votes
1answer
255 views

What light attenuation function does UDK use?

I'm a big fan of the light attenuation in UDK. Traditionally I've always used the constant-linear-quadratic falloff function to control how "soft" the falloff is, which gives three values to play ...
0
votes
1answer
102 views

HLSL How to flip geometry horizontally

I want to flip my asymmetric 3d model horizontally in the vertex shader alongside an arbitrary plane parallel to the YZ plane. This should switch everything for the model from the left hand side to ...
2
votes
1answer
115 views

What's the difference between Textures and VertexTextures in XNA?

The GraphicsDevice class of XNA has the properties Textures and VertexTextures. What is the exact difference? I don't really understand what MSDN tells me about this. I usually use Effect parameters ...