1: //--------------------------------------------------------------------------------------
2: // File: main.fx
3: //
4: //--------------------------------------------------------------------------------------
5:
6:
7: //--------------------------------------------------------------------------------------
8: // Global variables
9: //--------------------------------------------------------------------------------------
10: cbuffer cb0
11: {
12: float4 g_MaterialAmbientColor; // Material's ambient color
13: float4 g_MaterialDiffuseColor; // Material's diffuse color
14: float3 g_LightDir; // Light's direction in world space
15: float4 g_LightDiffuse; // Light's diffuse color
16:
17: float4x4 g_mWorld; // World matrix for object
18: float4x4 g_mWorldView; // World * View matrix
19: float4x4 g_mWorldViewProjection; // World * View * Projection matrix
20: }
21:
22: cbuffer cb1
23: {
24: float g_fZmin; //
25: float g_fZmid; //
26: float g_fZmax; //
27: float g_fBaseValue;
28: float g_fCompValue;// 0.00002 - 0.00002
29: }
30:
31: Texture2D g_MeshTexture; // Color texture for mesh
32:
33: //--------------------------------------------------------------------------------------
34: // Texture samplers
35: //--------------------------------------------------------------------------------------
36: SamplerState MeshTextureSampler
37: {
38: Filter = MIN_MAG_MIP_LINEAR;
39: AddressU = Wrap;
40: AddressV = Wrap;
41: };
42:
43: //--------------------------------------------------------------------------------------
44: // BlendState
45: //--------------------------------------------------------------------------------------
46: BlendState SrcAlphaBlending
47: {
48: AlphaToCoverageEnable = FALSE;
49: BlendEnable[0] = TRUE;
50: SrcBlend = SRC_ALPHA;
51: DestBlend = INV_SRC_ALPHA;
52: BlendOp = ADD;
53: SrcBlendAlpha = ZERO;
54: DestBlendAlpha = ZERO;
55: BlendOpAlpha = ADD;
56: RenderTargetWriteMask[0] = 0x0F;
57: };
58: BlendState DisableAlphaBlending
59: {
60: AlphaToCoverageEnable = FALSE;
61: BlendEnable[0] = FALSE;
62: RenderTargetWriteMask[0] = 0x0F;
63: };
64:
65: DepthStencilState DisableDepth
66: {
67: DepthEnable = FALSE;
68: DepthWriteMask = ZERO;
69: };
70:
71: DepthStencilState EnableDepth
72: {
73: DepthEnable = TRUE;
74: DepthWriteMask = ALL;
75: };
76:
77: DepthStencilState NoWriteDepth
78: {
79: DepthEnable = TRUE;
80: DepthWriteMask = ZERO;
81: };
82:
83: RasterizerState CullNone
84: {
85: FillMode = SOLID;
86: CullMode = NONE;
87: };
88:
89: //--------------------------------------------------------------------------------------
90: // Vertex shader output structure
91: //--------------------------------------------------------------------------------------
92: struct VS_OUTPUT
93: {
94: float4 Position : SV_Position; // vertex position
95: float4 Diffuse : COLOR0; // vertex diffuse color (note that COLOR0 is clamped from 0..1)
96: float2 TextureUV : TEXCOORD0; // vertex texture coords
97: };
98:
99: struct VS_OUTPUT_CLIPPING
100: {
101: float4 Position : SV_Position; // vertex position
102: float4 Diffuse : COLOR0; // vertex diffuse color (note that COLOR0 is clamped from 0..1)
103: float2 TextureUV : TEXCOORD0; // vertex texture coords
104: float1 depth : TEXCOORD1;
105: };
106:
107: //--------------------------------------------------------------------------------------
108: // This shader computes standard transform and lighting
109: //--------------------------------------------------------------------------------------
110: VS_OUTPUT RenderSceneVS( float4 vPos : POSITION,
111: float3 vNormal : NORMAL,
112: float2 vTexCoord0 : TEXCOORD0 )
113: {
114: VS_OUTPUT Output;
115: float3 vNormalWorldSpace;
116:
117: // Transform the position from object space to homogeneous projection space
118: Output.Position = mul(vPos, g_mWorldViewProjection);
119:
120: // Transform the normal from object space to world space
121: vNormalWorldSpace = normalize(mul(vNormal, (float3x3)g_mWorld)); // normal (world space)
122:
123: // Calc diffuse color
124: Output.Diffuse = g_MaterialDiffuseColor * g_LightDiffuse * max(0,dot(vNormalWorldSpace, g_LightDir)) +
125: g_MaterialAmbientColor;
126:
127: // Just copy the texture coordinate through
128: Output.TextureUV = vTexCoord0;
129:
130: return Output;
131: }
132:
133: //--------------------------------------------------------------------------------------
134: // This shader outputs the pixel's color by modulating the texture's
135: // color with diffuse material color
136: //--------------------------------------------------------------------------------------
137: float4 RenderScenePS( VS_OUTPUT In ) : SV_Target
138: {
139: // Lookup mesh texture and modulate it with diffuse
140: return g_MeshTexture.Sample(MeshTextureSampler, In.TextureUV) * In.Diffuse;
141: }
142:
143: //--------------------------------------------------------------------------------------
144: // Renders scene
145: //--------------------------------------------------------------------------------------
146: technique10 RenderScene
147: {
148: pass P0
149: {
150: SetVertexShader( CompileShader( vs_4_0, RenderSceneVS() ) );
151: SetGeometryShader( NULL );
152: SetPixelShader( CompileShader( ps_4_0, RenderScenePS() ) );
153:
154: SetBlendState( SrcAlphaBlending, float4( 0.0f, 0.0f, 0.0f, 0.0f ), 0xFFFFFFFF );
155: SetDepthStencilState( EnableDepth, 0 );
156: SetRasterizerState( CullNone );
157: }
158: }
159:
160: //--------------------------------------------------------------------------------------
161: // This shader computes standard transform and lighting
162: //--------------------------------------------------------------------------------------
163: VS_OUTPUT_CLIPPING RenderSceneClippingVS( float4 vPos : POSITION,
164: float3 vNormal : NORMAL,
165: float2 vTexCoord0 : TEXCOORD0 )
166: {
167: VS_OUTPUT_CLIPPING Output;
168: float3 vNormalWorldSpace;
169:
170: // Transform the position from object space to homogeneous projection space
171: Output.Position = mul(vPos, g_mWorldViewProjection);
172: Output.depth = Output.Position.w;
173:
174: // Transform the normal from object space to world space
175: vNormalWorldSpace = normalize(mul(vNormal, (float3x3)g_mWorld)); // normal (world space)
176:
177: // Calc diffuse color
178: Output.Diffuse = g_MaterialDiffuseColor * g_LightDiffuse * max(0,dot(vNormalWorldSpace, g_LightDir)) +
179: g_MaterialAmbientColor;
180:
181: // Just copy the texture coordinate through
182: Output.TextureUV = vTexCoord0;
183:
184: return Output;
185: }
186:
187: //--------------------------------------------------------------------------------------
188: // This shader outputs the pixel's color by modulating the texture's
189: // color with diffuse material color
190: //--------------------------------------------------------------------------------------
191: float4 RenderSceneClippingPS( VS_OUTPUT_CLIPPING In ) : SV_Target
192: {
193: clip(In.depth.x - g_fZmin );
194: clip(g_fZmax - In.depth.x );
195:
196: // Lookup mesh texture and modulate it with diffuse
197: return g_MeshTexture.Sample(MeshTextureSampler, In.TextureUV) * In.Diffuse;
198: }
199:
200: //--------------------------------------------------------------------------------------
201: // Renders scene with Clipping
202: //--------------------------------------------------------------------------------------
203: technique10 RenderSceneClipping
204: {
205: pass P0
206: {
207: SetVertexShader( CompileShader( vs_4_0, RenderSceneClippingVS() ) );
208: SetGeometryShader( NULL );
209: SetPixelShader( CompileShader( ps_4_0, RenderSceneClippingPS() ) );
210:
211: SetBlendState( SrcAlphaBlending, float4( 0.0f, 0.0f, 0.0f, 0.0f ), 0xFFFFFFFF );
212: SetDepthStencilState( EnableDepth, 0 );
213: SetRasterizerState( CullNone );
214: }
215: }
216:
217: //--------------------------------------------------------------------------------------
218: // Partial sort
219: //--------------------------------------------------------------------------------------
220: struct GS_SORT_IN
221: {
222: float3 Position : POSITION; // vertex position
223: float3 Normal : NORMAL; // vertex normal
224: float2 TextureUV : TEXCOORD0; // vertex texture coords
225: };
226:
227: GS_SORT_IN PartialSortVS( GS_SORT_IN input )
228: {
229: return input;
230: }
231:
232: GS_SORT_IN InterpolateVertex(GS_SORT_IN s0, GS_SORT_IN s1, float rate)
233: {
234: GS_SORT_IN output;
235:
236: output.Position = lerp(s0.Position, s1.Position, rate);
237: output.Normal = lerp(s0.Normal, s1.Normal, rate);
238: output.TextureUV = lerp(s0.TextureUV, s1.TextureUV, rate);
239:
240: return output;
241: }
242:
243: [maxvertexcount(6)]
244: void PartialSortFrontGS( triangle GS_SORT_IN input[3], inout TriangleStream<GS_SORT_IN> OutputStream )
245: {
246: #if 0
247: OutputStream.Append( input[0] );
248: OutputStream.Append( input[0] );
249: OutputStream.Append( input[0] );
250: #else
251: float z0 = mul(input[0].Position.xyz, (float3x3)g_mWorldView).z + g_mWorldView._43 - g_fZmid;
252: float z1 = mul(input[1].Position.xyz, (float3x3)g_mWorldView).z + g_mWorldView._43 - g_fZmid;
253: float z2 = mul(input[2].Position.xyz, (float3x3)g_mWorldView).z + g_mWorldView._43 - g_fZmid;
254:
255: if(z0 <= 0.0)
256: {
257: OutputStream.Append( input[0] );
258: if(z1 <= 0.0)
259: {
260: OutputStream.Append( input[1] );
261: if(z2 <= 0.0)
262: {
263: OutputStream.Append( input[2] );
264: }else{
265: OutputStream.Append( InterpolateVertex(input[1], input[2], z1/(z1-z2)) );
266:
267: OutputStream.RestartStrip();
268: OutputStream.Append( InterpolateVertex(input[1], input[2], z1/(z1-z2)) );
269: OutputStream.Append( InterpolateVertex(input[2], input[0], z2/(z2-z0)) );
270: OutputStream.Append( input[0] );
271: }
272: }else{
273: OutputStream.Append( InterpolateVertex(input[0], input[1], z0/(z0-z1)) );
274: if(z2 <= 0.0)
275: {
276: OutputStream.Append( InterpolateVertex(input[1], input[2], z1/(z1-z2)) );
277: OutputStream.RestartStrip();
278:
279: OutputStream.Append( input[0] );
280: OutputStream.Append( InterpolateVertex(input[1], input[2], z1/(z1-z2)) );
281: OutputStream.Append( input[2] );
282: }else{
283: OutputStream.Append( InterpolateVertex(input[2], input[0], z2/(z2-z0)) );
284: }
285: }
286: OutputStream.RestartStrip();
287: }else
288: if(z1 <= 0.0)
289: {
290: OutputStream.Append( InterpolateVertex(input[0], input[1], z0/(z0-z1)) );
291: OutputStream.Append( input[1] );
292: if(z2 <= 0.0)
293: {
294: OutputStream.Append( input[2] );
295: OutputStream.RestartStrip();
296:
297: OutputStream.Append( InterpolateVertex(input[0], input[1], z0/(z0-z1)) );
298: OutputStream.Append( input[2] );
299: OutputStream.Append( InterpolateVertex(input[2], input[0], z2/(z2-z0)) );
300: }else{
301: OutputStream.Append( InterpolateVertex(input[1], input[2], z1/(z1-z2)) );
302: }
303: OutputStream.RestartStrip();
304: }else
305: if(z2 <= 0.0)
306: {
307: OutputStream.Append( InterpolateVertex(input[1], input[2], z1/(z1-z2)) );
308: OutputStream.Append( input[2] );
309: OutputStream.Append( InterpolateVertex(input[2], input[0], z2/(z2-z0)) );
310: OutputStream.RestartStrip();
311: }else{
312: // OutputStream.Append( input[0] );
313: // OutputStream.Append( input[0] );
314: // OutputStream.Append( input[0] );
315: }
316: #endif
317: }
318:
319: [maxvertexcount(6)]
320: void PartialSortBackGS( triangle GS_SORT_IN input[3], inout TriangleStream<GS_SORT_IN> OutputStream )
321: {
322: #if 0
323: OutputStream.Append( input[0] );
324: OutputStream.Append( input[1] );
325: OutputStream.Append( input[2] );
326: #elif 0
327: float z0 = mul(input[0].Position.xyz, (float3x3)g_mWorldView).z + g_mWorldView._43 - g_fZmid;
328: float z1 = mul(input[1].Position.xyz, (float3x3)g_mWorldView).z + g_mWorldView._43 - g_fZmid;
329: float z2 = mul(input[2].Position.xyz, (float3x3)g_mWorldView).z + g_mWorldView._43 - g_fZmid;
330:
331: if(0 < z0 && 0 < z1 && 0 < z2)
332: {
333: OutputStream.Append( input[0] );
334: OutputStream.Append( input[1] );
335: OutputStream.Append( input[2] );
336: }else{
337: OutputStream.Append( input[0] );
338: OutputStream.Append( input[0] );
339: OutputStream.Append( input[0] );
340: }
341: #else
342: float z0 = mul(input[0].Position.xyz, (float3x3)g_mWorldView).z + g_mWorldView._43 - g_fZmid;
343: float z1 = mul(input[1].Position.xyz, (float3x3)g_mWorldView).z + g_mWorldView._43 - g_fZmid;
344: float z2 = mul(input[2].Position.xyz, (float3x3)g_mWorldView).z + g_mWorldView._43 - g_fZmid;
345:
346: if(0 < z0)
347: {
348: OutputStream.Append( input[0] );
349: if(0 < z1)
350: {
351: OutputStream.Append( input[1] );
352: if(0 < z2)
353: {
354: OutputStream.Append( input[2] );
355: }else{
356: OutputStream.Append( InterpolateVertex(input[1], input[2], z1/(z1-z2)) );
357: OutputStream.RestartStrip();
358:
359: OutputStream.Append( InterpolateVertex(input[1], input[2], z1/(z1-z2)) );
360: OutputStream.Append( InterpolateVertex(input[2], input[0], z2/(z2-z0)) );
361: OutputStream.Append( input[0] );
362: }
363: }else
364: {
365: OutputStream.Append( InterpolateVertex(input[0], input[1], z0/(z0-z1)) );
366: if(0 < z2)
367: {
368: OutputStream.Append( InterpolateVertex(input[1], input[2], z1/(z1-z2)) );
369: OutputStream.RestartStrip();
370:
371: OutputStream.Append( input[0] );
372: OutputStream.Append( InterpolateVertex(input[1], input[2], z1/(z1-z2)) );
373: OutputStream.Append( input[2] );
374: }else{
375: OutputStream.Append( InterpolateVertex(input[2], input[0], z2/(z2-z0)) );
376: }
377: }
378: OutputStream.RestartStrip();
379: }else
380: if(0 < z1)
381: {
382: OutputStream.Append( InterpolateVertex(input[0], input[1], z0/(z0-z1)) );
383: OutputStream.Append( input[1] );
384: if(0 < z2)
385: {
386: OutputStream.Append( input[2] );
387: OutputStream.RestartStrip();
388:
389: OutputStream.Append( InterpolateVertex(input[0], input[1], z0/(z0-z1)) );
390: OutputStream.Append( input[2] );
391: OutputStream.Append( InterpolateVertex(input[2], input[0], z2/(z2-z0)) );
392: }else{
393: OutputStream.Append( InterpolateVertex(input[1], input[2], z1/(z1-z2)) );
394: }
395: OutputStream.RestartStrip();
396: }else
397: if(0 < z2)
398: {
399: OutputStream.Append( InterpolateVertex(input[1], input[2], z1/(z1-z2)) );
400: OutputStream.Append( input[2] );
401: OutputStream.Append( InterpolateVertex(input[2], input[0], z2/(z2-z0)) );
402: OutputStream.RestartStrip();
403: }else{
404: // OutputStream.Append( input[0] );
405: // OutputStream.Append( input[0] );
406: // OutputStream.Append( input[0] );
407: }
408: #endif
409: }
410:
411: GeometryShader gsStreamOutFront = ConstructGSWithSO( CompileShader( gs_4_0, PartialSortFrontGS() ), "POSITION.xyz; NORMAL.xyz; TEXCOORD0.xy" );
412: GeometryShader gsStreamOutBack = ConstructGSWithSO( CompileShader( gs_4_0, PartialSortBackGS () ), "POSITION.xyz; NORMAL.xyz; TEXCOORD0.xy" );
413:
414: //--------------------------------------------------------------------------------------
415: // Renders scene with Clipping
416: //--------------------------------------------------------------------------------------
417: technique10 TechPartialSortFront
418: {
419: pass P0
420: {
421: SetVertexShader( CompileShader( vs_4_0, PartialSortVS() ) );
422: SetGeometryShader( gsStreamOutFront );
423: SetPixelShader( NULL );
424:
425: SetDepthStencilState( DisableDepth, 0 );
426: }
427: }
428: //--------------------------------------------------------------------------------------
429: technique10 TechPartialSortBack
430: {
431: pass P0
432: {
433: SetVertexShader( CompileShader( vs_4_0, PartialSortVS() ) );
434: SetGeometryShader( gsStreamOutBack );
435: SetPixelShader( NULL );
436:
437: SetDepthStencilState( DisableDepth, 0 );
438: }
439: }
440:
441:
442: //--------------------------------------------------------------------------------------
443: // BG
444: //--------------------------------------------------------------------------------------
445: struct VS_OUTPUT_BG
446: {
447: float4 Position : SV_Position; // vertex position
448: float2 TextureUV : TEXCOORD0; // vertex texture coords
449: };
450: //--------------------------------------------------------------------------------------
451: VS_OUTPUT_BG RenderSceneBgVS( float4 vPos : POSITION,
452: float2 vTexCoord0 : TEXCOORD0 )
453: {
454: VS_OUTPUT_BG Output;
455:
456: Output.Position = vPos;
457: Output.TextureUV = vTexCoord0;
458:
459: return Output;
460: }
461: //--------------------------------------------------------------------------------------
462: float4 RenderSceneBgPS( VS_OUTPUT_BG In ) : SV_Target
463: {
464: return g_MeshTexture.Sample(MeshTextureSampler, In.TextureUV);
465: }
466: //--------------------------------------------------------------------------------------
467: technique10 RenderSceneBg
468: {
469: pass P0
470: {
471: SetVertexShader( CompileShader( vs_4_0, RenderSceneBgVS() ) );
472: SetGeometryShader( NULL );
473: SetPixelShader( CompileShader( ps_4_0, RenderSceneBgPS() ) );
474:
475: SetDepthStencilState( DisableDepth, 0 );
476: SetRasterizerState( CullNone );
477: }
478: }
479:
480:
481: //--------------------------------------------------------------------------------------
482: // SNOW
483: //--------------------------------------------------------------------------------------
484: struct GS_SNOW_IN
485: {
486: float4 Pos0 : POSITION; // vertex position
487: float4 Pos1 : TEXCOORD0;
488: float4 Pos2 : TEXCOORD2;
489: float4 Pos3 : TEXCOORD1;
490: };
491: struct GS_OUTPUT_SNOW
492: {
493: float4 Position : SV_Position; // vertex position
494: float2 TextureUV : TEXCOORD0; // vertex texture coords
495: };
496: //--------------------------------------------------------------------------------------
497: GS_SNOW_IN RenderSceneSnowVS( float3 vPos : POSITION,
498: float3 vBinormal : BINORMAL,
499: float3 vTangent : TANGENT )
500: {
501: GS_SNOW_IN Output;
502: const float SCALE = 0.05;
503:
504: Output.Pos0 = mul(float4(vPos, 1.0), g_mWorldViewProjection);
505: vPos += vBinormal * SCALE;
506: Output.Pos1 = mul(float4(vPos, 1.0), g_mWorldViewProjection);
507: vPos += vTangent * SCALE;
508: Output.Pos3 = mul(float4(vPos, 1.0), g_mWorldViewProjection);
509: vPos -= vBinormal * SCALE;
510: Output.Pos2 = mul(float4(vPos, 1.0), g_mWorldViewProjection);
511:
512: return Output;
513: }
514: //--------------------------------------------------------------------------------------
515: [maxvertexcount(4)]
516: void RenderSceneSnowGS( point GS_SNOW_IN input[1], inout TriangleStream<GS_OUTPUT_SNOW> OutputStream )
517: {
518: GS_OUTPUT_SNOW output;
519:
520: output.Position = input[0].Pos0;
521: output.TextureUV = float2(0,0);
522: OutputStream.Append( output );
523:
524: output.Position = input[0].Pos1;
525: output.TextureUV = float2(0,1);
526: OutputStream.Append( output );
527:
528: output.Position = input[0].Pos2;
529: output.TextureUV = float2(1,0);
530: OutputStream.Append( output );
531:
532: output.Position = input[0].Pos3;
533: output.TextureUV = float2(1,1);
534: OutputStream.Append( output );
535:
536: OutputStream.RestartStrip();
537: }
538: //--------------------------------------------------------------------------------------
539: float4 RenderSceneSnowPS( GS_OUTPUT_SNOW In ) : SV_Target
540: {
541: float tex = g_MeshTexture.Sample(MeshTextureSampler, In.TextureUV).r;
542: clip(tex - 0.9 );
543:
544: return float4(tex,tex,tex,1);
545: }
546: //--------------------------------------------------------------------------------------
547: technique10 RenderSceneSnow
548: {
549: pass P0
550: {
551: SetVertexShader( CompileShader( vs_4_0, RenderSceneSnowVS() ) );
552: SetGeometryShader( CompileShader( gs_4_0, RenderSceneSnowGS() ) );
553: SetPixelShader( CompileShader( ps_4_0, RenderSceneSnowPS() ) );
554:
555: SetDepthStencilState( NoWriteDepth, 0 );
556: SetRasterizerState( CullNone );
557: }
558: }
559: //--------------------------------------------------------------------------------------
560: VS_OUTPUT RenderSceneDepthVS( float4 vPos : POSITION,
561: float3 vNormal : NORMAL,
562: float2 vTexCoord0 : TEXCOORD0 )
563: {
564: VS_OUTPUT Output;
565:
566: Output.Position = mul(vPos, g_mWorldViewProjection);
567: Output.Diffuse = 0;
568: Output.TextureUV.r = Output.Position.z;
569: Output.TextureUV.g = 0;
570:
571: return Output;
572: }
573:
574: float4 RenderSceneDepthPS( VS_OUTPUT In ) : SV_Target
575: {
576: return In.TextureUV.rrrr;
577: }
578:
579: technique10 RenderSceneDepth
580: {
581: pass P0
582: {
583: SetVertexShader( CompileShader( vs_4_0, RenderSceneDepthVS() ) );
584: SetGeometryShader( NULL );
585: SetPixelShader( CompileShader( ps_4_0, RenderSceneDepthPS() ) );
586:
587: SetBlendState( DisableAlphaBlending, float4( 0.0f, 0.0f, 0.0f, 0.0f ), 0xFFFFFFFF );
588: SetDepthStencilState( EnableDepth, 0 );
589: SetRasterizerState( CullNone );
590: }
591: }
592: //--------------------------------------------------------------------------------------
593: VS_OUTPUT RenderSnowMapVS( float4 vPos : POSITION,
594: float2 vTexCoord0 : TEXCOORD0 )
595: {
596: VS_OUTPUT Output = (VS_OUTPUT)0;
597: const float SNOWMAP_INV = 1.0/256.0;
598:
599: float bias = g_MeshTexture.SampleLevel(MeshTextureSampler, vTexCoord0, 0).r * 2;// * 2は、射影行列の(far-near)の補正
600:
601: float bn = g_MeshTexture.SampleLevel(MeshTextureSampler, vTexCoord0+float2(0,-SNOWMAP_INV), 0).r * 2;
602: float bs = g_MeshTexture.SampleLevel(MeshTextureSampler, vTexCoord0+float2(0, SNOWMAP_INV), 0).r * 2;
603: float be = g_MeshTexture.SampleLevel(MeshTextureSampler, vTexCoord0+float2(-SNOWMAP_INV,0), 0).r * 2;
604: float bw = g_MeshTexture.SampleLevel(MeshTextureSampler, vTexCoord0+float2( SNOWMAP_INV,0), 0).r * 2;
605:
606:
607: vPos.y -= bias * 0.99f;
608: Output.Position = mul(vPos, g_mWorldViewProjection);
609: Output.Diffuse.rgb = 1;
610: Output.Diffuse.a = (vPos.y < -5.0) ? 0: g_fBaseValue;
611:
612: Output.Diffuse.a = (g_fCompValue < (bn-bias)*(bn-bias)) ? 0 : Output.Diffuse.a;
613: Output.Diffuse.a = (g_fCompValue < (bs-bias)*(bs-bias)) ? 0 : Output.Diffuse.a;
614: Output.Diffuse.a = (g_fCompValue < (be-bias)*(be-bias)) ? 0 : Output.Diffuse.a;
615: Output.Diffuse.a = (g_fCompValue < (bw-bias)*(bw-bias)) ? 0 : Output.Diffuse.a;
616:
617: return Output;
618: }
619:
620: float4 RenderSnowMapPS( VS_OUTPUT In ) : SV_Target
621: {
622: clip(In.Diffuse.a - 0.99);
623: return In.Diffuse;
624: }
625:
626: technique10 RenderSnowMap
627: {
628: pass P0
629: {
630: SetVertexShader( CompileShader( vs_4_0, RenderSnowMapVS() ) );
631: SetGeometryShader( NULL );
632: SetPixelShader( CompileShader( ps_4_0, RenderSnowMapPS() ) );
633:
634: SetBlendState( SrcAlphaBlending, float4( 0.0f, 0.0f, 0.0f, 0.0f ), 0xFFFFFFFF );
635: SetDepthStencilState( EnableDepth, 0 );
636: SetRasterizerState( CullNone );
637: }
638: }