Changeset 1118


Ignore:
Timestamp:
07/11/06 15:47:50 (18 years ago)
Author:
szirmay
Message:
 
Location:
GTP/trunk/App/Demos/Illum/Ogre/Media/materials
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • GTP/trunk/App/Demos/Illum/Ogre/Media/materials/programs/GameTools_DepthShadow.hlsl

    r1102 r1118  
    33{ 
    44        float4 hPosition        : POSITION; 
    5         float4 Position : TEXCOORD0; 
     5        float4 Position         : TEXCOORD0;     
    66}; 
    77 
    8 VS_OUT hDepthVS(float4 position : POSITION,      
    9                 uniform float4x4 worldView, 
    10                 uniform float4x4 worldViewProj) 
     8VS_OUT DepthVS(float4 position : POSITION,       
     9                                uniform float4x4 worldViewProj,                          
     10                                uniform float4x4 viewProj, 
     11                                uniform float4x4 cameraMatrix) 
    1112{ 
    1213   
    1314  VS_OUT OUT; 
     15  
    1416  OUT.hPosition = mul(worldViewProj, position); 
    15   OUT.Position = mul(worldView, position); 
    16   OUT.Position.z *= -1.0; 
     17  OUT.Position = mul(viewProj, position); 
     18   
    1719  return OUT; 
    1820} 
    1921 
    20  
    21  
     22//for directional light 
    2223float4 DepthPS(VS_OUT IN ):COLOR 
    2324{ 
    24         float dist = length(IN.Position.xyz); 
    25         return float4(dist, dist, dist, 1); 
    26         //return 1;      
     25        float4 pos = (IN.Position / IN.Position.w); 
     26        pos = (pos +1.0 ) / 2.0; 
     27        return pos.z;    
    2728} 
    2829 
     
    3334        float4 hPosition        : POSITION; 
    3435        float4 Position         : TEXCOORD0; 
    35         float4 cPosition        : TEXCOORD1; 
     36        float4 lPosition        : TEXCOORD1; 
    3637}; 
    3738 
    3839VS_OUT_SHADOW depthShadowVS(float4 position : POSITION,  
    39                 uniform float4x4 world, 
    40                 uniform float4x4 worldView, 
    41                 uniform float4x4 worldViewProj) 
     40                                                        uniform float4x4 worldViewProj, 
     41                                                        uniform float4x4 lightViewProj) 
    4242{ 
    4343  VS_OUT_SHADOW OUT; 
    4444  OUT.hPosition = mul(worldViewProj, position); 
    45   OUT.Position = mul(world, position); 
    46   OUT.cPosition = mul(worldView, position); 
     45  OUT.lPosition = mul(lightViewProj, position);   
     46  OUT.Position = position;   
    4747  return OUT; 
    4848} 
     
    5050 
    5151float4 depthShadowPS(VS_OUT_SHADOW IN, 
    52                                         uniform float4x4 lightView, 
    5352                                        uniform float4x4 lightViewProj, 
    54                                         uniform float4x4 lightView2, 
    55                                         uniform float4x4 lightViewProj2, 
    56                                         uniform sampler2D depthShadowMap : register(s0), 
    57                                         uniform sampler2D depthShadowMap2 : register(s1)):COLOR 
    58 {                                        
    59         float bias = 0.06; 
    60         float4 shadowColor = float4(0.6, 0.6, 0.6, 1.0); 
    61  
    62         float4 light1 = float4(1,1,1,1); 
     53                                        uniform sampler2D depthShadowMap : register(s0) 
     54                                        ):COLOR 
     55{        
     56        float bias = 0.001; 
     57        float4 light = float4(1,1,1,1); 
     58        float4 shadow = float4(0.3,0.3,0.3,1); 
    6359         
    64         float4 lightCamPos1 = mul(lightView, IN.Position); 
    65         float d1 = length(lightCamPos1.xyz);     
    66         float4 lightScreenPos1 = mul(lightViewProj, IN.Position); 
    67         lightScreenPos1 = lightScreenPos1 / lightScreenPos1.w ;  
    68         lightScreenPos1 = ( lightScreenPos1 + 1.0 ) / 2.0; 
    69         lightScreenPos1.y = 1.0 - lightScreenPos1.y; 
    70         float4 storedDepth1 = tex2D(depthShadowMap, lightScreenPos1.xy); 
    71                 if(storedDepth1.r + bias < d1) 
    72                         light1 = shadowColor;    
    73          
    74          
    75         return light1;   
     60        float4 pos = (IN.lPosition / IN.lPosition.w); 
     61        pos = (pos +1.0 ) / 2.0; 
     62        pos.y = 1.0 - pos.y; 
     63        float4 storedDepth = tex2D(depthShadowMap, pos.xy); 
     64        if(storedDepth.r + bias < pos.z) 
     65                light = shadow; 
     66        //return abs( pos.z - storedDepth.z );   
     67        return light;    
    7668} 
    7769 
  • GTP/trunk/App/Demos/Illum/Ogre/Media/materials/scripts/GameTools.material

    r1102 r1118  
    170170      pass  
    171171      {  
    172                 cull_hardware anticlockwise 
     172                //cull_hardware anticlockwise 
    173173                 
    174174                vertex_program_ref GameTools/ShadowMap/DepthVS 
    175175        {        
    176             param_named_auto worldView worldview_matrix 
    177             param_named_auto worldViewProj worldviewproj_matrix 
    178              
     176           param_named_auto viewProj viewproj_matrix 
     177           param_named_auto worldViewProj worldviewproj_matrix             
    179178            }  
    180179                fragment_program_ref  GameTools/ShadowMap/DepthPS 
  • GTP/trunk/App/Demos/Illum/Ogre/Media/materials/scripts/GameTools.program

    r1102 r1118  
    228228{ 
    229229        source GameTools_DepthShadow.hlsl 
    230         entry_point hDepthVS 
    231         target vs_1_1 
     230        entry_point DepthVS 
     231        target vs_3_0 
    232232}  
    233233 
     
    236236        source GameTools_DepthShadow.hlsl 
    237237        entry_point DepthPS 
    238         target ps_2_0 
     238        target ps_3_0 
    239239 
    240240}  
Note: See TracChangeset for help on using the changeset viewer.