Jump to content

  • Log In with Google      Sign In   
  • Create Account

SpaceRoach

Member Since 22 Jan 2011
Offline Last Active Jun 27 2014 06:37 AM

Topics I've Started

Academic research moving away from rendering?

27 January 2013 - 08:57 AM

To be more specific, real-time rendering.

 

Most of the academia I checked are engaged in mathematical and visualisation work, but very few seem to be doing any sort of research in real-time graphics. Also noticed that majority of the recent publications have come from the industry. Did this kind of situation exist before as well, just went unnoticed?

 

 

 

 


Can't get ssao to work properly

04 July 2012 - 10:46 AM

Edit: Forgot to mention, I'm using slimdx with wpf ( if it matters )

Hi folks,

I'm trying to get a simple SSAO shader to work, using this site as reference http://www.john-chap...ontent.php?id=8

And naturally I've run into problems again.

I'm getting this output ( the first one is with a smaller radius, and the next one with a larger radius, see shader)

http://i.imgur.com/EjqFa.png

http://i.imgur.com/7S2u9.png

Unfortunately, I can't use PIX since it crashes my application before it even starts. I realize that it may be harder to debug without showing the entire code, so first, here's my main SSAO shader. This is almost identical to the one being used in the aforementioned site except for the fact that I'm using a position buffer instead of reconstructing from depth.

float3 currentPosition = PositionTex.Sample(SSAOSampler,input.TexC).xyz;                    //Current view space fragment position from Position buffer

float3 currentNormal = normalize(NormalTex.Sample(SSAOSampler,input.TexC).xyz);					//Current view space fragment normal

float2 NoiseScale = 0.0f;

NoiseScale.xy = BufferSize/(SSAO_noiseSize);

float3 randomVec = (RandomTex.Sample(SSAOSampler, input.TexC * NoiseScale).xyz * 2.0f) - 1.0f; //Random noise texture for kernel rotation

float3 tangent = normalize(randomVec - (currentNormal * dot(randomVec, currentNormal)));

float3 bitangent = cross(currentNormal, tangent);

float3x3 tbn = float3x3(tangent, bitangent, currentNormal);

float occ = 0.0f;

float Radius = 50.0f/BufferSize;

for(int i = 0 ; i < SSAO_kernelSize ; i++ )
{

  float3 vec =  AO_SampleVectors[i].xyz;

  float3 sample = mul(vec,tbn);

  sample = sample * Radius + currentPosition;

  float4 offset = float4(sample, 1.0f);

  offset = mul(offset,Projection);

  offset.xy /= offset.w;

  offset.x = offset.x * 0.5 + 0.5;

  offset.y = -offset.y * 0.5 + 0.5;

  float sampleDepth = PositionTex.Sample(SSAOSampler, offset.xy).z;

  float range_check = abs(currentPosition.z - sampleDepth) < Radius ? 1.0 : 0.0;

  occ += (sampleDepth <= sample.z ? 1.0 : 0.0) * range_check ;

}

occ/=SSAO_kernelSize;

float4 Color = {1.0f,1.0f,1.0f,1.0f};

Color.rgb = 1 - occ;

return Color;


To get the normal buffer and position buffers


Vertex shader


matrix viewproj = mul(View, Projection);

input.pos = mul(input.pos,rotation);						//Note : rotation matrix = world matrix in this case, just so you don't confuse it

input.norm = normalize(mul(input.norm,rotation));

output.pos1 = mul(input.pos,View);  // pos1 is the view space position

output.pos = mul(input.pos,viewproj);

output.uv = input.uv;

output.norm = normalize(mul(input.norm,View)); // norm is the view space normal

return output;

//////////////////////////////////////////////////////////////////////////////////

Pixel shader


output.Position = input.pos1;

output.Normal = normalize(input.norm);

return output;


I'll post pics of my position and normal buffer if those are required.

Thanks!

Variance Shadow Maps: faint shadow problems

25 June 2012 - 09:43 AM

I'm currently trying to implement Variance shadow maps, from the original paper and nvidia slides. I'm very well aware of their drawback of light bleeding and some what sure about how or why they happen.
In my app, I'm just applying a 5x5 gaussian filter over the 2 channel depth map, and with anistropic filtering enabled, simply following the steps as mentioned in the paper.

