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

learn more… | top users | synonyms

2
votes
1answer
204 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
381 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
237 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
87 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
2k 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
1k 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
75 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
401 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 ...
0
votes
0answers
64 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
139 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
275 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
245 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
125 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
343 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
359 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
546 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
325 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 ...
2
votes
0answers
130 views

Stereo 3D: drawing 2D elements at apparent screen depth

I'm developing an application making use of DirectX11's stereoscopic features. At such I am not relying on nVidia's automatic implementation. That means I have to replicate a way to render 2d elements ...
3
votes
1answer
183 views

When are HLSL literals taken as a float and integer?

float2 uv = float2(fX % 1, fY % 1) * 1/16; In the above example 1/16 is treated as a float, multiplying the float2 by 0.0625, but in: float2 uv = float2(fX % 1, fY % 1) * 1/16 + float2(1/16,0); ...
2
votes
1answer
75 views

Is it possible to retrieve shader function names associated with a technique pass using the DirectX Effect API?

For example, given the pass pass p0 { SetVertexShader(CompileShader(vs_4_0, VSFunction())) SetPixelShader(CompileShader(ps_4_0, PSFunction())) } Ss it possible to retrieve the names ...
2
votes
2answers
167 views

Are global shader variables slower than texture look ups?

I want to send quite a bit of data to the GPU, the data will never change (or will change very rarely) after it has been created. Is there a performance impact to using global shader variables or ...
0
votes
1answer
185 views

Volume raycaster problems HLSL

Hi this is my first question here so if I fail to include some necessary piece of information please dont rip my head off. ^^ I can't seem to get my volume raycaster to workt properly. I've been ...
0
votes
1answer
77 views

Vertex and Fragment Shader worldNormal

How to access/calculate worldNormal in a Vertex and Fragment shader ? Thanks a lot !
0
votes
1answer
138 views

Angle to Vector3?

I am working on getting my directional lights to match the sun in my atmospheric scattering shader. I have a float that ranges from 0 to 6.28 (TwoPi). How would I calculate a vector3 from this angle? ...
4
votes
2answers
128 views

When to apply AA as post?

I'm working with a deferred shading technique. I have diffuse, normal and depth buffers, which I combine for the final scene composition. Where and when exactly do I apply an anti-aliasing pass (such ...
2
votes
2answers
70 views

XNA HLSL Exclude texture?

I'm going through HLSL tutorials and I have lighting and texturing setup. Right now in my shader I take a texture, but if I leave that variable blank it gives me an error. Half of my models have ...
2
votes
1answer
194 views

Shader Variable Types

I have a simple question. what are the meaning of : half4 myHalf; myHalf.yyyy; myHalf.xxzz; // or myHalf.yw Thanks a lot !
3
votes
0answers
169 views

SSAO Distortion [closed]

I'm currently (attempting) to add SSAO to my engine, except it's...not really work, to say the least. I use a deferred renderer to render my scene. I have four render targets: Albedo, Light, Normal, ...
2
votes
1answer
93 views

Why is it when I render a basic cube, my editor's grid changes too?

I have one HLSL file for DirectX11 that only has input layout for color and position. Then another HLSL file for the simple cube that has position, normal and textures. What I noticed is when I render ...
1
vote
1answer
1k views

Volumetric Fog Shader - Camera Issue

I am trying to build an infinite fog shader. This fog is applied on a 3D plane. For the moment I have a Z-Depth Fog. And I encounter some issues. As you can see in the screenshot, there are two views. ...
0
votes
1answer
750 views

What is the difference between a modelview-projection matrix and world-view-projection matrix?

So basically I wrote a shader a long time ago that uses all World and WVP matrices. Now I am working in an engine that will only give me access to ModelView, MVP, and model to world space matrices. ...
0
votes
2answers
248 views

HLSL Pixel Shader Compile, Flow Control, Instruction Count, XNA Issue

im trying to find help with an issue im having moving from the XNA 3.1 framework to XNA 4.0. The shaders I wrote for my 2D game work fine in XNA 3.1, but wont even compile in 4.0. At first I got ...
1
vote
2answers
63 views

Defining lines from a heightmap

To a pixel shader of a 2D game, I'm passing a 1-row heightmap that holds the height in UV coordinates of evenly distributed points throughout the texture I'm drawing, but as for n points there will ...
6
votes
1answer
711 views

