Difference between revisions of "TEST-STRCMP4CODES"
From SimsWiki
Line 1: | Line 1: | ||
+ | # Caustics | ||
+ | # | ||
+ | |||
+ | define TiledTextureAnimShaderProgram(tilesX tilesY speed) | ||
+ | shaderProgram -target vertexProgram -method assemble | ||
+ | |||
+ | bindConstants 0 -bindingID frameInfo # for time in .w | ||
+ | bindConstants 1 -data (&tilesX, &tilesY, &speed, 1) # tx, ty, speed | ||
+ | bindConstants 2 -data ((1/&tilesX), (1/&tilesY), (&tilesY - 1), 1) # 1/tx 1/ty ty-1 | ||
+ | if (tsIsDay) | ||
+ | bindConstants 3 -bindingID immediateData -data (0.75, 0.75, 0.75, 1) | ||
+ | else | ||
+ | bindConstants 3 -bindingID immediateData -data (0.2, 0.2, 0.2, 1) | ||
+ | endif | ||
+ | |||
+ | shaderSource | ||
+ | vs_1_1 | ||
+ | dcl_position v0 | ||
+ | dcl_texcoord v1 | ||
+ | |||
+ | mov oPos, v0 # clip space quad, no transforms needed. | ||
+ | |||
+ | # tiled texture animation | ||
+ | mov r0, c0 | ||
+ | mul r1, c1.z, r0.w | ||
+ | frc r5.y, r1.y | ||
+ | |||
+ | mul r1, c1.y, r5.y # f -> [0, ty) | ||
+ | frc r5.y, r1 | ||
+ | sub r3.y, r1, r5.y # v' = floor(f) | ||
+ | |||
+ | mul r1, c1.x, r5.y # f -> [0, tx) | ||
+ | frc r5.y, r1 | ||
+ | sub r3.x, r1, r5.y # u' = floor(f) | ||
+ | |||
+ | add r8.xy, v1.xy, r3.xy | ||
+ | mul oT0.xy, r8.xy, c2.xy | ||
+ | |||
+ | mov oD0, c3 # also spit out diffuse color with modcolor information | ||
+ | |||
+ | endShaderSource | ||
+ | |||
+ | end | ||
+ | enddef | ||
+ | |||
+ | define CausticsGeneratorMaterial() | ||
material | material | ||
# This material updates a render target with the current frame | # This material updates a render target with the current frame |
Revision as of 03:36, 3 September 2007
- Caustics
define TiledTextureAnimShaderProgram(tilesX tilesY speed)
shaderProgram -target vertexProgram -method assemble bindConstants 0 -bindingID frameInfo # for time in .w bindConstants 1 -data (&tilesX, &tilesY, &speed, 1) # tx, ty, speed bindConstants 2 -data ((1/&tilesX), (1/&tilesY), (&tilesY - 1), 1) # 1/tx 1/ty ty-1 if (tsIsDay) bindConstants 3 -bindingID immediateData -data (0.75, 0.75, 0.75, 1) else bindConstants 3 -bindingID immediateData -data (0.2, 0.2, 0.2, 1) endif shaderSource vs_1_1 dcl_position v0 dcl_texcoord v1
mov oPos, v0 # clip space quad, no transforms needed. # tiled texture animation mov r0, c0 mul r1, c1.z, r0.w frc r5.y, r1.y mul r1, c1.y, r5.y # f -> [0, ty) frc r5.y, r1 sub r3.y, r1, r5.y # v' = floor(f) mul r1, c1.x, r5.y # f -> [0, tx) frc r5.y, r1 sub r3.x, r1, r5.y # u' = floor(f)
add r8.xy, v1.xy, r3.xy mul oT0.xy, r8.xy, c2.xy mov oD0, c3 # also spit out diffuse color with modcolor information endShaderSource end
enddef
define CausticsGeneratorMaterial()
material # This material updates a render target with the current frame # of the tile animation. This is the only way to handle a repeated # animating texture (not to mention using it for projective texturing) # in the absence of clip maps. create DetermineHardwareSupport() if ($causticsEnabled and $useFixedFunctionPath = false and $useSWVertexShaderPath = false) shader -layer +9999
pass renderClipSpaceRect renderTarget causticsTile -fixed (64, 64) -allocateDepthBuffer false -undo
create TiledTextureAnimShaderProgram(8 4 1) alphaBlend srcFactor(one) add dstFactor(zero) alphaTest false 0 alphaTestFunction acceptIfGreater
depthTest false -enableDepthWrite false depthTestFunction accept
# 7/24/2004 Fix bug with kRenderTypeNormal default stencil state and nv40. # It reads random stencil values even this target has no depth stencil target. # This stencil call will break pixo, but pixo does not show caustics. 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