Difference between revisions of "TEST-STRCMP4CODES"

From SimsWiki
Jump to: navigation, search
(pool5)
(hlsl)
Line 1: Line 1:
shaderProgram -target pixelProgram -method compile -version 2_0             
+
pass -clipAlways -modifiedEachFrameHint
         shaderSource                           
+
#fillmode wireframe
            sampler reflect; 
+
alphaBlend srcFactor(one) add dstFactor(one)
             sampler bump;          
+
      seti textureLights (numLightsOfType(environmentCube))       
             struct cInputPixel
+
 
            {             
+
shaderProgram -target vertexProgram -method compile -version 1_1
              float4 sPos        : TEXCOORD0;              
+
 
              float2 Wave0        : TEXCOORD1;
+
bindConstants 0 -bindingID geomToClip -constantCount 4
              float2 Wave1        : TEXCOORD2;
+
bindConstants 4 -bindingID geomToCamera -constantCount 3
              float2 Wave2        : TEXCOORD3;
+
 
              float2 Wave3        : TEXCOORD4;
+
bindConstants 7 -bindingID frameInfo
              float3 Eye          : TEXCOORD5;
+
 
              float4 specular    : COLOR0;
+
bindConstants 11 -bindingID immediateData -data ($wmXRepeat, 0, $wmXWaveHeight, $wmXSpeed)
             };
+
bindConstants 12 -bindingID immediateData -data (0, $wmYRepeat, $wmYWaveHeight, $wmYSpeed)
 +
 
 +
# pre-evaluate these
 +
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
 +
          
 +
        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);
 +
 +
             float4 nightColor: register(c25);
 
              
 
              
            float Fresnel(float NdotL, float fresnelBias, float fresnelPow, float facing)
+
float4 lightDirection : register(c14);
            {             
+
float4 lightColor : register(c15);
              return max(fresnelBias + (1.0f - fresnelBias)*pow(facing, fresnelPow), 0.0);
+
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 diffuseColor: COLOR0;
 +
float4 specularColor: COLOR1;
 +
float3 reflection : TEXCOORD0;
 +
 +
};
 
              
 
              
            float4 PixelMain(cInputPixel pi) : COLOR
+
            {        
+
              float3 vEye = normalize(pi.Eye);
+
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);
 +
 +
// z = h * sin(...)
  
              // Get bump layers
+
float z;
              float3 vBumpTexA = tex2D(bump, pi.Wave0.xy).xyz;
+
// scale temp to fit -pi +pi range
              float3 vBumpTexB = tex2D(bump, pi.Wave1.xy).xyz;
+
//temp = temp *  (1 / (2 * 3.14159)) + 0.5;
              float3 vBumpTexC = tex2D(bump, pi.Wave2.xy).xyz;
+
              float3 vBumpTexD = tex2D(bump, pi.Wave3.xy).xyz;
+
float3 waveNormal;
               
+
              // Average bump layers
+
z = sin(temp) * waveDataX.z + inputVertex.position.z;
              float3 vBumpTex=normalize(2.0 * (vBumpTexA.xyz + vBumpTexB.xyz + vBumpTexC.xyz + vBumpTexD.xyz)-4.0);
+
               
+
waveNormal.x = cos(temp) * waveDataHelper.x + inputVertex.normal.x;
              // Apply individual bump scale for refraction and reflection             
+
              float3 vReflBump = vBumpTex.xyz * float3(0.1, 0.1, 1.0);
+
temp = dot(posAndTime, waveDataY);
             
+
//temp = temp *  (1 / (2 * 3.14159)) + 0.5;
              float4 vReflection = tex2Dproj(reflect, pi.sPos + float4(vReflBump.xy, 0.0f, 0.0f));//*0.001 + float4(2.0*vBumpTexD-1.0f.xxx, 1);
+
             
+
z +=  sin(temp) * waveDataY.z;
              // Compute Fresnel term
+
              float NdotL = max(dot(vEye, vReflBump), 0);
+
waveNormal.y = cos(temp) * waveDataHelper.y + inputVertex.normal.y;
              float facing = (1.0 - NdotL);
+
              float fresnel = Fresnel(NdotL, 0.2, 5.0, facing);
+
waveNormal.z = inputVertex.normal.z;
                             
+
               vReflection.a = fresnel;              
+
waveNormal = normalize(waveNormal);
              return saturate(vReflection + float4(0.0, 0.25, 0.5, 0.0) + pi.specular);
+
            }
+
posAndTime.w = 1.0;
        endShaderSource
+
posAndTime.z = z;
      end                                                    
+
 +
outputVertex.clipPosition = mul( posAndTime, clipSpaceMatrix);
 +
 +
