Tagged Questions

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

learn more… | top users | synonyms

-1
votes
1answer
29 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
32 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
1answer
42 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
44 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
29 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
58 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
67 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
51 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
105 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
1answer
45 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: ...
2
votes
2answers
50 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
35 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
39 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
71 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
88 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
165 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
43 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
30 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 ...
2
votes
0answers
136 views

HLSL defines vs static const

So far I've been declaring all my constant variables as static const in my hlsl shader code, yet virtually every single shader piece I've come across uses #defines instead. I know the reasons I would ...
1
vote
1answer
71 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
51 views

Vertex definitions and shaders

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
72 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
463 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
25 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
56 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
208 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
59 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
67 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
56 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
60 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
76 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
60 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
138 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
157 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
116 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
79 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
61 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
298 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
87 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
94 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 ...
0
votes
1answer
87 views

What coordinates are we passing to pixel shader from vertex shader?

I have read articles about shader programing and understood the very basic knowledge of shader programing. One thing I always get confused is about the texture mapping. What I pass(output) from VS to ...
0
votes
0answers
52 views

DirectX9 Normal/Bump Mapping Weird Texturing Artifact

As you can see the artifact here is like a triangle of the mesh getting more light. The important part of my code is below. This is the vertex declaration. VertexElement[0].Stream = 0; ...
0
votes
1answer
57 views

HLSL tile shader

How would I make this HLSL code tile my texture: float4x4 World; float4x4 View; float4x4 Projection; float4x4 WorldInverseTranspose; float4 AmbientColor = float4(1, 1, 1, 1); float AmbientIntensity ...
1
vote
1answer
201 views

Tile textures on 3D models. HLSL shader code maybe?

I'm making a game in C# with XNA. I'm now applying textures to models. However if I change the scale of the model, the texture stretches with it. How can I make the texture tile over the model instead ...
0
votes
0answers
58 views

Pixel Shader : Backbuffer is 'Black'

After Fiddling around I am pretty sure this is not a Shader issue. Edit 4: The only diference I can see is that BasicEffect calls these methods before drawing: // Make sure that domain, hull and ...
0
votes
0answers
122 views

How can I mark a pixel in the stencil buffer?

I never used the stencil buffer for anything until now, but I want to change this. I have an idea of how it should work: the gpu discards or keeps rasterized pixels before the pixel shader based on ...
1
vote
1answer
124 views

How to make other semantics behave like SV_Position?

I'm having a lot of trouble with shadow mapping, and I believe I've found the problem. When passing vectors from the vertex shader to the pixel shader, does the hardware automatically change any of ...
1
vote
0answers
110 views

Sphere Texture Mapping shows visible seams

As you can see from the above picture there is a visible seam in the texture mapping. The underlying mesh is a geosphere based on octahedron subdivisions. On that particular latitude, vertices have ...
7
votes
1answer
413 views

Tessellation vs Geometry Shader

Correct me if I'm wrong, but both the Geometry Shader and the Tessellation Shader jobs are to generate vertices in the Graphic Pipeline. What I would like to know is how they are different and when ...