0
votes
0answers
11 views

Deferred Lighting - Mapping generated texture on to screen when there size don't match

A while ago I asked how to map to the generated texture to screen and I was told to use Load function. I found this answer to be fine when the texture and screen size match but it doesn't work when ...
0
votes
1answer
27 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 ...
0
votes
1answer
51 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
37 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
19 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 ...
0
votes
1answer
75 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
0answers
32 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; ...
1
vote
1answer
22 views

HLSL 5.0 vector interpolation issues

I'm having issues with the depth components of my shadowmapping shaders. The shadow map rendering shader is fine, and works very well. The world rendering shader is more problematic. The only value ...
0
votes
2answers
95 views

Can't read .cso files but I can read their .hlsl versions?

Well I've been trying to read a .cso file to use as a shader for a DirectX program I'm currently making. Problem is no matter how I implemented a way to read the file it never worked. And after ...
0
votes
1answer
60 views

Can't read .cso files but I can read their .hlsl versions?

Well I've been trying to read a .cso file to use as a shader for a DirectX program I'm currently making. Problem is no matter how I implemented a way to read the file it never worked. And after ...
1
vote
1answer
84 views

Gamma Space and Linear Space with Shader

I am using Unity and I can choose between two color space mode in the settings: Gamma or Linear Space. I am trying to build a Custom Lighting Surface shader but I am facing some problems with those ...
0
votes
2answers
69 views

InputAssembler and emtpy/incomplete buffers

I was wondering what the InputAssembler does if the size of the bound buffers does not match the vertex count of the Draw() call. I've seen the example at ...
2
votes
1answer
142 views

HLSL float4 addition returning all 0.0f vector, unexpected result

Edit: Added images at the bottom to show the current issue. I have the following few lines in my hlsl pixel shader where color and specular are both float4. color = color * textureColor; // Add ...
2
votes
1answer
87 views

Compare world space distance to shadow map depth

I am rendering shadow maps to cubemaps (just rendering raw depth buffer) then projecting them to the scene to do omni-directional shadow mapping. The cubemap is sampled by the light direction vector ...
0
votes
2answers
176 views

How to mix pixel colors in Shader?

I have a pixel that have a colour RGB. This color is calculated by the shader and can be anything. How can I override this color by a colour I choose. If my pixel is white it's simple, I can do this: ...
0
votes
1answer
106 views

How to share matrix in HLSL?

I am trying to share this across multiple effect files: matrix worldMatrix : register(vs_4_0, b0); If I set this from one effect file, will it effect every effect file which has the same type of ...
9
votes
3answers
688 views

How can I create a glitter effect?

I am trying to create a glittering effect for my realtime shader but I don't know how. Here is one example, and another example. What technique can I use to implement this?
0
votes
1answer
157 views

Rendering Textured Terrain With SharpDX Toolkit [closed]

So i recently moved from XNA to SharpDX Toolkit and started with some basics. The 2d part was easy since nearly nothing has changed but im really struggeling with the 3d part. For example i wanted to ...
0
votes
1answer
346 views

How to get pixel coordinates between 0,1 from SV_POSITION [duplicate]

I am new to HLSL and Directx. I was trying to write a simple gradient Shader by modifying one of Microsoft samples. 1.I can not understand why SV_POSITION is float4? If it is pixel coordinates ...
0
votes
1answer
80 views

Multiplying matrices in HLSL

