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

learn more… | top users | synonyms

0
votes
1answer
30 views

Need help creating points in an array

I'm creating a lightning geometry shader using hlsl that creates an array of points based on an arbitrary number of generations. The gist of what I want to accomplish is here: ...
0
votes
0answers
27 views

raise an event when an object appears using HLSL and XNA [on hold]

I've written an HLSL code to make transparency of player using depth view of Kinect on the background image. this is my HLSL code : sampler stream : register(s0); sampler back : register(s1); sampler ...
2
votes
1answer
45 views

The way of avoiding branching for textured and not-textured objects

I know that branching is an expensive operation on GPU (not as much as it used to be, but still). The most common situation where I use branching is when I have both textured and non-textured ...
0
votes
0answers
79 views

HLSL 5.0 assembly shows tons of ieq / add / or instructions for array indexing in loop

First of all, I have to apologize for the long code samples, but their content is not so important. Besides they are really simple and I tried to comment as much as possible. I'm working on a pixel ...
1
vote
3answers
136 views

2D HLSL World position

I'm trying to get world position from my vertex shader to my pixel shader so that I can disable the shader once a preset X coordinate has been passed (no shading once I'm over X). Getting the screen ...
0
votes
1answer
63 views

Directx: HLSL Texture based height map. (Shader 5.0)

I'm trying to implement a GPU based height map the simplest (and fastest) way that I know how. I passed a (.png, D3DX11CreateShaderResourceViewFromFile()) texture into the shader, and I'm attempting ...
1
vote
0answers
61 views

Screen Space Decals Normal Mapping [closed]

I'm trying to implement screen space decals with normal mapping support. Up to this point I'm able to project decals into my scene. I'm even able to sample from the normal map in decal space. I ...
1
vote
1answer
59 views

How to diagnose the problem when the input assembler and the vertex shader look correrct, but the Output Merger is wrong? [on hold]

I'm porting some OpenGL code to Direct X 11. I ended up with nothing being drawn on the screen. I reverted to a simple program, which I am writing about here. I'm now trying to use the Graphics ...
0
votes
1answer
43 views

Compiling a shader with fxc results in invalid ps_5_0 output semantic 'COLOR0'

I'm attempting to compile a shader at the command prompt. What am I doing wrong that would make it generate this error? fxc /Od /Zi /T ps_5_0 /E "ps_main" /Fo "basic.pso" "basic.ps" Here is the ...
-2
votes
1answer
42 views

SharpDx Custom effect in SpriteBatch

