Jump to content
  • Advertisement
Sign in to follow this  
ryan mccabe

texture ghosting on camera move

This topic is 2585 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

I have a scene with a rotating cube with the same image on each side. The camera moves (no ration yet), and the cube spins. When the camera is still the cube is fine. When I move the camera the texture starts to ghost, no matter how fast the camera moves the texture on the cube gets a horrible ghosting effecting. I don't think its my camera movement algorithm, the first thing I did was rebuild my camera class using this one from two kings which seems to be similar to other recommended models. Ive been playing around with stencils, buffers, and swap chains for a while, and while I'm pretty sure Ive got half of it memorized, nothing has effected the ghosting on camera movement, not even rebuilding the camera. I hope there is enough detail there for someone to pick out whats going on, if not ask and Ill fill in any gaps. Why is my texturing ghosting when the camera is moving??

Multisample AA, and vsync are on. The monitor doesn't ghost with anything else. . .
Thanks

Share this post


Link to post
Share on other sites
Advertisement
By ghosting do you mean semi-transparent or completely blacked out textures? Also, what version of direct3d are you working with?

Share this post


Link to post
Share on other sites

Its a faded afterimage so semi transparent. Im working with direct3d 11.


In that case my best bet would be it's a blending issue of some kind. Are you manually setting the blendstate somewhere? And could you post your pixel shader?

Share this post


Link to post
Share on other sites
ClearRenederTargetView is called at the start of each scene / frame. The blendstate description isn't touched, perhaps I should set it? The pixel shader:



// Filename: texture.ps
///////////
//GLOBALS//
///////////

//shaderTexture is the texture resource
Texture2D shaderTexture;

//SampleType determines how the texture is downsized
SamplerState SampleType;

//diffuse and light direction
cbuffer LightBuffer
{
float4 diffuseColor;
float3 lightDirection;
float padding;
};

/////////////
// TYPEDEFS//
/////////////

struct PixelInputType
{
float4 position : SV_POSITION;
float2 tex : TEXCOORD0;
float3 normal : NORMAL;
};

// Pixel Shader
float4 TexturePixelShader(PixelInputType input) : SV_TARGET
{
float4 textureColor;
float3 lightDir;
float lightIntensity;
float4 color;

//Sample the pixel color from the texture using the sampler at this texture coord location
textureColor = shaderTexture.Sample(SampleType, input.tex);

// Invert the light direction for calculations.
lightDir = -lightDirection;

// Calculate the amount of light on this pixel.
lightIntensity = saturate(dot(input.normal, lightDir));

// Determine the final amount of diffuse color based on the diffuse color combined with the light intensity.
color = saturate(diffuseColor * lightIntensity);

// Multiply the texture pixel and the final diffuse color to get the final pixel color result.
color = color * textureColor;


return color;
}




I'm adapting the engine from http://www.rastertek.com/tutindex.html. So far the pixel shader is something I haven't touched but there have been a few places where the tutorials have led me down the wrong path and I've needed to rework the code for proper functionality. I'll start working on improved shader and see what happens.

Also, the effect is worst on light areas. Right now the scene contains multiple spheres with a night time image of earth applied, the lights turn in to streaks as I move the camera. It actually looks somewhat realistic however its undefined behavior so Id like to correct it.

Share this post


