Difference between revisions of "TEST-STRCMP4CODES"

From SimsWiki
Jump to: navigation, search
(nei4)
(pool5)
Line 1: Line 1:
OutputVertex VertexMain( InputVertex inputVertex)
+
shaderProgram -target pixelProgram -method compile -version 2_0             
{
+
        shaderSource                           
// Do Y-direction waves
+
            sampler reflect;
// r0 = (x, y, z, t)
+
            sampler bump;         
OutputVertex outputVertex;
+
            struct cInputPixel
float4 posAndTime;
+
            {             
posAndTime.xyz = inputVertex.position;
+
              float4 sPos        : TEXCOORD0;              
posAndTime.w = frameInfo.w;
+
              float2 Wave0        : TEXCOORD1;
float temp = dot(posAndTime, waveDataX);
+
              float2 Wave1        : TEXCOORD2;
float z = sin(temp) * waveDataX.z + inputVertex.position.z;
+
              float2 Wave2        : TEXCOORD3;
temp = dot(posAndTime, waveDataY);
+
              float2 Wave3        : TEXCOORD4;
posAndTime.z =  z + sin(temp) * waveDataY.z ;//-0.1f; //The -.01 is a fudge factor to remove some of the edge creep associated with moving the height of the wave. -tom
+
              float3 Eye          : TEXCOORD5;
posAndTime.w = 1.0f;
+
              float4 specular    : COLOR0;
outputVertex.clipPosition = mul( posAndTime, clipSpaceMatrix);
+
            };
outputVertex.sPos = float4(0.5f*(outputVertex.clipPosition.ww - outputVertex.clipPosition.xy), outputVertex.clipPosition.ww);
+
           
float3 waveNormal = normalize(inputVertex.normal + float3(cos(temp)*waveDataHelper.xy, 0));
+
            float Fresnel(float NdotL, float fresnelBias, float fresnelPow, float facing)
float3 cameraSpaceNormal = normalize(mul(waveNormal, cameraSpaceMatrix));
+
            {             
float3 cameraSpacePosition = mul( posAndTime, cameraSpaceMatrix);
+
              return max(fresnelBias + (1.0f - fresnelBias)*pow(facing, fresnelPow), 0.0);
float3 viewVector = normalize(-cameraSpacePosition);
+
            }
float3 halfVector = normalize(viewVector + lightDirection);
+
           
outputVertex.specular = lightSpecular*pow(dot(cameraSpaceNormal, halfVector), 50)*nightColor*lightColor*0.5;
+
            float4 PixelMain(cInputPixel pi) : COLOR
float2 fTranslation=float2(fmod(frameInfo.w, 100)*0.005, fmod(frameInfo.w, 100)*0.005);
+
            {       
float2 vTexCoords = posAndTime.xy*0.05;
+
              float3 vEye = normalize(pi.Eye);
// Output bump layers texture coordinates   
+
 
float fSinTranslation=sin(fTranslation*100)*0.005;
+
              // Get bump layers
float2 vTranslation0=fTranslation+fSinTranslation;
+
              float3 vBumpTexA = tex2D(bump, pi.Wave0.xy).xyz;
float2 vTranslation1=fTranslation-fSinTranslation;
+
              float3 vBumpTexB = tex2D(bump, pi.Wave1.xy).xyz;
float2 vTranslation2=fTranslation;
+
              float3 vBumpTexC = tex2D(bump, pi.Wave2.xy).xyz;
// Scale texture coordinates to get mix of low/high frequency details
+
              float3 vBumpTexD = tex2D(bump, pi.Wave3.xy).xyz;
outputVertex.Wave0.xy = vTexCoords.xy*0.01+fTranslation*2.0;
+
               
outputVertex.Wave1.xy = vTexCoords.xy+fTranslation*2.5;
+
              // Average bump layers
outputVertex.Wave2.xy = vTexCoords.xy+fTranslation*-2.3;
+
              float3 vBumpTex=normalize(2.0 * (vBumpTexA.xyz + vBumpTexB.xyz + vBumpTexC.xyz + vBumpTexD.xyz)-4.0);
outputVertex.Wave3.xy = vTexCoords.xy*0.1+fTranslation*1.5;              
+
               
                                   
+
              // Apply individual bump scale for refraction and reflection             
// compute binormal
+
              float3 vReflBump = vBumpTex.xyz * float3(0.1, 0.1, 1.0);
float3 binormal = normalize(cross(waveNormal, float3(1.0f, 0.0f, 0.0f)));            
+
             
float3 tangent = normalize(cross(binormal, waveNormal));
+
              float4 vReflection = tex2Dproj(reflect, pi.sPos + float4(vReflBump.xy, 0.0f, 0.0f));//*0.001 + float4(2.0*vBumpTexD-1.0f.xxx, 1);
// tangent space matrix
+
             
float3x3 objToTangentSpace = float3x3(tangent, binormal, waveNormal);
+
              // Compute Fresnel term
float3 viewVectorInObjSpace = mul(viewVector, (float3x3)cameraToGeomMatrix);
+
              float NdotL = max(dot(vEye, vReflBump), 0);
outputVertex.Eye.xyz = mul(objToTangentSpace, viewVectorInObjSpace);
+
              float facing = (1.0 - NdotL);
outputVertex.colorTint = waterTint;
+
              float fresnel = Fresnel(NdotL, 0.2, 5.0, facing);
outputVertex.colorTint.a = inputVertex.alpha.xxxx;
+
                             
// outputVertex.color = waterTint.xxxx;
+
              vReflection.a = fresnel;              
return(outputVertex);
+
              return saturate(vReflection + float4(0.0, 0.25, 0.5, 0.0) + pi.specular);
}
+
            }
