View Single Post in: Recolouring Roofs with Object Workshop (NEW Tutorial)

Mad Poster
#64 Old 1st Aug 2006 at 11:08 AM
Oh well, not a solved puzzle yet.. but hey what a "high-light"!

# texture, lit, normal mappedm, no specular
# modify this material for roof highlights
materialDefinition RoofTopHighlight
setDefinition StandardMaterial
addParam stdMatSpecPower 0
addParam stdMatDiffCoef (0.4, 0.385, 0.38)
addParam stdMatBaseTextureName roof-redtile
addParam stdMatBaseTextureEnabled true
addParam stdMatNormalMapTextureName roof-redtile-bump
addParam stdMatNormalMapTextureEnabled true
addParam stdMatBaseTextureAddressingU clamp
addParam stdMatBaseTextureAddressingV clamp
addParam stdMatBaseTextureAddressingW clamp
addParam stdMatNormalMapTextureAddressingU clamp
addParam stdMatNormalMapTextureAddressingV clamp
addParam stdMatNormalMapTextureAddressingW clamp

& an amazing imposter!

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


Edited, but it's the roof top definition that affects the most.