Jump to content


D3D10 Shadow Mapping


123 replies to this topic

#41 XVincentX

    Valued Member

  • Members
  • PipPipPip
  • 115 posts

Posted 15 February 2009 - 09:09 PM

Another update.
I decided to look directly at the buffer with this new shader


#define FarClip 200


cbuffer cMultiFrame

{

	row_major float4x4	WorldMatrix;

	bool Lamp;

};


cbuffer cSometime

{

	row_major float4x4	ViewMatrix;

	row_major float4x4	VSpotMatrix; //Matrice spotlight

	float4 LightInfo; //Luce puntiforme del lampione

	float4 LightInfo2; //Direzione del fanale

	float4 LightInfo3; //Posizione del fanale

	float Phi;

	float Theta;

};


cbuffer cNeverChange

{

	row_major float4x4	ProjMatrix;

	row_major float4x4  VMatrix[6];

};


Texture2D Text;

Texture2D SpotText;

TextureCube Cubemap;

SamplerState SamplText;


float Attenuation

    ( 

        float distance,  

        float a, 

        float b, 

        float c

    )

{

    float Atten = 1.0f / ( a + b * distance + c * pow(distance,2) );

    return Atten;

}


struct VS_INPUT

{

	float4 Pos	:	POSITION;

	float3 Nor	:	NORMAL;

	float2 Tex	:	TEXCOORD;

};


struct PS_INPUT

{

	float4	Pos	:	SV_POSITION;

	float4	PSpot2D	:	P2DPOS;

	float4	WPos:	WORLDPOS;

	float3	Nor	:	NORMAL;

	float2	Tex	:	TEXCOORD;

	float3	LPos :	PROJPOS;

	float	Dist:	DISTANCE;

	float	Dist2:	DISTANCE2;

};


struct VGS_OUTPUT

{

	float4	Pos	:	SV_POSITION;

	float4	WPos:	WORLDPOSITION;

	uint RTIndex : SV_RenderTargetArrayIndex;

};


struct VPS_OUTPUT

{

	float4	Pos	:	SV_POSITION;

	float4	WPos:	WORLDPOSITION;

};



PS_INPUT vs_position (VS_INPUT In)

{

	PS_INPUT Out = (PS_INPUT)0;


	Out.Pos = mul(mul(mul(In.Pos,WorldMatrix),ViewMatrix),ProjMatrix);

	Out.PSpot2D = mul(mul(mul(In.Pos,WorldMatrix),VSpotMatrix),ProjMatrix);

	Out.WPos = mul(In.Pos,WorldMatrix);

	Out.Nor = mul(In.Nor,WorldMatrix);

	Out.Tex = In.Tex;

	

	Out.Dist = distance(Out.WPos,LightInfo.xyz);

	Out.Dist2 = distance(Out.WPos,LightInfo3.xyz);

	Out.LPos = Out.WPos - LightInfo.xyz;


	return Out;	

}


VS_INPUT vs_void (VS_INPUT In)

{

	return In;

}



float4 ps_light (PS_INPUT In)	:	SV_TARGET

{	



	float4 BaseColor = (Lamp == true) ? float4(0.25f, 0.21f, 0.20f, 1) : Text.Sample(SamplText,In.Tex);

	float3 vLight = normalize(LightInfo.xyz-In.WPos);

	float NdotL = dot(In.Nor,vLight);

	float Att = Attenuation(distance(LightInfo.xyz,In.WPos),0.003,0.003,0.003);

	float4 PointLight = (saturate(NdotL)) * Att;

	

	float3 LightToVecDirection = normalize(LightInfo3.xyz - In.WPos);

	float3 LightToSourceDirection = normalize(LightInfo3.xyz - LightInfo2.xyz);

	float cosAlpha = dot(LightToVecDirection,LightToSourceDirection);

	

	float2 VTexC;

     VTexC[0] = In.PSpot2D.x/In.PSpot2D.w/2.0f +0.5f;

     VTexC[1] = -In.PSpot2D.y/In.PSpot2D.w/2.0f +0.5f;

	

	float SpotShadow = SpotText.Sample(SamplText,VTexC);

	

		

    float Atten = 0.0f;

    

    if( cosAlpha > Theta )

    {

        Atten = 1.0f;

    }

    else if( cosAlpha > Phi )

    {

        Atten = 0.5f;

    }

    

    if (Atten != 0)

    {

		if ((In.Dist2/FarClip) >= SpotShadow)

		{

			return SpotShadow;

		}

    }


		float4 SpotLight = (Atten * dot( In.Nor, LightToVecDirection ));		

		return (PointLight + SpotLight) * BaseColor;	


}


