Tag Info

New answers tagged

0

This question already has been answered. See the second link here: http://stackoverflow.com/questions/12794428/calculating-world-space-coordinates-in-the-pixel-shader


0

Okay so, finally achieved my goal. view = Matrix.CreateScale(new Vector3(1, 0.75f, 1)) * Matrix.CreateTranslation(-playerpos.X, -playerpos.Y, 1); world = Matrix.Invert(view); projection = Matrix.CreateOrthographicOffCenter(0, view.Width, view.Height, 0, -1, 1); Matrix halfPixelOffset = Matrix.CreateTranslation(-0.5f, -0.5f, 0); projection = halfPixelOffset ...


1

It basically doesn't matter. #define uses token-pasting to insert the specified value into the shader code whereever it occurs; the shader itself will see the token as if you simply hard-coded it at every occurrence instead. A static const variable in, in actuality, a variable. Specifically, it is a variable that is initialized once, whose value persists ...


0

The whole way I was going about it is wrong. I'll answer my own question in case anybody else comes here from google. Instead of generating a whole tonne of points and appending them in one geometry shader to create lightning, the answer is to only generate each iteration of the lightning per geometry shader invocation to remove the need for having a ...


4

For best performance you should avoid changing uniforms as well as shaders by using vertex attributes. Ideally pack all your 2D object textures into 1 single large texture (called an atlas) so you can render all your 2D objects in one call using a single vertex buffer. In your large texture you also put a 4x4 white area and map the texture coordinates of ...


0

I wrote HLSL code for transparency and then I will transparent one image inside the body and another image used for my foreground : sampler stream : register(s0); sampler back : register(s1); sampler character : register(s2); float4 DepthToRGB(float2 texCoord : TEXCOORD0) : COLOR0 { // We can't easily sample non-normalized data, // Texture is a short ...


0

As described here, the texture wasn't bound to the Vertex shader. Without this (@Mooseboys) The texture data was not presented to the Vertex Shader, causing NULL or zero values. Binding the texture resolved the problem.


1

World position is vertex position multiplied by world matrix, not view matrix. So it should be like this in the vertex shader: output.WorldPos = mul(input.Pos,World); Unless you want View position to work with. I haven't checked the code for bugs if you want to use that.


0

Fix your matWorldViewProj. w values are NaN, so the transformation will fail miserably. The w column should be (0,0,0,1). Also, you should be getting complaints at the following line: Output.Position = mul(Input.Position, matWorldViewProj); as you multiply a 4x4 matrix with a float3. Change it to: Output.Position = mul(float4(Input.Position,1), ...


2

There are two main ways to do this. First way is to do exactly what you're trying to avoid doing, and use a render target. This is the way used by the Shadow Mapping sample for D3D9 in the old DirectX SDK, although it needn't be 32-bit (D3DFMT_R16F may well be sufficient). As a possible optimization you could use a NULL depth/stencil target, enable ...


2

COLOR0 is DX9. Since you're dealing with DX11 (ps_5_0) you need to replace COLOR0 with SV_Target.



Top 50 recent answers are included