Difference between revisions of "TEST-STRCMP4CODES"

From SimsWiki
Jump to: navigation, search
Line 1: Line 1:
pass -clipAlways -modifiedEachFrameHint
+
  material     
#fillmode wireframe
+
     
alphaBlend srcFactor(srcAlpha) add dstFactor(invSrcAlpha)
+
      create DetermineHardwareSupport()
       seti textureLights (numLightsOfType(environmentCube)
+
        
       depthTest true -enableDepthWrite false          
+
      if ($causticsEnabled and $useFixedFunctionPath = false and $useSWVertexShaderPath = false)
 
+
        
shaderProgram -target vertexProgram -method compile -version 1_1
+
         shader -layer +9999
  
bindConstants 0 -bindingID geomToClip -constantCount 4
+
            pass             
bindConstants 4 -bindingID geomToCamera -constantCount 3
+
              renderClipSpaceRect
 +
              renderTarget causticsTile -fixed (64, 64) -allocateDepthBuffer false -undo
 +
              create TiledTextureAnimShaderProgramEP3(8 4 1)
 +
             
 +
              alphaBlend srcFactor(one) add dstFactor(zero)
 +
              alphaTest false 0
 +
              alphaTestFunction acceptIfGreater
  
bindConstants 7 -bindingID frameInfo
+
              depthTest false -enableDepthWrite false
 +
              depthTestFunction accept
  
bindConstants 11 -bindingID immediateData -data ($wmXRepeat, 0, $wmXWaveHeight, $wmXSpeed)
+
                stencil false
bindConstants 12 -bindingID immediateData -data (0, $wmYRepeat, $wmYWaveHeight, $wmYSpeed)
+
  
# pre-evaluate these
+
              fillmode $stdMatFillMode                           
setf xscale (-$wmXRepeat * $wmXWaveHeight)
+
setf yscale (-$wmYRepeat * $wmYWaveHeight)
+
bindConstants 13 -bindingID immediateData -data ($xscale,$yscale, 1,0)
+
bindConstants 14 -bindingID allStandardLightData -constantCount 4 -constantType float
+
bindConstants 18 -bindingID cameraToGlobal -constantCount 3
+
bindConstants 21 -bindingID cameraToGeom -constantCount 3
+
       
+
        if (tsIsDay)       
+
            bindConstants 25 -bindingID immediateData -data (0.75, 0.75, 0.75, 1)       
+
        else
+
            bindConstants 25 -bindingID immediateData -data (0.2, 0.2, 0.2, 1)       
+
        endif
+
 
+
shaderSource
+
 
+
float4 frameInfo : register(c7);
+
float4 waveDataX : register(c11);
+
float4 waveDataY : register(c12);
+
float4 waveDataHelper : register(c13);
+
float4x4 clipSpaceMatrix : register(c0);
+
float4x3 cameraSpaceMatrix : register(c4);
+
float4x3 cameraToGlobalMatrix : register(c18);
+
float4x3 cameraToGeomMatrix : register(c21);
+
+
+
            float4 nightColor: register(c25);
+
           
+
float4 lightDirection : register(c14);
+
float4 lightColor : register(c15);
+
float4 lightSpecular : register(c16);
+
const static float4 refractionWeights={1,1,2,0};
+
+
const static float4 layerBlue={0.3, 0.7, 1.0, 1};
+
+
struct InputVertex
+
{
+
float3 position: POSITION0;
+
float3 normal : NORMAL0;
+
};
+
+
struct OutputVertex
+
{
+
float4 clipPosition : POSITION;
+
float4 sPos        : TEXCOORD0;
+
float2 Wave0        : TEXCOORD1;
+
              float2 Wave1        : TEXCOORD2;
+
              float2 Wave2        : TEXCOORD3;
+
              float2 Wave3        : TEXCOORD4;
+
              float3 Eye          : TEXCOORD5;
+
              float4 specular    : COLOR0;   
+
};
+
           
+
+
+
OutputVertex VertexMain( InputVertex inputVertex)
+
{
+
// Do Y-direction waves
+
// r0 = (x, y, z, t)
+
+
OutputVertex outputVertex;
+
+
float4 posAndTime;
+
posAndTime.xyz = inputVertex.position;
+
posAndTime.w = frameInfo.w;
+
+
float temp = dot(posAndTime, waveDataX);
+
float z = sin(temp) * waveDataX.z + inputVertex.position.z;
+
temp = dot(posAndTime, waveDataY);
+
posAndTime.z =  z + sin(temp) * waveDataY.z;
+
posAndTime.w = 1.0f;
+
+
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));
+
        float3 cameraSpaceNormal = normalize(mul(waveNormal, cameraSpaceMatrix));
