HLSL is a proprietary shading language developed by Microsoft for use with the Microsoft Direct3D API.
31
votes
6answers
9k views
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 ...
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 ...
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 ...
16
votes
11answers
3k views
What are some good resources for learning HLSL?
The last time I tried learning HLSL, I made a few shaders and mostly understood what I was doing, but I still felt like I was stumbling in the dark. Most of what I learned I got from various blog ...
15
votes
3answers
2k views
How can I create a lighting effect like this?
This is the most beautiful 2d lighting I have ever seen, and I'd like to perform lighting like this too. How do I do it?
I don't care about the physics or how the particles are simulated - I only ...
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 ...
13
votes
2answers
1k views
Best way to mask 2D sprites in XNA?
I currently am trying to mask some sprites. Rather than explaining it in words, I've made up some example pictures:
The area to mask (in white)
Now, the red sprite that needs to be cropped.
The ...
13
votes
6answers
2k views
Modern Shader Book?
I'm interested in learning about Shaders: What are they, when/for what would I use them, and how to use them. (Specifically I'm interested in Water and Bloom effects, but I know close to 0 about ...
12
votes
3answers
874 views
HLSL Translucent Plastic Shader
I'm trying to produce a shader to replicate a white plastic object with a colored light inside. Either by having a shader that will be translucent and if I put a light inside the object the light will ...
11
votes
4answers
965 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 : ...
9
votes
4answers
499 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 ...
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 ...
8
votes
3answers
851 views
Very slow direct3D texture sampling
So I'm writing a small game using Direct3D 9 and I'm using multitexturing for the terrain. All I'm doing is sampling 3 textures and a blend map and getting the overall color from the three textures ...
7
votes
4answers
430 views
What types of effects or shaders would you teach in a rendering class? [closed]
I am looking for a list of topics that would be fun to learn and not too complicated to implement with a prototyping tool like FX Composer or Rendermonkey for an intermediate class of real-time ...
7
votes
2answers
975 views
HLSL - Creating Shadows in 2D
The way that I create shadows is by the following technique:
http://www.catalinzima.com/2010/07/my-technique-for-the-shader-based-dynamic-2d-shadows/
But I have questions to HLSL. The way that I ...
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
4answers
1k views
HLSL: Using instance float input to select texture index, possible?
I'm writing a game for the xbox360 using XNA.
I would like to draw several models with a single DrawInstancedPrimitives call. Each model will use a different texture.
To do this, I would like to ...
6
votes
2answers
609 views
Rendering collections of light sources
I have a small test environment where small point lights are scattered. Players should able to collect them.
The collectible lights are rendered using a simple billboard technique where two triangles ...
6
votes
2answers
2k views
Random number hlsl
How do you generate a random number in HLSL?
I'm asking because I want to try gpu ray tracing. You need to generate random directions in a pixel shader. So I want randFloat(), where the result is a ...
6
votes
2answers
960 views
Electricity effect using XNA and Shaders
I'm looking for a shader or sample that does an electricity or lines-of-force effect between two points that can be used with XNA 3.1.
6
votes
2answers
293 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.
6
votes
1answer
125 views
XNA Deferred + Forward, Depth Problem?
Im working with my deferred engine in XNA 4.0 and Im combining it with a forwardpipeline to support semi-transparency and other "forward only" effects.
Let me describe what I do:
Render GBuffer ...
5
votes
2answers
719 views
Different number of lights => different shader
I have a shader that computes lighting for each light.
PointLight PointLights[10];
uniform const float NumPointLights;
for(int i = 0; i < NumPointLights; i++)
{
lightVec = ...
5
votes
1answer
549 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 ...
5
votes
1answer
262 views
Changing water color based on depth
I'm looking to make a water shader that colors the water based on its depth. Up until now my water shader that I've used has basically been extremely reflective and only looked somewhat blue because ...
5
votes
3answers
315 views
Finding out what pixel on the screen the fragment falls on
In my 2D game, I render tiles. I want to do lighting without needing an extra buffer the size of the screen.
Either in glsl or hlsl, what could I feed to the shader each time I render a bitmap so ...
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 ...
5
votes
1answer
185 views
HLSL Circle all white
I have been trying to get my shader code (HLSL) to draw a simple circle but after a day and a half I am getting nowhere. It seems people are using the x^2 + y^2 = r^2 and remap texcoords but I only ...
5
votes
2answers
493 views
Spin/Rotational Blur
How do I perform a circular/rotational/spin blur on an image - using DirectX9.0 and HLSL?
For example:
5
votes
1answer
305 views
Partial Shader Signatures HLSL D3D11 C++
I had been debugging a problem I was having in a single shader file with 2 functions in it. I'm using DirectX 11, vs_5_0 and ps_5_0. I have stripped it down to its basic components to understand what ...
5
votes
1answer
586 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 ...
5
votes
1answer
424 views
Dealing with alpha for 2D per pixel lighting
Right now I've got a simple light shader. Every bitmap I draw goes through it to make up the scene. I only draw quads.
texture tex;
sampler2D s = sampler_state {
texture = <tex>;
...
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 ...
4
votes
2answers
495 views
Rendering everything with a shader when only squares are needed?
I am building a game that is tile-based (filled with glowy vector squares). Right now, I am considering using instancing for drawing these, but I would like to know if there is a faster approach.
The ...
4
votes
1answer
205 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
382 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 ...
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 ...
4
votes
1answer
738 views
How do I use screen-space derivatives to antialias a parametric shape in a pixel shader?
In Valve's Alpha Tested Magnification paper, it mentions using "per-pixel screen-space derivatives" for doing anti-aliasing. My understanding is that this is the ddx and ddy intrinsic functions in ...
4
votes
1answer
147 views
How can I use shaders to make a square have a waving effect?
I'm new to using shaders to do some fancy effects and I'm struggling with them. I'm using DirectX 11 and HLSL. I have this square in the middle of the screen:
It's just a square that I've created ...
4
votes
2answers
356 views
Rain drops on screen
I am trying to make simple rain drop effect on screen.Something like this
http://fc00.deviantart.net/fs20/f/2007/302/5/6/Rain_drops_by_rockraikar.png
My idea is to:
Create small drop shaped normal ...
4
votes
2answers
270 views
Is it possible in HLSL to use bitfields?
I have in memory a representation of my 2d GameMap (think of a Scorched Earth like landscape).
The map is made up of MapElements, a MapElement is made up of 64 bits defined like
struct MapElement {
...
4
votes
4answers
922 views
From camera coordinates to world coordinates
I want to calculate world coordinates from camera coordinates. However, I seem to have problems with my understandings of how matrices in HLSL work.
From world to camera is clear:
cameraPosition = ...
4
votes
2answers
1k views
C# XNA - Sky Sphere Question
I have been banging my head against the wall trying to get a sky sphere to work appropriately in XNA 4.0. I have the sphere loading correctly, and even textured, but i would like something a little ...
4
votes
1answer
190 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 ...
4
votes
1answer
245 views
A Quick HLSL Question (How to modify some HLSL code)
Thanks for wanting to help!
I'm trying to create a circular, repeating ring (that moves outward) on a texture. I've achieved this, to a degree, with the following code:
float distance = ...
4
votes
2answers
648 views
XNA 4.0 - Normal mapping shader - strange texture artifacts
I recently started using custom shader. Shader can do diffuse and specular lighting and normal mapping. But normal mapping is causing really ugly artifacts (some sort of pixeling noise) for textures ...
3
votes
2answers
409 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 ...
3
votes
2answers
491 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 ...
3
votes
2answers
536 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 ...
