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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 6, 20262026-06-06T20:42:11+00:00 2026-06-06T20:42:11+00:00

How to store Effect parameters in class ? I’m stuck in this problem for

  • 0

How to store Effect parameters in class ?
I’m stuck in this problem for the 3rd day now and I think I’m slowly going to be insane.

I tried to create a class named EffectParameter so I can store/set my parameter values for each object’s shader dynamically.

I tried the to store the ParameterValue in Object type

Object ParameterData;

But I encountered a problem where I need to read from this class….this is where everything going down in the hill.

The method effect.Parameters["parametername"].SetValue() only accept a few kind of types.
And I cannot pass an object to this method.

So I tried to Cast this object.

public T ReadData<T>()
{
    return (T)(object)this.ParameterDataVal;
}

But with this my problem is that I need to know the specific type of this object when I set it (Float,Texture2D etc.)

And I cannot use a type variable to determine the type of this object.
I tried to use (typevariable)(object)this.ParameterDataVal;
But it just gave me errors.

I was mad,so I searched the net for solution for dynamic typing.
But I found no method for my problem.

Then I realized maybe I’m making problems of a simple thing.
So I decided to I use an EffectParameter to store my data.

But then I had another problem with this, again when I try to set this data to the effect….
So I tried to give this Parameter to the effect with a method,but I still getting error that ‘It’s readonly.’.

So I cannot add my EffectParameter to the collection.
I tried many ways. But no success.

I’m totally lost in this. I have no idea what else to do.

Anybody ever encountered this problem or somebody can provide me a good solution plan?

  • 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-06T20:42:14+00:00Added an answer on June 6, 2026 at 8:42 pm

    The solution’s class:

        public class ObjectShader
        {
    
            public Effect effect;
    
            public System.Drawing.Image TextureImage;
    
            public string ShaderName;
    
            string TechniqueName;
    
    
                public ObjectShader(string name,Effect ef)
                {
                    this.ShaderName = name;
                    this.effect = ef;
    
    
                }
    
    
                public void SetValue(string name, System.Drawing.Image val)
                {
                    this.TextureImage = val;
    
                }
    
    
    
                public void SetValue(string name,float val)
                {
                    this.effect.Parameters[name].SetValue(val);
    
                }
    
                public void SetValue(string name, float[] val)
                {
                    this.effect.Parameters[name].SetValue(val);
    
                }
    
    
                public void SetValue(string name, string val)
                {
                    this.effect.Parameters[name].SetValue(val);
    
                }
    
                public void SetValue(string name, Matrix val)
                {
                    this.effect.Parameters[name].SetValue(val);
    
                }
    
                public void SetValue(string name, Matrix[] val)
                {
                    this.effect.Parameters[name].SetValue(val);
    
                }
    
                public void SetValue(string name, Vector2 val)
                {
                    this.effect.Parameters[name].SetValue(val);
    
                }
    
                public void SetValue(string name, Vector2[] val)
                {
                    this.effect.Parameters[name].SetValue(val);
    
                }
    
                public void SetValue(string name, Vector3 val)
                {
                    this.effect.Parameters[name].SetValue(val);
    
                }
    
                public void SetValue(string name, Vector3[] val)
                {
                    this.effect.Parameters[name].SetValue(val);
    
                }
    
                public void SetValue(string name, int val)
                {
                    this.effect.Parameters[name].SetValue(val);
    
                }
                public void SetValue(string name, int[] val)
                {
                    this.effect.Parameters[name].SetValue(val);
    
                }
    
    
        }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I store dates as String in my database, in this format: YYYY-MM-DD HH:MM and
I writing an Effect class (for an opengl program) and I'm also attempting to
I have a class that uses magic methods to store properties. Here is a
We meet a problem when we use https in camel-jetty. Once the key store
Effort I've read this question , but I still think there has to be
I want to take a string and store it in a MYSQL db. This
Wanted to know, because side effect of this could be to alert user that
I have a codebase that (until now) used git to store its dependencies. The
I'm not sure where to set this. But my gloss effect is added to
My json-store contains one record. This record is dirty after changing a field and

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.