I'm trying to port a blur effect from an XNA project over to SharpDx, and I get a "Null Reference Exception" wich I'm unable to find the reason for. private void blurShadow(RenderTarget2D to, ...
1
vote
2answers
41 views

Dynamic Flow Control in HLSL with Array References

I'm trying to do lighting calculations for an array of point lights in HLSL. I simply want to pass light direction vectors from the vertex shader to the pixel shader. Here is sample code: static ...
0
votes
2answers
81 views

Transparency using HLSL in XNA

I currently working on Depth Data on Kinect SDK v1.8 on XNA and I wanna show an Image Inside the Depth view of Human body. the image below is just an example of what I wanna do : ...
1
vote
0answers
58 views

Geometry shader: Dynamic output?

I'm currently using a geometry shader to generate grass blades out of single root points that are layed out in a grid. For each root point, I generate a grass blade with, right now, a constant number ...
0
votes
0answers
34 views

Very subtle HLSL syntax change causes compliation error

The following HLSL works and compiles: texture2D renderTarget; float h; // declared here sampler GetRenderTarget = sampler_state { texture = <renderTarget>; }; float3 GetHsvFromRgb(float3 ...
2
votes
1answer
66 views

HLSL compiled code

I've been using RenderDoc for debugging my shaders, and one thing that struck me as odd is that sometimes, after stepping through the debugger, I notice some vector attributes are interchanged, for ...
0
votes
1answer
76 views

Fullscreen triangle pass and texcoords

So I have a fullscreen triangle shader like this: #ifndef FULLSCREEN_TRIANGLE_VERTEX_HLSL #define FULLSCREEN_TRIANGLE_VERTEX_HLSL // Variation on Timothy Lottes FXAA vertex shader, for CCW frontface ...
1
vote
1answer
87 views

How does Direct3D know if a constant buffer is for the vertex or pixel shader?

I have a question about constant buffers in directX 11. They really confuse me and after searching on google most sites simply supply sample code without explaining how it works. I am probably ...
2
votes
1answer
111 views

Shader - Transmittance or Absorption

I am trying to create a transmittance or absorption shader (glsl, hlsl, cg, etc...) in realtime but I don't find any good tutorial or white paper about this subject. I only find offline rendering ...
0
votes
2answers
91 views

How do I sample a Depth/Stencil Texture in HLSL?

I am shadow mapping in Direct3D 9. I'm trying to avoid rendering depth to a 32-bit render target. So, I've created a depth/stencil texture( a texture w/usage Depth/Stencil ). When I render I do this: ...
3
votes
2answers
64 views

In XNA 4, how can I access SpriteBatch's transformMatrix in my shader?

I would like to use a custom effect with a regular XNA SpriteBatch. I have a 2D camera which computes a transform matrix, so I need my shader to take this into account. I have put a world matrix ...
0
votes
0answers
48 views

marshaling c# struct with array to const buffer

I am trying to use a const buffer to pass a structure with an array of values into the pixel shader. However, all my color[] array values are coming in as zeros. I have the struct defined as: ...
0
votes
0answers
51 views

Depth Map not rendering properly in DirectX / HLSL / SharpDX

I've been struggling with this for awhile, and everything I find online says this SHOULD be working, but I apparently missed something. I'm attempting to run Deferred Rendering in SharpDX on a ...
0
votes
1answer
82 views

“_SRGB” suffix for BC texture format doesn't result in sRGB-to-linear correction at sampling

I am working on a 3D engine as a hobby (Direct3D 11). Currently I am trying to implement sRGB -> linear -> sRGB color space conversions via texture formats with "_SRGB" suffix. So, my textures are ...
2
votes
0answers
100 views

SSAO and normal issues

I'm using a SSAO alghorithm called "SAO", seen here: http://graphics.cs.williams.edu/papers/SAOHPG12/ I'm currently having issues with "smooth" normals, for example when using normal/height maps. To ...
3
votes
2answers
172 views

Shader - Calculate depth relative to Object

I am trying to calculate depth relative to the object.Here is a good solution to retrieve depth relative to camera : Depth as distance to camera plane in GLSL varying float distToCamera; void main() ...
0
votes
0answers
44 views

HLSL - Binary operations

I'm trying to do binary operations with integers in the hlsl code. For example: int n = 10 & 15; Binary value of 10 = 1010 and Binary value of 15 = 1111. With this, n = 10, because (1010 & ...
0
votes
0answers
35 views

HLSL Shader Relative Positioning

I've got a shader that does the texturing, lighting, etc. for my game engine (written on top of MonoGame, in case that's relevant) for my block-terrain-based game (everything is rendered as triangles ...
3
votes
1answer
160 views

In HLSL, what is the difference between “static const” and “#define” for constants?

So far I've been declaring all my constant variables as static const in my HLSL code, yet virtually every single shader example I've come across uses #define instead. I know the reasons I would I use ...
1
vote
1answer
100 views

Static constants set to default value in HLSL

I'm using dx11 and I'm working on SSAO. I am having wierd results, so I tried debugging it using RenderDoc and stepping through the pixel shader log, all the values of the static array seems to ...
2
votes
1answer
56 views

Vertex definitions and shaders [closed]

I noticed that from looking at other examples like say .. riemers tutorials he takes a buffer with a bunch of vector3's in it and ties it to a shader which expects a float4 ... why does this work in ...
0
votes
2answers
73 views

HLSL Shadow Mapping occurs only around player

I've recently begun playing around with Monogame (OpenSource "remake" of XNA). My current task is to write a simple shadow mapping shader. After following Riemer's XNA Tutorial I got the shadows to ...
2
votes
2answers
709 views

How to implement Fog Of War with an shader?

Okay, I'm creating a RTS game and want to implement an AgeOfEmpires-like Fog Of War(FOW). That means a tile(or pixel) can be: 0% transparent (unexplored) 50% transparent black (explored but not in ...
0
votes
0answers
30 views

XNA `tex2Dlod` always returns transparent black

I want to sample a texture in a vertex shader, so at first I just tried using float2 texcoords = ...; color = tex2D(texture, texcoords); But apparently I cannot use tex2D in a vertex shader, and ...
1
vote
0answers
57 views

Multi Pass Blend

I am seeking the simplest working example of a two pass HLSL pixel shader. It can do anything really, but the main idea is to perform "ping ponging" to take the output of the first pass and then send ...
-1
votes
1answer
303 views

How add fog with pixel shader (HLSL) XNA?

I started to make a small game in XNA . And recently i tried to add a "fog" on "pixel shader HLSL" with the class Effect from XNA . I search online about some tutorial and found many sample. But ...
1
vote
1answer
75 views

HLSL: An array of textures and sampler states

The shader must switch between multiple textures depending on the Alpha value of the original texture for each pixel. Now this would word fine if I didn't have to worry about SamplerStates. I have ...
0
votes
1answer
89 views

HLSL SampleCmp compile error

When trying to compile the following HLSL: Texture2DArray gShadowmap : register(TEXTURE_REGISTER_DEPTH); SamplerState gShadowmapSampler : register(SAMPLER_REGISTER_DEPTH); // ... float3 projCoords ...
1
vote
0answers
63 views

XNA HLSL UV Mapping

I was testing my hlsl lighting shader, I've copied it from a tutorial and it works perfectly, but all the meshes in the model needs to have texture coordinate, I guess this is because this part: ...
0
votes
1answer
63 views

Deferred Lighting - How to map to the generated texture?

I'm trying to implement deferred lighting and I have done the first and second pass but I'm stuck on the third as I don't know how to map from the current pixel being drawn to the generated texture ...
0
votes
1answer
91 views

HLSL Pixel Shader Sematics

I have a HLSl pixel shader that I'm using to create a deferred buffer, I have simplified the code to show you: struct PS_INPUT { float4 PosWVP : SV_POSITION; float4 ...
0
votes
0answers
20 views

Shader | Special Effect - Unit selection [duplicate]

I would like to know how the shaders used to show which unit is selected are made. Here is an image to illustrate. How the merge effect of the blue circles can be achieved ? I didn't found any ...
1
vote
1answer
65 views

Unity, shader, vertexID

I'm writing a shader and I just wanna ask if it's possible to get the ID of the vertex that is currently being manipulated. I read something about gl_vertexID, but I couldn't find out if that is ...
0
votes
1answer
170 views

HLSL - can't get texture to wrap or mirror

I'm currently converting an app from XNA to SharpDx and I'm therefore upgrading my shaders to version 4 (vs_4_0/ps_4_0). When using this sampler: SamplerState MySampler { Filter = ...
0
votes
1answer
218 views

Can't sample texture in HLSL using DX11

Environment: Windows 7 x64 Visual Studo 2012 DirextX11 HLSL Shader Model 5 Ogre 1.9 Okay, so I'm trying to sample a texture in my pixel shader but I'm coming across some strange problems. Here's ...
0
votes
1answer
137 views

Fullscreen triangle SV_POSITION and deferred shading

So I'm trying deferred shading in DirectX11. I am using the following method (used in the FXAA shader and described here: http://www.altdev.co/2011/08/08/interesting-vertex-shader-trick/) to render ...
0
votes
1answer
80 views

XNA Masking Mayhem

I'd like to start by mentioning that I'm just an amateur programmer of the past 2 years with no formal training and know very little about maximizing the potential of graphics hardware. I can write ...
1
vote
1answer
71 views

D3D11 shader signature validation with SV semantics

I'm trying to figure out what the rules are for linking the outputs of one shader stage to the inputs of the next. Since D3D11 does not have any error checking for linkage between shader stages, I ...
4
votes
2answers
305 views

Conditional Defines and HLSL

Is it possible to use project level conditional defines in hlsl code? I'm trying to conditionaly compile a shader using MonoGame Content Procesor. Depending on project type (ie. Windows, Windows8...) ...
1
vote
2answers
98 views

Transform coordinates in vertex shader or in geometry shader?

Currently I have a vertex shader which just passes the coordinates to the geometry shader and a geometry shader which does some sort of tessellation. Now I also want to transform my model with a 4x4 ...
0
votes
1answer
104 views

How to fix this existing shadow shader/material with alpha textures?

I hope I could get some help here in finally resolving this problem of mine re: shadow casting with alpha textures. Here's a screenshot on what I am hoping for as a result: A friend of mine just ...