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

learn more… | top users | synonyms

4
votes
2answers
551 views

Rendering everything with a shader when only squares are needed?

I am building a game that is tile-based (filled with glowy vector squares). Right now, I am considering using instancing for drawing these, but I would like to know if there is a faster approach. The ...
4
votes
1answer
237 views

How can I handle the combination of multiple shader effects?

To be able to work efficiently with effects, is there a good way to combine multiple reusable "base" effects to achieve a more complex final result? For example, say I have an effect that handles ...
12
votes
1answer
297 views

Accounting for waves when doing planar reflections

I've been studying Nvidia's examples from the SDK, in particular the Island11 project and I've found something curious about a piece of HLSL code which corrects the reflections up and down depending ...
3
votes
3answers
253 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
1answer
104 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 ...
1
vote
1answer
136 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
139 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 ...
0
votes
3answers
93 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
228 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
300 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
151 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 ...
2
votes
2answers
173 views

XNA hlsl tex2D() only reads 3 channels from normal maps and specular maps

Our engine uses deferred rendering and at the main draw phase gathers plenty of data from the objects it draws. In order to save on tex2D calls, we packed our objects' specular maps with all sorts of ...
14
votes
1answer
629 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 ...
0
votes
0answers
153 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
1answer
169 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 < ...
1
vote
0answers
146 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
622 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
262 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 ...
1
vote
1answer
961 views

Pixel Shader, YUV-RGB Conversion failing

I am tasked with playing back a video hthat comes in in a YUV format as an overlay in a larger game. I am not a specialist in Direct3d, so I am struggling. I managed to get a shader working and am ...
0
votes
1answer
104 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 ...
8
votes
1answer
294 views

Fast lighting with multiple lights

How can I implement fast lighting with multiple lights? I don't want to restrain the player, he can place an unlimited number and possibly overlapping (point) lights into the level. The problem is ...
2
votes
2answers
1k views

Computing pixel's screen position in a vertex shader: right or wrong?

