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 3393594
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 18, 20262026-05-18T04:04:08+00:00 2026-05-18T04:04:08+00:00

I have 2 HLSL ps2.0 shaders. Simplified, they are: Shader 1 Reads texture Outputs

  • 0

I have 2 HLSL ps2.0 shaders. Simplified, they are:

Shader 1

  • Reads texture
  • Outputs colour value based on this texture

Shader 2

  • Problem: Need to read in the colour from Shader 1
  • Outputs the final colour which is a function of the input colour

(They need to be different shaders as I’ve reached the maximum vertex-shader outputs for 1 shader)


My problem is I cannot work out how Shader 2 can access the existing fragment/pixel colour.

Knowing how to do any of these things with HLSL would solve my problem;

  • Read existing pixel colour (I don’t think this is possible)
  • Pass result of Shader 1 to Shader 2 as a float4
  • Render result of Shader 1 as a texture in memory, and have Shader 2 read that in
  • 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-05-18T04:04:09+00:00Added an answer on May 18, 2026 at 4:04 am

    Compositor scripts seem to be only for fullscreen (or more accurately, full viewport) effects.

    Render-to-texture is the way to go. It’s not necessarily accomplished with compositor scripts.

    This thread of mine on the Ogre forums goes into more detail;

       Ogre::Root r(...);
       Ogre::RenderWindow* window = r.createRenderWindow(...);
       //...
       Ogre::SceneManager* sm = r.createSceneManager(Ogre::ST_GENERIC, "sm");
       //...
    
       //Main scene camera
       Ogre::Camera* c = sm->createCamera("camera");
       {
           c->setNearClipDistance(5);
           Ogre::Viewport* v = window->addViewport(c);
           v->setBackgroundColour (Ogre::ColourValue(0, 0, 0));
           c->setAspectRatio (static_cast<double> (v->getActualWidth ()) / v->getActualHeight ());
       }
    
       //RTT
       Ogre::TexturePtr ptrTexture = Ogre::TextureManager::getSingleton().createManual(
           "RttTex",
           Ogre::ResourceGroupManager::DEFAULT_RESOURCE_GROUP_NAME,
           Ogre::TEX_TYPE_2D,
           512,//window->getWidth(),
           512,//window->getHeight(),
           0, //MIP_DEFAULT?
           Ogre::PF_R8G8B8,
           Ogre::TU_RENDERTARGET,
           0
       );
       Ogre::RenderTexture* renderTexture = ptrTexture->getBuffer()->getRenderTarget();
       renderTexture->setAutoUpdated(true);
    
       //Create material to use with rect
       {
           //You should replace this with the material you wish to render to texture
           //It can be defined in c++ (as this is) or in a material script
           Ogre::MaterialPtr material = Ogre::MaterialManager::getSingleton().create("material", Ogre::ResourceGroupManager::DEFAULT_RESOURCE_GROUP_NAME);
           Ogre::Technique* tech = material->createTechnique();
           tech->createPass();
           material->getTechnique(0)->getPass(0)->setLightingEnabled(false);
           material->getTechnique(0)->getPass(0)->setDepthCheckEnabled(false);
           material->getTechnique(0)->getPass(0)->createTextureUnitState("my_square_texture.dds");
       }
    
       //Create rect2D in yz plane to which we will draw our textures
       //Most likely you'll wish to reposition the node so it's offscreen
       const static float r_dimension = 1000.0;
       Ogre::SceneNode* rect_node = sm->getRootSceneNode()->createChildSceneNode("rect_node");
       {
           Ogre::ManualObject *rect = sm->createManualObject("rect");
           rect->begin("material", Ogre::RenderOperation::OT_TRIANGLE_FAN);
           rect->position(0, r_dimension, r_dimension);
           rect->textureCoord(0,0);
           rect->normal(0, 1, 0);
           rect->position(0, -r_dimension, r_dimension);
           rect->textureCoord(0,1);
           rect->normal(0, 1, 0);
           rect->position(0, -r_dimension, -r_dimension);
           rect->textureCoord(1,1);
           rect->normal(0, 1, 0);
           rect->position(0, r_dimension, -r_dimension);
           rect->textureCoord(1,0);
           rect->normal(0, 1, 0);
           rect->end();
           rect_node->attachObject(rect);
       }
    
       //Create camera, make it look at this rect2D
       Ogre::Camera* rtt_cam = sm->createCamera("rtt_cam");
    
       //Use same FOV as main camera
       Ogre::Radian fov_y = c->getFOVy();
       rtt_cam->setFOVy(fov_y);
    
       //Position the camera such that the texture fills the viewpoint
       {
           //Angle from normal (ie, "vector origin->camera") to to top of tecture is FOV/2
           //Distance origin to top of texture is r_dimension
           double cam_to_rect_distance = r_dimension/tan((fov_y.valueRadians())/2);
           rtt_cam->setPosition(cam_to_rect_distance, 0, 0);
           rtt_cam->lookAt(rect_node->getPosition());
       }
    
       //Debug using main window
       //window->addViewport(rtt_cam);
    
       //Write to RTT
       Ogre::Viewport* v = renderTexture->addViewport(rtt_cam);
    
       v->setClearEveryFrame(true); //You may wish to set this to false and render only when your material updates/changes
       v->setBackgroundColour(Ogre::ColourValue::Blue); //Debug colour. If we see blue border in RTT our cam position is wrong.
       v->setOverlaysEnabled(false); //We don't want overlays to show up on the RTT
    
       //TEMP Create debug screen (lifted from Ogre Tutorial 7)
       //Draws the result of RTT onscreen picture-in-picture
       {
           Ogre::Rectangle2D *miniScreen = new Ogre::Rectangle2D(true);
           miniScreen->setCorners(0.5f, -0.5f, 1.0f, -1.0f);
           //miniScreen->setBoundingBox(Ogre::AxisAlignedBox(-100000.0f * Ogre::Vector3::UNIT_SCALE, 100000.0f * Ogre::Vector3::UNIT_SCALE));
           Ogre::SceneNode* miniScreenNode = sm->getRootSceneNode()->createChildSceneNode("MiniScreenNode");
           miniScreenNode->attachObject(miniScreen);
    
           //Create material to read result of Rtt, purely for debug purposes
           Ogre::MaterialPtr screenMaterial = Ogre::MaterialManager::getSingleton().create("ScreenMatt", Ogre::ResourceGroupManager::DEFAULT_RESOURCE_GROUP_NAME);
           Ogre::Technique* screenTechnique = screenMaterial->createTechnique();
           screenTechnique->createPass();
           screenMaterial->getTechnique(0)->getPass(0)->setLightingEnabled(false);
           screenMaterial->getTechnique(0)->getPass(0)->createTextureUnitState("RttTex");
    
           miniScreen->setMaterial("ScreenMatt");
    
           //TODO ideally we'd have render target listeners call setVisible(false) on pre update and  setVisible(true) post update,
           //so we don't get the infinite line picture-in-picture-in-picture in the preview window.
       }
    
       //Now you can bind your shader's material script to the rtt
    {
        Ogre::MaterialPtr material = Ogre::MaterialManager::getSingleton().getByName("your_material_name");
        Ogre::Technique *technique = material->getTechnique(0);
        Ogre::Pass *pass = technique->getPass(0);
        Ogre::TextureUnitState *tunit = pass->getTextureUnitState("your_materials_tunit_name");
        tunit->setTextureName("Rtt");
    }
    
       //...
    
       while (! window->isClosed ()) {
           //...
           r.renderOneFrame();
       }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

have a problem. At first look at this HTML <div id=map style=background-image: url(map.png); width:
The Problem : I am rendering a mesh using HLSL (High Level Shader Language)
I have been attempting to build HLSL shader support into VLC player. I have
I have a code in HLSL which aims to simulate the IBL (Image-based light
have written this little class, which generates a UUID every time an object of
have a nice day. I got problem when trying to create an image from
I have a pixel shader and I want to calculate the position of each
Is there any kind of HLSL or HYDRA Pixel Shader languages vorking in toch
Have not done this before, so obviously I suck at it. Here 64 pixels
The DirectX API for setting HLSL shader parameters takes arguments for the slot that

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.