Ignore:
Timestamp:
03/07/07 17:37:10 (17 years ago)
Author:
szirmay
Message:
 
File:
1 edited

Legend:

Unmodified
Added
Removed
  • GTP/trunk/App/Demos/Illum/Ogre/Media/PMDemo/PathMapWeightCompute.hlsl

    r2188 r2202  
    33 
    44uniform int nRadionColumns; 
    5 uniform sampler2D radionSampler : register(s0); 
     5uniform sampler2D radionSampler       : register(s0); 
     6uniform sampler2D entryPointCountSampler : register(s1); 
     7uniform sampler2D allWeightsSampler   : register(s2); 
    68uniform float3 lightPos; 
    79uniform float3 lightDir; 
     10uniform float clusterCount; 
    811 
    912struct vsInputComputeWeights 
     
    4346                dist2 = SAMPLECUTDIST2; 
    4447        diff = normalize(diff); 
    45         float cosa = - dot(lightDir, diff); 
    46         float cosb = dot(dir, diff);     
     48        float cosa = max(dot(lightDir, -diff), 0); 
     49        float cosb = max(dot(dir, diff), 0);     
    4750         
    4851        /* 
     
    5760        float visibility = 1; 
    5861         
    59         float ret; 
    60         if(  visibility < 0.5 || cosa < 0 || cosb < 0) 
    61                 ret = 0.0; 
     62        float4 ret = cosa * cosb; 
     63 
     64        //return float4(lightDir + ret.x * 0.00000000001, 1); 
     65        return ret; 
     66        //return ret.x*0.0000000001 + 0.5; 
     67} 
     68 
     69float4 psSumWeights(vsOutputComputeWeights input) : COLOR0 
     70{ 
     71        float halfPixel = 0.5 / clusterCount; 
     72        float iCluster = input.tex.x + halfPixel; 
     73        int entryPointCount = tex2D(entryPointCountSampler, float2(iCluster, 0.25)); 
     74        int currentEntryPoint = tex2D(entryPointCountSampler, float2(iCluster, 0.75)); 
     75        //sum entrypoint weights 
     76        float weight = 0; 
     77        float clusterRad = 0; 
     78        for(int i = 0; i < entryPointCount; i++) 
     79        { 
     80                float hp = float2(0.5 / (float) nRadionColumns, 0.5 / 4096.0); 
     81                float2 coord1 = float2((float)(currentEntryPoint % nRadionColumns)  / (float) nRadionColumns, 
     82                                                                currentEntryPoint / (float) nRadionColumns / 4096.0) + hp; 
     83                coord1.y = 1.0 - coord1.y; 
     84                float2 coord2 = coord1 + float2(hp.x / 2.0, 0); 
     85                float radrad = tex2Dlod(radionSampler, float4(coord2, 0, 0)).a; 
     86                //weight += tex2Dlod(allWeightsSampler, float4(coord1, 0, 0)).r * radrad; 
     87                weight += tex2Dlod(allWeightsSampler, float4(coord1, 0, 0)).r; 
     88                //clusterRad += radrad; 
     89                currentEntryPoint++; 
     90        }        
     91        /* 
     92        if(clusterRad >= 0) 
     93                weight /= clusterRad; 
    6294        else 
    63                 ret = pow(cosa, 9) * cosb / dist2; 
    64  
    65         if(ret < 0.000001) 
    66                 ret = 0.0; 
     95                weight = 0;*/ 
    6796         
    68                 return 1 + ret * 0.0000000001; 
    69         return float4(ret, ret, ret, ret); 
     97    weight /= (float) entryPointCount; 
     98                 
     99        return weight; 
    70100} 
Note: See TracChangeset for help on using the changeset viewer.