[maxvertexcount(18)]

void Gs_Cubemap(triangle VS_INPUT input[3], inout TriangleStream<VGS_OUTPUT> Out)

{

    VGS_OUTPUT output;

    

    for( int f = 0; f < 6; f++ )

    {

        output.RTIndex = f;

        for( int v = 0; v < 3; v++ )

        {

            output.Pos = mul(mul(mul( input[v].Pos, WorldMatrix),VMatrix[f]),ProjMatrix );

            output.WPos = mul(input[v].Pos,WorldMatrix);

            Out.Append( output );

        }

        

        Out.RestartStrip();

	}

}


float ps_depth (VGS_OUTPUT In)	:	SV_TARGET

{	

	return distance(In.WPos,LightInfo.xyz) / FarClip;

}


float ps_spotdepth (VPS_OUTPUT In)	:	SV_TARGET

{	

	return distance(In.WPos,LightInfo3.xyz) / FarClip;

}


VPS_OUTPUT vs_spot(VS_INPUT In)

{

	VPS_OUTPUT p = (VPS_OUTPUT)0;

	

	p.Pos = mul(mul(mul(In.Pos,WorldMatrix),VSpotMatrix),ProjMatrix);

	p.WPos = mul(In.Pos,WorldMatrix);

	

	return p;

}


And i had this new result.
Posted Image

Can this help?

#42 Goz

    Senior Member

  • Members
  • PipPipPipPip
  • 574 posts

Posted 16 February 2009 - 09:39 AM

Well you can definitely see there is an error there. The car in the shadow map "should" line up with the car in the scene (By my understand anyway). This implies, to me, that there is a problem with your shadow lookup method.

It "looks" like you are offset by 0.5 in the y direction. But i'm checking over your code and I can't see why that would be.

#43 XVincentX

    Valued Member

  • Members
  • PipPipPip
  • 115 posts

Posted 16 February 2009 - 12:07 PM

May the view matrix be wrong?

#44 XVincentX

    Valued Member

  • Members
  • PipPipPip
  • 115 posts

Posted 16 February 2009 - 06:45 PM

Another update.
Today i was playing aroud application trying to have a decent camera system.
After some tries, i changed the Projection matrix, from this
D3DXMatrixPerspectiveFovLH(&cNeverChange.proj,D3DXToRadian(90.0f),1.0f,1.0f,200.0f);
to this other one
D3DXMatrixPerspectiveFovLH(&cNeverChange.proj,(float)D3DX_PI * 0.25f ,4/3,1.0f,200.0f);

And i had this new result.

Posted Image

That looks like better in terms of projection texture, but i read that to make the light rendering i have to make a projection matrix with 90 as degree and 1 as aspect ratio.
I'm using also the SAME matrix to render the normal scene.

Mabye something is going wrong here?

#45 XVincentX

    Valued Member

  • Members
  • PipPipPip
  • 115 posts

Posted 16 February 2009 - 06:56 PM

Making also a quad backbuffer (so they can really share the same matrix) the situations improves.

Posted Image

But it stills say me that all spotlight is in shadow.

#46 Goz

    Senior Member

  • Members
  • PipPipPipPip
  • 574 posts

Posted 17 February 2009 - 09:45 PM

Ok .. now offset the values written into the shadow buffer by some tiny amount.

ie change

return distance(In.WPos,LightInfo3);

to return distance(In.WPos,LightInfo3) + 0.00001f; and see if that improves your results.

Either that or you could also change

if ((In.Dist2/FarClip) >= SpotShadow)

to

if ((In.Dist2/FarClip) > SpotShadow)

Basically, what i'm guessing is happening, is that when you test a pixel to see if it is furhter than the shadow buffer you ALSO check to see if it is the same distance. Logically any pixel that has gone through the same set of transformations in 2 different shaders is STILL going to evaluate to the same position (It would be a nightmare if this didn't happen). That way any pixel that falls on the same position as the shadow texel will have the same depth.

#47 XVincentX

    Valued Member

  • Members
  • PipPipPip
  • 115 posts

Posted 17 February 2009 - 11:49 PM

Nothing of two helped. I was able to get a decent result only adding 30.0f in distance pixel shader.
This is the best result i had.

Posted Image

that looks like ok, but 30 it's too much...i think.

