Presentation is loading. Please wait.

Presentation is loading. Please wait.

Advanced Materials Using Shaders. Show demo advanced_ogre.

Similar presentations


Presentation on theme: "Advanced Materials Using Shaders. Show demo advanced_ogre."— Presentation transcript:

1 Advanced Materials Using Shaders

2 Show demo advanced_ogre

3 Extract colour data from multiple textures Blend the colour together Use shadow map to blend the intensity of each pixel

4 ETTerrainMaterial material ETTerrainMaterial { technique { pass {// splatting} pass {// blend with shadow map} } //other techniques for fallback }

5 ETTerrainMaterial // splatting pass lighting off vertex_program_ref My/Programs/VSLodMorph2 { } fragment_program_ref My/Programs/PSSplat2 { param_named splatScaleX float 20 param_named splatScaleZ float 20 } texture_unit { // first coverage map, dynamically managed texture ETSplatting0 } // splatting textures

6 VSLodMorph2 void terrain_vp( float4 position : POSITION, float2 uv1 : TEXCOORD0, float delta : BLENDWEIGHT, out float4 oPosition : POSITION, out float2 oUv1 : TEXCOORD0, uniform float4x4 worldViewProj, uniform float morphFactor ) { position.y = position.y + (delta.x * morphFactor); oPosition = mul(worldViewProj, position); oUv1 = uv1; }

7 PSSplat2 void main ( float2 iTexCoord0 : TEXCOORD0, out float4 oColor : COLOR, uniform sampler2D covMap1, uniform sampler2D covMap2, uniform sampler2D splat1, …. uniform float splatScaleX, uniform float splatScaleZ ) { float3 cov1 = tex2D(covMap1, iTexCoord0).rgb; float3 cov2 = tex2D(covMap2, iTexCoord0).rgb; iTexCoord0.x *= splatScaleX; iTexCoord0.y *= splatScaleZ; oColor = tex2D(splat1, iTexCoord0) * cov1.x + tex2D(splat2, iTexCoord0) * cov1.y + tex2D(splat3, iTexCoord0) * cov1.z + tex2D(splat4, iTexCoord0) * cov2.x + tex2D(splat5, iTexCoord0) * cov2.y + tex2D(splat6, iTexCoord0) * cov2.z; }

8 Coverage Maps void createCoverageMap() { WAGO_COVERAGE_MAP *c; c = new WAGO_COVERAGE_MAP("ETSplatting0", "My", 128, 128, 3); c->loadMap("ETcoverage.0.png", "My"); // c = new WAGO_COVERAGE_MAP("ETSplatting1", "My", 128, 128, 3); c->loadMap("ETcoverage.1.png", "My"); // c = new WAGO_COVERAGE_MAP("ETLightmap", "My", 128, 128, 3); c->loadMap("ETlightmap.png", "My"); }

9 Coverage Maps WAGO_COVERAGE_MAP::WAGO_COVERAGE_MAP(const String &name, const String &group, uint nx, uint nz, int numChannels) { //initialize data mTexture = TextureManager::getSingleton().createManual(name, group, TEX_TYPE_2D, mWidth, mHeight, 1, 0, getFormat(mNumChannels), TU_DEFAULT, this); }

10 Load from File void WAGO_COVERAGE_MAP::loadMap(const String &filename, const String &res_group) { Image image; image.load(filename, res_group); if (mWidth!=image.getWidth() || mHeight!=image.getHeight()) { image.resize(mWidth, mHeight); } loadFromImage(image); }

11 ETShader.program fragment_program My/Programs/PSSplat2 cg { source PSSplat2.cg entry_point main profiles ps_2_0 arbfp1 } fragment_program My/Programs/PSLighting cg { source PSLighting.cg entry_point main profiles ps_1_1 arbfp1 }

12 ETShader.program vertex_program My/Programs/VSLodMorph2 cg { source VSLodMorph.cg entry_point terrain_vp profiles vs_1_1 arbvp1 default_params { param_named_auto morphFactor custom 77 param_named_auto worldViewProj worldviewproj_matrix }

13


Download ppt "Advanced Materials Using Shaders. Show demo advanced_ogre."

Similar presentations


Ads by Google