HLSL is a proprietary shading language developed by Microsoft for use with the Microsoft Direct3D API.
1
vote
1answer
291 views
Writing to multiple RenderTarget2D's from HLSL shader
I need to write to two render targets: one for colour and another for depth+normal (for post-processing). I have a problem, though. Both targets seem to be getting the value output by COLOR0, while ...
3
votes
1answer
585 views
*DX11, HLSL* - Colour as 4 floats or one UINT
With the DX11 pipeline, would it be much quicker for the vertex buffer to pass one single UINT with one byte per channel to the input assembler, as opposed to three floats? Then the vertex shader ...
2
votes
2answers
325 views
How would I create an HLSL effect like an animated “working” image?
I want to create the effect in the image in HLSL specifically get a block of pixels to move from a specified start point to an end point, so that it can go across the entire screen, but I don't have a ...
2
votes
1answer
484 views
Shader optimization - Cg/HLSL pseudo and via multiplication
HLSL/Cg do not allow texture fetching inside conditional blocks. To get around this I am first checking a variable and performing some computations, afterwards I set a float flag to 0.0 or 1.0, ...
3
votes
1answer
516 views
Shadow-mapping xna
I've been trying to implement shadows in my game and I've been following quite a few tutorials online, mainly Riemers, but I'm always getting the same 2 errors when I'm drawing my models and setting ...
2
votes
1answer
204 views
Shader and Custom Vertex Format Errors
I am creating an editor of sorts that allow you to create 3D voxel models. I just got started and have ran into a few errors. Here is what it is producing:
I think the problem has to do with the ...
1
vote
2answers
174 views
How (if possible) would I change the BasicEffect Matrix mid draw
Say, for example, I have a list of enemies. Each enemy is a textured quad which is the stored in a singular shared VertexBuffer and IndexBuffer with the buffer usage set to BufferUsage.WriteOnly ...
3
votes
4answers
448 views
Enconding/Decoding bit value in Texture Alpha Channel
I am Rendering to a SurfaceFormat.Color. (R8G8B8A8)
The alpha of this format has 8 bits and I want to be able to use those 8 bits as a bit field.
For example, in one pass of my render, I want to save ...
2
votes
2answers
587 views
Is the output from D3DCompile specific to one GPU, or not?
In Direct3D 11 there is a two-stage shader compilation process; you first pass the HLSL source code into D3DCompile, which outputs a "blob" of bytecode. You then take this blob and call ...
2
votes
2answers
608 views
Why can't I get a bool packed and aligned into a D3D constant buffer?
Alright, I'm having a hard time getting a bool packed and aligned into a hlsl constant buffer and I'm not sure why.
Here is the buffer in hlsl
cbuffer MaterialBuffer : register(b1) {
float3 ...
1
vote
1answer
230 views
screen coordinate not working with pixel values
I have a very simple effect file shown below. I am using this to draw 2D lines, however it is not behaving how I expected and I can't seem to get my head round why.
If I draw a line that goes from ...
1
vote
1answer
373 views
Sampling from Normal Map and Diffuse Map in Pixel Shader
I'm having some issue changing a basic lighting shader to take a normal texture and a diffuse texture for a model and then using the normal texture for lighting.
The code is very simple and i can't ...
2
votes
0answers
372 views
3D Studio Max Models and Shaders to XNA
I am looking for a way to import my 3D models, including materials and shaders to from 3D Studio Max to XNA.
For example, if I have a model, with diffuse, bump, reflection textures and values (in ...
2
votes
1answer
1k views
Some assistance with selective 2D Bloom in XNA
I'm in need of some assistance, as I've been at this for 2 days now and have gotten almost nowhere.
I'm trying to use the XNA Bloom sample's component to apply bloom only to my UI text. (The only ...
1
vote
3answers
174 views
Extracting blend values from uint32 not working as expected
I have the following shader configuration code :
uint gBlendValue = 0xffffff00;
Terrain.Effect.GetVariableByName("gBlendValue").AsScalar().Set(gBlendValue);
And I have the following shader code :
...
2
votes
2answers
413 views
How do I keep a triangle strip between geometry shader invocations?
I'm using a small geometry shader to build a "ribbon" from a set of points. For each point, I create 4 vertices that represent a section of the ribbon:
[maxvertexcount(4)]
void GS( point GS_Input ...
2
votes
2answers
423 views
HLSL: how to get/set effectvariable to an array of structs with Direct3D10
HLSL Code:
//Lights
struct Light
{
float3 pos;
float3 dir;
int type;
} m_aLights[3];
How can I get/set an effectvariable to m_aLights with Direct3D10?
Thanks
18
votes
2answers
2k views
How do I create a wide-angle / fisheye lens with HLSL?
What are the concepts that need to be implemented in order to achieve the effect of a wide angle lens of varying extremities?
Pseudocode and specific explanation referring to the various stages of ...
3
votes
2answers
229 views
Fire range arc behind buildings
need some help with HLSL. Each charater in my game shows a fire range arc (which is a textured model) which show how far the guy can shoot, see
It looks ok, but I hate the fact that it shows even ...
0
votes
1answer
589 views
Some help understanding and modifying a 2D shader
I have a similar question as the one posed here, except that I don't wish to use a 1D Color Palette.
I simply wish to have it display 1 color of my choosing (red, for example). I plan to use this ...
3
votes
2answers
490 views
How to achieve hologram projection effect with head tracking
I want to recreate this:
http://www.youtube.com/watch?v=9xMSGmjOZIg&feature=related
I can take care of tracking the user's head, and in one of the comments I believe the author says that he used ...
2
votes
1answer
781 views
Why is a fully transparent pixel still rendered?
I am trying to make a pixel shader that achieves an effect similar to this video http://www.youtube.com/watch?v=f1uZvurrhig&feature=related
My basic idea is render the scene to a temp render ...
0
votes
2answers
1k views
How to achieve after-image pixel shader effect
How would one go about writing a pixel shader like this one in XNA 4.0?
http://www.youtube.com/watch?v=f1uZvurrhig&feature=related
1
vote
1answer
626 views
How to set TextureFilter to Point to make example Bloom filter work?
I have simple app that renders some particles and now I am trying to apply the bloom shader from the xna samplers ( http://create.msdn.com/en-US/education/catalog/sample/bloom ) to it, but I am ...
5
votes
2answers
489 views
Spin/Rotational Blur
How do I perform a circular/rotational/spin blur on an image - using DirectX9.0 and HLSL?
For example:
2
votes
1answer
392 views
tiled map - changing textures? (XNA HLSL)
I have successfully created a tiled map of various textures. Right now, i had a Vector4 in my own custom Vertex declaration deciding what texture each of the tiles should be. This is working ...
1
vote
1answer
544 views
Rendering fancy particles?
I'm making a tower-defense game for Windows (not phone) in XNA.
I've seen this video of another tower-defense game for Windows Phone that uses particle effects, which I really like. They change ...
9
votes
1answer
2k views
Wave ripple effect?
I've been working on a tower-defense game for some time now, and so far I am really satisfied with the results. However, there's one thing I'd like to add.
I've seen a video of GeoDefense for Windows ...
5
votes
1answer
4k views
DirectX11, how do I manage and update multiple shader constant buffers?
Alright, I'm having a hard time grasping how constant buffers are bound to a pipeline stage and updated. I understand that DirectX11 can have up to 15 shader-constant buffers per stage and each buffer ...
3
votes
1answer
380 views
Increasing resolution of a texture?
I'm doing some experiments on my own to improve my general skills with HLSL and so forth. In other words, I'm not doing any serious game development, but only looking to expand my knowledge within the ...
5
votes
1answer
544 views
XNA HLSL - what happens if I grab a pixel outside a texture?
I'm using the tex2D function of HLSL, and I am wondering what will happen if I try to grab a pixel from a pixel coordinate outside of my texture (as an example 1.1). Will it clamp? Will it repeat the ...
1
vote
1answer
736 views
XNA - Getting HLSL pixel of current render target?
I'm setting a render target in XNA using the following lines of code:
Game.GraphicsDevice.SetRenderTarget(physicsTexture);
Game.GraphicsDevice.Clear(Color.White);
...
0
votes
1answer
489 views
D3D11 - Setting multiple ID3D11SamplerStates for the pixel shader stage once and leaving them be
In my Direct3D 11 application, I am using several sampler states to retrieve texture data. Some of them are used in all pixel shaders, some of them are only used in very specific ones.
The question ...
19
votes
2answers
928 views
Weird white outline around model
I'm working on a game in XNA 4 and I recently switched to a deferred shading implementation following this guide. A strange white outline is showing up on my models now and I'm not sure whats causing ...
16
votes
7answers
832 views
Spawning units in a world made by Perlin noise?
There's some issues that I've come across in my Perlin noise-based game. Take a look at the attached screenshot below.
The white areas you see are walls, and the black areas are walkable. The ...
1
vote
1answer
952 views
Why can't I add a float4 read from a Texture2D.Sample in the Vertex Shader
These lines work (compile fine):
float4 offset = HeightMap.Sample(HeightSampler, input.Texcoord);
input.Position.xyzw += float4(0, 1, 0, 0);
These do not (any use of offset together with ...
1
vote
1answer
342 views
Perlin noise example the same on CPU as GPU?
I am looking for an example site with a Perlin Noise implementation in both CPU and GPU, that generates somewhat the same results in those two places.
I see many CPU implementations of Perlin Noise, ...
5
votes
1answer
585 views
Perlin noise - copying the algorithm on the CPU?
I have successfully made a Perlin noise algorithm on the GPU. It works as expected, and generates great results. Now, as part of the physics calculations in my game, I need to replicate the exact same ...
1
vote
0answers
462 views
How can I run the pixel shader effect?
Stated below is the code for my pixel shader which I am rendering after the vertex shader.
I have set the wordViewProjection matrix in my program but I don't know to set the progress variable i.e in ...
3
votes
2answers
406 views
Textures do not render on ATI graphics cards?
I'm rendering textured quads to an orthographic view in XNA through hardware instancing. On Nvidia graphics cards, this all works, tested on 3 machines. On ATI cards, it doesn't work at all, tested on ...
4
votes
3answers
1k views
Loading and using an HLSL shader?
I've been looking everywhere and all I can find are tutorials on writing the shaders. None of them showed me how to incorporate them into my scene.
So essentially:
Given an hlsl shader, if I were to ...
3
votes
1answer
240 views
Write to one channel of R16G16 texture on Xbox
I was going to draw my shadow map into one channel of a 16 bit texture and then draw a different shadow map into another channel of the same texture.
I realized that this might not be possible to do ...
1
vote
1answer
640 views
How to make a custom semantics HLSL shader for the pixel shader
I'm pretty sure it's possible but i have no idea how.
Could anyone tell me how to make a custom semantic for a pixel shader.
Thanks
13
votes
4answers
2k views
how does HDR work?
I'm trying to understand what HDR is and how it works.
I understand the basic concepts and have an slight idea of how it is implemented with D3D/hlsl.
However it's still pretty foggy.
Say I'm ...
1
vote
1answer
650 views
downsampling algorithm
what are the steps to perform downsampling on a texture ?
I've got as far as rendering the scene to a render target, but I'm not sure as to how to then render that to a smaller texture in order to ...
11
votes
4answers
960 views
How does an HLSL shader actually end up affecting the render output?
I understand the syntax of HLSL, for example let's pretend I have this as my HLSL:
struct VOut
{
float4 position : SV_POSITION;
float4 color : COLOR;
};
VOut VShader(float4 position : ...
4
votes
3answers
2k views
Inverting matrix in HLSL
I've got an object in HLSL and I'm using hardware instancing to render multiple copies. But I've come a bit of a cropper when it comes to the vertex normals. Currently I am not using normal mapping ...
3
votes
2answers
535 views
Trying to understand relatively simple normal map antialiasing paper
See this paper: ftp://download.nvidia.com/developer/Papers/Mipmapping_Normal_Maps.pdf
They describe the very simple implementation of an algorithm for antialiasing normal maps.
I don't understand ...
7
votes
3answers
1k views
Rotating a vector by another vector in shader
I have a terrain surface with a normal for each point on the terrain.
I have a second detail normal map to be applied to the terrain.
These normals are in 3-space.
The Y value of both normals is
...
6
votes
2answers
292 views
Does it make sense to include an index for linelists?
Does it make sense to include an index by using DrawIndexedPrimitives, when using linelists performance wise? I could imagine it would be easy for the GPU to generate such indexes anyway.