Ogre shader usage

Source: Internet
Author: User

For the usage of ogre shader, refer to the two instructions:

Http://www.ogre3d.org/forums/viewtopic.php? F = 1 & t = 76580 # p483996

Http://www.ogre3d.org/tikiwiki/tiki-index.php? Page = RT + shader + System

 

I tried it myself.

 

// Create scenemanager and camera
Ogre: scenemanager * Sm = RT-> createscenemanager (Ogre: st_generic, "testscence ");

// Shader
If (Ogre: rtshader: shadergenerator: Initialize ()){

Ogre: rtshader: shadergenerator * mshadergenerator = ogre: rtshader: shadergenerator: getsingletonptr ();
Mshadergenerator-> setshadercachepath ("C: \ Download \ OgreSDK_vc10_v1-8-1 \ media \ rtshaderlib \ cache ");
Mshadergenerator-> addscenemanager (SM );
}

 

Set the shader material.

Ogre: entity * ET = Sm-> createentity ("robot. mesh ");
// Ogre: resourcegroupmanager: getsingleton (). Create
Et-> setmaterial (Ogre: materialmanager: getsingleton (). getbyname ("RTSs/layeredblending"); // This is defined in the material script. The file is in the shaderlib folder under ogre media.
Ogre: scenenode * node = Sm-> getrootscenenode ()-> createchildscenenode (Ogre: vector3 (0, 0 ));
Node-> attachobject (ET );
Node-> Roll (Ogre: radian (0.9 ));
Node-> Scale (1, 1, 3 );

An error occurred while running. The resource was not added.

Ogre: resourcegroupmanager: getsingleton (). addresourcelocation (
"C: \ Download \ OgreSDK_vc10_v1-8-1 \ media \ rtshaderlib"
, "Filesystem"
, "Rtshaderlib ");

Ogre: resourcegroupmanager: getsingleton (). addresourcelocation (
"C: \ Download \ OgreSDK_vc10_v1-8-1 \ media \ rtshaderlib \ materials"
, "Filesystem"
, "Rtshaderlib ");

After joining the program, the program runs successfully. The robot was previously completely yellow and now it is striped.

 

 

Script Definition

// This material demonstrates the texture blending extension.
Material RTSs/layeredblending
{
Technique
{
Pass
{
Lighting off
Texture_unit
{
Scale 0.1 0.1
Texture Rockwall. TGA
}

Texture_unit
{
// RT shader System Section-required by the layered blend extension.
Rtshader_system
{
Layered_blend luminosity
Source_modifier src1_inverse_modulate custom 2
}
Texture ogrelogo.png
}
}
}
}

 

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.