Tagged Questions
-1
votes
0answers
41 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 ...
4
votes
1answer
144 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 ...
3
votes
2answers
183 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 ...
0
votes
0answers
97 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 ...
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
2answers
103 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 ...
5
votes
1answer
180 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 ...
0
votes
1answer
136 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 ...
2
votes
1answer
84 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 ...
1
vote
1answer
61 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>;
...
2
votes
1answer
83 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 ...
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 ...
5
votes
1answer
253 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 ...
3
votes
2answers
172 views
Which will be faster? Switching shaders or ignore that some cases don't need full code?
I have two types of 2d objects:
In first case (for about 70% of objects), I need that code in the shader:
float2 texCoord = input.TexCoord + textureCoord.xy
But in the second case I have to use:
...
9
votes
4answers
495 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 ...
1
vote
1answer
235 views
Low-level GPU code and Shader Compilation
Bear with me, because I will raise several questions at once. I still feel, though, that overall this can be treated as one question that may be answered succinctly.
I recently dove into solidifying ...
1
vote
2answers
304 views
HLSL Pixel Shader that does palette swap
I have implemented a simple pixel shader which can replace a particular colour in a sprite with another colour.
It looks something like this:
sampler input : register(s0);
float4 ...
1
vote
0answers
275 views
Need help transforming DirectX 9 skybox hlsl shader to DirectX 11
I am in the middle of implementing a skybox to my game. I have been following this tutorial http://rbwhitaker.wikidot.com/skyboxes-2. I am using MonoGame as a framework and in order to support both ...
1
vote
1answer
186 views
XNA Shader Texture Memory
I was wondering about texture optimization in XNA 4.0.
Will the the contentmanager send the texturedata to the GPU directly when the texture gets loaded or do I send the texture data to the GPU when ...
5
votes
1answer
302 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 ...
1
vote
0answers
170 views
Outline Shader Effect for Orthogonal Geometry in XNA
I just recently started learning the art of shading, but I can't give an outline width to 2D, concave geometry when restrained to a single vertex/pixel shader technique (thanks to XNA).
the shape I ...
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
313 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 ...
1
vote
0answers
198 views
Full screen shader causes performance hit
I basically want to have a shader run that can do something like toon shading, or grayscale the whole screen, or radial lighting.
To do this, I create a new bitmap each time the display resizes that ...
0
votes
1answer
113 views
My blur gets ugly when radius too high
I have the following h and v blur:
Horz
texture tex;
sampler2D s = sampler_state {
texture = <tex>;
};
int tWidth;
int tHeight;
float blurSize = 9.0;
float4 ...
2
votes
2answers
505 views
My hlsl shader cannot unroll a loop?
I have this shader:
texture tex;
sampler2D s = sampler_state {
texture = <tex>;
};
int tWidth = 1;
int tHeight = 1;
int blurLength = 3;
float4 ps_main(VS_OUTPUT ...
1
vote
1answer
398 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 ...
1
vote
3answers
279 views
Writing a shader once without using CG?
Is there a tool that can convert a fragment shader from hlsl to glsl or glsl to hlsl? I do not want to use cg since it is not able to work on mobile platforms.
Is there a tool that can make it so I ...
4
votes
2answers
633 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 ...
2
votes
1answer
177 views
How do you create a cbuffer or global variable that is gpu modifiable?
I'm implementing tonemapping in a pixel shader, for hdr lighting.
The vertex shader outputs vertices with colors. I need to find the max color and save it in a global.
However when I try and write ...
4
votes
1answer
374 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 ...
2
votes
1answer
518 views
Can you store negative numbers with XNA HLSL?
I am trying to make a ripple effect with a HLSL shader, it works so far but I need to output negative numbers and that won't work for the calculations. Is there some way to do this with the ...
1
vote
1answer
124 views
How to mix effects together?
Lets say I have got terrain effect, contains multitexturing, light. Now water effect. It must be different, but must be also affected by light. Other one, player effect, must also be affected by ...
2
votes
1answer
485 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 ...
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
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 ...
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 ...
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 ...
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 ...
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 ...
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
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
...
4
votes
4answers
919 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 = ...
6
votes
2answers
606 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 ...
5
votes
2answers
717 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 = ...
2
votes
3answers
1k views
2D shader to draw representation of rotating sphere
I want to display a 3D textured sphere, and then rotate it in one direction. The direction will never change, and the camera will never move. One way is to actually create a spherical mesh, map a ...
