0
votes
0answers
30 views

Transform texture coordinates when using shader

Assuming I define four vertices of a quad with texture coordinates that cover a whole texture or region of a texture, I can animate these coordinates by setting a transform using SetTransform( ...
0
votes
0answers
21 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; ...
2
votes
1answer
89 views

How can I compile a Direct3D 9 effect from a file?

I started working with shaders recently in DirectX9. I noticed that there is a D3DXCompileShaderFromFile function for IDirect3DVertexShader9 and pixel shader. Which compiles the shader and gives you ...
0
votes
2answers
89 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 ...
4
votes
2answers
93 views

Should I use different input layout for meshes (vertices) with and without normal maps?

I'm writing an DirectX11 game. About 60% of my game models (or "of my vertices") have: Position Texture coordinate Some of them use: Position Texture coordinate Normals And few of them: ...
9
votes
3answers
1k views

How many active shaders at one frame in the game (should I typically use)? 5? Or more like 100?

I have a question: how many shaders are usually active at the same time in one scene in modern games? I mean: I know that multiple shaders are being used (switching between them in each frame). And ...
1
vote
1answer
70 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
0answers
48 views

Bilinear filter in repeating texture, HLSL

I have a repeating texture that I'm using as a scroll surface. The idea is that as I pan the surface I adjust the texture coordinates, filling in what gets wrapped on the right as it disappears from ...
3
votes
1answer
113 views

Using normals in DirectX 10

I've got a working OBJ loader that loads vertices, indices, texture coordinates, and normals. As of right now it doesn't process texture coordinates or normals but it stores them in arrays and creates ...
0
votes
2answers
175 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
99 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
628 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?
1
vote
1answer
58 views

Does `SetResourceArray` copy the data into the GPU?

I am trying to create multiple textures, and only several of them change every few frames. I don't want to have to copy in the whole array via SetResourceArray for just a few textures that change, ...
2
votes
1answer
106 views

How do we apply different textures to different faces generated via geometry shader?

I am trying to render a cube by starting of with one vertex into the shader, then geometry shader to expand into a cube, and then apply a different texture to each side. The part I am facing the issue ...
1
vote
2answers
148 views

How can I render 3D dots at object vertex positions?

What is the best way to put a dot on a vertex? I have a model (a plane for example) consisting of a few thousand vertices. I want to draw a red dot at every vertex's 3D position, just like 3ds Max's ...
0
votes
1answer
255 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 ...
3
votes
1answer
208 views

Multiple pixel shader passes

I currently have a pixel shader that calculates the texture and I have another that calculates the light. I want another shader that does both. What I would ideally like to do is instead of creating a ...
0
votes
1answer
246 views

Difference between texture.Load() and texture.Sample() methods in DirectX?

The question is simply that: What is the difference between texture.Load() and texture.Sample() in DirectX? I've used a Texture2D to store the depth in a pass of a DirectX Shader (with SharpDX), and ...
0
votes
2answers
104 views

Alpha interpolation in a pixel shader

How does the interpolation in a fragment shader work when it comes to the alpha parameter? I'm programming a shader with SharpDX, DirectX11. My idea is to interpolate 2 3d points of a segment, so ...
0
votes
2answers
126 views

Accesing depth buffer from shader

I read this presentation and on 6th slide I found that is not need to use multiple render targets and depth can be taken directly from depth buffer. From which version of DirectX or OpenGL can be ...
3
votes
2answers
67 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
1answer
123 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
159 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
135 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 ...
2
votes
1answer
341 views

Fog shader camera problem

I have some difficulties with my vertex-fragment fog shader in Unity. I have a good visual result but the problem is that the gradient is based on the camera's position, it moves as the camera moves. ...
1
vote
1answer
207 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 ...
2
votes
1answer
517 views

Simple Optimized Blur Shader

I have a vertex-fragment shader that use the Unity3D GrabPass functionality (it grabs the screen). And I apply my GrabPass to have a transparent effect. GrabPass { "_GrabTex" } sampler2D ...
5
votes
2answers
584 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
488 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
254 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
171 views

Texture Shaders vs. Pixel/Fragment Shaders?

My question is a simple one. Functionally, practically, and performance-wise, what are the differences between using a D3DX Texture Shader, and using a Pixel/Fragment Shader rendered with a full ...
-4
votes
1answer
134 views

My 2d Shader in XNA falls apart the second I put it into Farseer [closed]

I wrote a simple light shader that I tested in a simple 2d spaceship shooter and it worked fine. Once I imported it into my friend's farseer project with rotatable shapes, it doesn't seem to work ...
3
votes
1answer
403 views

Matrix in constant buffer on the GPU contains NaNs but not on the CPU

I've got a shader with the following constant buffer: cbuffer ShaderParameters { matrix inverseViewProjectionMatrix; float4 cameraPosition; }; When using Visual Studio 2012's graphic ...
0
votes
1answer
143 views

Strange rendering in Direct3D 10 [closed]

I'm writing an application which renders graphics on the screen. The application can switch between Direct3D9 and Direct3D10 graphics modules (I wrote DLLs that wrap both D3D9 and D3D10). When trying ...
1
vote
1answer
112 views

How can I get a pointer to ID3DX11EffectShaderVariable from ID3DX11Effect

I'm using the DirectX Effects framework and I want to create an input layout automatically when compiling an effect. I've tried to call ID3DX11Effect->GetVariableByName() with the shader's name, to ...
-1
votes
1answer
128 views

How To Buffer Many Vertex, Geometry, and Pixel Shaders

What is the best way to buffer Vertex Shaders, Pixel Shaders, etc into the Device/Device Context without having to reload them from the filesystem every time? ID3D11Device::CreateVertexShader ...
2
votes
1answer
218 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 ...
8
votes
1answer
292 views

Curious Transparent Holes Render Artifact

So I'm trying to implement "smooth" terrain in my block engine by giving each surface block a heightmap. Basically, what I do to generate these "heightmaps" for each block is I generate the heights ...
2
votes
1answer
160 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 ...
12
votes
3answers
4k views

Fastest way to render lines with AA, varying thickness in DirectX

So I'm doing some DirectX development, using SharpDX under .NET to be exact (but DirectX/C++ API solutions are applicable). I'm looking for the fastest way to render lines in an orthogonal projection ...
3
votes
1answer
190 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 ...
4
votes
2answers
970 views

ConsumeStructuredBuffer, what am I doing wrong?

I'm trying to implement the 3rd exercise in chapter 12 of Introduction to 3D Game Programming with DirectX 11, that is: Implement a Compute Shader to calculate the length of 64 vectors. Previous ...
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 ...
0
votes
2answers
357 views

How can I capture every frame in DirectX 9 using a shader

This is actually a follow up to this question How to capture the screen in DirectX 9 to a raw bitmap in memory without using D3DXSaveSurfaceToFile The proponent of the best solution suggested that I ...
3
votes
1answer
485 views

Where is the Shader Designer in Visual Studio?

I have Visual Studio 2012 Ultimate and I've been trying to access the Shader Designer. I searched through MSDN's text and Channel9's videos, but they keep failing to mention how to access it. Can ...
1
vote
1answer
289 views

Intercepting DirectX calls and optimizing the overal performance of games

I would like to use a DirectX proxy dll to intercept (and possibly optimize) the graphics calls being made by normal PC games. I am going to "screen cast" a game with ffmpeg or something similar and ...
1
vote
2answers
227 views

What could cause a pixel shader to paint outside the lines of the vertex shader output?

From what I understand, the pixels that a pixel shader operates on are specified implicitly by the SV_POSITION output (in DirectX) of the vertex shader. What then could cause a pixel shader to render ...
4
votes
1answer
743 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 ...
9
votes
2answers
695 views

Handle many lights in a scene (with shaders)

I'm curious about how to handle many lights in a scene. Given a very big map in a role playing game, with dungeons (with lights in there) etc. I know about deferred lighting, but that only answers how ...
9
votes
3answers
2k views

Pixel-perfect rendering to a rendertarget with a fullscreen quad

I have some trouble rendering a bunch of values to a rendertarget. The values never end up in the exact range I want them to. Basically I use a fullscreen quad and a pixel shader to render to my ...