I am building a deferred rendering engine and I have a question. The article I took the sample code from suggested computing screen position of the pixel as follows: VertexShaderFunction() { ... ...
1
vote
1answer
495 views

Using multiple passes in OpenCL .net

I'm new to opencl but I have some experience using HLSL. In HLSL multiple passes are used when you need to finish a computation before moving on to the next step. I would like to know how this sort ...
0
votes
0answers
93 views

Projecting shadow map

I'm having a problem with shadow mapping and don't know where to go from here. Take a look at this screenshot: The cube circled in green is the light position, the light direction is pointed ...
5
votes
1answer
1k views

What does ddx (hlsl) actually do?

I'm a bit confused. The official documentation (http://msdn.microsoft.com/en-us/library/windows/desktop/bb509588(v=vs.85).aspx) says that ddx(input) is the partial derivative of the input with ...
0
votes
0answers
82 views

How to encode float3 into float2 and back again in HLSL?

Good afternoon, I am looking to offload some 3D calculations to the GPU without raising my requirements to DX10. Specifically, I am generating densities in 64x64x64 3D blocks, which fit nicely into ...
0
votes
1answer
109 views

Storing few values in an int - small gain

This might be a bit hard-to-answer question, but... I had a DirectX::XMFLOAT3 as a vertex attribute. I have changed it to just an int by placing the 3 floats into int (using only 8 bits per float). In ...
0
votes
0answers
102 views

Shadow Mapping Wrong Results

Since 2 days, i'm trying to figure out whats wrong with my shadow shader. The shadow map is drawn correctly, just the projection on to the scene is not working. The Vertex Shader Code seems fine: ...
1
vote
1answer
282 views

Color grading, shaders and 3d textures

I'm trying to implement color correction with the 3d lookup table. The lookup table is actually just a 2d texture 256x16 and consists of 16 squares which one is 16x16. When it comes to rendering, I ...
0
votes
2answers
303 views

HLSL's Tex2D for GLSL?

I am trying to port a HLSL shader to GLSL. I'm just not quite sure how to convert this line: outA += Input.Color.a * tex2D(s, Input.TexCoord.xy + float2(-4.0 * pxSz.x * blurSize,0)).a * 0.05; ...
5
votes
1answer
446 views

What does HLSL's tex2D return at (0,0)?

I'm trying to understand the mapping of texels to pixels, especially in the context of pixel shaders. I already found out the following: When I define a standard quad with vertices at integer ...
2
votes
1answer
194 views

Hemispherical Projection

I'm trying to implement a radiosity processor. I'm aware of many places online to find information about radiosity. I found a great source on NVidia's website is GPU Gems - Chapter 39 . On this page ...
0
votes
1answer
330 views

XNA & HLSL - rendering a model with its original materials (colors)

I am currently trying to code my own HLSL effect file, in order to render an FBX model I made with Autodesk maya, and to which I have applied some materials (colors). before trying to write an effect ...
1
vote
1answer
214 views

HLSL Textured Light: outputs only a specific part of the texture (new problem)

Problem 1 I am trying to create a spotlight that instead of giving the circle within the spotlight a simple color, applies a texture to it. However, where the texture is supposed to be is only a ...
2
votes
1answer
82 views

Write colors with alphablending but don't write into the alpha channel

I am using XNA 4.0, hence DX9 and HLSL. I have a RenderTarget2D "MAIN" that I want to add semi-transparent objects "TRANS" to. I want them to blend with MAIN using the TRANS's alpha and inverseAlpha ...
0
votes
1answer
1k views

HLSL Gaussian blur pixelshader: blur is not occurring

I am trying to use postprocessing to create a gaussian blur, however, no blur is to be seen, what am I doing wrong? I have included the full code at the bottom of this post in a google docs link, but ...
1
vote
1answer
936 views

HLSL grayscale pixel shader: How to get the original colors of the model?

The following code gives me a completely black colored model, while it should be a model shaded in greyscale: float4 SimplePixelShader(VertexShaderOutput input) : COLOR0 { //some lambertian ...
3
votes
2answers
71 views

Local shape color blending

I am trying to implement this in Unity 4 Pro. But I am stuck in the blending part. I don't understand how you could blend multiples textures/colors using multiples volumes on an object. How could you ...
2
votes
2answers
351 views

How do I rotate a single object in HLSL?

I have a World with a 3D model of a head in it and that World rotates, like such: protected override void Update(GameTime gameTime) { //other stuff angle += 0.00005f; //more other stuff ...
18
votes
12answers
6k views

What are some good resources for learning HLSL?

The last time I tried learning HLSL, I made a few shaders and mostly understood what I was doing, but I still felt like I was stumbling in the dark. Most of what I learned I got from various blog ...
0
votes
0answers
62 views

XNA HLSL no model textures

I am using XNA and HLSL to render all the models in my game, so far there is only one, a flashlight. My flashlight model is a .fbx file type, and it loads the model in the game perfectly fine. ...
0
votes
1answer
130 views

How to control in the vertex shader where pixel ends up in the renderTarget?

What if I have an arbitrary renderTarget, that is smaller than the screen (say it is 1x1 pixel) and I want to make sure in the VertexShaderFunction that all my pixels end up exactly in that 1 pixel ...
2
votes
1answer
258 views

What is this alpha blending result?

I'm having an exam soon and got a problem with one alpha blending exercise: BlendState BS3 { BlendEnable[0] = TRUE; SrcBlend[0] = ONE; SrcBlendAlpha[0] = ZERO; ...
3
votes
1answer
237 views

Adding false if statement to pixel shader produces a lag

One of lines in pixel shader produces a lag (lower fps). I can't understand why. if (TextureEnabled) color *= texDiffuse.Sample(texDiffuseSam, input.UV); Interesting fact is: TextureEnabled is ...
4
votes
1answer
122 views

Masking an area inside/outside a line strip

I have some point lights in my game which are just sprites implemented with help of HLSL. Currently I'm trying to implement dynamic shadows and I managed to make the program calculate the area in ...
4
votes
2answers
319 views

Calculate mipmap level in a loop with varying iteration?

How can I calculate the correct mipmap level in a shader? It needs to be used in a loop which runs a variable number of times so the compiler will not allow me to use Sample or the derivative ...
1
vote
1answer
306 views

Which coordinate space is the canonical default for each shader pipeline stage?

I'm working with Direct3D 11 and HLSL. I use four different shaders (vertex, hull, domain and pixel). I always have troubles using the right coordinate space in my shaders. Could somebody identify ...
2
votes
1answer
493 views

GPGPU Programming using HLSL and XNA

XNA Newbie question: I'm trying to get the GPU to perform some calculations for me. I'm trying to figure out how to send some data to the GPU, get the GPU to process it, then get the result back. ...
2
votes
0answers
295 views

XNA 4.0 Pixel Shader 3.0 Exact Texture Lookup/Sample Issue

I am stuck on trying to solve this problem. I originally had some shaders written that worked for XNA 3.1, but after converting to XNA 4.0 they would no longer compile due to instruction counts, flow ...