endShaderSource
+
        endShaderSource
end # shaderProgram
+
      end                                                   
 +
     
 +
      sampler reflect
 +
        texture "PoolReflection"
 +
        textureAddressing clamp clamp
 +
      end
 +
     
 +
      sampler bump
 +
        texture "poolShape-body-bump"
 +
        textureAddressing tile tile
 +
      end 
 +
           
 +
end # end pass
 +
 
 +
enddef

Revision as of 01:28, 16 June 2009

shaderProgram -target pixelProgram -method compile -version 2_0

        shaderSource                            
           sampler reflect;  
           sampler bump;          
           struct cInputPixel
           {               
              float4 sPos         : TEXCOORD0;               
              float2 Wave0        : TEXCOORD1;
              float2 Wave1        : TEXCOORD2;
              float2 Wave2        : TEXCOORD3;
              float2 Wave3        : TEXCOORD4;
              float3 Eye          : TEXCOORD5;
              float4 specular     : COLOR0;
           };
           
           float Fresnel(float NdotL, float fresnelBias, float fresnelPow, float facing)
           {               
              return max(fresnelBias + (1.0f - fresnelBias)*pow(facing, fresnelPow), 0.0);
           }
           
           float4 PixelMain(cInputPixel pi) : COLOR
           {         
              float3 vEye = normalize(pi.Eye);
              // Get bump layers
              float3 vBumpTexA = tex2D(bump, pi.Wave0.xy).xyz;
              float3 vBumpTexB = tex2D(bump, pi.Wave1.xy).xyz;
              float3 vBumpTexC = tex2D(bump, pi.Wave2.xy).xyz;
              float3 vBumpTexD = tex2D(bump, pi.Wave3.xy).xyz;
                
              // Average bump layers
              float3 vBumpTex=normalize(2.0 * (vBumpTexA.xyz + vBumpTexB.xyz + vBumpTexC.xyz + vBumpTexD.xyz)-4.0);
                
              // Apply individual bump scale for refraction and reflection               
              float3 vReflBump = vBumpTex.xyz * float3(0.1, 0.1, 1.0);  
              
              float4 vReflection = tex2Dproj(reflect, pi.sPos + float4(vReflBump.xy, 0.0f, 0.0f));//*0.001 + float4(2.0*vBumpTexD-1.0f.xxx, 1);
              
              // Compute Fresnel term
              float NdotL = max(dot(vEye, vReflBump), 0);
              float facing = (1.0 - NdotL);
              float fresnel = Fresnel(NdotL, 0.2, 5.0, facing);
                             
              vReflection.a = fresnel;               
              return saturate(vReflection + float4(0.0, 0.25, 0.5, 0.0) + pi.specular);
           }
        endShaderSource
     end                                                     
     
     sampler reflect
        texture "PoolReflection"
        textureAddressing clamp clamp
     end		
     
     sampler bump
        texture "poolShape-body-bump"
        textureAddressing tile tile
     end   
           

end # end pass

enddef

Personal tools
Namespaces

Variants
Actions
Navigation
game select
Toolbox