Difference between revisions of "ShaderImposters"
From SimsWiki
(EP2-NL) |
(EP5-SS) |
||
| Line 1: | Line 1: | ||
<pre> | <pre> | ||
| − | + | EP5-SS | |
0xCD7FE87A | 0xCD7FE87A | ||
0x1C0532FA | 0x1C0532FA | ||
| Line 44: | Line 44: | ||
alphaTest true 127 | alphaTest true 127 | ||
| − | alphaTestFunction acceptIfGreater | + | alphaTestFunction acceptIfGreater |
fillmode $stdMatFillMode | fillmode $stdMatFillMode | ||
| − | create | + | create ImposterColorScalarWithTextureLight(true) |
stage | stage | ||
| Line 57: | Line 57: | ||
textureBlend multiply(texture colorScalar) multiply(texture colorScalar) | textureBlend multiply(texture colorScalar) multiply(texture colorScalar) | ||
| − | end | + | end |
| − | end | + | end |
| + | |||
| + | if (tsHasSnow >= 1) | ||
| + | pass -fixedFunction | ||
| + | create LightingStatesNoStdLights() | ||
| + | |||
| + | # the imposters are saved with pre-multiplied alpha. | ||
| + | alphaBlend srcFactor(srcAlpha) add dstFactor(invSrcAlpha) | ||
| + | |||
| + | alphaTest true 0 | ||
| + | alphaTestFunction acceptIfGreaterOrEqual | ||
| + | |||
| + | #ffDepthOffset 1 | ||
| + | depthTest true -enableDepthWrite false | ||
| + | depthTestFunction acceptIfEqual | ||
| + | |||
| + | |||
| + | fillmode $stdMatFillMode | ||
| + | |||
| + | create ImposterColorScalarWithTextureLight(true) | ||
| + | |||
| + | stage | ||
| + | texture "snow-light-pass1" | ||
| + | textureAddressing tile tile | ||
| + | ffTextureCoordsSource fromPosition | ||
| + | ffTextureMatrix -cameraToGlobal -scalev (23, 23) -invert | ||
| + | textureBlend multiply(texture colorScalar) multiply(texture colorScalar) | ||
| + | end | ||
| + | |||
| + | stage | ||
| + | texture "snow-light-pass2" | ||
| + | textureAddressing tile tile | ||
| + | ffTextureMatrix -cameraToGlobal -scalev (17, 17) -invert | ||
| + | ffTextureCoordsSource fromPosition | ||
| + | textureBlend multiplyAdd(texture colorScalar outRegister) multiplyAdd(texture colorScalar outRegister) | ||
| + | end | ||
| + | |||
| + | end | ||
| + | endif | ||
end | end | ||
end | end | ||
| Line 84: | Line 122: | ||
alphaTest true 0 | alphaTest true 0 | ||
| − | alphaTestFunction acceptIfGreater | + | alphaTestFunction acceptIfGreater |
| − | + | depthTest true -enableDepthWrite false | |
| + | |||
if ($isTypeQuad) | if ($isTypeQuad) | ||
| Line 110: | Line 149: | ||
end | end | ||
end | end | ||
| + | |||
| + | |||
endif | endif | ||
| Line 118: | Line 159: | ||
alphaTest true 0 | alphaTest true 0 | ||
| − | alphaTestFunction acceptIfGreater | + | alphaTestFunction acceptIfGreater |
| + | depthTest true -enableDepthWrite false | ||
| + | |||
| + | seti snowLevel (tsHasSnow) | ||
if ($isTypeQuad) | if ($isTypeQuad) | ||
| Line 143: | Line 187: | ||
textureBlend multiply(texture colorScalar) multiply(texture colorScalar) | textureBlend multiply(texture colorScalar) multiply(texture colorScalar) | ||
end | end | ||
| + | |||
| + | |||
| + | if ($snowLevel >= 1) | ||
| + | stage | ||
| + | texture "snow-light-pass2" | ||
| + | textureAddressing tile tile | ||
| + | ffTextureCoordsSource fromPosition | ||
| + | ffTextureMatrix -cameraToGlobal -scalev (23, 23) -invert | ||
| + | textureBlend multiply(texture outRegister) multiply(outRegister texture) | ||
| + | end | ||
| + | endif | ||
end | end | ||
| + | |||
if ($includeHighlight) | if ($includeHighlight) | ||
| Line 250: | Line 306: | ||
textureBlend multiply(texture colorScalar) select(colorScalar) | textureBlend multiply(texture colorScalar) select(colorScalar) | ||
| − | end | + | end |
end | end | ||
| + | |||
| + | if (tsHasSnow >= 1) | ||
| + | pass | ||
| + | shaderProgram -target vertexProgram -method assemble | ||
| + | bindConstants 0 -bindingID geomToClip -constantCount 4 | ||
| + | |||
| + | setf invRoofTextureTiles (1/8) | ||
| + | |||
| + | shaderSource | ||
| + | vs_1_1 | ||
| + | def c4, $invRoofTextureTiles, -$invRoofTextureTiles, 0, 1 | ||
| + | dcl_position v0 | ||
| + | |||
| + | m4x4 oPos, v0, c0 | ||
| + | mad oT0.xy, v0, c4.xy, c4.zw | ||
| + | endShaderSource | ||
| + | end | ||
| + | |||
| + | alphaBlend srcFactor(srcAlpha) add dstFactor(invSrcAlpha) | ||
| + | |||
| + | fillmode $stdMatFillMode | ||
| + | ffDepthOffset 1 | ||
| + | depthTest true -enableDepthWrite false | ||
| + | depthTestFunction acceptIfLessOrEqual | ||
| + | |||
| + | create ImposterColorScalarWithTextureLight(true) | ||
| + | |||
| + | stage | ||
| + | texture "snow-light-roof-pass1" | ||
| + | textureAddressing tile tile | ||
| + | textureFilterHint bilinear bilinear | ||
| + | textureBlend multiply(texture colorScalar) multiply(texture diffuse) | ||
| + | end | ||
| + | |||
| + | stage | ||
| + | textureBlend select(outRegister) multiply(outRegister colorScalar) | ||
| + | end | ||
| + | end | ||
| + | endif | ||
end | end | ||
end | end | ||
Revision as of 10:58, 16 July 2008
EP5-SS
0xCD7FE87A
0x1C0532FA
0xA335F05F
0xFFD7EBE7
# imposters
#
# Shaders for imposters
#
# NOTE: because imposters are generated by
# rendering the lot to textures, all imposter
# textures effectively have pre-multiplied alpha.
# This parameter gets used for lots saved prior to ~12/20/03. For the
# new lots, this parameter gets set in code. This parameter is used to
# slightly tint the imposter terrain surface to make it slightly stand out
# in the neighborhood terrain.
setc lightMapTint (1.0, 1.0, 1.0)
#layer ID of neighborhood terrain canvas
seti nhoodCanvasLayer -8
setb isQuad false
# Used for double-sided slices, which are assumed to be
# drawn in correct front/back order.
define ImposterDualPackedSliceMaterial()
# params: page
material
shader -layer (($stdMatLayer * 8))
vertexFormatPred position 0 true
numLightsPred $kShadeLight (numLightsOfType(${kShadeLight}))
pass -fixedFunction
create LightingStatesNoStdLights()
# the imposters are saved with pre-multiplied alpha.
alphaBlend srcFactor(one) add dstFactor(invSrcAlpha)
alphaTest true 127
alphaTestFunction acceptIfGreater
fillmode $stdMatFillMode
create ImposterColorScalarWithTextureLight(true)
stage
texture "slices_${page}"
textureMIPFilterHint disabled
textureFilterHint point point
textureBlend multiply(texture colorScalar) multiply(texture colorScalar)
end
end
if (tsHasSnow >= 1)
pass -fixedFunction
create LightingStatesNoStdLights()
# the imposters are saved with pre-multiplied alpha.
alphaBlend srcFactor(srcAlpha) add dstFactor(invSrcAlpha)
alphaTest true 0
alphaTestFunction acceptIfGreaterOrEqual
#ffDepthOffset 1
depthTest true -enableDepthWrite false
depthTestFunction acceptIfEqual
fillmode $stdMatFillMode
create ImposterColorScalarWithTextureLight(true)
stage
texture "snow-light-pass1"
textureAddressing tile tile
ffTextureCoordsSource fromPosition
ffTextureMatrix -cameraToGlobal -scalev (23, 23) -invert
textureBlend multiply(texture colorScalar) multiply(texture colorScalar)
end
stage
texture "snow-light-pass2"
textureAddressing tile tile
ffTextureMatrix -cameraToGlobal -scalev (17, 17) -invert
ffTextureCoordsSource fromPosition
textureBlend multiplyAdd(texture colorScalar outRegister) multiplyAdd(texture colorScalar outRegister)
end
end
endif
end
end
enddef
setb includeLightMap false
setb includeHighlight false
set textureCoordSet 0
define ImposterTerrainMaterial()
material
shader -layer (($nhoodCanvasLayer + 5)* 8)
vertexFormatPred position 0 true
numLightsPred $kShadeLight (numLightsOfType(${kShadeLight}))
setb isTypeQuad ($isQuad)
if ($includeLightMap)
pass -fixedFunction
create NonStandardLighting()
alphaBlend srcFactor(destColor) add dstFactor(invSrcAlpha)
fillmode $stdMatFillMode
alphaTest true 0
alphaTestFunction acceptIfGreater
depthTest true -enableDepthWrite false
if ($isTypeQuad)
#always accept it as we its alpha and we are writing over terrain
depthTest true -enableDepthWrite false
ffDepthOffset 100
depthTestFunction acceptIfLessOrEqual
endif
colorScalar $lightMapTint 1
stage
if ($isTypeQuad)
texture $lmapTexture
else
texture "terrainLmap"
endif
textureFilterHint bilinear bilinear
textureAddressing tile tile
ffTextureCoordsSource $textureCoordSet
textureBlend multiply(texture colorScalar) select(texture)
end
end
endif
pass -fixedFunction
create NonStandardLighting()
alphaBlend srcFactor(one) add dstFactor(invSrcAlpha)
fillmode $stdMatFillMode
alphaTest true 0
alphaTestFunction acceptIfGreater
depthTest true -enableDepthWrite false
seti snowLevel (tsHasSnow)
if ($isTypeQuad)
#always accept it as its alpha and we are writing over terrain
ffDepthOffset 100
depthTest true -enableDepthWrite false
depthTestFunction acceptIfLessOrEqual
endif
# use shape light only in neighborhood mode
# we don't want to make the terrain fade as it looks bad
create ImposterColorScalarWithTextureLight(tsIsInNeighborhood)
stage
if ($isTypeQuad)
texture $terrainTexture
else
texture "terrain"
endif
textureFilterHint bilinear bilinear
textureAddressing clamp clamp
textureBlend multiply(texture colorScalar) multiply(texture colorScalar)
end
if ($snowLevel >= 1)
stage
texture "snow-light-pass2"
textureAddressing tile tile
ffTextureCoordsSource fromPosition
ffTextureMatrix -cameraToGlobal -scalev (23, 23) -invert
textureBlend multiply(texture outRegister) multiply(outRegister texture)
end
endif
end
if ($includeHighlight)
pass -fixedFunction
create NonStandardLighting()
alphaBlend srcFactor(srcAlpha) add dstFactor(one)
fillmode $stdMatFillMode
alphaTest true 0
alphaTestFunction acceptIfGreater
colorScalar (0.2, 1, 0.2) 0.3
stage
textureBlend select(colorScalar) select(colorScalar)
end
end
endif
end
end
enddef
define ImposterWallMaterial()
material
shader -layer ($stdMatLayer * 8)
vertexFormatPred position 0 true
numLightsPred $kShadeLight (numLightsOfType(${kShadeLight}))
pass -fixedFunction
create NonStandardLighting()
if (numLightsOfType(${kShapeColorLight}) > 0 and not tsIsInNeighborhood)
alphaBlend srcFactor(srcAlpha) add dstFactor(invSrcAlpha)
depthTest true -enableDepthWrite false
else
alphaBlend srcFactor(one) add dstFactor(invSrcAlpha)
depthTest true -enableDepthWrite true
depthTestFunction acceptIfLessOrEqual
endif
alphaTest true 64
alphaTestFunction acceptIfGreater
fillmode $stdMatFillMode
cullmode cullClockwise
create ImposterColorScalarWithTextureLight(true)
stage
texture "walls_${page}"
textureMIPFilterHint disabled
textureFilterHint point point
textureBlend multiply(texture colorScalar) multiply(texture colorScalar)
end
end
end
end
enddef
define ImposterRoofMaterial()
material
shader -layer ($stdMatLayer * 8)
vertexFormatPred position 0 true
numLightsPred $kShadeLight (numLightsOfType(${kShadeLight}))
pass
create NonStandardLighting()
shaderProgram -target vertexProgram -method assemble
bindConstants 0 -bindingID geomToClip -constantCount 4
setf invRoofTextureTiles (1 / 64)
shaderSource
vs_1_1
def c4, $invRoofTextureTiles, -$invRoofTextureTiles, 0, 1
dcl_position v0
m4x4 oPos, v0, c0
mad oT0.xy, v0, c4.xy, c4.zw
endShaderSource
end
fillmode $stdMatFillMode
cullmode none
if (numLightsOfType(${kShapeColorLight}) > 0 and not tsIsInNeighborhood)
alphaBlend srcFactor(srcAlpha) add dstFactor(invSrcAlpha)
depthTest true -enableDepthWrite false
else
alphaBlend srcFactor(one) add dstFactor(zero)
endif
create ImposterColorScalarWithTextureLight(true)
stage
texture "roofs"
textureFilterHint bilinear bilinear
textureAddressing clamp clamp
textureBlend multiply(texture colorScalar) select(colorScalar)
end
end
if (tsHasSnow >= 1)
pass
shaderProgram -target vertexProgram -method assemble
bindConstants 0 -bindingID geomToClip -constantCount 4
setf invRoofTextureTiles (1/8)
shaderSource
vs_1_1
def c4, $invRoofTextureTiles, -$invRoofTextureTiles, 0, 1
dcl_position v0
m4x4 oPos, v0, c0
mad oT0.xy, v0, c4.xy, c4.zw
endShaderSource
end
alphaBlend srcFactor(srcAlpha) add dstFactor(invSrcAlpha)
fillmode $stdMatFillMode
ffDepthOffset 1
depthTest true -enableDepthWrite false
depthTestFunction acceptIfLessOrEqual
create ImposterColorScalarWithTextureLight(true)
stage
texture "snow-light-roof-pass1"
textureAddressing tile tile
textureFilterHint bilinear bilinear
textureBlend multiply(texture colorScalar) multiply(texture diffuse)
end
stage
textureBlend select(outRegister) multiply(outRegister colorScalar)
end
end
endif
end
end
enddef
define ImposterColorScalarWithTextureLight(useShapeColor)
# Allow shade colour, but only if we're not being highlighted.
if (&useShapeColor)
colorScalar (1, 1, 1, 1) -applyShapeColor 0 -applyTextureLightColor 0 0
else
colorScalar (1, 1, 1, 1) -applyTextureLightColor 0 0
endif
if (numLightsOfType(${kShadeLight}) != 0 and numLightsOfType(${kShapeColorLight}) = 0)
tsUserLight shadeLight 0
endif
enddef
define ImposterColorScalar()
# Allow shade colour, but only if we're not being highlighted.
colorScalar (1, 1, 1, 1) -applyShapeColor 0
if (numLightsOfType(${kShadeLight}) != 0 and numLightsOfType(${kShapeColorLight}) = 0)
tsUserLight shadeLight 0
endif
enddef