Link to post
Share on other sites
[font="arial, verdana, tahoma, sans-serif"][font="arial, verdana, tahoma, sans-serif"][font="arial, verdana, tahoma, sans-serif"][font="arial, verdana, tahoma, sans-serif"]If you're not setting the blendstate anywhere it should already be set to its default, and should work if I'm not mistaken. [/font][font="arial, verdana, tahoma, sans-serif"]That SamplerState object you're creating, is it defined and set somewhere within the source code? Otherwise I think you might have to set it's filter type and texture adress mode,[/font][font="arial, verdana, tahoma, sans-serif"]for example:[/font][/font][/font][/font]
[font="arial, verdana, tahoma, sans-serif"][font="arial, verdana, tahoma, sans-serif"][font="arial, verdana, tahoma, sans-serif"][font="arial, verdana, tahoma, sans-serif"]SamplerState SampleType
{
Filter = MIN_MAG_MIP_LINEAR;
AdressU = Wrap;
AdressV = Wrap;
};
[/font][/font][/font][/font][font="arial, verdana, tahoma, sans-serif"][font="arial, verdana, tahoma, sans-serif"][font="arial, verdana, tahoma, sans-serif"][font="arial, verdana, tahoma, sans-serif"]Another thing that I think might be causing problems is how you multiply the lighting vectors. Did you try using [/font][/font][/font][/font]
[font="arial, verdana, tahoma, sans-serif"][font="arial, verdana, tahoma, sans-serif"][font="arial, verdana, tahoma, sans-serif"][font="arial, verdana, tahoma, sans-serif"] [/font][/font][/font][/font]
[font="arial, verdana, tahoma, sans-serif"][font="arial, verdana, tahoma, sans-serif"][font="arial, verdana, tahoma, sans-serif"][font="arial, verdana, tahoma, sans-serif"]color = mul(color, textureColor); [/font][/font][/font][/font]
[font="arial, verdana, tahoma, sans-serif"][font="arial, verdana, tahoma, sans-serif"][font="arial, verdana, tahoma, sans-serif"][font="arial, verdana, tahoma, sans-serif"] [/font][/font][/font][/font]
[font="arial, verdana, tahoma, sans-serif"][font="arial, verdana, tahoma, sans-serif"][font="arial, verdana, tahoma, sans-serif"][font="arial, verdana, tahoma, sans-serif"]instead of [/font][/font][/font][/font]
[font="arial, verdana, tahoma, sans-serif"][font="arial, verdana, tahoma, sans-serif"][font="arial, verdana, tahoma, sans-serif"][font="arial, verdana, tahoma, sans-serif"] [/font][/font][/font][/font]
[font="arial, verdana, tahoma, sans-serif"][font="arial, verdana, tahoma, sans-serif"][font="arial, verdana, tahoma, sans-serif"][font="arial, verdana, tahoma, sans-serif"]color = color * textureColor; [/font][/font][/font][/font]
[font="arial, verdana, tahoma, sans-serif"][font="arial, verdana, tahoma, sans-serif"][font="arial, verdana, tahoma, sans-serif"][font="arial, verdana, tahoma, sans-serif"] [/font][/font][/font][/font]
[font="arial, verdana, tahoma, sans-serif"][font="arial, verdana, tahoma, sans-serif"][font="arial, verdana, tahoma, sans-serif"][font="arial, verdana, tahoma, sans-serif"]and [/font][/font][/font][/font]
[font="arial, verdana, tahoma, sans-serif"][font="arial, verdana, tahoma, sans-serif"][font="arial, verdana, tahoma, sans-serif"][font="arial, verdana, tahoma, sans-serif"] [/font][/font][/font][/font]
[font="arial, verdana, tahoma, sans-serif"][font="arial, verdana, tahoma, sans-serif"][font="arial, verdana, tahoma, sans-serif"][font="arial, verdana, tahoma, sans-serif"]color = saturate(mul(diffuseColor, lightIntensity)); [/font][/font][/font][/font]
[font="arial, verdana, tahoma, sans-serif"][font="arial, verdana, tahoma, sans-serif"][font="arial, verdana, tahoma, sans-serif"][font="arial, verdana, tahoma, sans-serif"] [/font][/font][/font][/font]
[font="arial, verdana, tahoma, sans-serif"][font="arial, verdana, tahoma, sans-serif"][font="arial, verdana, tahoma, sans-serif"][font="arial, verdana, tahoma, sans-serif"]instead of [/font][/font][/font][/font]
[font="arial, verdana, tahoma, sans-serif"][font="arial, verdana, tahoma, sans-serif"][font="arial, verdana, tahoma, sans-serif"][font="arial, verdana, tahoma, sans-serif"] [/font][/font][/font][/font]
[font="arial, verdana, tahoma, sans-serif"][font="arial, verdana, tahoma, sans-serif"][font="arial, verdana, tahoma, sans-serif"][font="arial, verdana, tahoma, sans-serif"]color = saturate(diffuseColor * lightIntensity);[/font][/font][/font][/font]

Share this post


Link to post
Share on other sites
^^ [font="Courier New"]mul[/font] is the matrix-multiply function. Using "[font="'Courier New"]*[/font]" is correct here.

Share this post


Link to post
Share on other sites

^^ [font="Courier New"]mul[/font] is the matrix-multiply function. Using "[font="Courier New"]*[/font]" is correct here.


Ah, okay :)

Share this post


Link to post
Share on other sites
hey :) ya sample states covered and the different filters have been tried.

samplerDesc.Filter = D3D11_FILTER_MIN_MAG_MIP_LINEAR;
samplerDesc.AddressU = D3D11_TEXTURE_ADDRESS_WRAP;
...
samplerDesc.MipLODBias = 0.0f;
samplerDesc.MaxAnisotropy = 1;
samplerDesc.ComparisonFunc = D3D11_COMPARISON_ALWAYS;
...
samplerDesc.MinLOD = 0;
samplerDesc.MaxLOD = D3D11_FLOAT32_MAX;



Maybe a little after image is more normal than I'm thinking?

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!