Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9053043
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 16, 20262026-06-16T13:19:41+00:00 2026-06-16T13:19:41+00:00

Im trying to implement deferred shading using Ogre 1.8. This is my final compositor:

  • 0

Im trying to implement deferred shading using Ogre 1.8. This is my final compositor:

compositor DeferredShadingShowLit
{
    technique
    {
        texture rt0 target_width target_height PF_A8R8G8B8
        texture_ref mrt_output DeferredShadingGBuffer mrt_output

        target rt0
        {
            input none
            shadows off

            pass clear
            {
                identifier 1
            }

            pass render_quad
            {
                identifier 2
                material DeferredShadingPostQuadLight
                input 0 mrt_output 0
                input 1 mrt_output 1
            }
        }

        target_output
        {
            input none

            pass render_quad
            {
                identifier 3
                material DeferredShadingFinal
                input 0 rt0
            }
        }
    }
}

I need to pass the lights position, that is altered every frame to the DeferredShadingPostQuadLight material (used to render lights). Its a simple example and i havent implemented any optimizations such as z tests and bounding volumes for lights. For that purpose im using compositor listener that is set up this way:

class LightListener : public Ogre::CompositorInstance::Listener
{
    public:

        LightListener(Ogre::Vector3 alightPos);
        virtual ~LightListener();
        virtual void notifyMaterialSetup(Ogre::uint32 pass_id, Ogre::MaterialPtr &mat);
        virtual void notifyMaterialRender(Ogre::uint32 pass_id, Ogre::MaterialPtr &mat);

        Ogre::Vector3 lightPos;
        Ogre::GpuProgramParametersSharedPtr fpParams;
};

LightListener::LightListener(Ogre::Vector3 alightPos)
{
    lightPos = alightPos;
}

LightListener::~LightListener()
{
}

void LightListener::notifyMaterialSetup(Ogre::uint32 pass_id, Ogre::MaterialPtr &mat)
{
    //if (pass_id == 2) // This gives me error
    fpParams = mat->getBestTechnique()->getPass(pass_id)->getFragmentProgramParameters();
}

void LightListener::notifyMaterialRender(Ogre::uint32 pass_id, Ogre::MaterialPtr &mat)
{
    //if (pass_id == 2) // This gives me error
    fpParams->setNamedConstant("lightPos", lightPos);
}

The problem is i cant access passes by their id as shown in the commented lines above.

However, if the lines are commented out and i change compositor script like this:

compositor DeferredShadingShowLit
{
    technique
    {
        texture rt0 target_width target_height PF_A8R8G8B8
        texture_ref mrt_output DeferredShadingGBuffer mrt_output

        target_output
        {
            input none
            shadows off

            pass clear
            {
            }

            pass render_quad
            {
                material DeferredShadingPostQuadLight
                input 0 mrt_output 0
                input 1 mrt_output 1
            }
        }
    }
}

fragment program of the DeferredShadingPostQuadLight material gets updated every frame without any problems.

Thing is i need to render to rt0 first and only then to target_output. Can you please show me what im doing wrong here? Thank you!

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-16T13:19:42+00:00Added an answer on June 16, 2026 at 1:19 pm

    I finally got it figured out! Answers on Ogre forums were often misleading. I traced the pass_id variables – the one you supply to the inherited virtual function notifyMaterialSetup and the one you put here mat->getBestTechnique()->getPass(pass_id) are actually completely different values. I have no idea why examples all over the internet have this code written like this. This is completely wrong. pass_id refers to compositor passes, whereas pass_id of mat->getBestTechnique()->getPass(pass_id) refers to materials passes. I got my own example working simply by altering the code like this:

    void LightListener::notifyMaterialSetup(Ogre::uint32 pass_id, Ogre::MaterialPtr &mat)
    {
        if (pass_id == 2)
        fpParams = mat->getBestTechnique()->getPass(0)->getFragmentProgramParameters();
        // I put 0 here because my material has only one pass
    }
    
    void LightListener::notifyMaterialRender(Ogre::uint32 pass_id, Ogre::MaterialPtr &mat)
    {
        if (pass_id == 2)
        fpParams->setNamedConstant("lightPos", lightPos);
    }
    

    Thanks for your attention!

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am trying to implement deferred shading using MRTs. For that, I need to
Im trying to set up deferred renderer using ogre compositor framework. I tried to
I'm trying to implement the folowing scenario, using JQuery deferred, without much luck. What
I'm trying to implement very basic deferred shading in DirectX9. I have the ability
Trying to implement a search similar to here .This searches properties based on city,locality,property
I'm trying implement a bracket in my program (using C#/.NET MVC) and I am
Trying to implement an autocomplete based on this It looks like it's very straight
Trying to implement this gallery on my website. http://coffeescripter.com/code/ad-gallery/ It is noted in the
I'm trying implement a way to recursively template using jsRender. The issue is, my
I have this weird kind of error. I am trying implement basic Euclidean algorithm

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.