#48 Goz

    Senior Member

  • Members
  • PipPipPipPip
  • 574 posts

Posted 18 February 2009 - 01:59 PM

Do you add the small epsilon value (my suggested 0.00001 might be too small) before or after the divide by far clip? (Seeing as i got that wrong).

I'm shocked that you need to push it back as far as 30 units you ought to be able to get away with far smaller. Can you write the spot shadow buffer to a file and take a look at the ACTUAL values in it?

#49 XVincentX

    Valued Member

  • Members
  • PipPipPip
  • 115 posts

Posted 18 February 2009 - 04:57 PM

sure. i will lock the buffer and write it on file.

#50 XVincentX

    Valued Member

  • Members
  • PipPipPip
  • 115 posts

Posted 18 February 2009 - 05:36 PM

Ok i did it.
Texture is completely aviable from here
http://xvincentx.netsons.org/depth.rar

To better understand it, this is the code i used to lock it.
	ID3D10Texture2D *z,*w;
	D3D10_TEXTURE2D_DESC gigi;
	SSV->GetResource((ID3D10Resource**)&z);
	z->GetDesc(&gigi);
	gigi.CPUAccessFlags = D3D10_CPU_ACCESS_READ;
	gigi.Usage = D3D10_USAGE_STAGING;
	gigi.BindFlags = 0;
	Device->CreateTexture2D(&gigi,NULL,&w);
	Device->CopyResource(w,z);

	D3D10_MAPPED_TEXTURE2D mapped;
	w->Map(0,D3D10_MAP_READ,0,&mapped);

	float *values = new float[gigi.Width*gigi.Height];

	memcpy(values,mapped.pData,sizeof(float)*gigi.Width*gigi.Height);
	w->Unmap(0);
	w->Release();


	FILE *zeta = fopen("depth.txt","w");

	for (int v = 0; v < _msize(values) / sizeof(float); v++)
	{
		fprintf(zeta,"%f \n",values[v]);

		if (v%800 == 0 && v >= 800)
			fprintf(zeta,"\n");

	}

	fclose(zeta);


The values looks like "normal" so i do not understand the need to subract 50.
About your sum value, i tried before and also after the division.

I forgot to post it to you yesterday.
Adding 0.1 in this way

return (distance(In.WPos,LightInfo3.xyz) ) / FarClip + 0.1f; 
Posted Image
This is the result.

Adding 0.11 instead of 0.1 the ball on the car vanishes, but anyway some parts are, anyway, unrendered correctly.
Posted Image

Compare these two images with the one with gray shadow: near the real car there is a black spot (due to return 0 statement)...while it should be lighted (anyway, it happens if instead of 30 i add 27)

#51 Goz

    Senior Member

  • Members
  • PipPipPipPip
  • 574 posts

Posted 19 February 2009 - 09:05 AM

Hmm A few new thoughts come to mind. You do the world position to spot light distance check in the vertex shader in the non-shadow pass and in the pixel shader in the shadow pass. Do them both in the vertex or pixel shader.

Also you didn't add the 0.0001 to the non-shadow pass did you?

It makes no sense that it would only work by adding 30 to the shadow distances because they are all between 0.0 and 1.0. By adding 30 you are pushing them to 30.0 to 31.0 and then checking them against distances in the 0 to 1 range. I really think there must be something you are doing wrong.

#52 Goz

    Senior Member

  • Members
  • PipPipPipPip
  • 574 posts

Posted 19 February 2009 - 09:12 AM

I have also re-written your shader code slightly. I haven't compiled it so it may fail but give it a try.


#define FarClip 200


cbuffer cMultiFrame

{

	row_major float4x4	WorldMatrix;

	bool Lamp;

};


cbuffer cSometime

{

	row_major float4x4	ViewMatrix;

	row_major float4x4	VSpotMatrix; //Matrice spotlight

	float4 LightInfo; //Luce puntiforme del lampione

	float4 LightInfo2; //Direzione del fanale

	float4 LightInfo3; //Posizione del fanale

	float Phi;

	float Theta;

};


cbuffer cNeverChange

{

	row_major float4x4	ProjMatrix;

	row_major float4x4  VMatrix[6];

};


Texture2D Text;

TextureCube Cubemap;

Texture2D SpotText;

SamplerState SamplText;


float Attenuation

    ( 

        float distance,  

        float a, 

        float b, 

        float c

    )

