# SuperPixel

Member Since 19 Jul 2010
Offline Last Active Jan 17 2013 03:27 PM

### Switching between Camera Types (TrackBall -> First Person -> etc.)

17 January 2013 - 12:29 PM

Hi to everyone,

I'm trying to build a generic camera class (so just one class) that with few simple operators can allow one to create any type of high level camera.
I'd like to do it this way because I think that, then, switching for example between a first person and a trackball like camera will be easier.
For now I've successfully implemented the usual 1st person camera by defining few simple operators on the camera class and creating orientation using quaternions.

Operators/Methods:

moveXCameraRelative
moveYCameraRelative

rotateXCameraRelative
rotateYCameraRelative

The thing is that I can't figure out how to switch between (say) a 1st person and a trackball without screwing everything. What I mean is flying a bit with a 1st person and then from that exact pov switch to trackball and use it and then back to 1st person transparently (like in a DCC tool).
What I thought is that I should accumulate orientations etc. but I guess that my current method is not very correct because instead of accumulating orientations deltas I accumulate the angle and calculate the orientation of accumulated angles instead of defining an offset quaternion. I saw some implementation they do something like:

Quaternion q(axis,delta) //the offset quaternion (relative rotation quaternion)

I do something like:

angle += delta;

Quaternion q(axis,angle); //the absolute rotation quaternion

should I use the first solution and accumulate quaternions instead of accumulate the absolute angle to have the possibility to implement the behaviour that I described before ?

Thanks in advance for your help

### Depth Stencil Texture array to render cube depth map in one pass

29 August 2012 - 03:20 PM

Hi all,

I'm wondering if it's possible to create 6 depth stencil surfaces for a cube depth map and then render

into them in the geometry shader in one pass using SV_RenderTargetArrayIndex.

I want to just bind the depth stencil part and not the render target part, since I'd like to disable color writes during shadow map generation, so there's no point in passing any render target.

I would do deviceContext->OMSetRenderTargets( ...,..., cubeDepthStencilMapView );

I would expect that if I do something like this in the geometry shader:

struct GS_OUTPUT{
float4 Pos : SV_Position;
uint	cubeDepthMapIndex : SV_RenderTargetArrayIndex;
};

...
for( uint i=0;i<6;++i){
cubeDepthMapIndex = i;

}
...


It will index the correct depth stencil surface even if there is no render target bound ? ...
I can't think that I have to create 6 depth stencil view and 6 render target view when the only thing that I need is just depth (moreover, color writes disabled make the rendering faster).

Can anyone confirm this possibility ?
thanks a lot in advance

### Odd PIX Playback Failure

24 July 2012 - 02:44 AM

Hi all,

I'm getting crazy to understand why pix does not playback at all !! I googled to find people that had a

similar problem but none of the post have been very useful.

I get that problem only during single frame capture in PIX (which is the only way to debug shaders).
If I try capture a replayable direct3d call stream on disk I don't get that error but unfortunately I can't debug the shaders either because It's possible only with single frame capture (F12).
Also, I checked the swap chain desc values and they are definitely correct.
My program starts perfectly from visual studio and perfectly if I double click on the executable as well.
I do not understand why PIX can't playback correctly if I start an experiment and I do a single frame capture of Direct3D.

One last thing: the d3d debug trace is perfect and I don't get any warning nor errors.

Thanks in advance for any reply

### Iterating to enanche gaussian blur will darken my image :(

19 July 2012 - 04:30 PM

Hi all,

I'm performing gaussian blur with a 9 taps filter and I use bilinear filtering in turn to reduce the number of taps (i.e. getting two sample at once thanks to hw filtering..., so using just half of the taps [9/2]+1).

If I iterate over the previous blurred result to get more blur on the resulting image, the image itself gets darker and darker as the number of iterations raise ... until it gets completely black ...

Why this behaviour ?

Note: I've calculated my weights from the pascal triangle and normalized them, also the tex coords offset will reflect the border of the pixel to account for the fact that I'm using bilinear filtering to read more sample at once.

I show just the horizontal pass pixel shader source:

static const float weight[3]  = {0.2270270270,0.3162162162,0.0702702703};
static const float offsets[3] = {0.0,1.3846153846,3.2307692308};
//perform horizontal blur
static const float2 invImageSize  = float2(1.f/1000.f,1.f/800.f);
static const float  downsampledLevel = 0.f;
float4 PSBlurH(VS_OUTPUT Input) : SV_Target{
float3 color	= colorTexture.SampleLevel(textureSampler,Input.tc*invImageSize,downsampledLevel).xyz*weight[0];
[unroll]
for(int i=1;i<3;++i){
color += colorTexture.SampleLevel(textureSampler,Input.tc+float2(offsets[i]*invImageSize.x,0.f),downsampledLevel).xyz*weight[i];
color += colorTexture.SampleLevel(textureSampler,Input.tc-float2(offsets[i]*invImageSize.x,0.f),downsampledLevel).xyz*weight[i];
}
return float4(color,1.f);
}


It seems that the background color is influencing the cube ... :/

Thanks in advance for any reply