A proprietary shading language developed by Microsoft for use with the Microsoft Direct3D API.

learn more… | top users | synonyms

1
vote
1answer
148 views

Is it possible to compile both VS and PS in a single file in VS2012?

VS2012 has a built-in option for compiling *.hlsl files at compile time (e.g. to check for errors). But from what I've seen it requires me to provide the entry point (function) name for each file. ...
0
votes
0answers
320 views

How does this bezier curve rendering shader determine if a curve is concave or convex?

I have read an article about rendering quadratic splines on a GPU with a shader. The algorithm is explained like this: For each quadratic Bézier curve we use Bézier control points of the curve to ...
0
votes
1answer
224 views

Rendering Textured Terrain With SharpDX Toolkit [closed]

So i recently moved from XNA to SharpDX Toolkit and started with some basics. The 2d part was easy since nearly nothing has changed but im really struggeling with the 3d part. For example i wanted to ...
0
votes
1answer
78 views

Why would I lose the D3D device during an HLSL unroll?

I have a pixel shader that downsamples a texture from one size to another. The downsample shader uses a nested 'for' loop to traverse the uv coordinates. When the for loop executes more than four ...
0
votes
1answer
734 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 ...
1
vote
1answer
99 views

XNA Render Targets Depth Testing

I imagine this is a problem that gets asked quite often, but reading up on it I can't seem to get a definitive answer on how to solve it. I've got two HLSL shaders (I've simplified them in the ...
1
vote
1answer
100 views

rrr subcsript for float type

I'm a little confused with this construction: float sdcolor = MyColor.r; // MyColor has float4 type float rcolor = sdcolor.rrr; // .ggg or .bbb isn't working return float4(rcolor , rcolor , rcolor , ...
0
votes
1answer
106 views

Multiplying matrices in HLSL

I have code that calculates a position like this in HLSL: output.ShadowPos = input.VertexPos; output.ShadowPos = mul(output.ShadowPos, gWorld); output.ShadowPos = mul(output.ShadowPos, ...
0
votes
3answers
378 views

Encode two integers into colour values and compare them in a HLSL shader

I am writing a 2D point and click adventure game in Monogame, and I'd like to be able to create an image mask for every room which defines which parts of the background a character can walk behind, ...
0
votes
1answer
128 views

Using tex2Dlod to determine the appropriate size of the texture

We have a top-down game with fixed camera position. We also use orthographic projection so every model in the game will always be viewed from the very same angle and from the very same distance. The ...
0
votes
1answer
141 views

Glow with forward rendering without two passes/MRT?

I am trying to implement controllable bloom. By controllable I mean bloom that can be requested even for non-bright pixels by adding the bloom value into a model's texture channel. To do this I need ...
3
votes
1answer
277 views

Is multipass rendering possible with SpriteBatch?

I'm trying to implement a bloom effect. This requires three shader passes: a brightness threshold, a horizontal blur, and a vertical blur. It also requires resizes, but these are irrelevant to the ...
1
vote
1answer
154 views

How do I draw an isoline in a shader with a triangle topology?

I have some problems with my displacment. So I would like to have a simple little isoline starting in every triangles face center of the mash pointing in the direction of the corresponding faces ...
0
votes
1answer
159 views

HLSL postprocessing for day to night (DTN)

I am trying to implement a "day-to-night"-filter (as commonly used in cinema) for a 2D game (XNA) by using a full screen HLSL pixel shader. The aim is to transform any bright and colorful image into a ...
3
votes
3answers
282 views

Does passing uniform constants from technique into shader cause branches?

I am trying to find a way to organize my evergrowing number of shader techniques/functions (I am coding in sm_3.0). One way is to do this: float4 PS_Crossroads(PS_INPUT input, uniform bool ...
0
votes
3answers
107 views

how do I modify Texture2DArray values in shader

I'm using HLSL Shader Model 5.0. I'm using a Texture2D with the vertex positions for a mesh. In the Shader I'm trying to displace patchepositions along the normal of the patches I'd like to actualize ...
1
vote
1answer
300 views

How does HLSL handle clip(vector)?

My goal is to convert clip() to GLSL, version 1.5. I'm currently doing a basic: if (x < 0) discard; But if x is not a scalar, obviously I can't use the "<" operator. So I'm wanting to ...
2
votes
1answer
340 views

Is this GLSL equivalent to this HLSL?

I was wondering if the both shader codes are equivalent. So the question is, is this GLSL vNormal = mat3(FUSEE_ITMV[0].xyz, FUSEE_ITMV[1].xyz, FUSEE_ITMV[2].xyz) * fuNormal; Equivalent to this ...
1
vote
1answer
175 views

Does HLSL implement Shader Model LOD instruction?

The DX Shader Model 5.0 has a lod instruction. It returns "the LOD (level of detail) that would be used for texture filtering". Does HLSL have a built-in intrinsic that can do the same? I know I ...
4
votes
1answer
139 views

PCF shadow shader math causing artifacts

For a while now I used PCSS for my shadow technique of choice until I discovered a type of percentage closer filtering. This method creates really smooth shadows and with hopes of improving ...
14
votes
1answer
662 views

Rendering oily/polluted water?

Any shader wizards out there have an idea of how to achieve an oily/polluted water effect, similar to this: Ideally, the water would not be uniformly oily, but instead the oil could be generated ...
1
vote
1answer
226 views

HLSL What you get when you subtract world position from InvertViewProjection.Translation?

In one of NVIDIA's Vertex shaders (the metal one) I found the following code: // transform object normals, tangents, & binormals to world-space: float4x4 WorldITXf : WorldInverseTranspose < ...
0
votes
0answers
162 views

Radiosity using a hemisphere

I'm working on a radiosity processor. I'm projecting scene geometry onto a hemisphere at a high order of tessellation during a visibility pass onto a 1024x1024 render target. The problem is that the ...
1
vote
0answers
178 views

write to depth buffer while using multiple render targets

Presently my engine is set up to use deferred shading. My pixel shader output struct is as follows: struct GBuffer { float4 Depth : DEPTH0; //depth render target float4 Normal : COLOR0; ...
1
vote
2answers
773 views

How AlphaBlend Blendstate works in XNA 4 when accumulighting light into a RenderTarget?

I am using a Deferred Rendering engine from Catalin Zima's tutorial: His lighting shader returns the color of the light in the rgb channels and the specular component in the alpha channel. Here is ...
5
votes
1answer
287 views

What light attenuation function does UDK use?

I'm a big fan of the light attenuation in UDK. Traditionally I've always used the constant-linear-quadratic falloff function to control how "soft" the falloff is, which gives three values to play ...
0
votes
1answer
116 views

HLSL How to flip geometry horizontally

I want to flip my asymmetric 3d model horizontally in the vertex shader alongside an arbitrary plane parallel to the YZ plane. This should switch everything for the model from the left hand side to ...
2
votes
1answer
127 views

What's the difference between Textures and VertexTextures in XNA?

The GraphicsDevice class of XNA has the properties Textures and VertexTextures. What is the exact difference? I don't really understand what MSDN tells me about this. I usually use Effect parameters ...
2
votes
2answers
2k views

Computing pixel's screen position in a vertex shader: right or wrong?

I am building a deferred rendering engine and I have a question. The article I took the sample code from suggested computing screen position of the pixel as follows: VertexShaderFunction() { ... ...
9
votes
1answer
305 views

Fast lighting with multiple lights

How can I implement fast lighting with multiple lights? I don't want to restrain the player, he can place an unlimited number and possibly overlapping (point) lights into the level. The problem is ...
3
votes
2answers
175 views

Rasterization Rules and States

This thread directly concerns lightmap generation; however, indirectly, the rasterization of polygons by the GPU. I am currently generating lightmaps using a pixel shader. To the shader I send 3 ...
5
votes
1answer
2k views

What does ddx (hlsl) actually do?

I'm a bit confused. The official documentation (http://msdn.microsoft.com/en-us/library/windows/desktop/bb509588(v=vs.85).aspx) says that ddx(input) is the partial derivative of the input with ...
0
votes
0answers
96 views

How to encode float3 into float2 and back again in HLSL?

Good afternoon, I am looking to offload some 3D calculations to the GPU without raising my requirements to DX10. Specifically, I am generating densities in 64x64x64 3D blocks, which fit nicely into ...
0
votes
1answer
117 views

Storing few values in an int - small gain

This might be a bit hard-to-answer question, but... I had a DirectX::XMFLOAT3 as a vertex attribute. I have changed it to just an int by placing the 3 floats into int (using only 8 bits per float). In ...
0
votes
0answers
106 views

Shadow Mapping Wrong Results

Since 2 days, i'm trying to figure out whats wrong with my shadow shader. The shadow map is drawn correctly, just the projection on to the scene is not working. The Vertex Shader Code seems fine: ...
1
vote
1answer
305 views

Color grading, shaders and 3d textures

I'm trying to implement color correction with the 3d lookup table. The lookup table is actually just a 2d texture 256x16 and consists of 16 squares which one is 16x16. When it comes to rendering, I ...
0
votes
2answers
389 views

HLSL's Tex2D for GLSL?

I am trying to port a HLSL shader to GLSL. I'm just not quite sure how to convert this line: outA += Input.Color.a * tex2D(s, Input.TexCoord.xy + float2(-4.0 * pxSz.x * blurSize,0)).a * 0.05; ...
5
votes
1answer
553 views

What does HLSL's tex2D return at (0,0)?

I'm trying to understand the mapping of texels to pixels, especially in the context of pixel shaders. I already found out the following: When I define a standard quad with vertices at integer ...
2
votes
2answers
189 views

XNA hlsl tex2D() only reads 3 channels from normal maps and specular maps

Our engine uses deferred rendering and at the main draw phase gathers plenty of data from the objects it draws. In order to save on tex2D calls, we packed our objects' specular maps with all sorts of ...
12
votes
1answer
333 views

Accounting for waves when doing planar reflections

I've been studying Nvidia's examples from the SDK, in particular the Island11 project and I've found something curious about a piece of HLSL code which corrects the reflections up and down depending ...
2
votes
1answer
208 views

Hemispherical Projection

I'm trying to implement a radiosity processor. I'm aware of many places online to find information about radiosity. I found a great source on NVidia's website is GPU Gems - Chapter 39 . On this page ...
0
votes
1answer
389 views

XNA & HLSL - rendering a model with its original materials (colors)

I am currently trying to code my own HLSL effect file, in order to render an FBX model I made with Autodesk maya, and to which I have applied some materials (colors). before trying to write an effect ...
2
votes
1answer
90 views

Write colors with alphablending but don't write into the alpha channel

I am using XNA 4.0, hence DX9 and HLSL. I have a RenderTarget2D "MAIN" that I want to add semi-transparent objects "TRANS" to. I want them to blend with MAIN using the TRANS's alpha and inverseAlpha ...
1
vote
1answer
545 views

Using multiple passes in OpenCL .net

I'm new to opencl but I have some experience using HLSL. In HLSL multiple passes are used when you need to finish a computation before moving on to the next step. I would like to know how this sort ...
1
vote
1answer
245 views

HLSL Textured Light: outputs only a specific part of the texture (new problem)

Problem 1 I am trying to create a spotlight that instead of giving the circle within the spotlight a simple color, applies a texture to it. However, where the texture is supposed to be is only a ...
0
votes
1answer
2k views

HLSL Gaussian blur pixelshader: blur is not occurring

I am trying to use postprocessing to create a gaussian blur, however, no blur is to be seen, what am I doing wrong? I have included the full code at the bottom of this post in a google docs link, but ...
3
votes
2answers
77 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 ...
1
vote
1answer
1k views

HLSL grayscale pixel shader: How to get the original colors of the model?

The following code gives me a completely black colored model, while it should be a model shaded in greyscale: float4 SimplePixelShader(VertexShaderOutput input) : COLOR0 { //some lambertian ...
2
votes
2answers
426 views

How do I rotate a single object in HLSL?

I have a World with a 3D model of a head in it and that World rotates, like such: protected override void Update(GameTime gameTime) { //other stuff angle += 0.00005f; //more other stuff ...
0
votes
0answers
65 views

XNA HLSL no model textures [on hold]

I am using XNA and HLSL to render all the models in my game, so far there is only one, a flashlight. My flashlight model is a .fbx file type, and it loads the model in the game perfectly fine. ...