i have a problem with softshadow-shader from Matt Aufderheide.
it has worked perfectly with A6, but with A7 it doesnt work anymore, the model i add the shader, gets invisible!!!



Code:
/*******************************************************
softshadows.wdl
(c)2005 Matt Aufderheide
*******************************************************/

string my_file;
string empty="";
string sourcefile;

//change this for different LOD versions..
//here I am using the LOD 0 file ..
//however if you want, you can change it 1,2,3 to always have a 
//low res model as your shadow..however it seems to work fine this way if you have LODs
//if you dont have LOD change this string to simply ".mdl"
string control_file="0.mdl"; 

//i have included this tga file
bmap softshadow_bmap = <shadow_color.tga>;

material mat_softshadows{}

//flatten the shadow to the ground normals
function shadow_to_normal()
{	
			
  			temp_ent = YOU;

			trace_mode = IGNORE_PASSENTS+ IGNORE_ME+ IGNORE_YOU+ IGNORE_MODELS;
			vec_set(vecFrom,YOU.X);
			vec_set(vecTo,vecFrom);
			vecTo.Z -= 500;
			result = trace(vecFrom,vecTo);

			YOU = temp_ent; // YOU (the entity itself) is changed by SONAR

			if(result > 0)
			{
				// place shadow 2 quants above the floor
				MY.z = YOU.z - RESULT + 2; //YOUR.min_z*/ + 2 - RESULT;
				MY.x = YOU.x;
				MY.y = YOU.y;

				// adapt shadow orientation to floor slope
				if ((NORMAL.x != 0) || (NORMAL.y != 0))
				{ // we're on a slope
					// conform shadow to slope
					MY.PAN = 0;
					MY.tilt = - asin(NORMAL.x);
					MY.roll = - asin(NORMAL.y);
					temp.pan = YOU.PAN;
					temp.tilt = 0;
					temp.roll = 0;
					rotate(my,temp,nullvector);
 				}
				else
				{
					MY.pan = YOU.pan;
					MY.tilt = 0; // set it flat onto the floor
					MY.roll = 0;
				}
			}


}


//this function controls the far disnace you can see shadow
function shadow_vis()
{
	while(me)
	{
		if (vec_dist(my.x,camera.x) > 1000) //adjust this dist here
		{
			my.invisible=on;
		}
		
		else
	
		{
			my.invisible=off;
		}
		
		wait(10+(random(5)));
	}
	
}

//animate and move the shadow mesh
function shadow_mesh()
{
	my.scale_x=your.scale_x;
	my.scale_y=your.scale_y;
	my.scale_z=your.scale_z;
	my.scale_z*=0.01;

	my.passable=on;
	my.push=-1;	
	
	my.ambient=0;
	my.transparent=on;
	my.flare=on;
	my.passable=on;
	my.push=-1;	
	
	shadow_vis();
	
	my.material=mat_softshadows;
	mat_softshadows.skin1=softshadow_bmap;

  	my.skill41=float(0.7); // adjust this to increase blurriness..
	
	while(me)
	{
		
		if you!=null
		{
			my.frame=your.frame;
			my.next_frame=your.next_frame;
			shadow_to_normal();	
		}
		
		if you==null
		{
			ent_remove(me);
		}
		
		wait(1);
	}
	
}


function render_shadows()
{
	str_cpy(my_file,empty);
	str_for_entfile (sourcefile, me);
	str_trunc(sourcefile,5);
	str_cpy(my_file,sourcefile);
	str_cat(my_file,control_file);
	ent_create(my_file,my.x,shadow_mesh);
}


starter softshadow_start
{
	effect_load(mat_softshadows,"softshadow.fx");
}




Now the .fx-file