{

    float Atten = 1.0f / ( a + b * distance + c * pow(distance,2) );

    return Atten;

}


struct VS_INPUT

{

	float4 Pos	:	POSITION;

	float3 Nor	:	NORMAL;

	float2 Tex	:	TEXCOORD;

};


struct PS_INPUT

{

	float4	Pos	:	SV_POSITION;

	float4	PSpot2D	:	P2DPOS;

	float4	WPos:	WORLDPOS;

	float3	Nor	:	NORMAL;

	float2	Tex	:	TEXCOORD;

};


struct VGS_OUTPUT

{

	float4	Pos	:	SV_POSITION;

	float4	WPos:	WORLDPOSITION;

	uint RTIndex : SV_RenderTargetArrayIndex;

};


struct VPS_OUTPUT

{

	float4	Pos	:	SV_POSITION;

	float4	WPos:	WORLDPOSITION;

};



PS_INPUT vs_position (VS_INPUT In)

{

	PS_INPUT Out = (PS_INPUT)0;


	Out.Pos = mul(mul(mul(In.Pos,WorldMatrix),ViewMatrix),ProjMatrix);

	Out.PSpot2D = mul(mul(mul(In.Pos,WorldMatrix),VSpotMatrix),ProjMatrix);

	Out.WPos = mul(In.Pos,WorldMatrix);

	Out.Nor = mul(In.Nor,WorldMatrix);

	Out.Tex = In.Tex;

	

	return Out;	

}


VS_INPUT vs_void (VS_INPUT In)

{

	return In;

}



float4 ps_light (PS_INPUT In)	:	SV_TARGET

{	

	float4 BaseColor = (Lamp == true) ? float4(0.25f, 0.21f, 0.20f, 1) : Text.Sample(SamplText,In.Tex);

	float3 vLight = normalize(LightInfo.xyz-In.WPos);

	float NdotL = dot(In.Nor,vLight);

	float Att = Attenuation(distance(LightInfo.xyz,In.WPos),0.003,0.003,0.003);

	float4 PointLight = (saturate(NdotL)) * Att;

	

	// Get the light to vec distance inside the pixel shader to match 

	float4 LightToVec		= LightInfo3.xyz - In.WPos;

	float  LightToVecDist		= length( LightToVec )

	float4 LightToVecDirection 	= lightToVec / lightToVecDist; // This normalises


	

	float4 LightToSourceDirection = normalize(LightInfo3 - LightInfo2);

	float cosAlpha = dot(LightToVecDirection,LightToSourceDirection);

	

	float2 VTexC = In.PSpot2D.xy / In.PSpot2D.w * 0.5f - float2(0.5f,0.5f);

	VTexC.y = 1.0f - VTexC.y;

	

	float SpotShadow = SpotText.Sample(SamplText,VTexC);

	

    float Atten = 0.0f;

    

    if( cosAlpha > Theta )

    {

        Atten = 1.0f;

    }

    else if( cosAlpha > Phi )

    {

        Atten = 0.5f;

    }

    

    if (Atten != 0)

    {

		if ((LightToVecDist / FarClip) >= SpotShadow)

		{

			return float4(1,0,0,0);

		}

    }


		float4 SpotLight = (Atten * dot( In.Nor, LightToVecDirection ));

		

		return (PointLight + SpotLight) * BaseColor;	


}


[maxvertexcount(18)]

void Gs_Cubemap(triangle VS_INPUT input[3], inout TriangleStream<VGS_OUTPUT> Out)

{

    VGS_OUTPUT output;

    

    for( int f = 0; f < 6; f++ )

    {

        output.RTIndex = f;

        for( int v = 0; v < 3; v++ )

        {

            output.Pos = mul(mul(mul( input[v].Pos, WorldMatrix),VMatrix[f]),ProjMatrix );

            output.WPos = mul(input[v].Pos,WorldMatrix);

            Out.Append( output );

        }

        

        Out.RestartStrip();

	}

}


float ps_depth (VGS_OUTPUT In)	:	SV_TARGET

{	

	return distance(In.WPos,LightInfo) / FarClip;

}


float ps_spotdepth (VPS_OUTPUT In)	:	SV_TARGET

{	

	return (distance(In.WPos,LightInfo3) / FarClip) + 0.0001;

}


VPS_OUTPUT vs_spot(VS_INPUT In)

{

	VPS_OUTPUT p = (VPS_OUTPUT)0;

	

	p.Pos = mul(mul(mul(In.Pos,WorldMatrix),VSpotMatrix),ProjMatrix);

	p.WPos = mul(In.Pos,WorldMatrix);

	

	return p;

}