I get the following

With standard PCF
Posted Image

With VSM and the 5x5 gauss blur
Posted Image

I've seen several screenshots where users have applied 3x3 or 5x5 gauss blurs and still getting dark shadows ( albeit with the light bleeding problem, but I'm not worried about that for now). I need to know if this is a somewhat common problem alongside lightbleeding or have I done something so terrible that light bleeding is getting amplified?

Without the blur, I get blocky shadows ( somewhat smoothed by the hardware filtering) but they're almost as dark as the pcf ones, ofcourse again with the light bleeding but like I said I want to focus on this problem first.

Also a note: if you compare the screen shots side by side, the second one is a little darker overall.
Now for some code

float4 PS_VSM( PS_IN input ) : SV_Target
{
		//...
		//fancy-shmancy light stuff
		//...

float2 ProjectedCoord;
ProjectedCoord.x = (input.LightSpacePos.x/input.LightSpacePos.w)/2 + 0.5f ;
ProjectedCoord.y = -(input.LightSpacePos.y/input.LightSpacePos.w)/2 + 0.5f ;

float4 avg = 0.0f;//,avg2 = 0.0f;

float value = 2;
float Step = 1.0f/BufferSize;

float4 Moments = SSTex.Sample(ShadowSampler2,ProjectedCoord);

float M1 = Moments.r;
float M2 = Moments.g;
float Lit = (input.Dist < M1);
float P = 0.0f;
float t = M1 - input.Dist;
float variance = min(max(M2 - (M1*M1), 0.0) + 0.00003, 1.0); //max((M2 - (M1*M1)),0.00001f);  I was using this commented part earlier, then in my attempt to fix this I replaced with something that I came across in numerous forum post
P = variance/(variance + (t*t));

float4 Output = 0.0f;
Output = max(Lit,P);
Output.a = 1.0f;
return (Color*Output + ambient)*Tex.Sample(Sampler,input.uv);

}

