Changeset 2373


Ignore:
Timestamp:
05/14/07 11:03:30 (17 years ago)
Author:
szirmay
Message:
 
Location:
GTP/trunk/App/Demos/Illum/Ogre
Files:
5 added
5 edited

Legend:

Unmodified
Added
Removed
  • GTP/trunk/App/Demos/Illum/Ogre/Media/MORIA/MoriaHallBase.hlsl

    r2368 r2373  
    2626uniform float3 wCamPos; 
    2727 
    28 uniform float4x4 LightView[MAX_LIGHT]; 
    29 uniform float lightFarPlane[MAX_LIGHT]; 
     28uniform float4 wLightPos1; 
     29uniform float4 wLightPos2; 
     30uniform float4 lightRange1; 
     31uniform float4 lightRange2; 
     32uniform float lightPower1; 
     33uniform float lightPower2; 
     34uniform float4 lightColor1; 
     35uniform float4 lightColor2; 
     36                                                 
     37uniform float4x4 LightView1; 
     38uniform float4x4 LightView2; 
     39uniform float lightFarPlane1; 
     40uniform float lightFarPlane2; 
    3041 
    3142uniform float specularity; 
     
    3647        float4 hPos : POSITION; 
    3748        float4 texCoord           : TEXCOORD0; 
    38         float2 bumpTexCoord   : TEXCOORD1; 
     49        float4 texCoord2      : TEXCOORD1; 
    3950        float3 wView              : TEXCOORD2; 
    4051        float3 wTangent           : TEXCOORD3; 
     
    4859                                                                                float2 texCoord1 : TEXCOORD0, 
    4960                                                                                float2 texCoord2 : TEXCOORD1, 
     61                                                                                float2 atlasTex  : TEXCOORD2, 
    5062                                                                                float3 tangent   : TEXCOORD3, 
    5163                                                                                uniform float normalCoord) 
     
    5567        OUT.texCoord = float4(texCoord1.xy, texCoord2.xy);       
    5668        if(normalCoord == 0) 
    57                 OUT.bumpTexCoord = texCoord1; 
     69                OUT.texCoord2.xy = texCoord1; 
    5870        else 
    59                 OUT.bumpTexCoord = texCoord2; 
     71                OUT.texCoord2.xy = texCoord2; 
     72         
     73        OUT.texCoord2.zw = atlasTex; 
    6074                 
    6175        OUT.hPos = mul(WorldViewProj, position); 
     
    7185} 
    7286 
    73 float4 MoriaHallBase_PS(MORIA_HALL_BASE_VSOUT IN, 
    74                                                 uniform float4 wLightPos, 
    75                                                 uniform float4 lightRange, 
    76                                                 uniform float lightPower, 
    77                                                 uniform float4 lightColor):COLOR0 
     87float4 MoriaHallBase_PS(MORIA_HALL_BASE_VSOUT IN):COLOR0 
    7888{        
    7989        float4 Color = 0; 
    80         float3 N = NormalMap(IN.wTangent, IN.wBinormal, IN.wNormal, IN.bumpTexCoord, bumpMap); 
     90        float3 N = NormalMap(IN.wTangent, IN.wBinormal, IN.wNormal, IN.texCoord2.xy, bumpMap); 
    8191        float3 V = normalize(IN.wView); 
    8292        // read textures 
    8393        float4 diffuseColor = tex2D(tileTexture, IN.texCoord.zw) * tex2D(detailTexture, IN.texCoord.xy); 
    84                  
     94         
     95//---------------------------------------------------------------------------------------------------------------- 
     96//light1                 
    8597        //light dir 
    86         float3 L = wLightPos.xyz - IN.wPos * wLightPos.w; 
     98        float3 L = wLightPos1.xyz - IN.wPos * wLightPos1.w; 
    8799        //illumination 
    88100        float4 col; 
    89         col = Illumination(N, L, V, lightColor * lightPower, lightRange, diffuseColor, specularity); 
    90         //shadowing 
    91         float3 lightCPos = mul(LightView[0], float4(IN.wPos, 1)).xyz; 
    92         float shadow = shadowPoint(ShadowMap1Point, lightCPos, lightFarPlane[0]); 
     101        col = Illumination(N, L, V, lightColor1 * lightPower1, lightRange1, diffuseColor, specularity); 
     102        //shadowing      
     103        float3 lightCPos = mul(LightView1, float4(IN.wPos, 1)).xyz; 
     104        float shadow = shadowPoint(ShadowMap1Point, lightCPos, lightFarPlane1); 
     105        Color += col * shadow;   
     106 
     107//---------------------------------------------------------------------------------------------------------------- 
     108//light2                         
     109        //light dir 
     110        L = wLightPos2.xyz - IN.wPos * wLightPos2.w; 
     111        //illumination 
     112        col = Illumination(N, L, V, lightColor2 * lightPower2, lightRange2, diffuseColor, specularity); 
     113        //shadowing      
     114        lightCPos = mul(LightView2, float4(IN.wPos, 1)).xyz; 
     115        shadow = shadowPoint(ShadowMap2Point, lightCPos, lightFarPlane2); 
    93116        Color += col * shadow;   
    94117         
    95118        //do Path Map to gather indirect illumination 
     119         
     120        float4 indirect = PathMapIndirect(PathMap, WeightIndexMap, WeightMap, IN.texCoord2.zw) * 1.2; 
     121        indirect *= diffuseColor; 
     122        Color = Color + indirect; 
     123         
    96124        //gather caustics for all casters 
    97125        //return diffuseColor; 
  • GTP/trunk/App/Demos/Illum/Ogre/Media/MORIA/illum.hlsl

    r2368 r2373  
    5353          return (SHADOW_COLOR + (1 - SHADOW_COLOR) * light); 
    5454} 
     55 
     56uniform float4 prmAtlasTilesHalfPixel; 
     57uniform float allClusterCount;  
     58uniform float clusterCount; 
     59 
     60float4 PathMapIndirect(sampler2D PMTex, sampler2D weightIndexTex, sampler2D weightTex, float2 texAtlas) 
     61{ 
     62        int2 prmAtlasTiles = prmAtlasTilesHalfPixel.xy; 
     63        float2 atlasHalfPixel = prmAtlasTilesHalfPixel.zw; 
     64         
     65        float3 col = 0; 
     66        for(int iCluster = 0; iCluster < 32; iCluster++) 
     67        { 
     68                float2 prmTexPos = float2( 
     69                        (texAtlas.x + (iCluster % prmAtlasTiles.x)) / prmAtlasTiles.x, 
     70                        1.0 - (texAtlas.y + (iCluster / prmAtlasTiles.x)) / prmAtlasTiles.y);// + atlasHalfPixel; 
     71 
     72                float weightIndex = tex2D(weightIndexTex, float2(((float)iCluster + 0.5) / clusterCount, 0.5)).r; 
     73                float3 weight = tex2D(weightTex, float2((weightIndex + 0.5)/allClusterCount, 0.5)).rgb; 
     74                float3 val = tex2D(PMTex, prmTexPos).xyz; 
     75                if(length(val - float3(1,1,1))== 0) 
     76                val = 0; 
     77                col += val.xyz * weight;                 
     78        } 
     79         
     80        return float4(col,1); 
     81} 
  • GTP/trunk/App/Demos/Illum/Ogre/Media/MORIA/moria.material

    r2368 r2373  
    2121                        IllumTechniques 
    2222                        { 
    23                                 //RenderTechnique PathMap 
    24                                 //{ 
    25                             //  new_passes false 
    26                                 //      start_tex_id 3 
    27                                 //}      
     23                                RenderTechnique PathMap 
     24                                { 
     25                                new_passes false 
     26                                        start_tex_id 3 
     27                                }        
    2828                                RenderTechnique DepthShadowReceiver 
    2929                                { 
    30                                         max_light_count 1 
     30                                        max_light_count 2 
    3131                                        set_light_viewproj false 
    3232                                        set_light_view true 
     
    4848                        fragment_program_ref GTP/MoriaDemo/MoriaHallBase_PS 
    4949                        {  
    50                           param_named_auto wLightPos light_position 0 
    51                           //param_named_auto wLightPos light_position 1                            
    52                           param_named_auto lightRange light_attenuation 0 
    53                           //param_named_auto lightRange[1] light_attenuation 1 
    54                           param_named_auto lightPower light_power 0 
    55                           //param_named_auto lightPower[1] light_power 1 
    56                           param_named_auto lightColor light_diffuse_colour 0 
    57                           //param_named_auto lightColor[1] light_diffuse_colour 1 
     50                          param_named_auto wLightPos1 light_position 0 
     51                          param_named_auto wLightPos2 light_position 1                             
     52                          param_named_auto lightRange1 light_attenuation 0 
     53                          param_named_auto lightRange2 light_attenuation 1 
     54                          param_named_auto lightPower1 light_power 0 
     55                          param_named_auto lightPower2 light_power 1 
     56                          param_named_auto lightColor1 light_diffuse_colour 0 
     57                          param_named_auto lightColor2 light_diffuse_colour 1 
    5858                          param_named specularity float 120 
    5959                        } 
  • GTP/trunk/App/Demos/Illum/Ogre/Media/materials/programs/GameTools_Blur.hlsl

    r2368 r2373  
    2424                        uniform float height ) : COLOR 
    2525 
    26  
     26/* 
    2727  float2 pixel = float2(1.0 / width, 1.0 / height); 
    2828  float2 uv = IN.Position + pixel * 0.5; 
     
    3535 
    3636  sum /= samplesU * samplesV; 
    37  
    38   return sum; 
    39   return tex2D(Texture, uv); 
     37*/ 
     38  float du = 2.0 / width; 
     39  float dv = 2.0 / height; 
     40  float2 uv = IN.Position; 
     41  float4 sum = float4(0,0,0,0);   
     42  sum += tex2D(Texture,uv); 
     43  sum += tex2D(Texture,uv + float2(du,0)); 
     44  sum += tex2D(Texture,uv + float2(du,dv)); 
     45  sum += tex2D(Texture,uv + float2(0,dv)); 
     46  return sum / 4.0; 
    4047} 
    4148 
  • GTP/trunk/App/Demos/Illum/Ogre/src/Moria/include/Moria.h

    r2367 r2373  
    182182                mainLightNode = rootNode->createChildSceneNode(); 
    183183                 
    184                 mainLightNode->setPosition(15,10,15);            
     184                mainLightNode->setPosition(15,5,15);             
    185185                mainLight->setPowerScale(30); 
    186186                //mainLight->setDirection(1,0, 0); 
     
    189189                mainLight->setAttenuation(40.0, 0, 4, 0); 
    190190 
     191                Light* blueLight = mSceneMgr->createLight("blueLight"); 
     192                blueLight->setType(Light::LT_POINT); 
     193                blueLight->setCastShadows(true); 
     194                blueLight->setDiffuseColour(ColourValue(0.45,0.75,0.8)); 
     195                blueLight->setPowerScale(30); 
     196                blueLight->setAttenuation(40.0, 0, 4, 0); 
     197                SceneNode* blueLightNode = rootNode->createChildSceneNode(); 
     198                blueLightNode->setPosition(15,10,15); 
     199                blueLightNode->attachObject(blueLight); 
     200                 
    191201                Vector4 v = mainLight->getAs4DVector(); 
    192202 
     
    240250                mRoot->addFrameListener(mFrameListener); 
    241251                OgreIlluminationManager::getSingleton().setPriority(3); 
    242                 mRoot->addFrameListener(&OgreIlluminationManager::getSingleton()); 
     252           mRoot->addFrameListener(&OgreIlluminationManager::getSingleton()); 
    243253    } 
    244254 
Note: See TracChangeset for help on using the changeset viewer.