#53 XVincentX

    Valued Member

  • Members
  • PipPipPip
  • 115 posts

Posted 19 February 2009 - 11:22 AM

I simply corrected the compiling error...it works.
As i can see you just computed distances all in pixel shader...while i made a mistake (one in vertex, another in pixel)
Why don't you use the normalize function?

#54 Goz

    Senior Member

  • Members
  • PipPipPipPip
  • 574 posts

Posted 19 February 2009 - 12:22 PM

So that code gives you the right shadowing?

The only reason I don't use the normalize function is that it saves computation. Normalize is the same as doing vec / length( vec ). So i need the length in the pixel shader and THEN i need to normalize the vector. Length is not a speedy calculation (sqrt( dot( vec, vec ) )) so i see no point in doing the work twice :)

But yes .. essentially the only difference is that I am calculating the distance per pixel instead of per vertex and interpolating. I'm not entirely sure why they don't both produce the same result. Its probably to do with perspective correct interpolation of the distance value that causes it to wander from exactly what you are after. I should go through the maths but I'm supposed to be working (Bloody bayesian likelihood ratios and n-Vectors all rolled into one! :wacko:)

#55 XVincentX

    Valued Member

  • Members
  • PipPipPip
  • 115 posts

Posted 19 February 2009 - 01:23 PM

Thank you again. I will try the same thing for the PointLight shadow made with cubemap, even if i'm fighing against a D3D10 Internal Compiler error.

#56 XVincentX

    Valued Member

  • Members
  • PipPipPip
  • 115 posts

Posted 19 February 2009 - 09:29 PM

Ok now i started to work on second shadow.
I tried to follow your example, reusing the same code, but (...) the result was not the hoped one.

#define FarClip 200

cbuffer cMultiFrame
{
	row_major float4x4	WorldMatrix;
	bool Lamp;
};

cbuffer cSometime
{
	row_major float4x4	ViewMatrix;
	row_major float4x4	VSpotMatrix; //Matrice spotlight
	float4 LightInfo; //Luce puntiforme del lampione
	float4 LightInfo2; //Direzione del fanale
	float4 LightInfo3; //Posizione del fanale
	float2 Angles;
};

cbuffer cNeverChange
{
	row_major float4x4	ProjMatrix;
	row_major float4x4  VMatrix[6];
};

Texture2D Text;
TextureCube Cubemap;
Texture2D SpotText;
SamplerState SamplText;

float Attenuation
    ( 
        float distance,  
        float a, 
        float b, 
        float c
    )
{
    float Atten = 1.0f / ( a + b * distance + c * pow(distance,2) );
    return Atten;
}

struct VS_INPUT
{
	float4 Pos	:	POSITION;
	float3 Nor	:	NORMAL;
	float2 Tex	:	TEXCOORD;
};

struct PS_INPUT
{
	float4	Pos	:	SV_POSITION;
	float4	PSpot2D	:	P2DPOS;
	float4	WPos:	WORLDPOS;
	float3	Nor	:	NORMAL;
	float2	Tex	:	TEXCOORD;
};

struct VGS_OUTPUT
{
	float4	Pos	:	SV_POSITION;
	float4	WPos:	WORLDPOSITION;
	uint RTIndex : SV_RenderTargetArrayIndex;
};

struct VPS_OUTPUT
{
	float4	Pos	:	SV_POSITION;
	float4	WPos:	WORLDPOSITION;
};


PS_INPUT vs_position (VS_INPUT In)
{
	PS_INPUT Out = (PS_INPUT)0;

	Out.Pos = mul(mul(mul(In.Pos,WorldMatrix),ViewMatrix),ProjMatrix);
	Out.PSpot2D = mul(mul(mul(In.Pos,WorldMatrix),VSpotMatrix),ProjMatrix);
	Out.WPos = mul(In.Pos,WorldMatrix);
	Out.Nor = mul(In.Nor,WorldMatrix);
	Out.Tex = In.Tex;
	
	return Out;	
}

VS_INPUT vs_void (VS_INPUT In)
{
	return In;
}


