SplattingShader12NM (No Mipmapping)

Xavyiy

01-10-2007 21:56:05

Hi all,
I'm coding an editor for PLSM2, I'm writting my own texture modes and I want to share it with the community.

The first texture mode is very simple: 12 splatting textures in argb channels of 3 coverage maps renderer in ONE pass.But really are 3 Splatting textures:

Normal splatting texture:


----------------------
- -
- -
- -
- 256x256 -
- -
- -
----------------------


SplattingShader12NM splatting texture:


512x512:

256 256
----------------------
- - -
- 1 - 2 - 256
- - -
----------------------
- - -
- 3 - 4 - 256
- - -
----------------------



What're the disadvantages?
Splatting textures without mipmapping.

SplattingShader12NM:
- 3 Coverage maps.
- 12 Splatting textures. Without mipmapping [SplattingShader12NM]
- 1 pass.

Shader file:

SplattingShader12NM.cg
//
// SplattingShader12NM.cg for PLSM2
// Xavier Verguín González
// September 2007
//
// - 3 Coverage maps
// - 12 Splatting textures(Without mipmapping)
// - 1 pass
//

void main_vp
(
float4 iPosition : POSITION,
float2 iTexcoord : TEXCOORD0,

out float4 oPosition : POSITION,
out float2 oCoverage : TEXCOORD0,

uniform float4x4 worldViewProj
)
{
oPosition = mul(worldViewProj, iPosition);

oCoverage = iTexcoord;
}

void main_fp
(
float2 iCoverage : TEXCOORD0,

out float4 oColor : COLOR,

uniform sampler2D textureUnit0: TEXUNIT0, // Coverage map 1
uniform sampler2D textureUnit1: TEXUNIT1, // Coverage map 2
uniform sampler2D textureUnit2: TEXUNIT2, // Coverage map 3
uniform sampler2D textureUnit3: TEXUNIT3, // Splatting tex 1 (1,2,3,4)
uniform sampler2D textureUnit4: TEXUNIT4, // Splatting tex 2 (5,6,7,8)
uniform sampler2D textureUnit5: TEXUNIT5 // Splatting tex 3 (9,10,11,12)
)
{
float2 Scale = {80, 80};

float4 Coverage1 = tex2D(textureUnit0, iCoverage.xy);
float4 Coverage2 = tex2D(textureUnit1, iCoverage.xy);
float4 Coverage3 = tex2D(textureUnit2, iCoverage.xy);

float2 ic = frac(iCoverage.xy * Scale) * 0.5;

oColor = tex2D(textureUnit3, ic) * Coverage1.x
+ tex2D(textureUnit3, ic + float2(0.5, 0)) * Coverage1.y
+ tex2D(textureUnit3, ic + float2(0, 0.5)) * Coverage1.z
+ tex2D(textureUnit3, ic + float2(0.5, 0.5)) * Coverage1.w
+ tex2D(textureUnit4, ic) * Coverage2.x
+ tex2D(textureUnit4, ic + float2(0.5, 0)) * Coverage2.y
+ tex2D(textureUnit4, ic + float2(0, 0.5)) * Coverage2.z
+ tex2D(textureUnit4, ic + float2(0.5, 0.5)) * Coverage2.w
+ tex2D(textureUnit5, ic) * Coverage3.x
+ tex2D(textureUnit5, ic + float2(0.5, 0)) * Coverage3.y
+ tex2D(textureUnit5, ic + float2(0, 0.5)) * Coverage3.z
+ tex2D(textureUnit5, ic + float2(0.5, 0.5)) * Coverage3.w;
}


Material file:

SplattingShader12NM.material
//
// SplattingShader12NM.material for PLSM2
// Xavier Verguín González
// September 2007
//
// - 3 Coverage maps
// - 12 Splatting textures(Without mipmapping)
// - 1 pass
//

vertex_program SplatShadercg12NM/VP cg
{
source SplatShader12NM.cg
entry_point main_vp
profiles vs_1_1 arbvp1
}

fragment_program SplatShadercg12NM/FP cg
{
source SplatShader12NM.cg
entry_point main_fp
profiles ps_2_0 arbfp1
}

material SplattingShader12NM
{
technique
{
pass
{
vertex_program_ref SplatShadercg12NM/VP
{
param_named_auto worldViewProj worldviewproj_matrix
}

fragment_program_ref SplatShadercg12NM/FP
{
}

texture_unit
{
texture Coverage
}

texture_unit
{
texture Coverage
}

texture_unit
{
texture Coverage
}

texture_unit
{
texture Splatting
filtering none none none
}

texture_unit
{
texture Splatting
filtering none none none
}

texture_unit
{
texture Splatting
filtering none none none
}
}
}
}


I'm working on two more texture modes: 6 and 12 splatting textures with Mipmapping, and in the future I'm going to try making a texture mode with normal mapping.

More soon.

Sorry for my little English.