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

learn more… | top users | synonyms

1
vote
0answers
524 views

Need help transforming DirectX 9 skybox hlsl shader to DirectX 11

I am in the middle of implementing a skybox to my game. I have been following this tutorial http://rbwhitaker.wikidot.com/skyboxes-2. I am using MonoGame as a framework and in order to support both ...
1
vote
1answer
227 views

XNA Shader Texture Memory

I was wondering about texture optimization in XNA 4.0. Will the the contentmanager send the texturedata to the GPU directly when the texture gets loaded or do I send the texture data to the GPU when ...
6
votes
1answer
573 views

Partial Shader Signatures HLSL D3D11 C++

I had been debugging a problem I was having in a single shader file with 2 functions in it. I'm using DirectX 11, vs_5_0 and ps_5_0. I have stripped it down to its basic components to understand what ...
16
votes
2answers
3k views

Best way to mask 2D sprites in XNA?

I currently am trying to mask some sprites. Rather than explaining it in words, I've made up some example pictures: The area to mask (in white) Now, the red sprite that needs to be cropped. The ...
2
votes
1answer
181 views

Why is my shadowmap all white?

I was trying out a shadowmap. But all my shadow is white. I think there is some problem with my homogeneous component. Can anybody help me? The rest of my code is written in xna Here is the hlsl code ...
1
vote
0answers
233 views

Outline Shader Effect for Orthogonal Geometry in XNA

I just recently started learning the art of shading, but I can't give an outline width to 2D, concave geometry when restrained to a single vertex/pixel shader technique (thanks to XNA). the shape I ...
0
votes
1answer
142 views

HLSL problem with divide by homogeneous component

When I try to divide my position.z by my position.w in HLSL I get as result always 1.0f or higher. Is this a common problem for some reason? When I divide my position.x or y by the w this works fine. ...
4
votes
1answer
658 views

Pass large array to pixel shader

I am trying to write a Pixelshader for a curve effect in Direct2d. A curve effect maps each color channel value to a different value by using a look up table. For this effect I would need to pass 3 ...
4
votes
1answer
312 views

A Quick HLSL Question (How to modify some HLSL code)

Thanks for wanting to help! I'm trying to create a circular, repeating ring (that moves outward) on a texture. I've achieved this, to a degree, with the following code: float distance = ...
0
votes
1answer
118 views

how to create texture for modelmesh?

Is there a possibiltiy to create a texture from a meshpart in xna. By getting a flat version of the mesh. So I can create a texture for it and edit that texture(via rendertarget)? I need to get the ...
1
vote
1answer
326 views

Heightmap in Shader not working

I'm trying to implement GPU-based geometry clipmapping and have problems to apply a simple heightmap to my terrain. For the heightmap I use a simple texture with the surface format "single". I've ...
0
votes
1answer
572 views

Shadows shimmer when camera moves

I've implemented shadow maps in my simple block engine as an exercise. I'm using one directional light and using the view volume to create the shadow matrices. I'm experiencing some problems with the ...
5
votes
1answer
463 views

Dealing with alpha for 2D per pixel lighting

Right now I've got a simple light shader. Every bitmap I draw goes through it to make up the scene. I only draw quads. texture tex; sampler2D s = sampler_state { texture = <tex>; ...
5
votes
3answers
621 views

Finding out what pixel on the screen the fragment falls on

In my 2D game, I render tiles. I want to do lighting without needing an extra buffer the size of the screen. Either in glsl or hlsl, what could I feed to the shader each time I render a bitmap so ...
5
votes
1answer
2k views

How do I use screen-space derivatives to antialias a parametric shape in a pixel shader?

In Valve's Alpha Tested Magnification paper, it mentions using "per-pixel screen-space derivatives" for doing anti-aliasing. My understanding is that this is the ddx and ddy intrinsic functions in ...
1
vote
0answers
251 views

Full screen shader causes performance hit

I basically want to have a shader run that can do something like toon shading, or grayscale the whole screen, or radial lighting. To do this, I create a new bitmap each time the display resizes that ...
0
votes
1answer
147 views

How would I write a shader that supports 2 different texture coordinates?

Hi I am not very good with writing shaders. How would I make a shader that simply supports 2 texture coordinates so I can load up 2 different textures to be used at the same time but on different ...
0
votes
1answer
153 views

My blur gets ugly when radius too high