float4 ps_light (PS_INPUT In)	:	SV_TARGET
{	
	float4 BaseColor = (Lamp == true) ? float4(0.25f, 0.21f, 0.20f, 1) : Text.Sample(SamplText,In.Tex);
	float3 vLight = normalize(LightInfo.xyz-In.WPos);
	float NdotL = dot(In.Nor,vLight);
	float Att = Attenuation(distance(LightInfo.xyz,In.WPos),0.003,0.003,0.003);
	float4 PointLight = (saturate(NdotL)) * Att;
	
	float3 LightToVec		=	  LightInfo3.xyz - In.WPos;
	float  LightToVecDist		= length(LightToVec);
	float3 LightToVecDirection 	= LightToVec / LightToVecDist;

	float4 LightToSourceDirection = normalize(LightInfo3 - LightInfo2);
	float cosAlpha = dot(LightToVecDirection,LightToSourceDirection);
	
	float2 VTexC;
	 
	 VTexC[0] = In.PSpot2D.x/In.PSpot2D.w * 0.5f + 0.5f;
     VTexC[1] = -In.PSpot2D.y/In.PSpot2D.w * 0.5f + 0.5f;

	float SpotShadow = SpotText.Sample(SamplText,VTexC);
	
    float Atten = 0.0f;
    
    if( cosAlpha > Angles.y )
    {
        Atten = 1.0f;
    }
    else if( cosAlpha > Angles.x )
    {
        Atten = 0.5f;
    }
    
		int ShadowValue = (!((LightToVecDist / FarClip) >= SpotShadow && Atten != 0));
    
		LightToVec = In.WPos - LightInfo.xyz;
		LightToVecDist = length(LightToVec);
		float CubeShadow = Cubemap.Sample(SamplText,(LightToVec/LightToVecDist));	
		int CubeValue = (((LightToVecDist / FarClip) > CubeShadow));
		
		float4 SpotLight = (Atten * float4(1.0f,0.8f,0.12f,0) * dot( In.Nor, LightToVecDirection ));		
		return (PointLight + SpotLight) * BaseColor * ShadowValue * CubeValue;	

}

[maxvertexcount(18)]
void Gs_Cubemap(triangle VS_INPUT input[3], inout TriangleStream<VGS_OUTPUT> Out)
{
    VGS_OUTPUT output;
    
    for( int f = 0; f < 6; f++ )
    {
        output.RTIndex = f;
        for( int v = 0; v < 3; v++ )
        {
            output.Pos = mul(mul(mul( input[v].Pos, WorldMatrix),VMatrix[f]),ProjMatrix );
            output.WPos = mul(input[v].Pos,WorldMatrix);
            Out.Append( output );
        }
        
        Out.RestartStrip();
	}
}

float ps_depth (VGS_OUTPUT In)	:	SV_TARGET
{	
	return distance(In.WPos,LightInfo) / FarClip;
}

float ps_spotdepth (VPS_OUTPUT In)	:	SV_TARGET
{	
	return (distance(In.WPos,LightInfo3) / FarClip) + 0.0001;
}

VPS_OUTPUT vs_spot(VS_INPUT In)
{
	VPS_OUTPUT p = (VPS_OUTPUT)0;
	
	p.Pos = mul(mul(mul(In.Pos,WorldMatrix),VSpotMatrix),ProjMatrix);
	p.WPos = mul(In.Pos,WorldMatrix);
	
	return p;
}


The cubemap it's correctly filled (in particular the face 4 is perfect), but i can see a lot of points on the image as result...

#57 Goz

    Senior Member

  • Members
  • PipPipPipPip
  • 574 posts

Posted 19 February 2009 - 09:45 PM

Is the point light at the same position as the spot light? Thats what the code suggests ...

#58 Goz

    Senior Member

  • Members
  • PipPipPipPip
  • 574 posts

Posted 19 February 2009 - 09:48 PM

Nope . my mistake .. not reading the code closely enough. Btw you don't need to do my optimisation there you may as well just use a normalize. The only reason i didn't was to avoid using 2 square roots. That said .. the code should be pretty much identical anyway.

Any reason the cubemap depth test isn't "not" like the spot shadow?

Also what does the output look like?

#59 XVincentX

    Valued Member

  • Members
  • PipPipPip
  • 115 posts

Posted 19 February 2009 - 10:00 PM

Here is the strange output
Posted Image

I tried also to recopy the original copy (that worked) in page 1, but nothing looks like to change.

#60 Goz

    Senior Member

  • Members
  • PipPipPipPip
  • 574 posts

Posted 20 February 2009 - 10:27 AM

Can you set ps_depth to

return (distance(In.WPos,LightInfo) / FarClip) + 0.0001;





1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users