• Announcements

    • khawk

      Download the Game Design and Indie Game Marketing Freebook   07/19/17

      GameDev.net and CRC Press have teamed up to bring a free ebook of content curated from top titles published by CRC Press. The freebook, Practices of Game Design & Indie Game Marketing, includes chapters from The Art of Game Design: A Book of Lenses, A Practical Guide to Indie Game Marketing, and An Architectural Approach to Level Design. The GameDev.net FreeBook is relevant to game designers, developers, and those interested in learning more about the challenges in game development. We know game development can be a tough discipline and business, so we picked several chapters from CRC Press titles that we thought would be of interest to you, the GameDev.net audience, in your journey to design, develop, and market your next game. The free ebook is available through CRC Press by clicking here. The Curated Books The Art of Game Design: A Book of Lenses, Second Edition, by Jesse Schell Presents 100+ sets of questions, or different lenses, for viewing a game’s design, encompassing diverse fields such as psychology, architecture, music, film, software engineering, theme park design, mathematics, anthropology, and more. Written by one of the world's top game designers, this book describes the deepest and most fundamental principles of game design, demonstrating how tactics used in board, card, and athletic games also work in video games. It provides practical instruction on creating world-class games that will be played again and again. View it here. A Practical Guide to Indie Game Marketing, by Joel Dreskin Marketing is an essential but too frequently overlooked or minimized component of the release plan for indie games. A Practical Guide to Indie Game Marketing provides you with the tools needed to build visibility and sell your indie games. With special focus on those developers with small budgets and limited staff and resources, this book is packed with tangible recommendations and techniques that you can put to use immediately. As a seasoned professional of the indie game arena, author Joel Dreskin gives you insight into practical, real-world experiences of marketing numerous successful games and also provides stories of the failures. View it here. An Architectural Approach to Level Design This is one of the first books to integrate architectural and spatial design theory with the field of level design. The book presents architectural techniques and theories for level designers to use in their own work. It connects architecture and level design in different ways that address the practical elements of how designers construct space and the experiential elements of how and why humans interact with this space. Throughout the text, readers learn skills for spatial layout, evoking emotion through gamespaces, and creating better levels through architectural theory. View it here. Learn more and download the ebook by clicking here. Did you know? GameDev.net and CRC Press also recently teamed up to bring GDNet+ Members up to a 20% discount on all CRC Press books. Learn more about this and other benefits here.

ali rahimi

Members
  • Content count

    134
  • Joined

  • Last visited

Community Reputation

440 Neutral

About ali rahimi

  • Rank
    Member

