Book Image

OGRE 3D 1.7 Beginner's Guide

Book Image

OGRE 3D 1.7 Beginner's Guide

Overview of this book

Want to make your own 3D applications, simulations, and games? OGRE 3D, an open source Object-Oriented 3D Graphics Rendering Engine written in C++, which can be utilized to create a variety of 3D applications and is commonly used in game creation, can help you to do so! OGRE 3D 1.7 Beginner's Guide, based on the latest version 1.7, makes it super easy for you to make your own monsters, spaceship shooters, weapons, enemies, and more!OGRE 3D 1.7 Beginner's Guide will teach you to develop 3D applications that are exciting and interesting and if used correctly can result in stunning games and simulations. You will start from the very beginning and then work your way up to complex scenes and stunning effects.In this book you will start with how to download and configure OGRE 3D, then create your first example scene. With the help of this sample scene, you will be introduced to several related topics each of which will be explained through several other examples and by do-it-yourself tasks. After each example there is a section that explains the theory behind the technique used for deeper understanding. You will also use what you learned in one example in another example and repeat each technique several times while learning new ones at the same time to strengthen the topics learned. Within no time you will master the art of game creation. Imagine how great you will feel when all your friends are playing the great-looking games you've created with OGRE 3D and this book.
Table of Contents (17 chapters)
Ogre 3D 1.7
Credits
About the Author
About the Reviewers
Preface
Index

Time for action — selecting a color channel


We are going to use the previous code, but we have to add and delete a lot:

  1. Start with the fragment program. Besides the normal parameter, add a float4 uniform parameter to store the color channel factors. Use these factors to multiply the color we retrieved from the original scene texture:

    void MyFragmentShader10(float2 uv : TEXCOORD0,
    out float4 color : COLOR,
    uniform sampler2D texture,
    uniform float4 factors
    )
    {
    color = tex2D(texture, uv);
    color *= factors;
    }
    
  2. Create a new material that uses the fragment shader and add the parameter with the default value of (1,1,1,0). This means that without changing the parameter, the scene will be rendered normally:

    fragment_program MyFragmentShader10 cg
    {
    source Ogre3DBeginnerGuideShaders.cg
    entry_point MyFragmentShader10
    profiles ps_1_1 arbfp1
    default_params
    {
    param_named factors float4 1 1 1 0
    }
    }
    material Ogre3DBeginnersGuide/Comp7
    {
    technique
    {
    pass
    {
    fragment_program_ref MyFragmentShader10
    {
    }
    texture_unit...