ShaderImposters
From SimsWiki
EP0-TS2 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 # 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() # depthTest true -enableDepthWrite false # depthTestFunction acceptIfLessOrEqual # the imposters are saved with pre-multiplied alpha. alphaBlend srcFactor(one) add dstFactor(invSrcAlpha) alphaTest true 127 alphaTestFunction acceptIfGreater fillmode $stdMatFillMode create ImposterColorScalar() stage texture "slices_${page}" textureMIPFilterHint disabled textureFilterHint point point textureBlend multiply(texture colorScalar) multiply(texture colorScalar) end end 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})) if ($includeLightMap) pass -fixedFunction create NonStandardLighting() alphaBlend srcFactor(destColor) add dstFactor(invSrcAlpha) fillmode $stdMatFillMode alphaTest true 0 alphaTestFunction acceptIfGreater colorScalar $lightMapTint 1 stage texture "terrainLmap" textureFilterHint point point 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 create ImposterColorScalar() stage texture "terrain" #reggrid textureFilterHint bilinear bilinear textureAddressing clamp clamp textureBlend multiply(texture colorScalar) multiply(texture colorScalar) end 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() depthTest true -enableDepthWrite true depthTestFunction acceptIfLessOrEqual alphaTest true 64 alphaTestFunction acceptIfGreater alphaBlend srcFactor(one) add dstFactor(invSrcAlpha) fillmode $stdMatFillMode cullmode cullClockwise create ImposterColorScalar() 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 alphaBlend srcFactor(one) add dstFactor(zero) fillmode $stdMatFillMode cullmode none # roof imposters are single-sided create ImposterColorScalar() stage texture "roofs" textureFilterHint bilinear bilinear textureAddressing clamp clamp textureBlend multiply(texture colorScalar) select(colorScalar) end end end end 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