I have code that calculates a position like this in HLSL: output.ShadowPos = input.VertexPos; output.ShadowPos = mul(output.ShadowPos, gWorld); output.ShadowPos = mul(output.ShadowPos, ...
1
vote
1answer
207 views

How does HLSL handle clip(vector)?

My goal is to convert clip() to GLSL, version 1.5. I'm currently doing a basic: if (x < 0) discard; But if x is not a scalar, obviously I can't use the "<" operator. So I'm wanting to ...
1
vote
1answer
143 views

Does HLSL implement Shader Model LOD instruction?

The DX Shader Model 5.0 has a lod instruction. It returns "the LOD (level of detail) that would be used for texture filtering". Does HLSL have a built-in intrinsic that can do the same? I know I ...
1
vote
1answer
275 views

Color grading, shaders and 3d textures

I'm trying to implement color correction with the 3d lookup table. The lookup table is actually just a 2d texture 256x16 and consists of 16 squares which one is 16x16. When it comes to rendering, I ...
5
votes
1answer
413 views

What does HLSL's tex2D return at (0,0)?

I'm trying to understand the mapping of texels to pixels, especially in the context of pixel shaders. I already found out the following: When I define a standard quad with vertices at integer ...
12
votes
1answer
292 views

Accounting for waves when doing planar reflections

I've been studying Nvidia's examples from the SDK, in particular the Island11 project and I've found something curious about a piece of HLSL code which corrects the reflections up and down depending ...
3
votes
2answers
69 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 ...
3
votes
1answer
233 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 ...
2
votes
1answer
68 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
1answer
148 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
163 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, ...
0
votes
2answers
166 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
1answer
217 views

Why does my blur shader implementation produce this strange result?

I tried to implement the blur shader shown here. Instead of having a simple 2D texture I use Unity's GrabPass function to capture what's behind the plane to have a transparent effect. Then I apply ...
5
votes
2answers
649 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 ...
8
votes
1answer
540 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 ...
2
votes
2answers
266 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 ...
1
vote
1answer
214 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 = ...
2
votes
2answers
219 views

Why does matrix multiplication lead to different result if it's done on CPU, compared to GPU(shader)?

If I'm calculating a "camera space" on the CPU, by multiplying the view with the projection matrix on the CPU , and afterwards multiplying the world to the result my vertices do not pass to the pixel ...
4
votes
1answer
426 views

What happens to data between vertex shader and pixel shader?

Short version: What can happen to the output of a vertex shader that leads to no(or very few) pixels being drawn, especially in relation to a perspective matrix. Long version: My problem refers to ...
4
votes
1answer
437 views

Applying an outline effect to primitives

I am trying to draw an outline on a collection of quads in Direct3D. I have three intersecting quads on the same plane in the following configuration: (The different colors here are just to ...
3
votes
1answer
261 views

Per Instance Textures, and Vertex And Pixel Shaders?

How do you implement per instance textures, vertex shaders, and pixel shaders? Given: 1. Two different model templates in Vertex Buffer, Square & Triangle 2. Instance Buffer with [n] instances of ...
2
votes
1answer
230 views

Direct3D shader compilation fails with constant buffers

I've been particularly annoyed by a 'bug' for a couple days involving D3DCompile and vertex shaders with constant buffers. I'm assuming the bug is my fault (missing flag or small nuance of the poorly ...
2
votes
1answer
170 views

Nine Patch Images in DirectX

In Android development I found nine patch images very useful to draw images that have a fixed border. When the image is scaled the inner part scales, but the border stays at a fixed size. I was ...
1
vote
2answers
209 views

Diffuse light direction

I'm learning a tutorial from Rastertek about diffuse light with DX 11, here's the shader code: float4 LightPixelShader(PixelInputType input) : SV_TARGET { float4 textureColor; float3 ...
3
votes
1answer
192 views

Why are some objects not rendering properly?

Here's a button I exported from Blender into a .x format: Now here it is in the game with BasicEffect applied to everything: And now with my custom shader: And there's the problem. While the ...
1
vote
1answer
132 views

Texture the quad with different parts of texture

I have a 2D quad. Let say it's position is (5,10) and size is (7,11). I want to texture it with one texture, but using three different parts of it. I want to texture the part of quad from x = 5 to x ...
9
votes
4answers
1k views

Avoid if statements in DirectX 10 shaders?

I have heard that if statements should be avoid in shaders, because both parts of the statements will be execute, and than the wrong will be dropped (which harms the performance). It's still a ...
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 ...
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 ...
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
797 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 ...