Changeset 2217


Ignore:
Timestamp:
03/09/07 10:31:48 (17 years ago)
Author:
szirmay
Message:
 
Location:
GTP/trunk/App/Demos/Illum/Ogre/Media
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • GTP/trunk/App/Demos/Illum/Ogre/Media/PMDemo/PRMDemo.material

    r2207 r2217  
    1111   entry_point psWalk 
    1212   target ps_3_0 
    13    flow_control avoid 
     13   flow_control prefer 
    1414} 
    1515 
     
    2222        IllumTechniques 
    2323        { 
    24                 RenderTechnique PathMap 
     24                RenderTechnique DepthShadowReciever 
    2525                { 
     26                max_light_count 2 
     27                        vertex_program_name GTP/Basic/LightCPos_VS 
     28                        fragment_program_name GTP/Basic/SM/Dist_VSM_PS 
     29                        set_light_view true 
     30                        set_light_farplane true 
     31                        light_viewproj_param_name LightViewProj 
     32                        light_view_param_name LightView 
     33                        light_farplane_param_name lightFarPlane 
     34                        world_view_proj_param_name WorldViewProj 
     35                        world_param_name World 
     36                } 
     37                RenderTechnique PathMap 
     38                { 
    2639             
    2740                } 
     
    3043        { 
    3144     colour_op replace 
    32     } 
    33    } 
    34     
     45    }     
     46   }    
    3547 } 
    3648} 
     
    119131   source PathMapWeightCompute.hlsl 
    120132   entry_point psComputeWeights 
    121    target ps_2_0    
     133   target ps_3_0    
    122134} 
    123135 
     
    141153                                filtering off 
    142154                        } 
     155                        texture_unit shadow_map //stores distances 
     156                        { 
     157                         
     158                } 
    143159                } 
    144160                 
     
    173189                        texture_unit //entrypoint texture 
    174190                        { 
    175                                 filtering off 
     191                                filtering none 
    176192                        } 
    177193                        texture_unit //entrypoint weight texture 
    178194                        { 
    179                                 filtering off 
     195                                filtering none 
    180196                        } 
    181197                        texture_unit //cluster length 
    182198                        { 
    183                                 filtering off 
     199                                filtering none 
    184200                        } 
    185201                } 
  • GTP/trunk/App/Demos/Illum/Ogre/Media/PMDemo/PathMap.hlsl

    r2213 r2217  
    22uniform float4 prmAtlasTilesHalfPixel; 
    33uniform sampler2D filteredAtlasSampler : register(s0); 
    4 uniform sampler1D clusterWeightIndexSampler : register(s1); 
     4uniform sampler2D clusterWeightIndexSampler : register(s1); 
    55uniform sampler2D clusterWeightSampler : register(s2); 
    66uniform float allClusterCount;  
    7 uniform float clusterCount; //clustercount / 4 
    8 //uniform float weights[32]; 
     7uniform float clusterCount; 
    98 
    109struct vsInputWalk 
     
    3837         
    3938        float3 col = 0; 
    40         for(int iCluster=0; iCluster<16; iCluster++) 
     39        for(int iCluster = 0; iCluster < 32; iCluster++) 
    4140        { 
    4241                float2 prmTexPos = float2( 
     
    4443                        1.0 - (input.texAtlas.y + (iCluster / prmAtlasTiles.x)) / prmAtlasTiles.y) + atlasHalfPixel; 
    4544 
    46                 //float4 weight = 0.065; 
    47                 //weight = float4(weights[iCluster/4], weights[iCluster/4 + 1],weights[iCluster/4 + 2], weights[iCluster/4 + 3]); 
    48                 //float4 weight = weights[iCluster/4]; 
    49                 float4 weightIndex = tex1D(clusterWeightIndexSampler, ((float)iCluster/4) / clusterCount).r / allClusterCount; 
    50                 float weight1 = tex2D(clusterWeightSampler, float2(weightIndex.r, 0.5)).r; 
    51                 float weight2 = tex2D(clusterWeightSampler, float2(weightIndex.g, 0.5)).r; 
    52                 float weight3 = tex2D(clusterWeightSampler, float2(weightIndex.b, 0.5)).r; 
    53                 float weight4 = tex2D(clusterWeightSampler, float2(weightIndex.a, 0.5)).r; 
    54                 float4 weight = float4(weight1, weight2, weight3, weight4); 
    55                  
    56                 float3 val = tex2D(filteredAtlasSampler, prmTexPos); 
    57                 col += val.xyz * weight.x; 
    58                 iCluster++; 
    59                  
    60                 prmTexPos.x += 1.0 / prmAtlasTiles.x; 
    61                 val = tex2D(filteredAtlasSampler, prmTexPos); 
    62                 col += val.xyz * weight.y; 
    63                 iCluster++; 
    64                  
    65                 prmTexPos.x += 1.0 / prmAtlasTiles.x; 
    66                 val = tex2D(filteredAtlasSampler, prmTexPos); 
    67                 col += val.xyz * weight.z; 
    68                 iCluster++; 
    69                  
    70                 prmTexPos.x += 1.0 / prmAtlasTiles.x; 
    71                 val = tex2D(filteredAtlasSampler, prmTexPos); 
    72                 col += val.xyz * weight.w; 
     45                float weightIndex = tex2D(clusterWeightIndexSampler, float2(((float)iCluster + 0.5) / clusterCount, 0.5)).r; 
     46                float weight = tex2D(clusterWeightSampler, float2((weightIndex + 0.5)/allClusterCount, 0.5)).r; 
     47                //weight = 0.0002 + 0.000000000001 * weight; 
     48                float3 val = tex2D(filteredAtlasSampler, prmTexPos).xyz; 
     49                col += val.xyz * weight;                 
    7350        } 
    7451         
    75         //return col.xxxx *0.00001 + tex2D(filteredAtlasSampler, float2(input.texAtlas.x /32.0f, 1.0 - input.texAtlas.y)); 
    76 //return float4(1,0,0,1)+col.xxxx*0.0000000001; 
    77 //return prmAtlasTilesHalfPixel.x*allClusterCount*clusterCount*0.000000000001 + tex2D(filteredAtlasSampler, float2(input.texAtlas.x /32.0f, 1.0 - input.texAtlas.y)).r; 
    78         return float4(col * 200, 1); 
     52        return float4(col * 300, 1); 
    7953} 
    8054 
  • GTP/trunk/App/Demos/Illum/Ogre/Media/PMDemo/PathMapWeightCompute.hlsl

    r2213 r2217  
    11#define SAMPLECUTDIST2 0.01 
    2 #define WEIGHTCUTOFF 0.01 
     2#define WEIGHTCUTOFF   0.01 
     3#define DIST_BIAS      0.005 
    34 
    45uniform int nRadionColumns; 
    5 uniform sampler2D radionSampler       : register(s0); 
    6 uniform sampler2D entryPointCountSampler : register(s1); 
    7 uniform sampler2D allWeightsSampler   : register(s2); 
    86uniform float3 lightPos; 
    97uniform float3 lightDir; 
    108uniform float clusterCount; 
     9uniform float4x4 lightViewProj; 
     10uniform float lightFarPlane; 
    1111 
    1212struct vsInputComputeWeights 
     
    2828    output.pos = input.pos; 
    2929    output.tex = (input.pos + 1.0) / 2.0; 
     30    //output.tex = input.tex; 
    3031    output.tex.y = 1.0 - output.tex.y; 
     32    
    3133    return output; 
    3234} 
    3335 
    34 float4 psComputeWeights(vsOutputComputeWeights input) : COLOR0 
     36float4 psComputeWeights(vsOutputComputeWeights input, 
     37                                                uniform sampler2D radionSampler : register(s0), 
     38                                                uniform sampler2D shadowMap : register(s1)) : COLOR0 
    3539{ 
    3640        float dataColumnWidth = 1.0 / (float)nRadionColumns; 
     
    4953        float cosb = max(dot(dir, diff), 0);     
    5054         
    51         /* 
    52         float4 occProjPos = mul(float4(pos, 1), occWorldToProjMatrix);   
    53         occProjPos /= occProjPos.w; 
    54         float2 occTexPos = mul( occProjPos.xyw, occProjToTexMatrix); 
    55         float visibility = tex2Dproj(depthMapSampler, float4(occTexPos, occProjPos.z - 0.1, 1) ); 
     55         
     56        float4 lightVPos = mul(lightViewProj, float4(pos,1)); 
     57        float dist = sqrt(dist2) / lightFarPlane; 
     58        lightVPos /= lightVPos.w; 
     59        lightVPos.xy = (lightVPos.xy + 1.0) / 2.0; 
     60        lightVPos.y = 1.0 - lightVPos.y; 
     61        float storedDist = tex2D(shadowMap, lightVPos.xy).r; 
     62        dist -= DIST_BIAS; 
     63        float visibility = (dist <= storedDist);         
    5664 
    57         float3 lightToPos = pos - lightPos; 
    58         float actualDepth = length(lightToPos); 
    59 */ 
    60         float visibility = 1; 
     65        //float visibility = 1; 
     66        //visibility = visibility * 0.00001 + 1.0; 
    6167         
    62         float4 ret = pow(cosa, 9) * cosb / dist2; 
    63  
    64         //float ize = 0; 
    65         //if(pos.y > 0) ize = 1; 
    66         //return float4(lightDir + ret.x * 0.00000000001, 1); 
    67         //return ret; 
     68        float4 ret = visibility * pow(cosa, 9) * cosb / dist2; 
    6869        return ret; 
    6970} 
    7071 
    71 float4 psSumWeights(vsOutputComputeWeights input) : COLOR0 
     72float4 psSumWeights(vsOutputComputeWeights input, 
     73                                        uniform sampler2D radionSampler       : register(s0), 
     74                                        uniform sampler2D entryPointCountSampler : register(s1), 
     75                                        uniform sampler2D allWeightsSampler   : register(s2)) : COLOR0 
    7276{ 
    7377        float halfPixel = 0.5 / clusterCount; 
     
    8084        for(int i = 0; i < entryPointCount; i++) 
    8185        { 
    82                 float hp = float2(0.5 / (float) nRadionColumns, 0.5 / 4096.0); 
    83                 float2 coord1 = float2((float)(currentEntryPoint % nRadionColumns)  / (float) nRadionColumns, 
    84                                                                 currentEntryPoint / (float) nRadionColumns / 4096.0) + hp; 
    85                 float2 coord2 = coord1 + float2(hp.x / 2.0, 0); 
    86                 float radrad = tex2Dlod(radionSampler, float4(coord2, 0, 0)).a; 
    87                 //weight += tex2Dlod(allWeightsSampler, float4(coord1, 0, 0)).r * radrad; 
    88                 weight += tex2Dlod(allWeightsSampler, float4(coord1, 0, 0)).r; 
     86                 
     87                float dataColumnWidth = 1.0 / (float)nRadionColumns; 
     88                int werx = currentEntryPoint % nRadionColumns; 
     89                int wery = currentEntryPoint / nRadionColumns; 
     90                float2 coord1 = float2((werx + 0.5) * dataColumnWidth, (wery  + 0.5) / 4096.0); 
     91                float2 coord2 = coord1 + float2(0.25 * dataColumnWidth, 0); 
     92                float w = tex2Dlod(allWeightsSampler, float4(coord1, 0, 0)).r; 
     93                float radrad = tex2Dlod(radionSampler, float4(coord1, 0, 0)).a;          
     94                weight += w * radrad;            
    8995                clusterRad += radrad; 
    9096                currentEntryPoint++; 
    9197        }        
    9298         
    93         /*if(clusterRad >= 0) 
     99        if(clusterRad >= 0) 
    94100                weight /= clusterRad; 
    95101        else 
    96                 weight = 0;*/ 
    97                          
    98     weight /= (float) entryPointCount; 
    99                  
     102                weight = 0; 
     103    
    100104        return weight; 
    101105} 
  • GTP/trunk/App/Demos/Illum/Ogre/Media/materials/GTPBasic/GTPShadowMap_PS.hlsl

    r2186 r2217  
    1515#define DEPTH_BIAS_VSM  0.001 
    1616#define DEPTH_EPSILON   0.00005 
    17 #define DIST_BIAS       0.1 
    18 #define DIST_BIAS_VSM   0.001 
     17#define DIST_BIAS       0.005 
     18#define DIST_BIAS_VSM   0.005 
    1919#define DIST_EPSILON    0.001 
    2020 
    21 #define shadowColor float4(0.2,0.2,0.2,1) 
     21#define shadowColor float4(0.5,0.5,0.5,1) 
    2222 
    2323float4 shadowMapDepth(LightVPos_OUT IN, 
     
    7878  {      
    7979    float4 pos = (IN.LightVPos / IN.LightVPos.w); 
    80         //float d = length(pos.xy); 
    81     //light = saturate((1.0 - d)/0.05);          
    82     //if(d <= 1.0) 
    83     //{ 
     80        float d = length(pos.xy); 
     81    light = saturate((1.0 - d)/0.05);            
     82    if(d <= 1.0) 
     83    { 
    8484                float dist = length(IN.LightCPos.xyz) / lightFarPlane; 
    8585                pos.xy = (pos.xy + 1.0) / 2.0; 
     
    8888                dist -= DIST_BIAS; 
    8989                light = max(dist <= storedDist.r, shadowColor);          
    90     //} 
     90    } 
    9191  } 
    9292         
Note: See TracChangeset for help on using the changeset viewer.