I have the following h and v blur: Horz texture tex; sampler2D s = sampler_state { texture = <tex>; }; int tWidth; int tHeight; float blurSize = 9.0; float4 ...
2
votes
2answers
1k views

My hlsl shader cannot unroll a loop?

I have this shader: texture tex; sampler2D s = sampler_state { texture = <tex>; }; int tWidth = 1; int tHeight = 1; int blurLength = 3; float4 ps_main(VS_OUTPUT ...
1
vote
1answer
660 views

how to modify shadow mapping in “3D Graphics with XNA Game Studio 4.0”? [closed]

So I've been following the tutorials from the book Sean James's "3D Graphics with XNA Game Studio 4.0", and have been doing fine until i reached the shadow mapping part. in this book it creates point ...
1
vote
1answer
952 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
2answers
690 views

How to make HLSL effect just for lighting without texture mapping?

I created an effect and just want to use lightning but in default effect that XNA create we should do texture mapping or the model appears 'RED', because of this lines of code in the effect file: ...
1
vote
3answers
587 views

Writing a shader once without using CG?

Is there a tool that can convert a fragment shader from hlsl to glsl or glsl to hlsl? I do not want to use cg since it is not able to work on mobile platforms. Is there a tool that can make it so I ...
0
votes
1answer
497 views

Sampler referencing in HLSL - Sampler parameter must come from a literal expression

The following method works fine when referencing a sampler in HLSL float3 P = lightScreenPos; sampler ShadowSampler = DPFrontShadowSampler; float depth; if (alpha >= 0.5f) { // Reference ...
1
vote
0answers
391 views

XNA HLSL: Skinned Model Deforming Wrong

I am creating a basic XNA recreation of Minecraft. My current problem is that my "Steve" model, which is skinned with an armature using vertex groups to deform, is showing up disfigured beyond all ...
2
votes
0answers
1k views

Why is my deferred lighting implementation so expensive?

I've implemented deferred lighting and I tried to put about 20-26 lights on the viewable space of my map, and it brings down the FPS from 61 to 28-31. It also makes my VGA temperature to go from 68°C ...
1
vote
1answer
851 views

2D Mask antialiasing in xna hlsl

I have two texture2d , one of these is a mask texture and have 2kind color and i use that for mask (filter) second texture2D something like float4 tex = tex2D(sprite, texCoord); float4 bitMask ...
9
votes
2answers
4k views

Random number hlsl

How do you generate a random number in HLSL? I'm asking because I want to try gpu ray tracing. You need to generate random directions in a pixel shader. So I want randFloat(), where the result is a ...
2
votes
1answer
635 views

Help understanding HLSL - newbie questions

Just starting out with HLSL, please bare with me :) There are times I'm a little confused by the syntax for instance in the pixel shader of an example I am following we have the following input and ...
1
vote
1answer
398 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 ...
4
votes
2answers
1k views

XNA 4.0 - Normal mapping shader - strange texture artifacts

I recently started using custom shader. Shader can do diffuse and specular lighting and normal mapping. But normal mapping is causing really ugly artifacts (some sort of pixeling noise) for textures ...
2
votes
1answer
364 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 ...
2
votes
1answer
677 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
787 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
534 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
775 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 ...
2
votes
1answer
381 views

How do you create a cbuffer or global variable that is gpu modifiable?

I'm implementing tonemapping in a pixel shader, for hdr lighting. The vertex shader outputs vertices with colors. I need to find the max color and save it in a global. However when I try and write ...
3
votes
1answer
3k 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
809 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 ...
0
votes
1answer
2k views

Changing the culling mode in the HLSL effect

I'm writing a cel-shading effect in HLSL and Direct3D 11, and I need to be able to flip the culling mode on the outline pass of the effect. I know you do this in XNA by setting CullMode to CW or CCW ...
2
votes
2answers
146 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 ...
7
votes
2answers
1k views

HLSL - Creating Shadows in 2D

The way that I create shadows is by the following technique: http://www.catalinzima.com/2010/07/my-technique-for-the-shader-based-dynamic-2d-shadows/ But I have questions to HLSL. The way that I ...
2
votes
1answer
607 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
380 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
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
3answers
6k 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, ...
0
votes
1answer
800 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
144 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 ...
0
votes
2answers
226 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 ...
1
vote
1answer
580 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 ...