Difference between revisions of "TEST-STRCMP4CODES"
(pool5) |
(hlsl) |
||
| Line 1: | Line 1: | ||
| − | shaderProgram -target | + | pass -clipAlways -modifiedEachFrameHint |
| − | + | #fillmode wireframe | |
| − | + | alphaBlend srcFactor(one) add dstFactor(one) | |
| − | + | seti textureLights (numLightsOfType(environmentCube)) | |
| − | + | ||
| − | + | shaderProgram -target vertexProgram -method compile -version 1_1 | |
| − | + | ||
| − | + | bindConstants 0 -bindingID geomToClip -constantCount 4 | |
| − | + | bindConstants 4 -bindingID geomToCamera -constantCount 3 | |
| − | + | ||
| − | + | bindConstants 7 -bindingID frameInfo | |
| − | + | ||
| − | + | bindConstants 11 -bindingID immediateData -data ($wmXRepeat, 0, $wmXWaveHeight, $wmXSpeed) | |
| − | + | bindConstants 12 -bindingID immediateData -data (0, $wmYRepeat, $wmYWaveHeight, $wmYSpeed) | |
| + | |||
| + | # pre-evaluate these | ||
| + | setf xscale (-$wmXRepeat * $wmXWaveHeight) | ||
| + | setf yscale (-$wmYRepeat * $wmYWaveHeight) | ||
| + | bindConstants 13 -bindingID immediateData -data ($xscale,$yscale, 1,0) | ||
| + | bindConstants 14 -bindingID allStandardLightData -constantCount 4 -constantType float | ||
| + | bindConstants 18 -bindingID cameraToGlobal -constantCount 3 | ||
| + | |||
| + | if (tsIsDay) | ||
| + | bindConstants 25 -bindingID immediateData -data (0.75, 0.75, 0.75, 1) | ||
| + | else | ||
| + | bindConstants 25 -bindingID immediateData -data (0.2, 0.2, 0.2, 1) | ||
| + | endif | ||
| + | |||
| + | shaderSource | ||
| + | |||
| + | float4 frameInfo : register(c7); | ||
| + | float4 waveDataX : register(c11); | ||
| + | float4 waveDataY : register(c12); | ||
| + | float4 waveDataHelper : register(c13); | ||
| + | float4x4 clipSpaceMatrix : register(c0); | ||
| + | float4x3 cameraSpaceMatrix : register(c4); | ||
| + | float4x3 cameraToGlobalMatrix : register(c18); | ||
| + | |||
| + | float4 nightColor: register(c25); | ||
| − | + | float4 lightDirection : register(c14); | |
| − | + | float4 lightColor : register(c15); | |
| − | + | const static float4 refractionWeights={1,1,2,0}; | |
| − | + | ||
| + | const static float4 layerBlue={0.3, 0.7, 1.0, 1}; | ||
| + | |||
| + | struct InputVertex | ||
| + | { | ||
| + | float3 position: POSITION0; | ||
| + | float3 normal : NORMAL0; | ||
| + | }; | ||
| + | |||
| + | struct OutputVertex | ||
| + | { | ||
| + | float4 clipPosition : POSITION; | ||
| + | float4 diffuseColor: COLOR0; | ||
| + | float4 specularColor: COLOR1; | ||
| + | float3 reflection : TEXCOORD0; | ||
| + | |||
| + | }; | ||
| − | + | ||
| − | + | ||
| − | + | OutputVertex VertexMain( InputVertex inputVertex) | |
| + | { | ||
| + | // Do Y-direction waves | ||
| + | // r0 = (x, y, z, t) | ||
| + | |||
| + | OutputVertex outputVertex; | ||
| + | |||
| + | float4 posAndTime; | ||
| + | posAndTime.xyz = inputVertex.position; | ||
| + | posAndTime.w = frameInfo.w; | ||
| + | |||
| + | float temp = dot(posAndTime, waveDataX); | ||
| + | |||
| + | // z = h * sin(...) | ||
| − | + | float z; | |
| − | + | // scale temp to fit -pi +pi range | |
| − | + | //temp = temp * (1 / (2 * 3.14159)) + 0.5; | |
| − | + | ||
| − | + | float3 waveNormal; | |
| − | + | ||
| − | + | z = sin(temp) * waveDataX.z + inputVertex.position.z; | |
| − | + | ||
| − | + | waveNormal.x = cos(temp) * waveDataHelper.x + inputVertex.normal.x; | |
| − | + | ||
| − | + | temp = dot(posAndTime, waveDataY); | |
| − | + | //temp = temp * (1 / (2 * 3.14159)) + 0.5; | |
| − | + | ||
| − | + | z += sin(temp) * waveDataY.z; | |
| − | + | ||
| − | + | waveNormal.y = cos(temp) * waveDataHelper.y + inputVertex.normal.y; | |
| − | + | ||
| − | + | waveNormal.z = inputVertex.normal.z; | |
| − | + | ||
| − | + | waveNormal = normalize(waveNormal); | |
| − | + | ||
| − | + | posAndTime.w = 1.0; | |
| − | + | posAndTime.z = z; | |
| − | + | ||
| + | outputVertex.clipPosition = mul( posAndTime, clipSpaceMatrix); | ||
| + | |||
| + | float3 cameraSpaceNormal = normalize(mul(waveNormal, cameraSpaceMatrix)); | ||
| + | |||
| + | float3 cameraSpacePosition = mul( posAndTime, cameraSpaceMatrix); | ||
| + | |||
| + | float3 viewVector = normalize(-cameraSpacePosition); | ||
| + | |||
| + | float3 R = reflect(viewVector, cameraSpaceNormal); | ||
| + | |||
| + | outputVertex.reflection = mul( -R, cameraToGlobalMatrix); | ||
| + | |||
| + | |||
| + | float fresnel = dot(viewVector , cameraSpaceNormal); | ||
| + | |||
| + | float rdotl = saturate(dot(R, lightDirection)); | ||
| + | |||
| + | float I = pow(rdotl+0.1, 15); // fudge factor to punch up the highlights. | ||
| + | |||
| + | nightColor = nightColor * 2; | ||
| + | |||
| + | outputVertex.diffuseColor = ((1.0 - fresnel) * saturate(nightColor) * 0.5) * layerBlue; | ||
| + | |||
| + | outputVertex.specularColor = I; | ||
| + | return(outputVertex); | ||
| + | |||
| + | } | ||
| + | |||
| + | |||
| + | endShaderSource | ||
| + | end # shaderProgram | ||
| + | |||
| + | stage | ||
| + | texture $wmReflectionTexture | ||
| + | textureAddressing clamp clamp clamp | ||
| + | textureBlend multiply(texture diffuse) select(diffuse) | ||
| + | end | ||
| − | |||
| − | |||
| − | |||
| − | |||
| − | + | addSpecular true | |
| − | + | ||
| − | + | ||
| − | + | ||
| − | + | ||
end # end pass | end # end pass | ||
| − | + | ||
| + | |||
enddef | enddef | ||
Revision as of 06:58, 24 June 2009
pass -clipAlways -modifiedEachFrameHint #fillmode wireframe alphaBlend srcFactor(one) add dstFactor(one)
seti textureLights (numLightsOfType(environmentCube))
shaderProgram -target vertexProgram -method compile -version 1_1
bindConstants 0 -bindingID geomToClip -constantCount 4 bindConstants 4 -bindingID geomToCamera -constantCount 3
bindConstants 7 -bindingID frameInfo
bindConstants 11 -bindingID immediateData -data ($wmXRepeat, 0, $wmXWaveHeight, $wmXSpeed) bindConstants 12 -bindingID immediateData -data (0, $wmYRepeat, $wmYWaveHeight, $wmYSpeed)
# pre-evaluate these setf xscale (-$wmXRepeat * $wmXWaveHeight) setf yscale (-$wmYRepeat * $wmYWaveHeight) bindConstants 13 -bindingID immediateData -data ($xscale,$yscale, 1,0) bindConstants 14 -bindingID allStandardLightData -constantCount 4 -constantType float bindConstants 18 -bindingID cameraToGlobal -constantCount 3
if (tsIsDay)
bindConstants 25 -bindingID immediateData -data (0.75, 0.75, 0.75, 1)
else
bindConstants 25 -bindingID immediateData -data (0.2, 0.2, 0.2, 1)
endif
shaderSource
float4 frameInfo : register(c7); float4 waveDataX : register(c11); float4 waveDataY : register(c12); float4 waveDataHelper : register(c13); float4x4 clipSpaceMatrix : register(c0); float4x3 cameraSpaceMatrix : register(c4); float4x3 cameraToGlobalMatrix : register(c18);
float4 nightColor: register(c25);
float4 lightDirection : register(c14); float4 lightColor : register(c15); const static float4 refractionWeights={1,1,2,0};
const static float4 layerBlue={0.3, 0.7, 1.0, 1};
struct InputVertex { float3 position: POSITION0; float3 normal : NORMAL0; };
struct OutputVertex { float4 clipPosition : POSITION; float4 diffuseColor: COLOR0; float4 specularColor: COLOR1; float3 reflection : TEXCOORD0;
};
OutputVertex VertexMain( InputVertex inputVertex) { // Do Y-direction waves // r0 = (x, y, z, t)
OutputVertex outputVertex;
float4 posAndTime; posAndTime.xyz = inputVertex.position; posAndTime.w = frameInfo.w;
float temp = dot(posAndTime, waveDataX);
// z = h * sin(...)
float z; // scale temp to fit -pi +pi range //temp = temp * (1 / (2 * 3.14159)) + 0.5;
float3 waveNormal;
z = sin(temp) * waveDataX.z + inputVertex.position.z;
waveNormal.x = cos(temp) * waveDataHelper.x + inputVertex.normal.x;
temp = dot(posAndTime, waveDataY); //temp = temp * (1 / (2 * 3.14159)) + 0.5;
z += sin(temp) * waveDataY.z;
waveNormal.y = cos(temp) * waveDataHelper.y + inputVertex.normal.y;
waveNormal.z = inputVertex.normal.z;
waveNormal = normalize(waveNormal);
posAndTime.w = 1.0; posAndTime.z = z;
outputVertex.clipPosition = mul( posAndTime, clipSpaceMatrix);
float3 cameraSpaceNormal = normalize(mul(waveNormal, cameraSpaceMatrix));
float3 cameraSpacePosition = mul( posAndTime, cameraSpaceMatrix);
float3 viewVector = normalize(-cameraSpacePosition);
float3 R = reflect(viewVector, cameraSpaceNormal);
outputVertex.reflection = mul( -R, cameraToGlobalMatrix);
float fresnel = dot(viewVector , cameraSpaceNormal);
float rdotl = saturate(dot(R, lightDirection));
float I = pow(rdotl+0.1, 15); // fudge factor to punch up the highlights.
nightColor = nightColor * 2;
outputVertex.diffuseColor = ((1.0 - fresnel) * saturate(nightColor) * 0.5) * layerBlue;
outputVertex.specularColor = I; return(outputVertex);
}
endShaderSource
end # shaderProgram
stage texture $wmReflectionTexture textureAddressing clamp clamp clamp textureBlend multiply(texture diffuse) select(diffuse) end
addSpecular true
end # end pass
enddef