Personal Information

  1. From the album Work In Progress

  2. From the album Work In Progress

  3. From the album Work In Progress

  4. From the album Work In Progress

    Free Radical: Terrain editor.
  5. From the album Work In Progress

    Free Radical: Dynamic Wet lens effect.
  6. From the album Work In Progress

    Free Radical: Accurate transition between top & bottom ocean surface.
  7. From the album Work In Progress

    Free Radical: Accurate transition between top & bottom ocean surface.
  8. This is a frustum culling. Just like the render view, shadows also need a frustum culling or more advanced culling technique. For now i just use a basic frustum culling for each sun shadow split which is better than no culling. However i must find a better method for the terrain shadow.
  9. From the album Work In Progress

    Free Radical: Terrain culling (Sun shadow splits).
  10. Erosion is more related to the overall shape and layer masks (which define erosion area). App like world machine will give you a full erosion mask and more. I think you miss understood masking with Erosion effect. Here you can see the result of my terrain. For a terrain we always have a low and high frequency texturing which must blend smoothly. That example code is  a good starting point to see how blending should be setup.   http://quest3d.com/forum/index.php?topic=70937.120
  11. There is a section of that pdf which describe the texturing method. To build a texture mask or heightmap you may use a different app like world machine. But it seams you are asking for a masking. well it's just a mask with a proper blending. This is an extreme example of high detail masking and 3 planer texturing which i did few months ago. So it might be useful. However i changed it a lot due to it's heavy pixel shader usage. //------------------------------------------------------------------------------- // www.ali-rahimi.net // Copyright (C), Ali Rahimi Shahmirzadi 2004-2013 // Name: Geoclip Terrain // Version: 1.0 // float4x4 wvp : WorldViewProjection ; float4x4 wv : WorldView; float4x4 viewIT : ViewInverseTranspose; float4x4 worldIT : WorldInverseTranspose; float4x4 world : World; float4x4 Matrix_Mask : CHANNELMATRIX0; float Scale :CHANNELVALUE0; float Hight :CHANNELVALUE1; float Tile_UV :CHANNELVALUE2; float Blend_Contrast :CHANNELVALUE3; float Tile_Z_Distance :CHANNELVALUE4; float Blend_Texture_Power :CHANNELVALUE5; float Blend_Texture_2_Power :CHANNELVALUE6; float Tile_Big_UV :CHANNELVALUE7; float Spec_Power :CHANNELVALUE8; float Spec_Glossiness :CHANNELVALUE9; float Material_ID :CHANNELVALUE10; float Variation_Map_Scale :CHANNELVALUE11; float Side_Desaturation :CHANNELVALUE12; float Side_Brightness :CHANNELVALUE13; float Side_Hight :CHANNELVALUE14; float Side_Z_Mask :CHANNELVALUE15; //------------------------------------------------------------------------------- // Textures //------------------------------------------------------------------------------- texture Displacement_Map : TEXTURE0; sampler2D Displacement_MapSampler = sampler_state { Texture = <Displacement_Map>; MinFilter = LINEAR; MagFilter = LINEAR; AddressU = clamp; AddressV = clamp; }; texture Normal_Map : TEXTURE1; sampler2D Normal_Map_Sampler = sampler_state { Texture = <Normal_Map>; MinFilter = LINEAR; MagFilter = LINEAR; MipFilter = LINEAR; AddressU = wrap; AddressV = wrap; }; texture Landscape_Mask : TEXTURE2; sampler2D Landscape_Mask_Sampler = sampler_state { Texture = <Landscape_Mask>; MinFilter = LINEAR; MagFilter = LINEAR; MipFilter = LINEAR; AddressU = clamp; AddressV = clamp; }; texture Albedo_1 : TEXTURE3; sampler2D Albedo_1_Sampler = sampler_state { Texture = <Albedo_1>; MinFilter = LINEAR; MagFilter = LINEAR; MipFilter = LINEAR ; AddressU = WRAP; AddressV = WRAP; }; texture Albedo_2 : TEXTURE4; sampler2D Albedo_2_Sampler = sampler_state { Texture = <Albedo_2>; MinFilter = LINEAR; MagFilter = LINEAR; MipFilter = LINEAR ; AddressU = WRAP; AddressV = WRAP; }; texture Albedo_3 : TEXTURE5; sampler2D Albedo_3_Sampler = sampler_state { Texture = <Albedo_3>; MinFilter = LINEAR; MagFilter = LINEAR; MipFilter = LINEAR ; AddressU = WRAP; AddressV = WRAP; }; texture Albedo_4 : TEXTURE6; sampler2D Albedo_4_Sampler = sampler_state { Texture = <Albedo_4>; MinFilter = LINEAR; MagFilter = LINEAR; MipFilter = LINEAR ; AddressU = WRAP; AddressV = WRAP; }; texture Normal_Map_1 : TEXTURE7; sampler2D Normal_Map_1_Sampler = sampler_state { Texture = <Normal_Map_1>; MinFilter = LINEAR; MagFilter = LINEAR; MipFilter = LINEAR ; AddressU = WRAP; AddressV = WRAP; }; texture Normal_Map_2 : TEXTURE8; sampler2D Normal_Map_2_Sampler = sampler_state { Texture = <Normal_Map_2>; MinFilter = LINEAR; MagFilter = LINEAR; MipFilter = LINEAR ; AddressU = WRAP; AddressV = WRAP; }; texture Normal_Map_3 : TEXTURE9; sampler2D Normal_Map_3_Sampler = sampler_state { Texture = <Normal_Map_3>; MinFilter = LINEAR; MagFilter = LINEAR; MipFilter = LINEAR ; AddressU = WRAP; AddressV = WRAP; }; texture Normal_Map_4 : TEXTURE10; sampler2D Normal_Map_4_Sampler = sampler_state { Texture = <Normal_Map_4>; MinFilter = LINEAR; MagFilter = LINEAR; MipFilter = LINEAR ; AddressU = WRAP; AddressV = WRAP; }; texture Variation_Map : TEXTURE11; sampler2D Variation_Map_Sampler = sampler_state { Texture = <Variation_Map>; MinFilter = LINEAR; MagFilter = LINEAR; MipFilter = LINEAR ; AddressU = WRAP; AddressV = WRAP; }; texture Detail_Displacement : TEXTURE12; sampler2D Detail_Displacement_Sampler = sampler_state { Texture = <Detail_Displacement>; MinFilter = LINEAR; MagFilter = LINEAR; AddressU = wrap; AddressV = wrap; }; texture Detail_Normal_Map : TEXTURE1; sampler2D Detail_Normal_Map_Sampler = sampler_state { Texture = <Detail_Normal_Map>; MinFilter = LINEAR; MagFilter = LINEAR; MipFilter = LINEAR; AddressU = clamp; AddressV = clamp; }; texture Displacement_Mask : TEXTURE14; sampler2D Displacement_Mask_Sampler = sampler_state { Texture = <Displacement_Mask>; MinFilter = LINEAR; MagFilter = LINEAR; MipFilter = LINEAR; AddressU = clamp; AddressV = clamp; }; //Overlay Color Blend Formula float Overlay(float input1, float input2) { float result = 0.0; if (input2 < 0.5) result = 2 * input1 * input2; else result = 1 - 2 * (1 - input1) * (1 - input2); return result; } //------------------------------------------------------------------------------- // Structs //------------------------------------------------------------------------------- // input from application to vertex shader struct a2v { float4 position : POSITION; }; // output from vertex shader to pixel shader struct v2f { float4 position : POSITION; float Depth : TEXCOORD0; float4 wposition : TEXCOORD1; float4 wposition_2 : TEXCOORD2; // float4 Vcolor : COLOR0; // float2 texCoord : TEXCOORD2; }; // output from pixel shader struct PixelShaderOut { float4 rtarget0 : COLOR0; float4 rtarget1 : COLOR1; float4 rtarget2 : COLOR2; float4 rtarget3 : COLOR3; }; //------------------------------------------------------------------------------- // Vertex Shader //------------------------------------------------------------------------------- v2f av(a2v In) { v2f Out = (v2f)0; float2 texCoord = (mul(In.position/Scale,world).xz)+float2(0.5,0.5); float4 Normal_Map = tex2Dlod(Normal_Map_Sampler, float4(texCoord.xy,0,0)).rgba; float Mask = tex2Dlod(Displacement_Mask_Sampler, float4(texCoord.xy,0,0)).x; float Detail_Displacement = tex2Dlod(Detail_Displacement_Sampler, float4(texCoord.xy,0,0)).x; float Displacement_Map = tex2Dlod(Displacement_MapSampler, float4(texCoord.xy,0,0)).x; // Displacement_Map = lerp(Detail_Displacement,Displacement_Map,Mask); Displacement_Map *= Hight; In.position.y +=Displacement_Map; Out.wposition_2 = mul(In.position, world); //------------------------------------------------------------------------------- // Side Displacement //------------------------------------------------------------------------------- float2 UV_X = mul(In.position,world).xy; float2 UV_Z = mul(In.position,world).zy; // float3 Normal = lerp(float3(0,0,1),Normal_Map.rgb,Mask); float3 Normal = Normal_Map.rgb; float Displacement_X = tex2Dlod(Normal_Map_Sampler, float4(Tile_Big_UV*UV_X.xy,0,0)).a; float Displacement_Z = tex2Dlod(Normal_Map_Sampler,float4(Tile_Big_UV*UV_Z.xy,0,0)).a; float3 Normal_Map_Mask = Normal.xyz; Normal_Map_Mask = Normal_Map_Mask.xzy; Normal_Map_Mask.z = saturate(1-Normal_Map_Mask.z); Normal_Map_Mask = saturate(5*pow(Normal_Map_Mask,5)); float Normal_Map_Mask_G = saturate(1-(2*(pow(Normal.b,7)))); float3 Side_Normal_Direction_Mask = Normal.xyz; float Displacement_X_1 = Displacement_X; Displacement_X_1 = saturate(1-Displacement_X_1); Displacement_X_1 = lerp(Displacement_X_1,0,Side_Normal_Direction_Mask.g); Displacement_X_1 = lerp(Displacement_X_1,0,Normal_Map_Mask.r); Displacement_X_1 *= Normal_Map_Mask_G; In.position.z += (Displacement_X_1*Side_Hight); float Displacement_X_2 = Displacement_X; Displacement_X_2 = saturate(1-Displacement_X_2); Displacement_X_2 = lerp(0,Displacement_X_2,Side_Normal_Direction_Mask.g); Displacement_X_2 = lerp(Displacement_X_2,0,Normal_Map_Mask.r); Displacement_X_2 *= Normal_Map_Mask_G; In.position.z -= (Displacement_X_2*Side_Hight); float Displacement_Z_1 = Displacement_Z; Displacement_Z_1 = saturate(1-Displacement_Z_1); Displacement_Z_1 = lerp(Displacement_Z_1,0,Side_Normal_Direction_Mask.r); Displacement_Z_1 = lerp(Displacement_Z_1,0,Normal_Map_Mask.b); Displacement_Z_1 *= Normal_Map_Mask_G; In.position.x -= (Displacement_Z_1*Side_Hight); float Displacement_Z_2 = Displacement_Z; Displacement_Z_2 = saturate(1-Displacement_Z_2); Displacement_Z_2 = lerp(0,Displacement_Z_2,Side_Normal_Direction_Mask.r); Displacement_Z_2 = lerp(Displacement_Z_2,0,Normal_Map_Mask.b); Displacement_Z_2 *= Normal_Map_Mask_G; In.position.x += (Displacement_Z_2*Side_Hight); float Displacement_Y = saturate((Displacement_X_1+Displacement_X_2+Displacement_Z_1+Displacement_Z_2)/1); Displacement_Y *= Normal_Map.a; In.position.y += (Displacement_Y*(Side_Hight/200)); //------------------------------------------------------------------------------- Out.position = mul(In.position, wvp); //transform vert position to homogeneous clip space float4 view_pos = mul(In.position, wv); Out.Depth = view_pos.z; Out.wposition = mul(In.position, world); // Out.Vcolor = float4(Displacement_Y,0,0,0); return Out; } //------------------------------------------------------------------------------- // SphereMapEncode2 //------------------------------------------------------------------------------- float2 SphereMapEncode2( float3 normal ) { float2 enc = normalize(normal.xy) * sqrt(normal.z*0.5f + 0.5f); enc = enc*0.5 + 0.5f; return enc; } //------------------------------------------------------------------------------- // Pixel Shader //------------------------------------------------------------------------------- PixelShaderOut af(v2f In) { //------------------------------------------------------------------------------- // Color 0 //------------------------------------------------------------------------------- float4 input1 = float4(In.Depth, 0, 0, 0); //------------------------------------------------------------------------------- // Color 1 //------------------------------------------------------------------------------- float3 VertexPosition = In.wposition.xyz; float2 UV_X = float2(VertexPosition.x, VertexPosition.y); float2 UV_Y = float2(VertexPosition.x, 1-VertexPosition.z); float2 UV_Z = float2(VertexPosition.z, VertexPosition.y); float3 VertexPosition_2 = In.wposition_2.xyz; float2 UV_X_2 = float2(VertexPosition_2.x, VertexPosition_2.y); float2 UV_Y_2 = float2(VertexPosition_2.x, 1-VertexPosition_2.z); float2 UV_Z_2 = float2(VertexPosition_2.z, VertexPosition_2.y); float2 texCoord = float2(UV_Y_2.x,1-UV_Y_2.y)/Scale+float2(0.5,0.5); float Displacement_Mask = tex2D(Displacement_Mask_Sampler, texCoord.xy).x; float4 Detail_Normal_Map = tex2D(Detail_Normal_Map_Sampler, texCoord.xy).xyzw; float4 Normal = tex2D(Detail_Normal_Map_Sampler, texCoord.xy).xyzw; float4 Mask = tex2D(Landscape_Mask_Sampler, texCoord.xy); // Mask = lerp(float4(0,0,1,0),Mask,Displacement_Mask); // Normal = lerp(Detail_Normal_Map,Normal,Displacement_Mask); // In.Vcolor.rgb;// float4 Matrix_Mask_1 = mul(float4(VertexPosition.xyz, 1), (float4x4)Matrix_Mask); bool Matrix_Mask_2 = all(abs(Matrix_Mask_1.xyz/Matrix_Mask_1.w - 0.5f) < 0.5f); // clip(saturate(Matrix_Mask_2)-0.5); float3 Normal_Map_Mask = Normal.xyz; Normal_Map_Mask = Normal_Map_Mask.xzy; Normal_Map_Mask.z = 1-Normal_Map_Mask.z; Normal_Map_Mask = Normal_Map_Mask * 2 - 1; Normal_Map_Mask = saturate(pow(Normal_Map_Mask,Blend_Contrast)); Normal_Map_Mask = normalize(Normal_Map_Mask); float3 World_Normal = Normal.xyz; World_Normal = World_Normal.xzy; World_Normal.z = 1-World_Normal.z; World_Normal = World_Normal * 2 - 1; float3 Nn = normalize(World_Normal.xyz); float3 Bn = normalize(cross(float3(0,0,-1), World_Normal)); float3 Tn = normalize(cross(Nn, Bn)); float3x3 toWorld = transpose(float3x3(Bn, -Tn, Nn)); //------------------------------------------------------------------------------- // Side Rock Normal //------------------------------------------------------------------------------- float3 Side_Normal_Direction_Mask = Normal.xyz; Side_Normal_Direction_Mask = 2*pow(Side_Normal_Direction_Mask,2); Side_Normal_Direction_Mask = saturate(Side_Normal_Direction_Mask); float4 Side_Detail_Normal_X = tex2D(Normal_Map_1_Sampler,(Tile_UV/4)*UV_X.xy); Side_Detail_Normal_X.g = lerp(Side_Detail_Normal_X.g,1-Side_Detail_Normal_X.g,Side_Normal_Direction_Mask.g); float4 Side_Detail_Normal_Z = tex2D(Normal_Map_1_Sampler,(Tile_UV/4)*UV_Z.xy); Side_Detail_Normal_Z = Side_Detail_Normal_Z.grba; Side_Detail_Normal_Z.r = lerp(1-Side_Detail_Normal_Z.r,Side_Detail_Normal_Z.r,Side_Normal_Direction_Mask.r); float4 Side_Detail_Normal = lerp(Side_Detail_Normal_X,Side_Detail_Normal_Z,Normal_Map_Mask.r); float4 Side_Normal_1_X = tex2D(Normal_Map_1_Sampler, Tile_Big_UV*UV_X_2.xy); Side_Normal_1_X.g = lerp(Side_Normal_1_X.g,1-Side_Normal_1_X.g,Side_Normal_Direction_Mask.g); float4 Side_Normal_1_Z = tex2D(Normal_Map_1_Sampler,Tile_Big_UV*UV_Z_2.xy); Side_Normal_1_Z = Side_Normal_1_Z.grba; Side_Normal_1_Z.r = lerp(1-Side_Normal_1_Z.r,Side_Normal_1_Z.r,Side_Normal_Direction_Mask.r); float4 Side_Normal_1 = lerp(Side_Normal_1_X,Side_Normal_1_Z,Normal_Map_Mask.r); //------------------------------------------------------------------------------- // Side Rock Albedo //------------------------------------------------------------------------------- float Side_Variation_1_X = tex2D(Variation_Map_Sampler,Variation_Map_Scale*UV_X.xy).r; float Side_Variation_1_Z = tex2D(Variation_Map_Sampler,Variation_Map_Scale*UV_Z.xy).r; float Side_Variation_1 = lerp(Side_Variation_1_X,Side_Variation_1_Z,Normal_Map_Mask.r); float Side_Variation_2_X = tex2D(Variation_Map_Sampler,(Variation_Map_Scale/5)*UV_X.xy).r; float Side_Variation_2_Z = tex2D(Variation_Map_Sampler,(Variation_Map_Scale/5)*UV_Z.xy).r; float Side_Variation_2 = lerp(Side_Variation_2_X,Side_Variation_2_Z,Normal_Map_Mask.r); float4 Side_Detail_Albedo_X = tex2D(Albedo_1_Sampler,(Tile_UV/4)*UV_X.xy); float4 Side_Detail_Albedo_Z = tex2D(Albedo_1_Sampler,(Tile_UV/4)*UV_Z.xy); float4 Side_Detail_Albedo = lerp(Side_Detail_Albedo_X,Side_Detail_Albedo_Z,Normal_Map_Mask.r); float4 Side_Albedo_1_X = tex2D(Albedo_1_Sampler,Tile_Big_UV*UV_X_2.xy); float4 Side_Albedo_1_Z = tex2D(Albedo_1_Sampler,Tile_Big_UV*UV_Z_2.xy); float4 Side_Albedo_1 = lerp(Side_Albedo_1_X,Side_Albedo_1_Z,Normal_Map_Mask.r); float4 Side_Albedo_2_X = tex2D(Albedo_2_Sampler,Tile_UV*UV_X.xy); float4 Side_Albedo_2_Z = tex2D(Albedo_2_Sampler,Tile_UV*UV_Z.xy); float4 Side_Albedo_2 = lerp(Side_Albedo_2_X,Side_Albedo_2_Z,Normal_Map_Mask.r); float4 Side_Albedo_3_X = tex2D(Albedo_3_Sampler,Tile_UV*UV_X.xy); float4 Side_Albedo_3_Z = tex2D(Albedo_3_Sampler,Tile_UV*UV_Z.xy); float4 Side_Albedo_3 = lerp(Side_Albedo_3_X,Side_Albedo_3_Z,Normal_Map_Mask.r); float4 Side_Albedo_4_X = tex2D(Albedo_4_Sampler,Tile_UV*UV_X.xy); float4 Side_Albedo_4_Z = tex2D(Albedo_4_Sampler,Tile_UV*UV_Z.xy); float4 Side_Albedo_4 = lerp(Side_Albedo_4_X,Side_Albedo_4_Z,Normal_Map_Mask.r); //------------------------------------------------------------------------------- // Combine big & small side albedo //------------------------------------------------------------------------------- float Side_Mask_R = pow((saturate (Mask.r+(Mask.r*Side_Albedo_4.a))),Blend_Texture_Power); float Side_Mask_G = pow((saturate (Mask.g+(Mask.g*Side_Albedo_2.a))),Blend_Texture_Power); float4 Side_Y_Small_Albedo = lerp((lerp(Side_Albedo_3,Side_Albedo_4,Side_Mask_R)),Side_Albedo_2,Side_Mask_G); // Side big small mask float Vertical_Normal_Mask = mul(toWorld, Side_Normal_1.xyz*2-1).g; Vertical_Normal_Mask = 1-Vertical_Normal_Mask; Vertical_Normal_Mask = saturate (Vertical_Normal_Mask); // float Side_Dis_Mask = Vertical_Normal_Mask; Vertical_Normal_Mask = pow((saturate (Vertical_Normal_Mask+(Vertical_Normal_Mask*Side_Detail_Albedo.a))),5); // Side albedo final result // float4 Side_Albedo = float4((normalize(Side_Detail_Albedo.rgb)+Side_Albedo_1.rgb)*Side_Detail_Albedo.rgb,(Side_Detail_Albedo.a+Side_Albedo_1.a)/2); // float4 Side_Albedo = float4(Overlay(Side_Detail_Albedo.rgb.x, Side_Albedo_1.rgb.x), Overlay(Side_Detail_Albedo.rgb.y, Side_Albedo_1.rgb.y), Overlay(Side_Detail_Albedo.rgb.z, Side_Albedo_1.rgb.z),(Side_Detail_Albedo.a+Side_Albedo_1.a)/2); float4 Side_Albedo = float4(Side_Detail_Albedo.rgb,(Side_Detail_Albedo.a+Side_Albedo_1.a)/2); Side_Albedo.rgb *=Side_Brightness; float3 lumvec = float3(0.3,0.59,0.11).rgb; float desat = dot(Side_Albedo.rgb,lumvec.rgb).x; Side_Albedo.rgb = float3(lerp(Side_Albedo.rgb,desat.xxx,Side_Desaturation)).rgb; Side_Albedo.rgb = lerp(Side_Y_Small_Albedo.rgb,Side_Albedo.rgb,Vertical_Normal_Mask); Side_Albedo.a = lerp((Side_Albedo_1.a+Side_Y_Small_Albedo.a)/2,Side_Albedo.a,Vertical_Normal_Mask); Side_Albedo.a = 1.5*pow(Side_Albedo.a,1.5); //------------------------------------------------------------------------------- // Top albedo //------------------------------------------------------------------------------- float Top_Variation_1 = tex2D(Variation_Map_Sampler, Variation_Map_Scale*UV_Y.xy).r; float Top_Variation_2 = tex2D(Variation_Map_Sampler, (Variation_Map_Scale/5)*UV_Y.xy).r; float4 Albedo_2 = tex2D(Albedo_2_Sampler, Tile_UV*UV_Y.xy); float4 Albedo_3 = tex2D(Albedo_3_Sampler, Tile_UV*UV_Y.xy); float4 Albedo_4 = tex2D(Albedo_4_Sampler, Tile_UV*UV_Y.xy); float Mask_R = pow((saturate (Mask.r+(Mask.r*Albedo_4.a))),Blend_Texture_Power); float Mask_G = pow((saturate (Mask.g+(Mask.g*Albedo_2.a))),Blend_Texture_Power); float4 Y_Small_Albedo = lerp((lerp(Albedo_3,Albedo_4,Mask_R)),Albedo_2,Mask_G); // Main side to top mask float Normal_Map_Mask_G = pow((saturate ((pow(Normal_Map_Mask.g,Blend_Texture_2_Power))+(Normal_Map_Mask.g*Side_Albedo.a))),Blend_Texture_Power); float4 Albedo = lerp(Side_Albedo,Y_Small_Albedo,Normal_Map_Mask_G); //------------------------------------------------------------------------------- // Top normal //------------------------------------------------------------------------------- float4 Normal_2 = tex2D(Normal_Map_2_Sampler, Tile_UV*UV_Y.xy); float4 Normal_3 = tex2D(Normal_Map_3_Sampler, Tile_UV*UV_Y.xy); float4 Normal_4 = tex2D(Normal_Map_4_Sampler, Tile_UV*UV_Y.xy); float4 Y_Small_Normal = lerp((lerp(Normal_3,Normal_4,Mask_R)),Normal_2,Mask_G); //------------------------------------------------------------------------------- // Side Rock Normal //------------------------------------------------------------------------------- float4 Side_Normal_2_X = tex2D(Normal_Map_2_Sampler,Tile_UV*UV_X.xy); Side_Normal_2_X.g = lerp(Side_Normal_2_X.g,1-Side_Normal_2_X.g,Side_Normal_Direction_Mask.g); float4 Side_Normal_2_Z = tex2D(Normal_Map_2_Sampler,Tile_UV*UV_Z.xy); Side_Normal_2_Z = Side_Normal_2_Z.grba; Side_Normal_2_Z.r = lerp(1-Side_Normal_2_Z.r,Side_Normal_2_Z.r,Side_Normal_Direction_Mask.r); float4 Side_Normal_2 = lerp(Side_Normal_2_X,Side_Normal_2_Z,Normal_Map_Mask.r); float4 Side_Normal_3_X = tex2D(Normal_Map_3_Sampler,Tile_UV*UV_X.xy); Side_Normal_3_X.g = lerp(Side_Normal_3_X.g,1-Side_Normal_3_X.g,Side_Normal_Direction_Mask.g); float4 Side_Normal_3_Z = tex2D(Normal_Map_3_Sampler,Tile_UV*UV_Z.xy); Side_Normal_3_Z = Side_Normal_3_Z.grba; Side_Normal_3_Z.r = lerp(1-Side_Normal_3_Z.r,Side_Normal_3_Z.r,Side_Normal_Direction_Mask.r); float4 Side_Normal_3 = lerp(Side_Normal_3_X,Side_Normal_3_Z,Normal_Map_Mask.r); float4 Side_Normal_4_X = tex2D(Normal_Map_4_Sampler,Tile_UV*UV_X.xy); Side_Normal_4_X.g = lerp(Side_Normal_4_X.g,1-Side_Normal_4_X.g,Side_Normal_Direction_Mask.g); float4 Side_Normal_4_Z = tex2D(Normal_Map_4_Sampler,Tile_UV*UV_Z.xy); Side_Normal_4_Z = Side_Normal_4_Z.grba; Side_Normal_4_Z.r = lerp(1-Side_Normal_4_Z.r,Side_Normal_4_Z.r,Side_Normal_Direction_Mask.r); float4 Side_Normal_4 = lerp(Side_Normal_4_X,Side_Normal_4_Z,Normal_Map_Mask.r); float4 Side_Y_Small_Normal = lerp((lerp(Side_Normal_3,Side_Normal_4,Side_Mask_R)),Side_Normal_2,Side_Mask_G); // Side normal final result float4 Side_Normal_1_ = float4(Overlay(Side_Normal_1.rgb.x, Side_Detail_Normal.rgb.x), Overlay(Side_Normal_1.rgb.y, Side_Detail_Normal.rgb.y), Side_Normal_1.z,Side_Normal_1.a); Side_Normal_1_.a = (Side_Detail_Normal.a+Side_Normal_1.a)/2; Side_Normal_1_ = lerp(Side_Normal_1,Side_Normal_1_,Vertical_Normal_Mask); float4 Side_Normal = float4(Overlay(Side_Normal_1_.rgb.x, Side_Y_Small_Normal.rgb.x), Overlay(Side_Normal_1_.rgb.y, Side_Y_Small_Normal.rgb.y), Side_Normal_1_.z,Side_Normal_1_.a); Side_Normal.a = (Side_Y_Small_Normal.a+Side_Normal_1_.a)/2; Side_Normal = lerp(Side_Normal,Side_Normal_1_,Vertical_Normal_Mask); float4 Final_Normal = lerp(Side_Normal,Y_Small_Normal,Normal_Map_Mask_G); Final_Normal.rgb = Final_Normal.rgb * 2 - 1; Final_Normal.rgb = mul(toWorld, Final_Normal.xyz).rgb; float2 EncNormal = SphereMapEncode2(Final_Normal.xyz); float4 input2 = float4 (EncNormal, 0,0); //------------------------------------------------------------------------------- // Color 2 //------------------------------------------------------------------------------- float Terrain_SSAO = Normal.z; Terrain_SSAO = saturate(2*pow(Terrain_SSAO,5)); Terrain_SSAO = pow(saturate((Terrain_SSAO*Final_Normal.y)+Final_Normal.y),4); float Variation_1 = lerp(Side_Variation_1,Top_Variation_1,Normal_Map_Mask_G); Variation_1 = saturate(0.1+(2*pow(Variation_1,2))); Variation_1 = lerp(1,Variation_1,saturate(In.Depth/2000)); float Variation_2 = lerp(Side_Variation_2,Top_Variation_2,Normal_Map_Mask_G); Variation_2 = saturate(0.1+(2*pow(Variation_2,2))); float Variation = lerp(Variation_1,Variation_2,saturate(In.Depth/10000)); float Spec_Power_Out = Albedo.a * Spec_Power; Albedo.rgb = Albedo.rgb*Variation;//*(saturate(0.5+Terrain_SSAO)); // Albedo.rgb = In.Vcolor.rgb + Albedo.rgb ; // Albedo.rgb = In.Vcolor.rgb ; // Albedo.rgb = 1; float4 input3 = float4(Albedo.rgb,Spec_Power_Out); //------------------------------------------------------------------------------- // Color 3 //------------------------------------------------------------------------------- float4 input4 = float4(saturate(0.6+Terrain_SSAO),0, Spec_Glossiness, Material_ID); //------------------------------------------------------------------------------- // Output Pixel Shader //------------------------------------------------------------------------------- PixelShaderOut output; output.rtarget0 = input1; output.rtarget1 = input2; output.rtarget2 = input3; output.rtarget3 = input4; return output; } //------------------------------------------------------------------------------- // Technique //------------------------------------------------------------------------------- technique GBuffer { pass pass0 { VertexShader = compile vs_3_0 av(); ZEnable = TRUE; ZWriteEnable = TRUE; // fillmode = point; // fillmode = solid; // fillmode = wireframe; ZFunc = LESS; StencilEnable = TRUE; stencilfunc = ALWAYS; StencilPass = REPLACE; StencilFail = KEEP; StencilZFail = KEEP; StencilRef = 1; PixelShader = compile ps_3_0 af(); } }
  12. This should help http://dice.se/wp-content/uploads/GDC12_Terrain_in_Battlefield3.pdf
  13. From the album Work In Progress

    Terrain color generated with world machine
  14. From the album Work In Progress

    Free Radical: Terrain test with World Machine.
  15. From the album Work In Progress

    Free Radical: Terrain test with World Machine.