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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T11:57:45+00:00 2026-05-22T11:57:45+00:00

Hey, I got a very simple problem. I want to change a float inside

  • 0

Hey, I got a very simple problem.

I want to change a float inside a shader function and send it back to the main program

The shader looks like this

float size; // THE VARIABLE...

float4 PS_COLOR(float2 texCoord: TEXCOORD0) : COLOR
{
    size = 3.0f; // AFTER THIS CALL IT SHOULD RETURN 3 IN THE MAIN PROGRAM
    return 1.0f;
} 

technique LangweiligerShader
{
   pass pass0
   {
      PixelShader = compile ps_2_0 PS_COLOR();
   }
}

in my main function, I set the size variable like this:

effect.SetValue(EffectHandle.FromString("size"), 1000f);

Then I call the Draw method, which applies the shader (its loaded correctly and works since the drawn texture is white)

And after that I get the size variable with

effect.GetValueFloat(EffectHandle.FromString("size"))

Here is the problem… The variable is 1000, but it should be 3

any suggestions?

  • 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-22T11:57:46+00:00Added an answer on May 22, 2026 at 11:57 am

    I do not think that what you are trying is possible. The Pixel shader is called for every pixel in the output screen area. So the variable would be set many times each frame. If the variable depends on a calculation within the pixel shader function, many differen results would be written.

    If you want to use the GPU for calculations that return values of some kind, I suggest you look into some framwork like CUDA or OpenCL.

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

Sidebar

Related Questions

Hey there, i got this very annoying problem: I have a CheckBoxList getting items
Hey, I am so close to fininshing my guess a number game, very simple
Hey, I've got what has become an extremely frustrating problem with $_Post variables. I'll
Hey! Another small problem (isn't it a bug in jQuery?). I've got a textarea
Hey there, I've got a block of HTML that I'm going to be using
Hey. I've got some code from Agile Web Development that wraps some HTML around
Hey so what I want to do is snag the content for the first
Hey, I've been developing an application in the windows console with Java, and want
I've got some very large XML files which I read using a System.Xml.Serialization.XmlSerializer .
Hey Guys I would very much appreciate some help with the following. We're using

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.