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

learn more… | top users | synonyms

1
vote
1answer
348 views

Write alpha channel into SurfaceFormat.Single rendertarget in XNA/HLSL

I need to initialize a rendertarget ('SurfaceFormat.Single' format) drawing sprites into it. I would like the alpha channel of the sprite to be written into the rendertarget, so that regardless of ...
2
votes
1answer
317 views

Does the standard lighting equation ever allow objects to be brighter than their textures?

It occurred to me that the standard lighting setup you see in all the tutorials doesn't allow lights to actually make an object appear brighter than its texture. The light value is always clamped ...
14
votes
4answers
3k views

how does HDR work?

I'm trying to understand what HDR is and how it works. I understand the basic concepts and have an slight idea of how it is implemented with D3D/hlsl. However it's still pretty foggy. Say I'm ...
2
votes
1answer
596 views

Adding VFACE semantic causes overlapping output semantics error

My pixel shader input is a follows struct VertexShaderOut { float4 Position : POSITION0; float2 TextureCoordinates : TEXCOORD0; float4 PositionClone : ...
2
votes
1answer
724 views

Omni-directional shadow mapping

What is a good/the best way to fill a cube map with depth values that are going to give me the least amount of trouble with floating point imprecision? To get up and running I'm just writing the raw ...
2
votes
1answer
491 views

Using SurfaceFormat.Single and HLSL for GPGPU with XNA

I'm trying to implement a so-called ping-pong technique in XNA; you basically have two RenderTarget2D A and B and at each iteration you use one as texture and the other as target - and vice versa - ...
1
vote
1answer
627 views

Need to combine a color, mask, and sprite layer in a shader

My task: to display a sprite using different team colors. I have a sprte graphic, part of which has to be displayed as a team color. The color isn't 'flat', i.e. it shades from brighter to darker. I ...
0
votes
2answers
219 views

DX11 - Weird shader behavior with and without branching

I have found problem in my shader code, which I dont´t know how to solve. I want to rewrite this code without "ifs" tmp = evaluate and result is 0 or 1 (nothing else) if (tmp == 1) val = X1; if (tmp ...
3
votes
1answer
2k views

SV_POSITION in pixel shader

What are the uses for SV_POSITION in the pixel shader? Previously this was the POSITION semantic and it wasn't readable in the pixel shader, but now that it is, what can it be used for? In an SM2 ...
4
votes
1answer
657 views

Bitwise operators in DX9 ps_2_0 shader

I've got the following code in a shader: // v & y are both uints nPixel = v; nPixel << 8; nPixel |= y; and this gives me the following error in compilation: shader.fx(80,10): error ...
2
votes
3answers
5k views

Hue, saturation, brightness, contrast effect in hlsl

I am new to pixel shader, and I am trying to write a simple brightness, contrast, hue, saturation effect. I have written a shader for it but I doubt that my shader is not providing me correct result, ...
2
votes
2answers
140 views

Distance to a sphere, in Screen Space

Is it possible to find the distance of a pixel to a rendered sphere, in screen space? All my naive solutions for just using the 2D screen distances are failing because of the warping that occurs ...
20
votes
2answers
4k views

How do I create a wide-angle / fisheye lens with HLSL?

What are the concepts that need to be implemented in order to achieve the effect of a wide angle lens of varying extremities? Pseudocode and specific explanation referring to the various stages of ...
1
vote
1answer
1k views

Problem with HLSL :TextureCoordinate0 is missing

I'm trying to create a very simple game, and am working with HLSL. I got this error in my draw method: The current vertex declaration does not include all the elements required by the current ...
2
votes
1answer
582 views

Can you store negative numbers with XNA HLSL?

I am trying to make a ripple effect with a HLSL shader, it works so far but I need to output negative numbers and that won't work for the calculations. Is there some way to do this with the ...
4
votes
2answers
336 views

Is it possible in HLSL to use bitfields?

I have in memory a representation of my 2d GameMap (think of a Scorched Earth like landscape). The map is made up of MapElements, a MapElement is made up of 64 bits defined like struct MapElement { ...
1
vote
1answer
255 views

HLSL weird matrix behaviour

I have some problems using an int 3x3 matrix as the convolution filter to do edge detection. (I know int matrices are not very meaningful since there is only float on the gpu) Here is the code: ...
0
votes
1answer
677 views

CG/CGFX to GLSL

So, I'm making the painful move from my beloved XNA to OpenTK, and I'm stuck: Since I've got a LOT of existing shaders written in HLSL, NVidia's CG compiler seems like a natural way to minimize the ...
1
vote
1answer
138 views

How to mix effects together?

Lets say I have got terrain effect, contains multitexturing, light. Now water effect. It must be different, but must be also affected by light. Other one, player effect, must also be affected by ...
1
vote
1answer
463 views

Writing to multiple RenderTarget2D's from HLSL shader

I need to write to two render targets: one for colour and another for depth+normal (for post-processing). I have a problem, though. Both targets seem to be getting the value output by COLOR0, while ...
3
votes
1answer
902 views

*DX11, HLSL* - Colour as 4 floats or one UINT

With the DX11 pipeline, would it be much quicker for the vertex buffer to pass one single UINT with one byte per channel to the input assembler, as opposed to three floats? Then the vertex shader ...
2
votes
1answer
876 views

Shader optimization - Cg/HLSL pseudo and via multiplication

HLSL/Cg do not allow texture fetching inside conditional blocks. To get around this I am first checking a variable and performing some computations, afterwards I set a float flag to 0.0 or 1.0, ...
3
votes
1answer
644 views

Shadow-mapping xna

I've been trying to implement shadows in my game and I've been following quite a few tutorials online, mainly Riemers, but I'm always getting the same 2 errors when I'm drawing my models and setting ...
2
votes
1answer
253 views

Shader and Custom Vertex Format Errors

I am creating an editor of sorts that allow you to create 3D voxel models. I just got started and have ran into a few errors. Here is what it is producing: I think the problem has to do with the ...
1
vote
2answers
191 views

How (if possible) would I change the BasicEffect Matrix mid draw

Say, for example, I have a list of enemies. Each enemy is a textured quad which is the stored in a singular shared VertexBuffer and IndexBuffer with the buffer usage set to BufferUsage.WriteOnly ...
6
votes
2answers
1k views

Electricity effect using XNA and Shaders

I'm looking for a shader or sample that does an electricity or lines-of-force effect between two points that can be used with XNA 3.1.
4
votes
4answers
632 views

Enconding/Decoding bit value in Texture Alpha Channel

I am Rendering to a SurfaceFormat.Color. (R8G8B8A8) The alpha of this format has 8 bits and I want to be able to use those 8 bits as a bit field. For example, in one pass of my render, I want to save ...
2
votes
2answers
753 views

Is the output from D3DCompile specific to one GPU, or not?

In Direct3D 11 there is a two-stage shader compilation process; you first pass the HLSL source code into D3DCompile, which outputs a "blob" of bytecode. You then take this blob and call ...
3
votes
2answers
1k views

Why can't I get a bool packed and aligned into a D3D constant buffer?

Alright, I'm having a hard time getting a bool packed and aligned into a hlsl constant buffer and I'm not sure why. Here is the buffer in hlsl cbuffer MaterialBuffer : register(b1) { float3 ...
1
vote
1answer
265 views

screen coordinate not working with pixel values

I have a very simple effect file shown below. I am using this to draw 2D lines, however it is not behaving how I expected and I can't seem to get my head round why. If I draw a line that goes from ...
9
votes
1answer
3k views

Wave ripple effect?

I've been working on a tower-defense game for some time now, and so far I am really satisfied with the results. However, there's one thing I'd like to add. I've seen a video of GeoDefense for Windows ...
1
vote
1answer
549 views

Sampling from Normal Map and Diffuse Map in Pixel Shader

I'm having some issue changing a basic lighting shader to take a normal texture and a diffuse texture for a model and then using the normal texture for lighting. The code is very simple and i can't ...
3
votes
1answer
2k views

Some assistance with selective 2D Bloom in XNA

I'm in need of some assistance, as I've been at this for 2 days now and have gotten almost nowhere. I'm trying to use the XNA Bloom sample's component to apply bloom only to my UI text. (The only ...
1
vote
3answers
198 views

Extracting blend values from uint32 not working as expected

I have the following shader configuration code : uint gBlendValue = 0xffffff00; Terrain.Effect.GetVariableByName("gBlendValue").AsScalar().Set(gBlendValue); And I have the following shader code : ...
3
votes
2answers
251 views

Fire range arc behind buildings

need some help with HLSL. Each charater in my game shows a fire range arc (which is a textured model) which show how far the guy can shoot, see It looks ok, but I hate the fact that it shows even ...
0
votes
1answer
658 views

Some help understanding and modifying a 2D shader

I have a similar question as the one posed here, except that I don't wish to use a 1D Color Palette. I simply wish to have it display 1 color of my choosing (red, for example). I plan to use this ...
3
votes
2answers
627 views

How to achieve hologram projection effect with head tracking

I want to recreate this: http://www.youtube.com/watch?v=9xMSGmjOZIg&feature=related I can take care of tracking the user's head, and in one of the comments I believe the author says that he used ...
2
votes
1answer
1k views

Why is a fully transparent pixel still rendered?

I am trying to make a pixel shader that achieves an effect similar to this video http://www.youtube.com/watch?v=f1uZvurrhig&feature=related My basic idea is render the scene to a temp render ...
0
votes
2answers
1k views

How to achieve after-image pixel shader effect

How would one go about writing a pixel shader like this one in XNA 4.0? http://www.youtube.com/watch?v=f1uZvurrhig&feature=related
1
vote
1answer
723 views

How to set TextureFilter to Point to make example Bloom filter work?

I have simple app that renders some particles and now I am trying to apply the bloom shader from the xna samplers ( http://create.msdn.com/en-US/education/catalog/sample/bloom ) to it, but I am ...
5
votes
2answers
628 views

Spin/Rotational Blur

How do I perform a circular/rotational/spin blur on an image - using DirectX9.0 and HLSL? For example:
11
votes
4answers
1k views

How does an HLSL shader actually end up affecting the render output?

I understand the syntax of HLSL, for example let's pretend I have this as my HLSL: struct VOut { float4 position : SV_POSITION; float4 color : COLOR; }; VOut VShader(float4 position : ...
2
votes
1answer
427 views

tiled map - changing textures? (XNA HLSL)

I have successfully created a tiled map of various textures. Right now, i had a Vector4 in my own custom Vertex declaration deciding what texture each of the tiles should be. This is working ...
1
vote
1answer
652 views

Rendering fancy particles?

I'm making a tower-defense game for Windows (not phone) in XNA. I've seen this video of another tower-defense game for Windows Phone that uses particle effects, which I really like. They change ...
9
votes
1answer
6k views

DirectX11, how do I manage and update multiple shader constant buffers?

Alright, I'm having a hard time grasping how constant buffers are bound to a pipeline stage and updated. I understand that DirectX11 can have up to 15 shader-constant buffers per stage and each buffer ...
12
votes
3answers
1k views

HLSL Translucent Plastic Shader

I'm trying to produce a shader to replicate a white plastic object with a colored light inside. Either by having a shader that will be translucent and if I put a light inside the object the light will ...
3
votes
1answer
469 views

Increasing resolution of a texture?

I'm doing some experiments on my own to improve my general skills with HLSL and so forth. In other words, I'm not doing any serious game development, but only looking to expand my knowledge within the ...
6
votes
1answer
667 views

XNA HLSL - what happens if I grab a pixel outside a texture?

I'm using the tex2D function of HLSL, and I am wondering what will happen if I try to grab a pixel from a pixel coordinate outside of my texture (as an example 1.1). Will it clamp? Will it repeat the ...
20
votes
2answers
1k views

Weird white outline around model

I'm working on a game in XNA 4 and I recently switched to a deferred shading implementation following this guide. A strange white outline is showing up on my models now and I'm not sure whats causing ...
1
vote
1answer
938 views

XNA - Getting HLSL pixel of current render target?

I'm setting a render target in XNA using the following lines of code: Game.GraphicsDevice.SetRenderTarget(physicsTexture); Game.GraphicsDevice.Clear(Color.White); ...