Ignore:
Timestamp:
10/17/06 09:25:48 (18 years ago)
Author:
szirmay
Message:
 
Location:
GTP/trunk/App/Demos/Illum/Ogre/Media
Files:
9 added
5 edited

Legend:

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

    r1131 r1629  
    2121float4 DepthPS(VS_OUT IN ):COLOR 
    2222{ 
     23//return 1; 
    2324        float4 pos = (IN.Position / IN.Position.w); 
    24         pos = (pos +1.0 ) / 2.0; 
     25        //pos = (pos +1.0 ) / 2.0; 
    2526        return float4(pos.z, pos.z * pos.z, 1, 1);       
    2627} 
     
    4849} 
    4950 
    50  
     51/* 
    5152float4 depthShadowPS(VS_OUT_SHADOW IN, 
    5253                                        uniform float4x4 lightViewProj, 
     
    5455                                        ):COLOR 
    5556{        
    56         float bias = 0.1; 
     57        float bias = 0.0001; 
    5758        float4 light = float4(1,1,1,1); 
    58         float4 shadow = float4(0.3,0.3,0.3,1); 
     59        float4 shadow = float4(0.6,0.6,0.6,1); 
    5960         
    6061        float4 pos = (IN.lPosition / IN.lPosition.w); 
     
    6364        float4 storedDepth = tex2D(depthShadowMap, pos.xy); 
    6465         
    65         if(storedDepth.r + bias > pos.z) 
     66        if(storedDepth.r + bias < pos.z) 
    6667        { 
    6768                float M1 = storedDepth.r; 
     
    7677        return light;    
    7778} 
     79*/ 
    7880 
     81 
     82float4 depthShadowPS(VS_OUT_SHADOW IN, 
     83                                        uniform float4x4 lightViewProj, 
     84                                        uniform sampler2D depthShadowMap : register(s0) 
     85                                        ):COLOR 
     86{        
     87        float bias = 0.0001; 
     88        float4 light = float4(1,1,1,1); 
     89        float4 shadow = float4(0.65,0.65,0.65,1); 
     90        //float4 shadow = float4(0,0,0,1); 
     91         
     92        if(IN.lPosition.z > 0.0) 
     93        { 
     94                float4 pos = (IN.lPosition / IN.lPosition.w); 
     95                pos.xy = (pos.xy + 1.0) / 2.0; 
     96         
     97         
     98                pos.y = 1.0 - pos.y; 
     99                float4 storedDepth = tex2D(depthShadowMap, pos.xy); 
     100         
     101                if(storedDepth.r + bias < pos.z) 
     102                {                
     103                        light = shadow; 
     104                } 
     105                //if(length(pos.xy)>1) 
     106                //              light = shadow; 
     107        } 
     108         
     109         
     110        return light;    
     111} 
  • GTP/trunk/App/Demos/Illum/Ogre/Media/materials/programs/GameTools_Phong.hlsl

    r1611 r1629  
    6060    float3 pos = IN.wPos; 
    6161     
    62     float M = 1; 
     62    float M = 4; 
    6363    
    6464    float3 lightpositions[8]; 
     
    9292        L = normalize(L); 
    9393        float3 H = normalize(L + V); 
    94         float lightscale = 1.0; 
     94        float lightscale = 3.0; 
    9595        float4 spec = specular * lightcolors[i] * pow(dot(H, N), shininess) * lightscale; 
    9696        float4 diff = diffuse * lightcolors[i] * abs(dot(L, N)) * lightscale; 
     
    103103 
    104104} 
     105 
     106vertOUT PhongViewSpaceVS(float4 position : POSITION, 
     107                float3 normal   : NORMAL, 
     108                half3 tangent   : TEXCOORD1,  
     109                float2 texCoord : TEXCOORD0,                     
     110                uniform float4x4 worldViewProj, 
     111                uniform float4x4 worldView, 
     112                uniform float4x4 worldViewIT) 
     113{ 
     114  vertOUT OUT; 
     115  OUT.hPos = OUT.hPosition = mul(worldViewProj, position); 
     116  OUT.wPos = mul(worldView, position).xyz;   
     117  OUT.mNormal = mul(worldViewIT, normal).xyz; 
     118  //OUT.mNormal = normal; 
     119  OUT.texCoord = texCoord;   
     120  return OUT; 
     121} 
     122 
     123float4 PhongTexturedPS( vertOUT IN, 
     124                uniform float3 cameraPos, 
     125       uniform float4 lightpos1, 
     126           uniform float4 lightpos2, 
     127           uniform float4 lightpos3, 
     128           uniform float4 lightpos4, 
     129           uniform float4 lightpos5, 
     130           uniform float4 lightpos6, 
     131           uniform float4 lightpos7, 
     132           uniform float4 lightpos8, 
     133           uniform float4 lightdir1, 
     134           uniform float4 lightdir2, 
     135           uniform float4 lightdir3, 
     136           uniform float4 lightdir4, 
     137           uniform float4 lightdir5, 
     138           uniform float4 lightdir6, 
     139           uniform float4 lightdir7, 
     140           uniform float4 lightdir8, 
     141           uniform float lightscale1, 
     142           uniform float lightscale2, 
     143           uniform float lightscale3, 
     144           uniform float lightscale4, 
     145           uniform float lightscale5, 
     146           uniform float lightscale6, 
     147           uniform float lightscale7, 
     148           uniform float lightscale8, 
     149           uniform float4 lightcol1, 
     150           uniform float4 lightcol2, 
     151           uniform float4 lightcol3, 
     152           uniform float4 lightcol4, 
     153           uniform float4 lightcol5, 
     154           uniform float4 lightcol6, 
     155           uniform float4 lightcol7, 
     156           uniform float4 lightcol8, 
     157           uniform float4 ambientLight, 
     158           uniform float shininess, 
     159           uniform float4 specular, 
     160           uniform float4 diffuse, 
     161           uniform float4 ambient, 
     162           uniform sampler2D colorTexture, 
     163           uniform float4x4 worldViewIT           
     164 
     165            ) : COLOR0 
     166{ 
     167    
     168         
     169    float3 N = IN.mNormal; 
     170    //float3 N = mul(worldViewIT, IN.mNormal); 
     171    N = normalize( N );  
     172    float3 pos = IN.wPos; 
     173     
     174    float M = 3; 
     175    
     176    float4 lightpositions[8]; 
     177    float4 lightdirs[8]; 
     178    float4 lightcolors[8]; 
     179 
     180    lightpositions[0] = lightpos1; 
     181    lightpositions[1] = lightpos2; 
     182    lightpositions[2] = lightpos3; 
     183    lightpositions[3] = lightpos4; 
     184    lightpositions[4] = lightpos5; 
     185    lightpositions[5] = lightpos6; 
     186    lightpositions[6] = lightpos7; 
     187    lightpositions[7] = lightpos8; 
     188     
     189    lightdirs[0] = lightdir1; 
     190    lightdirs[1] = lightdir2; 
     191    lightdirs[2] = lightdir3; 
     192    lightdirs[3] = lightdir4; 
     193    lightdirs[4] = lightdir5; 
     194    lightdirs[5] = lightdir6; 
     195    lightdirs[6] = lightdir7; 
     196    lightdirs[7] = lightdir8; 
     197 
     198    lightcolors[0] = lightcol1 * lightscale1; 
     199    lightcolors[1] = lightcol2 * lightscale2; 
     200    lightcolors[2] = lightcol3 * lightscale3; 
     201    lightcolors[3] = lightcol4 * lightscale4; 
     202    lightcolors[4] = lightcol5 * lightscale5; 
     203    lightcolors[5] = lightcol6 * lightscale6; 
     204    lightcolors[6] = lightcol7 * lightscale7; 
     205    lightcolors[7] = lightcol8 * lightscale8; 
     206 
     207        float4 texColor = tex2D(colorTexture, IN.texCoord); 
     208        if(length(texColor)==0)texColor = 1; 
     209    float4 I = 0; 
     210    I = texColor * ambientLight * ambient; 
     211        float maxlightangle = 3.14 / 2.0; 
     212    for(int i=0; i< M; i++) 
     213    { 
     214                float3 V = normalize(cameraPos - pos); 
     215                float3 L = lightpositions[i].xyz - pos * lightpositions[i].w; 
     216                float d = length(L); 
     217                L = normalize(L); 
     218                float3 H = normalize(L + V); 
     219                 
     220                float spotscale = 1.0; 
     221                if( lightdirs[i].w && lightpositions[i].w)//spotlight 
     222                { 
     223                        float lightangle; 
     224                        lightangle = acos(dot(-L, normalize(lightdirs[i].xyz)));                         
     225                        spotscale = 1 - saturate(lightangle / maxlightangle); 
     226                        //spotscale *= spotscale; 
     227                } 
     228                         
     229                float4 spec = spotscale * specular * lightcolors[i] * pow(dot(H, N), shininess); 
     230                float4 diff = spotscale * texColor * diffuse * lightcolors[i] * dot(L, N); 
     231                I += 1.0 / d / d * (spec + diff);        
     232                //I+= spotscale; 
     233    } 
     234 
     235        //return texColor; 
     236        //return float4(N,1); 
     237    return I; 
     238 
     239} 
     240 
    105241 
    106242 
  • GTP/trunk/App/Demos/Illum/Ogre/Media/materials/scripts/GameTools.material

    r1590 r1629  
    9696                        ambient 0.3 0.3 0.4 
    9797                        diffuse 0.9 0.9 1.0 
    98                          
     98                        //lighting off 
    9999                        IllumTechniques 
    100                         { 
    101                                  
    102                                 RenderTechnique CausticReciever 
     100                        {                        
     101                                //RenderTechnique CausticReciever 
     102                                //{ 
     103                                //      max_caster_count        10 
     104                                //} 
     105                                RenderTechnique DepthShadowReciever 
    103106                                { 
    104                                         max_caster_count        10 
    105107                                }                                
    106108                        }                
     
    209211      pass  
    210212      {  
    211                 //cull_hardware anticlockwise 
     213                cull_hardware anticlockwise 
    212214                //cull_hardware none 
    213215                 
  • GTP/trunk/App/Demos/Illum/Ogre/Media/materials/scripts/diffscene.material

    r1611 r1629  
    8686                        { 
    8787                                param_named shininess float 2 
    88                                 param_named ambient 0.819489 0.891 0.656667 1 
    89                                 param_named diffuse 0.819489 0.891 0.656667 1 
    90                                 param_named specular 0.53846 0.53846 0.53846 1   
     88                                param_named ambient float4 0.819489 0.891 0.656667 1 
     89                                param_named diffuse float4 0.819489 0.891 0.656667 1 
     90                                param_named specular float4 0.53846 0.53846 0.53846 1    
    9191                        }                        
    9292                } 
     
    120120                        { 
    121121                                param_named shininess float 32.154 
    122                                 param_named ambient 0.177898 0.917 0.472184 1 
    123                                 param_named diffuse 0.177898 0.917 0.472184 1                            
     122                                param_named ambient float4 0.177898 0.917 0.472184 1 
     123                                param_named diffuse float4 0.177898 0.917 0.472184 1                             
    124124                        }                        
    125125                } 
     
    185185                        specular 1 1 1 2 
    186186                        emissive 0 0 0 
    187                                                  
     187                         
     188                        //RenderTechnique DepthShadowReciever 
     189                        //{ 
     190                                 
     191                        //}                      
    188192        //              shading phong 
    189193 
  • GTP/trunk/App/Demos/Illum/Ogre/Media/materials/scripts/kupola.material

    r1094 r1629  
    1111                { 
    1212                         
    13                         RenderTechnique CausticReciever 
     13                        //RenderTechnique CausticReciever 
     14                        //{ 
     15                        //      max_caster_count        10 
     16                        //} 
     17                        RenderTechnique DepthShadowReciever 
    1418                        { 
    15                                 max_caster_count        10 
     19                                 
    1620                        } 
    17                         //RenderTechnique DepthShadowReciever 
    18                         //{ 
    19                                  
    20                         //} 
    2121                } 
    2222                 
     
    6464                        { 
    6565                                 
    66                                 RenderTechnique CausticReciever 
     66                                //RenderTechnique CausticReciever 
     67                                //{ 
     68                                //      max_caster_count        10 
     69                                //} 
     70                                RenderTechnique DepthShadowReciever 
    6771                                { 
    68                                         max_caster_count        10 
     72                                         
    6973                                } 
    70                                 //RenderTechnique DepthShadowReciever 
    71                                 //{ 
    72                                          
    73                                 //} 
    7474                        } 
    7575                         
Note: See TracChangeset for help on using the changeset viewer.