|
|
(16 intermediate revisions by one user not shown) |
Line 1: |
Line 1: |
− | #
| + | define TransparentMirrorReflection() |
− | # roof material definitions.
| + | |
− | #
| + | |
− | | + | |
− | # material for roof preview when they're displayed
| + | |
− | define RoofPreviewMaterial() | + | |
| material | | material |
− | shader -layer 9999 | + | if (viewerRenderType = $kRenderTypeShadow) |
− | vertexFormatPred position 0 true | + | create StandardShaderShadow() |
− | vertexFormatPred normal 0 true
| + | else |
− | vertexFormatPred blendindices 0 false | + | if (viewerRenderType = $kRenderTypeThumbnail) |
− | vertexFormatPred targetindices 0 false
| + | create TransparentBlankMirrorMaterial($kRenderTypeThumbnail) |
− |
| + | else |
− | pass -fixedFunction
| + | if (not $mirrorReflectionsEnabled) |
− | colorScalar (0.5, 0.4, 0.4, 1.0)
| + | set currentType (viewerRenderType) |
− | create LightingStatesNoStdLights() | + | create TransparentBlankMirrorMaterial($currentType) |
− | depthTest true -enableDepthWrite true
| + | else |
− | | + | create TransparentMirrorReflectionMaterial() |
− | alphaBlend srcFactor(srcAlpha) add dstFactor(invSrcAlpha)
| + | endif |
− | | + | endif |
− | stage
| + | endif |
− | textureBlend select(colorScalar) select(colorScalar) | + | |
− | end
| + | |
− | end
| + | |
− | | + | |
− | pass -fixedFunction
| + | |
− | create LightingStatesNoStdLights()
| + | |
− | fillmode wireframe | + | |
− | cullmode none
| + | |
− | depthTest true -enableDepthWrite false
| + | |
− | colorScalar (0, 0, 0)
| + | |
− | | + | |
− | stage
| + | |
− | textureBlend select(colorScalar) select(colorScalar) | + | |
− | end | + | |
− | end | + | |
− | | + | |
− | end | + | |
| end | | end |
| enddef | | enddef |
| | | |
− | define RoofPreviewMaterialBack() | + | define TransparentBlankMirrorMaterial(renderType) |
− | material
| + | shader |
− | shader -layer 9999 | + | validateRenderShaderContext -viewerRenderType &renderType |
− | vertexFormatPred position 0 true | + | |
− | vertexFormatPred normal 0 true
| + | |
− | vertexFormatPred blendindices 0 false
| + | |
− | vertexFormatPred targetindices 0 false
| + | |
| | | |
− | pass -fixedFunction | + | pass |
− | colorScalar (0.25, 0.1, 0.1, 1.0) | + | shaderProgram -target vertexProgram -method assemble |
− | create LightingStatesNoStdLights() | + | bindConstants 0 -bindingID geomToClip -constantCount 4 |
− | | + | shaderSource |
− | depthTest true -enableDepthWrite true | + | vs_1_1 |
− | | + | dcl_position v0 |
− | alphaBlend srcFactor(srcAlpha) add dstFactor(invSrcAlpha)
| + | m4x4 oPos, v0, c0 |
− | | + | endShaderSource |
| + | end |
| + | |
| + | colorScalar (0,0,0) 0.5 |
| stage | | stage |
| textureBlend select(colorScalar) select(colorScalar) | | textureBlend select(colorScalar) select(colorScalar) |
− | end | + | end |
| end | | end |
− | | + | end |
− | end | + | |
− | end
| + | |
| enddef | | enddef |
| | | |
− | define RoofPreviewMaterialStrip() | + | define TransparentMirrorReflectionMaterial() |
− | material
| + | |
− | shader -layer 9999 | + | shader -layer -9998 # this material must render first |
− | vertexFormatPred position 0 true | + | validateRenderShaderContext -viewerRenderType $kRenderTypeMirror # reflection render |
− | vertexFormatPred blendindices 0 false
| + | |
− | vertexFormatPred targetindices 0 false
| + | |
− |
| + | |
− | pass -fixedFunction
| + | |
− | colorScalar (1.0, 1.0, 1.0, 1.0)
| + | |
− | create LightingStatesNoStdLights()
| + | |
| | | |
− | depthTest true -enableDepthWrite false | + | pass -renderEachFrame |
| + | renderTarget $reflectionRenderTarget -setViewport viewportFromParentRenderContext |
| | | |
− | stage | + | depthTest true -enableDepthWrite true |
− | textureBlend select(colorScalar) select(colorScalar)
| + | |
− | end
| + | |
− | end
| + | |
| | | |
− | end
| + | applyStencilStateForOverlappingReflections |
− | end
| + | |
− | enddef
| + | |
| | | |
− | define RoofPreviewMaterialUpperStrip()
| + | alphaBlend srcFactor(zero) add dstFactor(one) |
− | material
| + | |
− | shader -layer 9999
| + | |
− | vertexFormatPred position 0 true
| + | |
− | vertexFormatPred blendindices 0 false
| + | |
− | vertexFormatPred targetindices 0 false
| + | |
− |
| + | |
− | pass -fixedFunction
| + | |
− | colorScalar (1.0, 0.0, 0.0, 1.0) | + | |
− | create LightingStatesNoStdLights()
| + | |
| | | |
− | depthTest true -enableDepthWrite false | + | cullmode none |
| | | |
− | stage | + | shaderProgram -target vertexProgram -method assemble |
− | textureBlend select(colorScalar) select(colorScalar) | + | bindConstants 0 -bindingID geomToClipFromParentView -constantCount 4 |
− | end | + | shaderSource |
| + | vs_1_1 |
| + | dcl_position v0 |
| + | def c5, 1,0,0,1 |
| + | m4x4 r0, v0, c0 |
| + | mov oPos.x, -r0 |
| + | mov oPos.yzw, r0 |
| + | endShaderSource |
| + | end |
| end | | end |
− |
| |
| end | | end |
− | end
| |
− | enddef
| |
| | | |
− | define RoofPreviewMaterialTopBoundary()
| + | shader -layer 6 |
− | material
| + | validateRenderShaderContext -viewerRenderType $kRenderTypeNormal |
− | shader -layer 9999 | + | pass -modifiedEachFrameHint |
− | vertexFormatPred position 0 true | + | shaderProgram -target vertexProgram -method assemble |
− | vertexFormatPred normal 0 true | + | bindConstants 0 -bindingID geomToClip -constantCount 4 |
− | vertexFormatPred blendindices 0 false
| + | bindConstants 4 -bindingID clipToViewTarget -constantCount 4 |
− | vertexFormatPred targetindices 0 false
| + | shaderSource |
− |
| + | vs_1_1 |
− | pass -fixedFunction
| + | dcl_position v0 |
− | colorScalar (0.4, 0, 0.1, 1.0)
| + | def c8, -0.5, -0.5, 1, 1 |
− | create LightingStatesNoStdLights() | + | def c9, 0.5, 0.5, 0, 0 |
| + | def c10, 0.25, 0.25, 0, 0 |
| + | m4x4 r0, v0, c0 |
| + | mov oPos, r0 |
| + | mul r2, c9, r0.w |
| + | mad r4, r0, c8, r2 |
| + | rcp r3.x, c4.x |
| + | rcp r3.y, c5.y |
| + | mov r3.zw, c9.zw |
| + | mul r3, r3, c10 |
| + | mad r6, r0, r3, r4 |
| + | mov oT0, r6.xyww |
| + | endShaderSource |
| + | end |
| | | |
− | depthTest true -enableDepthWrite true | + | alphaBlend srcFactor(srcAlpha) add dstFactor(invSrcAlpha) |
− | | + | |
− | alphaBlend srcFactor(srcAlpha) add dstFactor(invSrcAlpha)
| + | |
− | | + | |
− | stage
| + | |
− | textureBlend select(colorScalar) select(colorScalar)
| + | |
− | end
| + | |
− | end
| + | |
− | | + | |
− | pass -fixedFunction
| + | |
− | create LightingStatesNoStdLights()
| + | |
− | fillmode wireframe
| + | |
| depthTest true -enableDepthWrite false | | depthTest true -enableDepthWrite false |
− | colorScalar (0, 0, 0) | + | colorScalar (0,0,0) 0.25 |
| | | |
| stage | | stage |
− | textureBlend select(colorScalar) select(colorScalar) | + | textureTransformType vector3 homogeneous |
− | end | + | textureAddressing clamp clamp |
| + | texture $reflectionRenderTarget |
| + | textureBlend select(texture) select(colorScalar) |
| + | end |
| + | |
| end | | end |
− |
| |
− |
| |
| end | | end |
− | end
| |
− | enddef
| |
− |
| |
− | define RoofBumps()
| |
− | material
| |
− | shader -layer 0
| |
− | validateRenderShaderContext -vertexFormat position 0 required
| |
− | validateRenderShaderContext -vertexFormat normal 0 required
| |
− | validateRenderShaderContext -vertexFormat texcoord 0 required
| |
− |
| |
− | pass
| |
− | shaderProgram -target vertexProgram -method compile -version 2_0
| |
− | bindConstants 0 -bindingID geomToClip -constantCount 4
| |
− | bindConstants 4 -bindingID geomToCamera -constantCount 3
| |
− | bindConstants 7 -bindingID cameraToGeom -constantCount 3
| |
− | bindConstants 10 -bindingID allStandardLightData -constantCount 4 -constantType float
| |
− | bindConstants 14 -bindingID immediateData -data $stdMatDiffCoef
| |
− | bindConstants 15 -bindingID ambientLight -constantCount 1 -constantType float
| |
− | bindConstants 18 -bindingID allStandardLightData2 -constantCount 32
| |
− |
| |
− | shaderSource
| |
− | float4x4 modelviewproj : register(c0);
| |
− | float4x3 modelview : register(c4);
| |
− | float4x3 modelviewInv : register(c7);
| |
− |
| |
− | // light direction
| |
− | float4 lightDir0 : register(c18);
| |
− | float4 lightDir1 : register(c19);
| |
− | float4 lightDir2 : register(c20);
| |
− |
| |
− | // light colors
| |
− | float4 lightCol0 : register(c26);
| |
− | float4 lightCol1 : register(c27);
| |
− | float4 lightCol2 : register(c28);
| |
− |
| |
− | float4 color : register(c14);
| |
− | float4 ambient : register(c15);
| |
− |
| |
− | struct a2v
| |
− | {
| |
− | float4 pos : POSITION;
| |
− | float3 normal : NORMAL;
| |
− | float2 txcoord : TEXCOORD0;
| |
− | float2 tangent : TEXCOORD1;
| |
− | };
| |
− |
| |
− | struct v2f
| |
− | {
| |
− | float4 hpos : POSITION;
| |
− | float4 color : COLOR0;
| |
− | float4 ambient : COLOR1;
| |
− | float2 txcoord : TEXCOORD0;
| |
− | float3 lightDir0: TEXCOORD1;
| |
− | float3 lightDir1: TEXCOORD2;
| |
− | float3 lightDir2: TEXCOORD3;
| |
− | float3 lightCol0: TEXCOORD4;
| |
− | float3 lightCol1: TEXCOORD5;
| |
− | float3 lightCol2: TEXCOORD6;
| |
− | float3 normal : TEXCOORD7;
| |
− | };
| |
− |
| |
− | v2f VertexMain(a2v IN)
| |
− | {
| |
− | v2f OUT;
| |
− |
| |
− | // vertex position in object space
| |
− | float4 pos = float4(IN.pos.x,IN.pos.y,IN.pos.z,1.0);
| |
− |
| |
− | // vertex position in clip space
| |
− | OUT.hpos = mul(pos, modelviewproj);
| |
− |
| |
− | float3 tangent = float3(IN.tangent.x, IN.tangent.y, 0);
| |
− |
| |
− | // compute binormal
| |
− | float3 binormal = normalize(cross(IN.normal, tangent));
| |
− |
| |
− | // tangent space matrix
| |
− | float3x3 tbn = float3x3(tangent, binormal, IN.normal);
| |
− |
| |
− | // light direction in object space
| |
− | float3 lt0 = mul(lightDir0, (float3x3)modelviewInv);
| |
− | float3 lt1 = mul(lightDir1, (float3x3)modelviewInv);
| |
− | float3 lt2 = mul(lightDir2, (float3x3)modelviewInv);
| |
− |
| |
− | // light 0 direction in tangent space
| |
− | OUT.lightDir0 = normalize(mul(tbn, lt0));
| |
− | OUT.lightDir1 = normalize(mul(tbn, lt1));
| |
− | OUT.lightDir2 = normalize(mul(tbn, lt2));
| |
− |
| |
− | OUT.lightCol0 = lightCol0;
| |
− | OUT.lightCol1 = lightCol1;
| |
− | OUT.lightCol2 = lightCol2;
| |
− |
| |
− | // copy texture coordinates
| |
− | OUT.txcoord=IN.txcoord.xy;
| |
− | OUT.color = color;
| |
− | OUT.color.a = 1;
| |
− |
| |
− | OUT.ambient = ambient;
| |
− | OUT.normal = IN.normal;
| |
− |
| |
− | return OUT;
| |
− | }
| |
− |
| |
− | endShaderSource
| |
− | end # end shader program
| |
− |
| |
− | shaderProgram -target pixelProgram -method compile -version 1_4 #-disassemble "c:\sims2ep3\hlslPS.txt"
| |
− |
| |
− | shaderSource
| |
− | sampler texmap;
| |
− | sampler normmap;
| |
− | sampler roofnoise;
| |
− |
| |
− | struct v2f
| |
− | {
| |
− | float4 hpos : POSITION;
| |
− | float4 color : COLOR0;
| |
− | float4 ambient : COLOR1;
| |
− | float2 txcoord : TEXCOORD0;
| |
− | float3 lightDir0: TEXCOORD1;
| |
− | float3 lightDir1: TEXCOORD2;
| |
− | float3 lightDir2: TEXCOORD3;
| |
− | float3 lightCol0: TEXCOORD4;
| |
− | float3 lightCol1: TEXCOORD5;
| |
− | //float3 lightCol2: TEXCOORD6;
| |
− | //float3 normal : TEXCOORD7;
| |
− | };
| |
− |
| |
− | float4 PixelMain(v2f pi) : COLOR
| |
− | {
| |
− | // normal map
| |
− | float4 normal = tex2D(normmap, pi.txcoord);
| |
− |
| |
− | //bump.xyz = 4.0 * (bump.xyz - (0.5).xxx);
| |
− | // bump.z = pi.normal.z;
| |
− | //float3 normal = normalize(bump);
| |
− |
| |
− | // color map
| |
− | float4 color = tex2D(texmap, pi.txcoord);
| |
− |
| |
− | float diff0 = saturate(dot(pi.lightDir0, normal.xyz));
| |
− | //float diff1 = saturate(dot(pi.lightDir1, normal.xyz));
| |
− | //float diff2 = saturate(dot(pi.lightDir2, normal.xyz));
| |
− |
| |
− | float4 finalColor;
| |
− | finalColor.rgb = diff0;//(diff0*pi.lightCol0 + diff1*pi.lightCol1 + diff2 + pi.ambient)*pi.color.rgb*color.rgb;
| |
− |
| |
− | finalColor.a = 1.0;
| |
− | return finalColor;
| |
− | }
| |
− | endShaderSource
| |
− | end
| |
− |
| |
− |
| |
− | sampler normmap
| |
− | texture "roof-manor-test-bump"#$stdMatNormalMapTextureName
| |
− | textureAddressing clamp clamp clamp
| |
− | end
| |
− |
| |
− | sampler 1#texmap
| |
− | texture $stdMatBaseTextureName
| |
− | textureAddressing clamp clamp clamp
| |
− | end
| |
− | end # end pass
| |
− |
| |
− | end #end shader
| |
− | end # end material
| |
− | enddef
| |
− |
| |
− | define RoofSnow()
| |
− | material
| |
− | shader -layer 2
| |
− | validateRenderShaderContext -vertexFormat position 0 required
| |
− | validateRenderShaderContext -vertexFormat normal 0 required
| |
− | validateRenderShaderContext -vertexFormat texcoord 0 required
| |
− | validateRenderShaderContext -vertexFormat texcoord 1 required
| |
− |
| |
− | pass
| |
− | alphaBlend srcFactor(srcAlpha) add dstFactor(invSrcAlpha)
| |
− | cullmode $stdMatCullMode
| |
− | #fillmode wireframe
| |
− |
| |
− | shaderProgram -target vertexProgram -method compile -version 2_0
| |
− | bindConstants 0 -bindingID geomToClip -constantCount 4
| |
− | bindConstants 4 -bindingID geomToCamera -constantCount 3
| |
− | bindConstants 7 -bindingID cameraToGeom -constantCount 3
| |
− | bindConstants 15 -bindingID ambientLight -constantCount 1 -constantType float
| |
− | bindConstants 18 -bindingID allStandardLightData -constantCount 4 -constantType float
| |
− |
| |
− | shaderSource
| |
− | float4x4 modelviewproj : register(c0);
| |
− | float4x3 modelview : register(c4);
| |
− | float4x3 modelviewInv : register(c7);
| |
− | // light direction
| |
− | float4 lightDir0 : register(c18);
| |
− |
| |
− | float4 ambient : register(c15);
| |
− |
| |
− | struct a2v
| |
− | {
| |
− | float4 pos : POSITION;
| |
− | float3 normal : NORMAL;
| |
− | float2 tangent : TEXCOORD0;
| |
− | };
| |
− |
| |
− | struct v2f
| |
− | {
| |
− | float4 hpos : POSITION;
| |
− | float4 color : TEXCOORD0;
| |
− | float3 camNormal : TEXCOORD1;
| |
− | float3 lightDir : TEXCOORD2;
| |
− | float3 R : TEXCOORD3;
| |
− | float3 tanLightDir : TEXCOORD4;
| |
− | float2 bumpCoords : TEXCOORD5;
| |
− | };
| |
− |
| |
− | v2f VertexMain(a2v IN)
| |
− | {
| |
− | v2f OUT;
| |
− |
| |
− | // vertex position in object space
| |
− | float4 pos = float4(IN.pos.x,IN.pos.y,IN.pos.z,1.0);
| |
− |
| |
− | float3 tangent = float3(IN.tangent.x, IN.tangent.y, 0);
| |
− |
| |
− | // compute binormal
| |
− | float3 binormal = normalize(cross(IN.normal, tangent));
| |
− |
| |
− | // tangent space matrix
| |
− | float3x3 tbn = float3x3(tangent, binormal, IN.normal);
| |
− |
| |
− | // light direction in object space
| |
− | float3 lt0 = mul(lightDir0, (float3x3)modelviewInv);
| |
− |
| |
− | // light 0 direction in tangent space
| |
− | OUT.tanLightDir = normalize(mul(tbn, lt0));
| |
− | OUT.bumpCoords = float2(IN.pos.x, IN.pos.y);
| |
− |
| |
− |
| |
− |
| |
− | // vertex position in clip space
| |
− | OUT.hpos = mul(pos, modelviewproj);
| |
− |
| |
− | // copy texture coordinates
| |
− | OUT.camNormal = mul(IN.normal, (float3x3)modelview);
| |
− |
| |
− | float3 cameraSpacePosition = mul( pos, modelview);
| |
− | float3 viewVector = normalize(cameraSpacePosition);
| |
− | OUT.R = reflect(viewVector, OUT.camNormal);
| |
− |
| |
− | OUT.color.xyz = tangent*0.5f.xxx + 0.5f.xxx;//ambient.xyz;
| |
− | OUT.color.w = 1.0;
| |
− | OUT.lightDir.xyz = lightDir0.xyz;
| |
− | return OUT;
| |
− | }
| |
− |
| |
− | endShaderSource
| |
− | end # end shader program
| |
− |
| |
− | shaderProgram -target pixelProgram -method compile -version 2_0 # -disassemble "c:\sims2ep3\hlslPS.txt"
| |
− | shaderSource
| |
− |
| |
− | struct v2f
| |
− | {
| |
− | float4 hpos : POSITION;
| |
− | float4 color : TEXCOORD0;
| |
− | float3 camNormal : TEXCOORD1;
| |
− | float3 lightDir : TEXCOORD2;
| |
− | float3 R : TEXCOORD3;
| |
− | float3 tanLightDir : TEXCOORD4;
| |
− | float2 bumpCoords : TEXCOORD5;
| |
− | };
| |
− |
| |
− | float4 PixelMain(v2f pi) : COLOR
| |
− | {
| |
− | return pi.color;
| |
− | //return float4(0, 0, 0, 1) + 0.8*max(dot(pi.camNormal, pi.lightDir), 0).xxxx + pi.color;
| |
− | }
| |
− | endShaderSource
| |
− | end
| |
− |
| |
− |
| |
− | end # end pass
| |
− |
| |
− | end #end shader
| |
− | end # end material
| |
− | enddef
| |
− |
| |
− | define RoofSnowPS2()
| |
− | shaderProgram -target pixelProgram -method compile -version 2_0 # -disassemble "c:\sims2ep5\hlslPS.txt"
| |
− | bindConstants 0 -bindingID ambientLight -constantCount 1 -constantType float
| |
| | | |
− | shaderSource | + | shader -layer 6 |
− | float3 ambientLight : register(c0); | + | validateRenderShaderContext -viewerRenderType $kRenderTypeNormal |
− | | + | pass -modifiedEachFrameHint |
− | sampler normmap;
| + | shaderProgram -target vertexProgram -method assemble |
− | struct v2f
| + | bindConstants 0 -bindingID geomToClip -constantCount 4 |
− | {
| + | bindConstants 4 -bindingID clipToViewTarget -constantCount 4 |
− | float4 hpos : POSITION;
| + | shaderSource |
− | float4 color : COLOR0;
| + | vs_1_1 |
− | float4 tanHalfAngle : TEXCOORD0;
| + | dcl_position v0 |
− | float3 lightColor : TEXCOORD1;
| + | def c8, -0.5, -0.5, 1, 1 |
− | float3 tanLightDir : TEXCOORD2;
| + | def c9, 0.5, 0.5, 0, 0 |
− | float2 bumpCoords : TEXCOORD3;
| + | def c10, 0.25, 0.25, 0, 0 |
− | };
| + | m4x4 r0, v0, c0 |
| + | mov oPos, r0 |
| + | mul r2, c9, r0.w |
| + | mad r4, r0, c8, r2 |
| + | rcp r3.x, c4.x |
| + | rcp r3.y, c5.y |
| + | mov r3.zw, c9.zw |
| + | mul r3, r3, c10 |
| + | mad r1, r0, r3, r4 |
| + | rcp r1.w, r1.w |
| + | mul oT0.xy, r1.w, r1.xy |
| + | endShaderSource |
| + | end |
| | | |
− | float4 PixelMain(v2f pi) : COLOR
| |
− | {
| |
− | float4 normal0 = 2.0f * (tex2D(normmap, pi.bumpCoords) - 0.5f);
| |
− | float4 normal1 = 2.0f * (tex2D(normmap, pi.bumpCoords*0.4) - 0.5f);
| |
− | float4 normal = 0.5f*(normal0+normal1);
| |
− |
| |
− | float diffuse = saturate(dot(pi.tanLightDir, normal.xyz))*0.6f;
| |
− | return float4(float3(diffuse.xxx*float3(0.9,0.9,1) + ambientLight.xxx*0.8)*pi.lightColor.xyz, 1.0);
| |
− | }
| |
− | endShaderSource
| |
− | end
| |
− |
| |
− | enddef
| |
− |
| |
− | define RoofSnowPS1()
| |
− | shaderProgram -target pixelProgram -method compile -version 1_1 # -disassemble "c:\sims2ep5\hlslPS.txt"
| |
− | bindConstants 0 -bindingID ambientLight -constantCount 1 -constantType float
| |
− |
| |
− | shaderSource
| |
− | float3 ambientLight : register(c0);
| |
− |
| |
− | sampler normmap;
| |
− | struct v2f
| |
− | {
| |
− | float4 hpos : POSITION;
| |
− | float4 color : COLOR0;
| |
− | float4 tanHalfAngle : TEXCOORD0;
| |
− | float3 lightColor : TEXCOORD1;
| |
− | float3 tanLightDir : TEXCOORD2;
| |
− | float2 bumpCoords : TEXCOORD3;
| |
− | };
| |
− |
| |
− | float4 PixelMain(v2f pi) : COLOR
| |
− | {
| |
− | float4 normal = 2.0f * (tex2D(normmap, pi.bumpCoords) - 0.5f);
| |
− | float diffuse = saturate(dot(pi.tanLightDir, normal.xyz))*0.57f;
| |
− | return float4(float3(diffuse.xxx*float3(0.85,0.85,1) + ambientLight.xxx)*pi.lightColor.xyz, 1.0);
| |
− | }
| |
− | endShaderSource
| |
− | end
| |
− | enddef
| |
− |
| |
− | define RoofSnow2()
| |
− | material
| |
− | shader -layer -2
| |
− | validateRenderShaderContext -vertexFormat position 0 required
| |
− | validateRenderShaderContext -vertexFormat normal 0 required
| |
− | validateRenderShaderContext -vertexFormat texcoord 0 required
| |
− | validateRenderShaderContext -vertexFormat texcoord 1 required
| |
− |
| |
− | pass
| |
| alphaBlend srcFactor(srcAlpha) add dstFactor(invSrcAlpha) | | alphaBlend srcFactor(srcAlpha) add dstFactor(invSrcAlpha) |
− | cullmode $stdMatCullMode | + | depthTest true -enableDepthWrite false |
− | #fillmode wireframe | + | colorScalar (0,0,0) 0.25 |
− |
| + | |
− | shaderProgram -target vertexProgram -method compile -version 1_1
| + | |
− | bindConstants 0 -bindingID geomToClip -constantCount 4
| + | |
− | bindConstants 4 -bindingID geomToCamera -constantCount 3
| + | |
− | bindConstants 7 -bindingID cameraToGeom -constantCount 3
| + | |
− | bindConstants 15 -bindingID ambientLight -constantCount 1 -constantType float
| + | |
− | bindConstants 18 -bindingID allStandardLightData -constantCount 4 -constantType float
| + | |
− |
| + | |
− | if (tsIsDay)
| + | |
− | bindConstants 10 -bindingID immediateData -data (1, 1, 1, 1)
| + | |
− | else
| + | |
− | bindConstants 10 -bindingID immediateData -data (0.47, 0.47, 1.2, 1)
| + | |
− | endif
| + | |
− |
| + | |
− | shaderSource
| + | |
− | float4x4 modelviewproj : register(c0);
| + | |
− | float4x3 modelview : register(c4);
| + | |
− | float4x3 modelviewInv : register(c7);
| + | |
− | // light direction
| + | |
− | float4 lightDir0 : register(c18);
| + | |
− | float4 lightColor0 : register(c10);
| + | |
− |
| + | |
− |
| + | |
− | float4 ambient : register(c15);
| + | |
− |
| + | |
− | struct a2v
| + | |
− | {
| + | |
− | float4 pos : POSITION;
| + | |
− | float3 normal : NORMAL;
| + | |
− | float2 tangent : TEXCOORD0;
| + | |
− | float2 bumpcoord : TEXCOORD1;
| + | |
− | };
| + | |
| | | |
− | struct v2f
| + | stage |
− | {
| + | textureAddressing clamp clamp |
− | float4 hpos : POSITION;
| + | texture $reflectionRenderTarget |
− | float4 color : COLOR0;
| + | textureBlend select(texture) select(colorScalar) |
− | float4 tanHalfAngle : TEXCOORD0;
| + | |
− | float3 lightColor : TEXCOORD1;
| + | |
− | float3 tanLightDir : TEXCOORD2;
| + | |
− | float2 bumpCoords : TEXCOORD3;
| + | |
− | };
| + | |
− |
| + | |
− | v2f VertexMain(a2v IN)
| + | |
− | {
| + | |
− | v2f OUT;
| + | |
− | | + | |
− | // vertex position in object space
| + | |
− | float4 pos = float4(IN.pos.x,IN.pos.y,IN.pos.z,1.0);
| + | |
− |
| + | |
− | float3 tangent = float3(IN.tangent.x, IN.tangent.y, 0);
| + | |
− |
| + | |
− | // compute binormal
| + | |
− | float3 binormal = normalize(cross(IN.normal, tangent));
| + | |
− |
| + | |
− | // tangent space matrix
| + | |
− | float3x3 tbn = float3x3(tangent, binormal, IN.normal);
| + | |
− |
| + | |
− | // light direction in object space
| + | |
− | float3 lt0 = mul(lightDir0, (float3x3)modelviewInv);
| + | |
− |
| + | |
− | // light 0 direction in tangent space
| + | |
− | OUT.tanLightDir = normalize(mul(tbn, lt0));
| + | |
− | OUT.bumpCoords = float2(IN.bumpcoord.x, IN.bumpcoord.y);
| + | |
− |
| + | |
− | // compute tangent space view vector
| + | |
− | // object space view point
| + | |
− | float3 viewPoint = mul(float4(0, 0, 0, 1), modelviewInv).xyz;
| + | |
− | float3 viewVecObj = normalize(viewPoint - IN.pos.xyz);
| + | |
− |
| + | |
− | // object space light
| + | |
− | float3 lightDirObj = normalize(mul(lightDir0, (float3x3)modelviewInv));
| + | |
− |
| + | |
− | // half angle vector in object space
| + | |
− | float3 halfWayVector = normalize(lightDirObj + viewVecObj);
| + | |
− |
| + | |
− | // transform half angle vector to tangent space
| + | |
− | OUT.tanHalfAngle.xyz = normalize(mul(tbn, halfWayVector));
| + | |
− |
| + | |
− | // specular shadowing term
| + | |
− | OUT.tanHalfAngle.w = max(dot(halfWayVector, IN.normal), 0);
| + | |
− |
| + | |
− | // vertex position in clip space
| + | |
− | OUT.hpos = mul(pos, modelviewproj);
| + | |
− |
| + | |
− | OUT.color.xyz = ambient.xyz;
| + | |
− | OUT.color.w = 1.0;
| + | |
− | OUT.lightColor = lightColor0.xyz;
| + | |
− | return OUT;
| + | |
− | }
| + | |
− |
| + | |
− | endShaderSource
| + | |
− | end # end shader program | + | |
− | | + | |
− | if ($useHWShader1Path) | + | |
− | create RoofSnowPS1()
| + | |
− | else
| + | |
− | create RoofSnowPS2()
| + | |
− | endif
| + | |
− |
| + | |
− | sampler normmap
| + | |
− | texture "snow-ground-bump"
| + | |
− | textureAddressing tile tile
| + | |
− | end | + | |
− |
| + | |
− | end # end pass
| + | |
− |
| + | |
− | end #end shader
| + | |
− | end # end material
| + | |
− | enddef
| + | |
− | | + | |
− | | + | |
− | materialDefinition RoofPreview
| + | |
− | setDefinition StandardMaterial
| + | |
− | addParam stdMatSpecPower 0
| + | |
− | addParam stdMatDiffCoef (0.4, 0.385, 0.38)
| + | |
− | addParam stdMatBaseTextureName roof-manor
| + | |
− | addParam stdMatBaseTextureEnabled true
| + | |
− | addParam stdMatCullMode none
| + | |
− | end
| + | |
− | | + | |
− | | + | |
− | materialDefinition RoofUnder
| + | |
− | setDefinition StandardMaterial
| + | |
− | addParam stdMatSpecPower 0
| + | |
− | addParam stdMatDiffCoef (0.8, 0.8, 0.8)
| + | |
− | addParam stdMatBaseTextureName roof-manor-under
| + | |
− | addParam stdMatBaseTextureEnabled true
| + | |
− | addParam stdMatCullMode none
| + | |
− | end
| + | |
− | | + | |
− | materialDefinition RoofTrim
| + | |
− | setDefinition StandardMaterial
| + | |
− | addParam stdMatSpecPower 0
| + | |
− | addParam stdMatDiffCoef (0.8, 0.8, 0.8)
| + | |
− | addParam stdMatBaseTextureName roof-manor-trim
| + | |
− | addParam stdMatBaseTextureEnabled true
| + | |
− | addParam stdMatCullMode none
| + | |
− | end
| + | |
− | | + | |
− | materialDefinition RoofPreviewTopBoundary
| + | |
− | setDefinition RoofPreviewMaterialTopBoundary
| + | |
− | end
| + | |
− | | + | |
− | define RoofTopMaterial()
| + | |
− | material
| + | |
− | shader -layer 0
| + | |
− | seti snowLevel tsHasSnow
| + | |
− | seti rainLevel tsHasRain
| + | |
− |
| + | |
− | if ($rainLevel >= 1)
| + | |
− | pass -fixedFunction -modifiedEachFrameHint
| + | |
− | else
| + | |
− | pass -fixedFunction
| + | |
− | endif
| + | |
− | setb doSkinning false
| + | |
− | setb doMorphing false
| + | |
− | setb cutoutPass false
| + | |
− | create CommonStandardMaterialSetup()
| + | |
− |
| + | |
− | stage
| + | |
− | create StandardShaderTextureState(Base)
| + | |
− | textureBlend multiplyScale2(texture outRegister) multiply(texture outRegister)
| + | |
− | end
| + | |
− |
| + | |
− | if ($rainLevel >= 1)
| + | |
− | # first pass at roof rain stage
| + | |
− | stage | + | |
− | ffTextureCoordsSource 0
| + | |
− | texture "causticstiled"
| + | |
− | textureMatrixAnimation -targetType fixedFunction -atrans sawtooth .1 0 (0,1) (0,0)
| + | |
− | colorScalar (1.0, 0.98, 1.0, .9)
| + | |
− | textureAddressing tile tile
| + | |
− | textureBlend lerpColorScalarAlpha(outRegister texture) lerpColorScalarAlpha(colorScalar)
| + | |
− | end
| + | |
− | endif
| + | |
− |
| + | |
| end | | end |
− | | + | |
− | if ($snowLevel = 1 and viewerRenderType != $kRenderTypeImposter)
| + | |
− | pass -fixedFunction | + | |
− | alphaBlend srcFactor(srcAlpha) add dstFactor(invSrcAlpha)
| + | |
− | depthTest true -enableDepthWrite false
| + | |
− | depthTestFunction acceptIfLessOrEqual
| + | |
− | create LightingStates()
| + | |
− |
| + | |
− | colorScalar (0.25, 0.25, 0.35, 1)
| + | |
− |
| + | |
− | stage
| + | |
− | texture "snow-light-roof-pass1"
| + | |
− | ffTextureCoordsSource fromPosition
| + | |
− | ffTextureMatrix -cameraToGlobal -scalev (6, 6) -invert
| + | |
− | textureAddressing tile tile
| + | |
− | textureFilterHint bilinear bilinear
| + | |
− | textureBlend multiplyAdd(texture diffuse colorScalar) select(texture)
| + | |
− | end
| + | |
− | end
| + | |
− | endif
| + | |
− |
| + | |
− | end
| + | |
− | end
| + | |
− | enddef
| + | |
− | | + | |
− | define RoofSnowShader()
| + | |
− | create DetermineHardwareSupport()
| + | |
− | if (viewerRenderType != $kRenderTypeImposter)
| + | |
− | if ($useHWShader1Path or $useHWShader2Path)
| + | |
− | create RoofSnow2()
| + | |
− | else
| + | |
− | create RoofSnowFF()
| + | |
− | endif
| + | |
− | else
| + | |
− | create Null()
| + | |
− | endif
| + | |
− | enddef
| + | |
− | | + | |
− | define RoofSnowFF()
| + | |
− | material
| + | |
− | shader -layer 0
| + | |
− | pass -fixedFunction
| + | |
− | create LightingStates()
| + | |
− | create AttenuatedMatCoef(1)
| + | |
− |
| + | |
− | depthTest true -enableDepthWrite true
| + | |
− | colorScalar (1.0, 0.98, 1.0, 1)
| + | |
− |
| + | |
− | stage
| + | |
− | textureBlend multiply(colorScalar diffuse) select(texture)
| + | |
− | end #end stage
| + | |
| end | | end |
| end | | end |
− | end
| |
| enddef | | enddef |
| | | |
− | materialDefinition RoofSnowMaterial
| + | #---------------------------------------------------------------------------------------------------------------# |
− | setDefinition RoofSnowShader
| + | |
− | addParam stdMatCullMode none
| + | |
− | end
| + | |
− | | + | |
− | # texture, lit, normal mappedm, no specular | + | |
− | materialDefinition RoofTop
| + | |
− | setDefinition RoofTopMaterial
| + | |
− | addParam stdMatSpecPower 0
| + | |
− | addParam stdMatDiffCoef (0.4, 0.385, 0.38)
| + | |
− | addParam stdMatBaseTextureName roof-manor
| + | |
− | addParam stdMatBaseTextureEnabled true
| + | |
− | addParam stdMatBaseTextureAddressingU clamp
| + | |
− | addParam stdMatBaseTextureAddressingV clamp
| + | |
− | addParam stdMatBaseTextureAddressingW clamp
| + | |
− | addParam stdMatCullMode none
| + | |
− | end
| + | |
− | | + | |
− | | + | |
− | materialDefinition RoofEdges
| + | |
− | setDefinition StandardMaterial
| + | |
− | addParam stdMatSpecPower 0
| + | |
− | addParam stdMatDiffCoef (0.8, 0.8, 0.8)
| + | |
− | addParam stdMatBaseTextureName roof-manor-edges
| + | |
− | addParam stdMatBaseTextureEnabled true
| + | |
− | addParam stdMatCullMode none
| + | |
− | end
| + | |
− | | + | |
− | # texture, lit, normal mappedm, no specular
| + | |
− | materialDefinition RoofTopThumbnail
| + | |
− | setDefinition StandardMaterial
| + | |
− | addParam stdMatSpecPower 0
| + | |
− | addParam stdMatDiffCoef (0.8, 0.75, 0.75)
| + | |
− | addParam stdMatBaseTextureName roof-manor
| + | |
− | addParam stdMatBaseTextureEnabled true
| + | |
− | addParam stdMatNormalMapTextureName roof-manor-bump
| + | |
− | addParam stdMatNormalMapTextureEnabled true
| + | |
− | end
| + | |
− | | + | |
− | # 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
| + | |
− | end
| + | |
− | | + | |
− | ##############################################################
| + | |
− | # Roofs custom
| + | |
− | #
| + | |
− | | + | |
− | | + | |
− | define RoofMaterialFF()
| + | |
− | material
| + | |
− | shader -layer $roofLayer
| + | |
− | | + | |
− | pass -fixedFunction
| + | |
− |
| + | |
− | create LightingStates()
| + | |
− | create AttenuatedMatCoef(1)
| + | |
− |
| + | |
− | ffDepthOffset 2
| + | |
− |
| + | |
− | depthTest true -enableDepthWrite false
| + | |
− |
| + | |
− | stage
| + | |
− | texture $stdMatBaseTextureName
| + | |
− | textureAddressing clamp clamp
| + | |
− | ffTextureCoordsSource 0
| + | |
− | textureBlend multiply(texture diffuse) select(texture)
| + | |
− | end #end stage
| + | |
− | | + | |
− |
| + | |
− | end #pass
| + | |
− | end #end shader
| + | |
− | end #end material
| + | |
− | enddef
| + | |
| | | |
− | materialDefinition RoofMaterialStrips | + | materialDefinition transparent_mirror_reflection |
− | addParam stdMatBaseTextureName roof-manor
| + | setDefinition TransparentMirrorReflection |
− | addParam stdMatDiffCoef (0.4, 0.385, 0.38)
| + | |
− | addParam stdMatSpecPower 0
| + | |
− | addParam stdMatEmissiveCoef 0,0,0
| + | |
− | addParam stdMatSpecCoef 0,0,0
| + | |
− | addParam roofLayer 2
| + | |
− | setDefinition RoofMaterialFF | + | |
| end | | end |