I checked my depth buffer, and it seems to be getting blurred fine. I initially thought it might be due to some normalization problem with the gaussian function ( even though I'm using the normalization constant and the values do approximately add up to 1). But anyway here is the blurring just in case

...


float4 Blur_SinglePassH(ScreenSpaceOutput input) : SV_TARGET
{
float4 avg = 0.0f;

for(int i = 0 ; i < kernelSize ; i++)
avg += SSTex.Sample(ShadowSampler2,input.TexC + float2(Offsets[i]/BufferSize,0.0f))*GaussianWeights[i];

return avg;

}

float4 Blur_SinglePassV(ScreenSpaceOutput input) : SV_TARGET
{
float4 avg = 0.0f;

for(int i = 0 ; i < kernelSize ; i++)
avg += SSTex.Sample(ShadowSampler2,input.TexC + float2(0.0f,Offsets[i]/BufferSize))*GaussianWeights[i];

return avg;

}
...
...
...


technique10 BlurH
{
pass P0
{
SetGeometryShader( 0 );
SetVertexShader( CompileShader( vs_4_0, ScreenQuadVS() ) );
SetPixelShader( CompileShader( ps_4_0, Blur_SinglePassH() ) );
}

}


technique10 BlurV
{
pass P0
{
SetGeometryShader( 0 );
SetVertexShader( CompileShader( vs_4_0, ScreenQuadVS() ) );
SetPixelShader( CompileShader( ps_4_0, Blur_SinglePassV() ) );
}

}

//Before you mention it, yes I tried using 2 passes inside a single technique instead of 2 techniques but couldn't get it to work so stuck with this

Thank you!

[SlimDX 11,C#] No RawInput Documentation/tutorial?

05 June 2012 - 05:01 AM

I decided to move from directx 9 to 11 and came across SlimDX with C#. Of course most of the things are new and different but somehow I'm managing. Now I wanted to have some kind of an input system for a FPS-like camera and as most people suggested I turned towards SlimDX.RawInput. And...

I'm lost. Completely.

I can't find any sort of material which might explain what all the RegisterDevice and EventHandler functions are and what exactly am I supposed to do. The only thing I could write so far is

	class Input
	{
		public delegate void Input(object obj, SlimDX.RawInput.KeyboardInputEventArgs args);
		public void Initialize(Input ip)
		{

			Device1.RegisterDevice(SlimDX.Multimedia.UsagePage.Generic, SlimDX.Multimedia.UsageId.Keyboard, DeviceFlags.None);
			Device1.KeyboardInput += new System.EventHandler<KeyboardInputEventArgs>(ip);

		}			

	};

And I'm not even sure about the function declaration at the top, I just copied that from here http://digg.pp.fi/3d.../InputSystem.cs.

Am I supposed to be looking at the win32 RawInput documentation and just convert it to C# code? Is the SlimDX RawInput similar to the Win32 one or not?

Thanks!

Problem with normal mapping

04 March 2011 - 03:48 AM

hey folks,

I'm trying to create a normal mapped cylinder (dx 9 btw) with simple diffuse + ambient light.But what im getting is this ......The part which is facing the light is getting uniformly lit and the part which is away from it is only shaded with the ambient term , and there is an abrupt transition between the two , not a continous one.And the part which is getting lit is simply getting lit , seems as if the normal map isnt working . I've attached the screen shot below(sorry but i cant seem to open imageshack on my college net and i dont know of any other site)

And also , im not using effect files(once again :)) but separate pixel and vertex shaders.


the vertex shader
matrix world,view,proj;
matrix worldviewproj,viewproj;
matrix worldInv,rotation;

float4 LDir = {1.0f,0.0f,0.0f,0.0f};
vector EyePos;

struct input 
{
	vector position	:	POSITION0;
	float3 tangent	:	TANGENT0;
	float3 binormal	:	BINORMAL0;
	float3 normal	:	NORMAL0;
	float2 texcoord	:	TEXCOORD0;
};

struct output
{
	vector position	:	POSITION0;
	float2 texcoord	:	TEXCOORD0;
	float3 toEye	:	TEXCOORD1;
	float3 LDir		:	TEXCOORD2;
	
};

output VSMain(input ip)
{
	
	float3x3 TBN;
	
	TBN[0] = ip.tangent;
	
	TBN[1] = ip.binormal;
	
	TBN[2] = ip.normal;
	
	float3x3 TSpace = transpose(TBN);                              	//setup the object to tangent space matrix

	output op = (output)0;
	
	worldviewproj = mul(mul(world,view),proj);
	
	op.position = mul(ip.position,worldviewproj);
	
	EyePos = mul(EyePos,worldInv);           						// transform the eye pos from world space to object space
	
	vector toEye = EyePos - ip.position;
 	
	op.toEye = mul(toEye,TSpace);                                  	//transform to tangent space
	
	op.texcoord = ip.texcoord*4.0f;                                  	// pass the tiled texture coordinates
	
	LDir = mul(LDir,rotation);
	
	LDir = mul(LDir,worldInv);                       						//transform light direction from world to object space
	
	op.LDir = mul(LDir,TSpace);                 						// transform to tangent space
	
	return op;
}


the pixel shader

float4 LAmb = {0.3f,0.3f,0.3f,0.0f},LDff = {1.0f,1.0f,1.0f,0.0f};
float4 Mtrl = {1.0f,1.0f,1.0f,0.0f};

sampler Tex;
sampler NMap;

struct input
{
	float2 TexC		:	TEXCOORD0;
	float3 toEye	:	TEXCOORD1;
	float3 LDir		:	TEXCOORD2;
};

struct output
{
	float4 color 	:	COLOR0;
};

output PSMain(input ip)
{
	output op = (output)0;
	
	ip.toEye = normalize(ip.toEye);
	
	ip.LDir = normalize(ip.LDir);
	
	float3 normal = tex2D(NMap,ip.TexC); //sample the normal mal
	
	normal = 2.0f*normal - 1.0f;
	
	normal = normalize(normal);
  
	float s = max(dot(ip.LDir,normal),0.0f);
	
	vector a = tex2D(Tex,ip.TexC); 				//get the texture color
	
	op.color =  a*Mtrl*(LAmb + (LDff * s));  
	
	return op;
}

Note : you'll see that even though im not doing any specular calculation , ive still included the toEye term,thats because earlier i had included the specular term but then omitted it since i couldnt get even the diffuse to work so decided to fix it first


thanks in advance
manpreet

PARTNERS