Difference between revisions of "TEST-STRCMP4CODES"

From SimsWiki
Jump to: navigation, search
Line 1: Line 1:
shaderProgram -target pixelProgram -method compile -version 2_0             
+
define LotSkirtWater()
shaderSource                           
+
material     
sampler reflect; 
+
create DetermineHardwareSupport()
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;
+
float4 colorTint    : COLOR1;
+
};
+
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 ;
+
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.1, 0.5, facing);
+
vReflection.a = fresnel * 0.5;
+
return saturate(vReflection + pi.colorTint);
+
}
+
endShaderSource
+
end                                                   
+
  
sampler reflect
+
if ($useHWShader2Path)
texture "OceanReflection"
+
create LotSkirtPSWater()
textureAddressing clamp clamp
+
else
end
+
 
sampler bump
+
shader -layer $nhoodWaterLayer
texture "poolShape-body-bump"
+
validateRenderShaderContext -vertexFormat  position      0 required
textureAddressing tile tile
+
validateRenderShaderContext -vertexFormat  normal        0 required
end   
+
validateRenderShaderContext -vertexFormat  texcoord      0 required
end # end pass
+
viewerRenderTypePred viewerRenderType
end
+
           
 +
pass -fixedFunction
 +
   
 +
alphaBlend srcFactor(srcAlpha) add dstFactor(invSrcAlpha)
 +
colorScalar $lotSkirtWaterReflColour 0.50
 +
depthTest true -enableDepthWrite false                       
 +
   
 +
#tring to remove warble I think it may be caused by depth bias.
 +
#ffDepthOffset -2
 +
   
 +
stage
 +
ffTextureCoordsSource fromPosition
 +
ffTextureMatrix -cameraToClip -scalev ((-0.5 * $ratioW), (-0.5 * $ratioH)) -trans (0.5, 0.5)
 +
textureAddressing clamp clamp
 +
texture "ScreenReflection"
 +
       
 +
textureBlend multiply(texture colorScalar) multiply(diffuse colorScalar)
 +
end              
 +
               
 +
end
 +
end   
 +
endif
 +
  end
 +
enddef
 +
 
 +
define LotSkirtWaterNoReflection()
 +
  material
 +
      # fallback: no reflection.
 +
      shader -layer ($nhoodWaterLayer)
 +
        viewerRenderTypePred viewerRenderType
 +
       
 +
        create DetermineHardwareSupport()
 +
       
 +
        pass -fixedFunction
 +
  # For now, we are diabling the lighting since we simply want to use the vertex colors.
 +
  create LightingStatesNoStdLightsParam(false true)
 +
  alphaBlend srcFactor(srcAlpha) add dstFactor(invSrcAlpha)
 +
 
 +
            colorScalar (.4, .6, .9, .4)     
 +
           
 +
            #tring to remove warble I think it may be caused by depth bias.
 +
            #ffDepthOffset -2                             
 +
           
 +
            fillmode $stdMatFillMode
 +
            stage
 +
              #texture reflectionoutdoorwater-envcube
 +
              if ($cubeMapSupport)
 +
                  texture $skyboxCubeMap
 +
                  textureMIPFilterHint disabled
 +
 
 +
                  ffTextureCoordsSource fromReflectionVector
 +
                  ffTextureMatrix -orientCameraToGlobal
 +
 
 +
                  textureAddressing clamp clamp clamp
 +
                  textureBlend multiply(texture colorScalar) select(colorScalar)
 +
              else
 +
                  textureBlend select(colorScalar) multiply(diffuse colorScalar)
 +
              endif
 +
            end 
 +
        end   
 +
      end
 +
  end              
 
enddef
 
enddef

Revision as of 06:12, 7 September 2007

define LotSkirtWater() material create DetermineHardwareSupport()

if ($useHWShader2Path) create LotSkirtPSWater() else

shader -layer $nhoodWaterLayer validateRenderShaderContext -vertexFormat position 0 required validateRenderShaderContext -vertexFormat normal 0 required validateRenderShaderContext -vertexFormat texcoord 0 required viewerRenderTypePred viewerRenderType

pass -fixedFunction

alphaBlend srcFactor(srcAlpha) add dstFactor(invSrcAlpha) colorScalar $lotSkirtWaterReflColour 0.50 depthTest true -enableDepthWrite false

#tring to remove warble I think it may be caused by depth bias. #ffDepthOffset -2

stage ffTextureCoordsSource fromPosition ffTextureMatrix -cameraToClip -scalev ((-0.5 * $ratioW), (-0.5 * $ratioH)) -trans (0.5, 0.5) textureAddressing clamp clamp texture "ScreenReflection"

textureBlend multiply(texture colorScalar) multiply(diffuse colorScalar) end

end end endif

  end

enddef

define LotSkirtWaterNoReflection()

  material
     # fallback: no reflection.
     shader -layer ($nhoodWaterLayer)
        viewerRenderTypePred viewerRenderType
        
        create DetermineHardwareSupport()
        
        pass -fixedFunction

# For now, we are diabling the lighting since we simply want to use the vertex colors. create LightingStatesNoStdLightsParam(false true) alphaBlend srcFactor(srcAlpha) add dstFactor(invSrcAlpha)

           colorScalar (.4, .6, .9, .4)      
           
           #tring to remove warble I think it may be caused by depth bias.
           #ffDepthOffset -2                              
           
           fillmode $stdMatFillMode
           stage
              #texture reflectionoutdoorwater-envcube
              if ($cubeMapSupport)
                 texture $skyboxCubeMap
                 textureMIPFilterHint disabled
                 ffTextureCoordsSource fromReflectionVector
                 ffTextureMatrix -orientCameraToGlobal
                 textureAddressing clamp clamp clamp
                 textureBlend multiply(texture colorScalar) select(colorScalar)
              else
                 textureBlend select(colorScalar) multiply(diffuse colorScalar)
              endif
           end  
        end   
     end
  end               

enddef

Personal tools
Namespaces

Variants
Actions
Navigation
game select
Toolbox