float3 cameraSpaceNormal = normalize(mul(waveNormal, cameraSpaceMatrix));
 +
 
 +
float3 cameraSpacePosition = mul( posAndTime, cameraSpaceMatrix);
 +
 +
float3 viewVector = normalize(-cameraSpacePosition);
 +
 +
float3 R = reflect(viewVector, cameraSpaceNormal);
 +
 +
outputVertex.reflection = mul( -R, cameraToGlobalMatrix);
 +
 +
 +
float fresnel = dot(viewVector , cameraSpaceNormal);
 +
 +
float rdotl = saturate(dot(R, lightDirection));
 +
 +
float I = pow(rdotl+0.1, 15); // fudge factor to punch up the highlights.
 +
 +
               nightColor = nightColor * 2;                          
 +
                         
 +
outputVertex.diffuseColor = ((1.0 - fresnel) * saturate(nightColor) * 0.5) * layerBlue;
 +
 +
outputVertex.specularColor = I;
 +
return(outputVertex);
 +
 +
}
 +
 
 +
 
 +
endShaderSource
 +
end # shaderProgram
 +
 +
stage
 +
texture $wmReflectionTexture
 +
textureAddressing clamp clamp clamp
 +
textureBlend multiply(texture diffuse) select(diffuse)
 +
end
 
        
 
        
      sampler reflect
 
        texture "PoolReflection"
 
        textureAddressing clamp clamp
 
      end
 
 
        
 
        
      sampler bump
+
addSpecular true
        texture "poolShape-body-bump"
+
        textureAddressing tile tile
+
      end 
+
           
+
 
end # end pass
 
end # end pass
 
+
 
 +
 
 
enddef
 
enddef

Revision as of 01:58, 24 June 2009

pass -clipAlways -modifiedEachFrameHint #fillmode wireframe alphaBlend srcFactor(one) add dstFactor(one)

     seti textureLights (numLightsOfType(environmentCube))        
  

shaderProgram -target vertexProgram -method compile -version 1_1

bindConstants 0 -bindingID geomToClip -constantCount 4 bindConstants 4 -bindingID geomToCamera -constantCount 3

bindConstants 7 -bindingID frameInfo

bindConstants 11 -bindingID immediateData -data ($wmXRepeat, 0, $wmXWaveHeight, $wmXSpeed) bindConstants 12 -bindingID immediateData -data (0, $wmYRepeat, $wmYWaveHeight, $wmYSpeed)

# pre-evaluate these 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

        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);

           float4 nightColor: register(c25);
           

float4 lightDirection : register(c14); float4 lightColor : register(c15); 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 diffuseColor: COLOR0; float4 specularColor: COLOR1; float3 reflection : TEXCOORD0;

};


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);

// z = h * sin(...)

float z; // scale temp to fit -pi +pi range //temp = temp * (1 / (2 * 3.14159)) + 0.5;

float3 waveNormal;

z = sin(temp) * waveDataX.z + inputVertex.position.z;

waveNormal.x = cos(temp) * waveDataHelper.x + inputVertex.normal.x;

temp = dot(posAndTime, waveDataY); //temp = temp * (1 / (2 * 3.14159)) + 0.5;

z += sin(temp) * waveDataY.z;

waveNormal.y = cos(temp) * waveDataHelper.y + inputVertex.normal.y;

waveNormal.z = inputVertex.normal.z;

waveNormal = normalize(waveNormal);

posAndTime.w = 1.0; posAndTime.z = z;

outputVertex.clipPosition = mul( posAndTime, clipSpaceMatrix);

float3 cameraSpaceNormal = normalize(mul(waveNormal, cameraSpaceMatrix));

float3 cameraSpacePosition = mul( posAndTime, cameraSpaceMatrix);

float3 viewVector = normalize(-cameraSpacePosition);

float3 R = reflect(viewVector, cameraSpaceNormal);

outputVertex.reflection = mul( -R, cameraToGlobalMatrix);


float fresnel = dot(viewVector , cameraSpaceNormal);

float rdotl = saturate(dot(R, lightDirection));

float I = pow(rdotl+0.1, 15); // fudge factor to punch up the highlights.

              nightColor = nightColor * 2;                           
                          

outputVertex.diffuseColor = ((1.0 - fresnel) * saturate(nightColor) * 0.5) * layerBlue;

outputVertex.specularColor = I; return(outputVertex);

}


endShaderSource end # shaderProgram

stage texture $wmReflectionTexture textureAddressing clamp clamp clamp textureBlend multiply(texture diffuse) select(diffuse) end


addSpecular true

end # end pass


enddef

Personal tools
Namespaces

Variants
Actions
Navigation
game select
Toolbox