+
float3 cameraSpacePosition = mul( posAndTime, cameraSpaceMatrix);
+
float3 viewVector = normalize(-cameraSpacePosition);
+
+
float3 halfVector = normalize(viewVector + lightDirection);
+
outputVertex.specular = lightSpecular*pow(dot(cameraSpaceNormal, halfVector), 50)*nightColor*lightColor*0.5;
+
+
+
float2 fTranslation=float2(fmod(frameInfo.w, 100)*0.005, fmod(frameInfo.w, 100)*0.005);
+
              float2 vTexCoords = posAndTime.xy*0.05;
+
               
+
              // Output bump layers texture coordinates   
+
              float fSinTranslation=sin(fTranslation*100)*0.005;
+
              float2 vTranslation0=fTranslation+fSinTranslation;
+
              float2 vTranslation1=fTranslation-fSinTranslation;
+
              float2 vTranslation2=fTranslation;
+
               
+
              // Scale texture coordinates to get mix of low/high frequency details
+
              outputVertex.Wave0.xy = vTexCoords.xy+fTranslation*2.0;
+
              outputVertex.Wave1.xy = vTexCoords.xy*2.0+fTranslation*4.0;
+
              outputVertex.Wave2.xy = vTexCoords.xy*7.0+fTranslation*2.0;
+
              outputVertex.Wave3.xy = vTexCoords.xy*12.0+fTranslation;               
+
                                   
+
            // compute binormal
+
            float3 binormal = normalize(cross(waveNormal, float3(1.0f, 0.0f, 0.0f)));            
+
            float3 tangent = normalize(cross(binormal, waveNormal));
+
           
+
            // tangent space matrix
+
            float3x3 objToTangentSpace = float3x3(tangent, binormal, waveNormal);
+
           
+
            float3 viewVectorInObjSpace = mul(viewVector, (float3x3)cameraToGeomMatrix);
+
           
+
            outputVertex.Eye.xyz = mul(objToTangentSpace, viewVectorInObjSpace);
+
+
+
return(outputVertex);
+
}
+
 
+
 
+
endShaderSource 
+
end # shaderProgram
+
+
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);
+
               shaderProgram -target pixelProgram -method compile -version 1_1             
 +
                  shaderSource                           
 +
                    sampler caustics;
 +
                    struct cInputPixel
 +
                    {
 +
                        float4 color : COLOR;
 +
                        float2 tc0 : TEXCOORD0;
 +
                    };
 +
                    float4 PixelMain(cInputPixel pi) : COLOR
 +
                    {       
 +
                        float4 texColor = tex2D(caustics, pi.tc0);                                              
 +
                        return texColor*pi.color;                      
 +
                    }
 +
                  endShaderSource
 +
              end                                                   
 
                
 
                
               // Compute Fresnel term
+
               sampler 0
              float NdotL = max(dot(vEye, vReflBump), 0);
+
                  texture causticsTiled
              float facing = (1.0 - NdotL);
+
                  textureAddressing tile tile                 
               float fresnel = Fresnel(NdotL, 0.2, 5.0, facing);
+
               end
 
                                
 
                                
              vReflection.a = fresnel;             
+
             end 
              return saturate(vReflection + float4(0.0, 0.25, 0.5, 0.0) + pi.specular);
+
         end
             }
+
       else
         endShaderSource
+
        shader
      end                                                    
+
          
        
+
         end
      sampler reflect
+
       endif
         texture "PoolReflection"
+
  end
         textureAddressing clamp clamp
+
enddef
      end
+
        
+
setf causticsStrength 0.8
      sampler bump
+
setf causticsBaseStrength 0.5
        texture "poolShape-body-bump"
+
        textureAddressing tile tile
+
      end 
+
           
+
end # end pass
+

Revision as of 21:32, 2 September 2007

  material      
     
     create DetermineHardwareSupport()
     
     if ($causticsEnabled and $useFixedFunctionPath = false and $useSWVertexShaderPath = false)
     
        shader -layer +9999 
           pass              
              renderClipSpaceRect
              renderTarget causticsTile -fixed (64, 64) -allocateDepthBuffer false -undo
              create TiledTextureAnimShaderProgramEP3(8 4 1)
              
              alphaBlend srcFactor(one) add dstFactor(zero)
              alphaTest false 0
              alphaTestFunction acceptIfGreater
              depthTest false -enableDepthWrite false
              depthTestFunction accept
                stencil false
              fillmode $stdMatFillMode                             
              
              shaderProgram -target pixelProgram -method compile -version 1_1               
                 shaderSource                            
                    sampler caustics;
                    struct cInputPixel
                    {
                       float4 color : COLOR;
                       float2 tc0 : TEXCOORD0;
                    };
                    float4 PixelMain(cInputPixel pi) : COLOR
                    {         
                       float4 texColor = tex2D(caustics, pi.tc0);                                                
                       return texColor*pi.color;                        
                    }
                 endShaderSource
              end                                                     
              
              sampler 0
                 texture causticsTiled
                 textureAddressing tile tile                  
              end
                             
           end   
        end
     else
        shader
        
        end
     endif
  end

enddef

setf causticsStrength 0.8 setf causticsBaseStrength 0.5

Personal tools
Namespaces

Variants
Actions
Navigation
game select
Toolbox