TEST-STRCMP4CODES

From SimsWiki
Revision as of 06:36, 7 September 2007 by Niol (Talk | contribs)

Jump to: navigation, search
  1. beginshader RotatingSteamLayers
  2. description Two layers of rotating steam textures
  3. extraparam float steamLayer1RotationSpeed 0.02 -1 1 ; Rotational speed of layer 1
  4. extraparam float steamLayer2RotationSpeed 0.02 -1 1 ; Rotational speed of layer 2
  5. extraparam float steamLayer1RotationX 0.5 -1 2 ; Rotation center X texture coord for layer 1
  6. extraparam float steamLayer1RotationY 0.5 -1 2 ; Rotation center Y texture coord for layer 1
  7. extraparam float steamLayer2RotationX 0.5 -1 2 ; Rotation center X texture coord for layer 2
  8. extraparam float steamLayer2RotationY 0.5 -1 2 ; Rotation center Y texture coord for layer 2
  9. extraparam int stdMatLayer 0 -32 32 ; Layer for render order
  setf steamLayer1RotationSpeed 0.02
  setf steamLayer2RotationSpeed 0.02
  setf steamLayer1RotationX 0.5
  setf steamLayer1RotationY 0.5
  setf steamLayer2RotationX 0.5
  setf steamLayer2RotationY 0.5
  define RotatingSteamLayers()
     material
        attributes
           attribute steamFade float1 0
        end
        shader -layer ($stdMatLayer * 18 + 17)
           vertexFormatPred position 0 true
           vertexFormatPred blendindices  0 false
           vertexFormatPred targetindices 0 false
           create SteamPass($stdMatBaseTextureName $steamLayer1RotationSpeed ($steamLayer1RotationX, $steamLayer1RotationY))
           create SteamPass($stdMatBaseTextureName $steamLayer2RotationSpeed ($steamLayer2RotationX, $steamLayer2RotationY))
        end
     end
  enddef
  1. endshader RotatingSteamLayers


define SteamPass(steamTexture speed origin)

  pass -fixedFunction
     create LightingStates()
     depthTest true -enableDepthWrite false
     alphaBlend srcFactor(srcColor) add dstFactor(invSrcColor)
     ffMatCoef -emit (1,1,1) -diff (0,0,0) -diffAlpha @steamFade
     fillmode $stdMatFillMode
     stage
        ffTextureCoordsSource 0
        texture &steamTexture
        textureBlend select(texture) multiply(texture diffuse)
     end 
     stage
        ffTextureCoordsSource 0
        textureMatrixAnimation -targetType fixedFunction -arot sawtooth &speed 0 (0,1) -aorigin ((1, 1) - (&origin))
        texture &steamTexture
        textureBlend multiply(outRegister:alphaReplicate texture) multiply(outRegister texture)
     end 
  end

enddef


define CubeAlphaFalloffTexture()

  material
     attributes
        attribute color float3
        attribute alpha float1
        attribute scale float1
     end
     shader -layer ($stdMatLayer * 18 + 17)
        vertexFormatPred position      0 true
        vertexFormatPred normal        0 true
        vertexFormatPred texcoord      0 true
        vertexFormatPred blendindices  0 false
        vertexFormatPred targetindices 0 false
     create DetermineHardwareSupport()
     
     if ($useFixedFunctionPath or $useSWVertexShaderPath)
        pass -fixedFunction
           create LightingStatesNoStdLightsParam(true false)
           
           alphaBlend srcFactor(srcAlpha) add dstFactor(invSrcAlpha)
           depthTest true -enableDepthWrite false
           
           colorScalar @color @alpha
           ffScaleModelTransform @scale
           fillmode $stdMatFillMode
           stage
              texture $stdMatEnvCubeTextureName -alphaFalloffCubeMap 64 (0, 1, 0) (-30, 255) 5
              textureMIPFilterHint disabled
              ffTextureCoordsSource fromNormal
              textureTransformType vector3
              # ffTextureMatrix -orientToCamera
              textureAddressing clamp clamp clamp
              textureBlend select(texture:alphaReplicate) multiply(texture colorScalar)
           end 
           stage
              texture $stdMatBaseTextureName ${stdMatBaseTextureParam}
              ffTextureCoordsSource 0
              textureBlend select(colorScalar) multiply(outRegister texture)
           end 
        end
     else
        pass
        
           # supports global wireframe modes and so forth.
           create NonStandardLighting()
           
           alphaBlend srcFactor(srcAlpha) add dstFactor(invSrcAlpha)
           depthTest true -enableDepthWrite false
           shaderProgram -target vertexProgram -method assemble
              bindConstants 0 -bindingID geomToClip -constantCount 4
              bindConstants 10 -bindingID immediateData -data (@scale)
              bindConstants 4 -bindingID geomToCamera -constantCount 3
              shaderSource
                 vs_1_1
                 def c11, 0,0.5,1,2
                 dcl_position v0
                 dcl_normal v1
                 dcl_texcoord v2
                 
                 mul r0.xyz, v0, c10.x
                 mov r0.w, v0.wwww
                 m4x4 oPos, r0, c0
                 m3x3 oT0.xyz, v1,c4
                 
                 mov oT1.xy, v2
              endShaderSource
           end
           
           shaderProgram -target pixelProgram -method assemble
              bindConstants 0 -bindingID immediateData -data (@color)
              bindConstants 1 -bindingID immediateData -data (@alpha) -startChannel w
              shaderSource
                 ps_1_1
                 tex t0
                 tex t1
                 mov r0.rgb, c0
                 +mul r0.a,t0.a, c1.a
                 mul r0.a, t1.a, r0.a
              endShaderSource
           end


           sampler 0 
              texture $stdMatEnvCubeTextureName -alphaFalloffCubeMap 64 (0, 1, 0) (-30, 255) 5
              textureMIPFilterHint disabled
              textureAddressing clamp clamp clamp
           end
           
           sampler 1
              texture $stdMatBaseTextureName ${stdMatBaseTextureParam}
           end
        end
     endif
     end
     shader
     end
  end

enddef

materialDefinition steamSphere_steam

  setDefinition CubeAlphaFalloffTexture
  addParam stdMatLayer 13
  addParam stdMatEnvCubeTextureName steamSphere_alphaFalloff5
  addParam stdMatBaseTextureName steam-alpha

end

materialDefinition effectsSteam_steam

  setDefinition CubeAlphaFalloffTexture
  addParam stdMatLayer 13
  addParam stdMatEnvCubeTextureName steamSphere_alphaFalloff5
  addParam stdMatBaseTextureName effectsSteam-alpha

end

materialDefinition effectsSmallSteam_steam

  1. < test use of the StandardParticleModelMaterial
  setDefinition StandardParticleModelMaterial
  addParam stdMatBaseTextureName steam-alpha
  addParam stdMatDiffCoef (1, 1, 1)
  addParam stdMatBaseTextureAlphaReplicate true
  1. >
  setDefinition CubeAlphaFalloffTexture
  addParam stdMatLayer 15
  addParam stdMatEnvCubeTextureName steamSphere_alphaFalloff5
  addParam stdMatBaseTextureName steam-alpha

end


materialDefinition fightPuff_puffball

  setDefinition CubeAlphaFalloffTexture
  addParam stdMatLayer 13
  addParam stdMatEnvCubeTextureName steamSphere_alphaFalloff5
  addParam stdMatBaseTextureName effectsFightPuff-alpha

end

Personal tools
Namespaces

Variants
Actions
Navigation
game select
Toolbox