#include "def_effect.fx" //============================================================================= //ÁöÇü VSTERRAIN_OUTPUT Terrain_VS( VSTERRAIN_INPUT In ) { VSTERRAIN_OUTPUT Out = (VSTERRAIN_OUTPUT) 0; float4 pos = In.position; float3 normal = In.normal; float4 color = In.color; float4 output_pos, pos_world; int b_index = 0; // transform position to screen space before changing it. pos_world = mul( pos, blendMatrices[b_index] ); output_pos = mul( pos_world, view_proj_matrix ); Out.position = output_pos; //apply fog float distfog = saturate((fFogDistEnd - output_pos.z)/(fFogDistEnd - fFogDistStart)); float heightfog = saturate((fFogHeightEnd - pos_world.z)/(fFogHeightEnd - fFogHeightStart)); Out.fog = min(distfog, heightfog); float nLength = length(Light_position - pos_world); float3 L = normalize(Light_position - pos_world); float Atten = 1/(1+Light_ambient.a*nLength); // eye-baseÀÇ half-way º¤ÅÍ float3 light_vector = -Light_direction_forsp; float3 eye_vector = Camera_position - pos_world; float3 halfway = normalize(normalize(light_vector) + normalize(eye_vector)); float ddot = saturate(dot(normal, L)); float sdot = saturate(dot(normal, halfway)); Out.diffuse = color;// + color * ddot; // diffuse + ambient Out.diffuse.a = color.a; Out.specular = (Light_ambient + Light_diffuse * ddot * Atten) + (Light_specular * pow(sdot, 22)); // ÁöÇü ÅØ½ºÃ³ ¿¬»ê Ãß°¡ Out.texCoord1 = fTerrain1stTextureScale * (pos_world - fTerrainTextureCenter); Out.texCoord2 = fTerrain2ndTextureScale * (pos_world - fTerrainTextureCenter); Out.texCoord3 = fTerrain3thTextureScale * (pos_world - fTerrainTextureCenter); Out.texCoord4 = fTerrain4thTextureScale * pos; // ¾ê¸¸ ƯÀÌÇÑ °Í return Out; } // ¾È¾²ÀÓ VSTERRAIN_OUTPUT TerrainShadow_VS( VSTERRAIN_INPUT In ) { VSTERRAIN_OUTPUT Out = (VSTERRAIN_OUTPUT) 0; float4 pos = In.position; float3 normal = In.normal; float4 color = In.color; float4 output_pos, pos_world; int b_index = 0; // transform position to screen space before changing it. pos_world = mul( pos, blendMatrices[b_index] ); output_pos = mul( pos_world, view_proj_matrix ); Out.position = output_pos; //apply fog float distfog = saturate((fFogDistEnd - output_pos.z)/(fFogDistEnd - fFogDistStart)); float heightfog = saturate((fFogHeightEnd - pos_world.z)/(fFogHeightEnd - fFogHeightStart)); Out.fog = min(distfog, heightfog); float nLength = length(Light_position - pos_world); float3 L = normalize(Light_position - pos_world); // eye-baseÀÇ half-way º¤ÅÍ float3 light_vector = -Light_direction_forsp; float3 eye_vector = Camera_position - pos_world; float3 halfway = normalize(normalize(light_vector) + normalize(eye_vector)); //float ddot = saturate(dot(normal, L)); //float sdot = saturate(dot(normal, halfway)); Out.diffuse = color;// + color * ddot; // diffuse + ambient Out.diffuse.a = color.a; //Out.specular = (Light_ambient + Light_diffuse * ddot * Atten) + (Light_specular * pow(sdot, 22)); // ÁöÇü ÅØ½ºÃ³ ¿¬»ê Ãß°¡ float heightturm = (pos_world.z - fTerrainTextureCenter.z); float4 litproj = heightturm*float4(L.x, L.y, L.z, L.z);///L.z; Out.texCoord1 = fTerrain1stTextureScale * (pos_world - fTerrainTextureCenter - litproj); heightturm = (pos_world.z - fTerrainTextureCenterDusk.z); litproj = heightturm*float4(L.x, L.y, L.z, L.z);///L.z; Out.texCoord2 = fTerrain2ndTextureScale * (pos_world - fTerrainTextureCenterDusk - litproj); return Out; } //============================================================================= //ÁöÇü Å×Å©´Ð technique TerrainTech { pass P0 { VertexShader = compile vs_1_1 Terrain_VS(); PixelShader = NULL; } } technique TerrainShadowTech { pass P0 { VertexShader = compile vs_1_1 TerrainShadow_VS(); PixelShader = NULL; } }