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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T23:40:35+00:00 2026-05-30T23:40:35+00:00

I’m trying to write a shader using cg (for ogre3d). I can’t seem to

  • 0

I’m trying to write a shader using cg (for ogre3d). I can’t seem to parse a working shader that I’d like to use as a starting point for my own code.

Here’s the declaration for the shader:

void main
(
  float2 iTexCoord0 : TEXCOORD0,

  out float4 oColor : COLOR,

  uniform sampler2D covMap1,
  uniform sampler2D covMap2,
  uniform sampler2D splat1,
  uniform sampler2D splat2,
  uniform sampler2D splat3,
  uniform sampler2D splat4,
  uniform sampler2D splat5,
  uniform sampler2D splat6,

  uniform float splatScaleX,
  uniform float splatScaleZ
) 
{...}

My questions:

iTexCoord0 is obviously an input parameter. Why is it not declared uniform?

(oColor is obviously an output parameter. No question)

covMap1 – splat6 are textures. Are these parameters or something loaded into the graphics card memory (like globals)? The ogre definition for the shader program doesn’t list them as parameters.

Are splatScaleX and splatScaleZ also parameters? The ogre definition for the shader program also doesn’t list these as parameters.

Does the order of declaration mean anything when sending values from an external program?

I’d like to pass in an array of floats (the height map). I assume that would be

  uniform float splatScaleZ,
  uniform float heightmap[1024]
) 
{...}

If I don’t pass one of the parameters will the shader just not be executed (and my object will be invisible because it has no texture)?

Is there a better way to debug these than just hit/miss and guess?

  • 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-30T23:40:37+00:00Added an answer on May 30, 2026 at 11:40 pm

    iTexCoord0 is obviously an input parameter. Why is it not declared uniform?

    Uniforms are not the same things as input parameters. iTexCoord is a varying input, which is to say that for every vertex, it can have a unique value. This is set with commands like glVertexAttribPointer. Things like vertex coordinates, normals, texcoords, vertex colors, are examples of what you might use a varying input for.

    Uniforms are the other hand are intended to be static for an entire draw call, or potentially for the entire frame or life of the program. They are set with glUniform* commands. A uniform might be something like the modelview matrix for an object, or the position of the sun for a lighting calculation. They don’t change very often.

    [edit] These specific commands I think actually work with GLSL, but the theory should be the same for CG. Lookup a cg specific tutorial to figure out the exact commands to set varyings and uniforms.

    covMap1 – splat6 are textures. Are these parameters or something loaded into the graphics card memory (like globals)? The ogre definition for the shader program doesn’t list them as parameters.

    My CG is a little rusty, but if its the same as GLSL then the sampler2d is a uniform that takes an index that represent which sampler you want to sample from. When you do something like glActiveTexture(GL_TEXTURE3), glBindTexture(n), then you set the sampler uniform to “3” you can sample from that texture.

    Does the order of declaration mean anything when sending values from an external program?

    No, the variables are referred to in the external program by their string variable names.

    If I don’t pass one of the parameters will the shader just not be executed (and my object will be invisible because it has no texture)?

    Unknown. They will likely have “some” initial value, though whether that makes any sense and will generate anything visible is hard to guess.

    Is there a better way to debug these than just hit/miss and guess?

    http://http.developer.nvidia.com/CgTutorial/cg_tutorial_appendix_b.html
    See section B.3.8

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

Sidebar

Related Questions

I am trying to understand how to use SyndicationItem to display feed which is
I'm new to using the Perl treebuilder module for HTML parsing and can't figure
That's pretty much it. I'm using Nokogiri to scrape a web page what has
I have a string like this: La Torre Eiffel paragonata all’Everest What PHP function
I've got a string that has curly quotes in it. I'd like to replace
I have a French site that I want to parse, but am running into
I'm parsing an RSS feed that has an ’ in it. SimpleXML turns this
I am trying to render a haml file in a javascript response like so:
I'm trying to use string.replace('’','') to replace the dreaded weird single-quote character: ’ (aka
I'm trying to create an if statement in PHP that prevents a single post

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.