HLSL is a proprietary shading language developed by Microsoft for use with the Microsoft Direct3D API.
1
vote
2answers
33 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 ...
0
votes
0answers
26 views
Unity - Help Shader texture coordinate
I am making a 2D water shader. For this, I use GrabPass which works well. But I am facing an issue.
If I want to display the GrabPass texture I have to create my own texture coordinates because ...
0
votes
1answer
38 views
Shader registers for different graphics card
The title is not very explicative, so i'll try to make myself clear.
I have two "working"(on which i work on) PCs : a desktop that runs an NVIDIA GT440 an a laptop with a RADEON HD 4650. I have a ...
1
vote
2answers
75 views
In the Direct3D 9 Effect API, how do you find the texture variable linked to a sampler?
In Direct3D 9 effect files you can write a sampler state that specifies a texture variable to use, like
Texture2D g_texSkyDome;
SamplerState g_samplerSkyDome
{
Texture = <g_texSkyDome>;
...
3
votes
1answer
532 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 ...
1
vote
1answer
402 views
how to modify shadow mapping in “3D Graphics with XNA Game Studio 4.0”?
So I've been following the tutorials from the book Sean James's "3D Graphics with XNA Game Studio 4.0", and have been doing fine until i reached the shadow mapping part.
in this book it creates point ...
0
votes
2answers
61 views
What are registers in HLSL for?
I've read this: http://msdn.microsoft.com/en-us/library/windows/desktop/dd607359%28v=vs.85%29.aspx but it's more of a syntax descrption and not a purpose explanation. What actually are registers in ...
0
votes
1answer
31 views
Constant buffer content packing
I've read this: http://msdn.microsoft.com/en-us/library/windows/desktop/ff476898%28v=vs.85%29.aspx#Shader_Constant_Buffer but there's not much information in it. When creating a constant buffer do I ...
3
votes
0answers
67 views
Custom sampling points for anti-aliasing
I'm trying to write an anti-aliasing shader in HLSL, but I can't find any way to rasterize at a custom point. (in between pixels on the screen, but not orderly like supersampling)
Is there any way to ...
-1
votes
0answers
57 views
XNA/HLSL cone shape 2D light
I'm new to HLSL and I'm trying to create a simple light for my 2D game. I made a point light and it looks great. However now I'm trying to create a cone shape light but I just don't know how. can ...
0
votes
2answers
476 views
how to make HLSL effect just for lighning without texture mapping?
I'm new to XNA, i created an effect and just want to use lightning but in default effect that XNA create we should do texture mapping or the model appears 'RED', because of this lines of code in the ...
0
votes
1answer
59 views
Are there alternatives to Vertex Tweening?
Now that I'm getting into animating 3D entities in my game, I was wondering what the best approach for this would be. I did some research and came across something called "Vertex Tweening". However, ...
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 ...
0
votes
1answer
32 views
Weird rendering issue when applying lightmap through HLSL
I have a weird issue when trying to render the lightmaps in my game.
Please see the following screenshots.
Note how the scene looks up close with the lightmaps enabled.
Note how that same part of ...
3
votes
2answers
185 views
Techniques for reducing terrain shader complexity
My terrain shader does quite a bit, but I don't know how to break it up in any way that will reduce my instruction count without removing key features of the terrain. It does the following:
...
3
votes
0answers
99 views
Combining Effects
To be able to work efficiently with effects, isn't there a "good" way to combine multiple effects so that one effect handles stuff like "Multi texturing" and another controls the value like Ambient ...
1
vote
2answers
138 views
HLSL Multitexturing with more than 4 textures
I've come up with an idea that should work in multitexturing a terrain with more than 4 textures, up to a 64 if a supported ShaderModel is used.
I'm trying to use the RGBA color values as both values ...
1
vote
1answer
73 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 = ...
1
vote
0answers
102 views
tex2dlod and tex2d giving different values [closed]
I've been having trouble with vertex texture fetch for a terrain system I am implementing. I'm using C++/DirectX9.
I have already implemented exactly what I want as a prototype in C#/XNA and now ...
1
vote
0answers
113 views
How to achieve supersampling / anti-aliasing in pixel shaders?
I am trying to write a couple pixel shaders to apply to images similar to Photoshop effects. For example this effect: ...
0
votes
0answers
104 views
HLSL Triplanar texturing and multi texturing performance
I'm stuck for my terrain rendering shader code for DX9. I'm looking to implement triplanar texturing, a texture atlas, and blending between different textures. Right now it's working. The problem is ...
-4
votes
1answer
69 views
how can i improve this shader [closed]
I am trying to improve this vertex shader. I am wondering if anyone has any opinions on going about with it? Thank you.
struct VertexShaderData
{
float3 VertexPosition : POSITION;
float2 ...
2
votes
1answer
96 views
Switching to a vertex shader
TL;DR I need to switch from a vertex array passed to the pixel shader with a real vertex shader approach.
In my prototype, the terrain is procedurally generated and I have the following result:
...
0
votes
1answer
77 views
Adding Shader Model 3.0 support to my Direct3D9 app
So far, we've only used pixel shaders because we never needed to do any custom processing at the vertex shader level. However, the 3.0 model shader forces you to define a vertex shader. And that's ...
2
votes
2answers
173 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 ...
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 ...
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
189 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 ...
0
votes
2answers
76 views
The saturate function is not working in my pixel shader
I wrote a pixel shader for my game and when I tried to compile it an error occurred:
ID3DXEffectCompiler::CompileEffect: There was an error compiling expression
When I removed all the saturate ...
0
votes
0answers
39 views
Cascaded Shadow Maps left handed to right handed coord system
Im trying to port the Directx SDK (june 2010) sample (CascadedShadowMaps11) into a right handed version (to later implement in my engine) but i can't figure out the math, so far i got it partially ...
3
votes
1answer
124 views
Constant Buffer size mismatch on PS, fine on VS and GS
I have the following C/C++ struct:
struct ShadowMapCB {
Math::Matrix4 cropMatrix[4];
Math::Matrix4 textureMatrix[4];
float splitPlane[4];
};
and my HLSL constant buffer:
...
3
votes
1answer
183 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 ...
0
votes
2answers
106 views
How to implement input-texture limited alphablending of 2 textures with HLSL?
I try to implement a HLSL shader the does the normal Alphablend with premultiplied colors (just as XNA4 does) but depending on some existing colors. One can think of adding a glow to a 2D terrain ...
0
votes
1answer
139 views
XNA 3D custom shader/effect gives shakey rendering in the distance
I am rendering a simple flat plane + texture to use as the floor for a game. I'm rendering it using a custom effect I've written.
The problem I have is that the ground in the distance gets a bit ...
5
votes
1answer
184 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 ...
1
vote
1answer
114 views
Blur offset artifacts
I have simple blur shader which I calculate offsets in:
Piece of vertex shader:
output.texCoord1 = input.tex + float2( texelSize * -4.0f, 0.0f );
output.texCoord12 = input.tex + float2( texelSize * ...
0
votes
2answers
151 views
HLSL compiler specification (optimizations)
Can I read somewhere about optimizations that HLSL compiler performs?
For example, in some codes I have different variables that get a constant value (just to let myself adjust the shader with other ...
2
votes
1answer
86 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 ...
0
votes
2answers
331 views
HLSL shader optimization [closed]
The following HLSL shader (without preprocessing) results in 65 arithmetic operations (see below). Can the same effect achieved with <=64 operations?
// Center of "light"
float x;
float y;
// ...
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 ...
1
vote
1answer
178 views
MultiTexturing by neighbouring points textures
Visual example:
I've been trying to understand multitexturing for a while now, I've created a terrain generator but have no need for height just yet and I still want one texture to blend over to ...
2
votes
1answer
85 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
131 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 ...
31
votes
6answers
9k views
3
votes
1answer
164 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
646 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 ...
1
vote
1answer
568 views
2D Mask antialiasing in xna hlsl
I have two texture2d , one of these is a mask texture and have 2kind color
and i use that for mask (filter) second texture2D
something like
float4 tex = tex2D(sprite, texCoord);
float4 bitMask ...
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
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 ...
1
vote
0answers
192 views
How to simulate objects floating on water without a physics engine?
In my game the water movement is done in a shader using Gerstner equations. The water movement looks realistic enough for a school project but I encounter serious problem when I wanted to do sailing ...