Do I need to rewrite my HLSL shaders when porting from XNA to MonoGame?

I'm looking at porting an XNA project I have to monogame, but I have a fair number of HLSL shaders. It seems that Monogame for PC uses OpenGL as the rendering backend, and I'd rather not have to ...
2
votes
1answer
543 views

How do you add rotation to particles?

Today I was working on a particle system and I can't figure out how to give the particle billboards a rotation (so to have them spinning clockwise or counter-clockwise while facing the player). I ...
8
votes
1answer
609 views

2D Water top surface profile

I am trying to create the effect of the water surface thickness with a vertex-fragment shader. I am in a 3D game environment but It's a scroll view so a "2D" view. Here is a good tutorial of creating ...
5
votes
2answers
766 views

What range of values can HLSL's tex2D function return?

When using the tex2d function in a HLSL shader, as so: float height = tex2D(heightMap, IN.texCoord).r; What range of values can be returned to the height variable? Is it always a number between ...
2
votes
2answers
300 views

3D Distortion Effect

I'm trying to make a distortion effect similar to this: However I'm not making a 2d screen space effect. I'm applying it to a 3d scene and I want it to be placed IN the world, so it can be blocked ...
0
votes
1answer
134 views

Shader registers for different graphics card

The title is not very explicative, so i'll try to make myself clear. I have two "working"(on which i work on) PCs : a desktop that runs an NVIDIA GT440 an a laptop with a RADEON HD 4650. I have a ...
1
vote
2answers
139 views

In the Direct3D 9 Effect API, how do you find the texture variable linked to a sampler?

In Direct3D 9 effect files you can write a sampler state that specifies a texture variable to use, like Texture2D g_texSkyDome; SamplerState g_samplerSkyDome { Texture = <g_texSkyDome>; ...
4
votes
1answer
2k views

In HLSL pixel shader , why is SV_POSITION different to other semantics?

In my HLSL pixel shader, SV_POSITION seems to have different values to any other semantic I use. I don't understand why this is. Can you please explain it? For example, I am using a triangle with the ...
3
votes
0answers
125 views

Custom sampling points for anti-aliasing [closed]

I'm trying to write an anti-aliasing shader in HLSL, but I can't find any way to rasterize at a custom point. (in between pixels on the screen, but not orderly like supersampling) Is there any way to ...
0
votes
1answer
122 views

Are there alternatives to Vertex Tweening?

Now that I'm getting into animating 3D entities in my game, I was wondering what the best approach for this would be. I did some research and came across something called "Vertex Tweening". However, ...
0
votes
1answer
125 views

Weird rendering issue when applying lightmap through HLSL

I have a weird issue when trying to render the lightmaps in my game. Please see the following screenshots. Note how the scene looks up close with the lightmaps enabled. Note how that same part of ...
3
votes
2answers
717 views

Techniques for reducing terrain shader complexity

My terrain shader does quite a bit, but I don't know how to break it up in any way that will reduce my instruction count without removing key features of the terrain. It does the following: ...
1
vote
2answers
203 views

HLSL Multitexturing with more than 4 textures

I've come up with an idea that should work in multitexturing a terrain with more than 4 textures, up to a 64 if a supported ShaderModel is used. I'm trying to use the RGBA color values as both values ...
1
vote
1answer
258 views

Passing multiple colors to a pixel shader in DirectX

I have a pixel shader that sets the output color based on the interaction of an input texture, sort of like: if (case1) { output.Color = float4(0, 0, 0, 0); } else if (case2) { output.Color = ...
1
vote
0answers
364 views

tex2dlod and tex2d giving different values [closed]

I've been having trouble with vertex texture fetch for a terrain system I am implementing. I'm using C++/DirectX9. I have already implemented exactly what I want as a prototype in C#/XNA and now ...
0
votes
0answers
290 views

HLSL Triplanar texturing and multi texturing performance

I'm stuck for my terrain rendering shader code for DX9. I'm looking to implement triplanar texturing, a texture atlas, and blending between different textures. Right now it's working. The problem is ...
3
votes
1answer
148 views

Switching to a vertex shader

TL;DR I need to switch from a vertex array passed to the pixel shader with a real vertex shader approach. In my prototype, the terrain is procedurally generated and I have the following result: ...