Code:
/////////////////////////////////////////////////
 //multipass shader for "blurring the shadow
 //based on the WIKI fur shader example
 /////////////////////////////////////////////////
 
        texture mtlSkin1; //should be light grey
        matrix matWorldViewProj;
        matrix matWorld;
        matrix matWorldView;
        vector vecSkill1;
        vector vecSkill41;
        vector vecFog;
			vector vecSunDir;

        technique shadowblur
        {
                pass p0
                {
                        texture[0]=<mtlSkin1>;


                        zWriteEnable=false;
                        alphaBlendEnable=true;
                        
								srcblend=destcolor;
						   	destblend=zero;

                        vertexShaderConstant[0]=<matWorldViewProj>;
                        vertexShaderConstant[4]=<matWorld>;
                        vertexShaderConstant[8]=<matWorldView>;
                        vertexShaderConstant[16]=<vecSkill41>;          // shell_distance, 0, fur_u_scale, fur_v_scale
                        vertexShaderConstant[17]={0.0,0.0,0.0,0.0};     // shell_number
                        vertexShaderConstant[19]=<vecSunDir>;
                        vertexShaderConstant[20]=<vecFog>;
                        vertexShaderConstant[94]=<vecSkill1>;           // first_shell_brightness, brightness_increment, 0, 0
                        vertexShaderConstant[95]={0.5,1.0,2.0,0.0};

                        vertexShader =
   
                        asm
                        {
                                vs.1.1

										  dcl_position  v0
										  dcl_normal    v3
										  dcl_texcoord1 v7 //color uv
                  
                                mov r0,v0
                                mov r1,c16
                                mul r1,r1.x,c17.x               // shell distance * shell number
                                mul r1,r1,v3                    // scale normal
                                add r0.xyz,r0.xyz,r1.xyz        // shell offset (vertex position + scaled normal}

                                m4x4 oPos,r0,c0                 // transform position to clip space
                                mov oT0,v7                      // output uvs
                                
                                            mov r1.w,c20.w                  // r1.w=1
                                dp4 r0,v0,c10                   // distance to camera position
                                add r0,r0,-c20.x                // distance-fog_start
                                mad r0.x,-r0.x,c20.z,r1.w       // 1-(distance-fog_start}*(1/(fog_end-fog_start}}
                                max oFog,r0.x,c95.w           // clamp with custom max value

                        };
                        
                        
                        pixelShader=
                        asm
                        {
                                ps.1.1
                                
                                
                                tex t0 // sample colormap

                                mov r0,t0
    
                        };
                }

                //-----------------------------------------------------------------------------
					
					
                pass p1
                {
                        texture[0]=<mtlSkin1>;


                        zWriteEnable=false;
                        alphaBlendEnable=true;

                        vertexShaderConstant[0]=<matWorldViewProj>;
                        vertexShaderConstant[4]=<matWorld>;
                        vertexShaderConstant[8]=<matWorldView>;
                        vertexShaderConstant[16]=<vecSkill41>;
                        vertexShaderConstant[17]={1.0,0.0,0.0,0.0};
                        vertexShaderConstant[19]=<vecSunDir>;
                        vertexShaderConstant[20]=<vecFog>;
                        vertexShaderConstant[94]=<vecSkill1>;
                        vertexShaderConstant[95]={0.5,1.0,2.0,0.0};

                        vertexShader =

                        asm
                        {
                                vs.1.1
										  dcl_position  v0
										  dcl_normal    v3
										  dcl_texcoord1 v7 //color uv
               
                                mov r0,v0
                                mov r1,c16
                                mul r1,r1.x,c17.x
                                mul r1,r1,v3
                                add r0.xyz,r0.xyz,r1.xyz

                                m4x4 oPos,r0,c0
                                mov oT0,v7
                                
                                            mov r1.w,c20.w                  // r1.w=1
                                dp4 r0,v0,c10                   // distance to camera position
                                add r0,r0,-c20.x                // distance-fog_start
                                mad r0.x,-r0.x,c20.z,r1.w       // 1-(distance-fog_start}*(1/(fog_end-fog_start}}
                                max oFog,r0.x,c95.w           // clamp with custom max value
    
                                
                        };
                        pixelShader=
                        asm
                        {
                                ps.1.1
                 
                                tex t0
   
                             	  mov r0,t0
                        
 
                        };
                }
                
               
                pass p2
                {
                        texture[0]=<mtlSkin1>;
 

                        zWriteEnable=false;
                        alphaBlendEnable=true;

                        vertexShaderConstant[0]=<matWorldViewProj>;
                        vertexShaderConstant[4]=<matWorld>;
                        vertexShaderConstant[8]=<matWorldView>;
                        vertexShaderConstant[16]=<vecSkill41>;
                        vertexShaderConstant[17]={2.0,0.0,0.0,10000};
                        vertexShaderConstant[19]=<vecSunDir>;
                        vertexShaderConstant[20]=<vecFog>;
                        vertexShaderConstant[94]=<vecSkill1>;
                        vertexShaderConstant[95]={0.5,1.0,2.0,0.0};

                        vertexShader =

                        asm
                        {
                                vs.1.1
										  dcl_position  v0
										  dcl_normal    v3
										  dcl_texcoord1 v7 //color uv
                      
                                mov r0,v0
                                mov r1,c16
                                mul r1,r1.x,c17.x
                                mul r1,r1,v3
                                add r0.xyz,r0.xyz,r1.xyz

                                m4x4 oPos,r0,c0
                                mov oT0,v7
                                
                                mov oFog,c17.w

    
                        };
                        pixelShader=
                        asm
                        {
                                ps.1.1
                               
                                tex t0
                                										
                             	   mov r0,t0
                             

                        };
                }
                pass p3
                {
                        texture[0]=<mtlSkin1>;


                        zWriteEnable=false;
                        alphaBlendEnable=true;

                        vertexShaderConstant[0]=<matWorldViewProj>;
                        vertexShaderConstant[4]=<matWorld>;
                        vertexShaderConstant[8]=<matWorldView>;
                        vertexShaderConstant[16]=<vecSkill41>;
                        vertexShaderConstant[17]={3.0,0.0,0.0,10000};
                        vertexShaderConstant[19]=<vecSunDir>;
                        vertexShaderConstant[20]=<vecFog>;
                        vertexShaderConstant[94]=<vecSkill1>;
                        vertexShaderConstant[95]={0.5,1.0,2.0,0.0};

                        vertexShader =
    
                        asm
                        {
                                vs.1.1
										  dcl_position  v0
										  dcl_normal    v3
										  dcl_texcoord1 v7 //color uv
                   
                                mov r0,v0
                                mov r1,c16
                                mul r1,r1.x,c17.x
                                mul r1,r1,v3
                                add r0.xyz,r0.xyz,r1.xyz

                                m4x4 oPos,r0,c0
                                mov oT0,v7
                                
                                mov oFog,c17.w

                        };
                        pixelShader=
                        asm
                        {
                                ps.1.1
                              
                                tex t0
        
                             	   mov r0,t0
                
                        };
                }
                pass p4
                {
                        texture[0]=<mtlSkin1>;
 

                        zWriteEnable=false;
                        alphaBlendEnable=true;

                        vertexShaderConstant[0]=<matWorldViewProj>;
                        vertexShaderConstant[4]=<matWorld>;
                        vertexShaderConstant[8]=<matWorldView>;
                        vertexShaderConstant[16]=<vecSkill41>;
                        vertexShaderConstant[17]={4.0,0.0,0.0,10000};
                        vertexShaderConstant[19]=<vecSunDir>;
                        vertexShaderConstant[20]=<vecFog>;
                        vertexShaderConstant[94]=<vecSkill1>;
                        vertexShaderConstant[95]={0.5,1.0,2.0,0.0};

                        vertexShader =
     
                        asm
                        {
                                vs.1.1
										  dcl_position  v0
										  dcl_normal    v3
										  dcl_texcoord1 v7 //color uv
                      
                                mov r0,v0
                                mov r1,c16
                                mul r1,r1.x,c17.x
                                mul r1,r1,v3
                                add r0.xyz,r0.xyz,r1.xyz

                                m4x4 oPos,r0,c0
                                mov oT0,v7
                                
                                mov oFog,c17.w
 
                        };
                        pixelShader=
                        asm
                        {
                                ps.1.1
                            
                                tex t0
                                										
                             	   mov r0,t0
                             	
                        };
                }
                
                pass p5
                {
                        texture[0]=<mtlSkin1>;
   

                        zWriteEnable=false;
                        alphaBlendEnable=true;

                        vertexShaderConstant[0]=<matWorldViewProj>;
                        vertexShaderConstant[4]=<matWorld>;
                        vertexShaderConstant[8]=<matWorldView>;
                        vertexShaderConstant[16]=<vecSkill41>;
                        vertexShaderConstant[17]={5.0,0.0,0.0,10000};
                        vertexShaderConstant[19]=<vecSunDir>;
                        vertexShaderConstant[20]=<vecFog>;
                        vertexShaderConstant[94]=<vecSkill1>;
                        vertexShaderConstant[95]={0.5,1.0,2.0,0.0};

                        vertexShader =

                        asm
                        {
                                vs.1.1
										  dcl_position  v0
										  dcl_normal    v3
										  dcl_texcoord1 v7 //color uv
                   
                                mov r0,v0
                                mov r1,c16
                                mul r1,r1.x,c17.x
                                mul r1,r1,v3
                                add r0.xyz,r0.xyz,r1.xyz

                                m4x4 oPos,r0,c0
                                mov oT0,v7
                                
                                mov oFog,c17.w

                        };
                        pixelShader=
                        asm
                        {
                                ps.1.1
                                
                                tex t0
                                										
                             	   mov r0,t0
                             	
                        };
                }
                pass p6
                {
                        texture[0]=<mtlSkin1>;
    

                        zWriteEnable=false;
                        alphaBlendEnable=true;

                        vertexShaderConstant[0]=<matWorldViewProj>;
                        vertexShaderConstant[4]=<matWorld>;
                        vertexShaderConstant[8]=<matWorldView>;
                        vertexShaderConstant[16]=<vecSkill41>;
                        vertexShaderConstant[17]={6.0,0.0,0.0,10000};
                        vertexShaderConstant[19]=<vecSunDir>;
                        vertexShaderConstant[20]=<vecFog>;
                        vertexShaderConstant[94]=<vecSkill1>;
                        vertexShaderConstant[95]={0.5,1.0,2.0,0.0};

                        vertexShader =
     
                        asm
                        {
                                vs.1.1
										  dcl_position  v0
										  dcl_normal    v3
										  dcl_texcoord1 v7 //color uv
                  
                                mov r0,v0
                                mov r1,c16
                                mul r1,r1.x,c17.x
                                mul r1,r1,v3
                                add r0.xyz,r0.xyz,r1.xyz

                                m4x4 oPos,r0,c0
                                mov oT0,v7
                                
                                mov oFog,c17.w

                        };
                        pixelShader=
                        asm
                        {
                                ps.1.1
                            
                                tex t0
                                										
                             	   mov r0,t0
              
                        };
                }
               
        }



Last edited by Schloder87; 05/25/10 12:41.

Visit IGRAVISION at: http://www.igravision.com
_________________________