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

  • Home
  • SEARCH
  • 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 7887207
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T05:31:09+00:00 2026-06-03T05:31:09+00:00

Will this GLSL code create compile-time constants out of oneSixth and twoThirds? // GLSL

  • 0

Will this GLSL code create compile-time constants out of “oneSixth” and “twoThirds”?

// GLSL TESSELLATION EVALUATION SHADER
#version 410

layout (isolines, equal_spacing) in;
in vec4 tessColor[];
out vec4 pointColor;

const float oneSixth = 1. / 6.;
const float twoThirds = 2. / 3.;

void main ()
{
    float s2 = gl_TessCoord.s * gl_TessCoord.s;
    float s3 = s2 * gl_TessCoord.s;
    float w0 = oneSixth - .5 * gl_TessCoord.s + .5 * s2 - oneSixth * s3;
    float w1 = twoThirds - s2 + .5 * s3;
    float w2 = oneSixth + .5 * gl_TessCoord.s + .5 * s2 - .5 * s3;
    float w3 = oneSixth * s3;

    gl_Position = w0 * gl_in[0].gl_Position + w1 * gl_in[1].gl_Position +
            w2 * gl_in[2].gl_Position + w3 * gl_in[3].gl_Position;
    pointColor = w0 * tessColor[0] + w1 * tessColor[1] +
            w2 * tessColor[2] + w3 * tessColor[3];
}

A colleague of mine thinks this code is inefficient and says I should hard-code the division or it will happen at run-time.

const float oneSixth = .1666666667;
const float twoThirds = .6666666667;

I’m new to GLSL but I’m skeptical that this is necessary. Any thoughts? Is it vendor dependent?

  • 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-03T05:31:10+00:00Added an answer on June 3, 2026 at 5:31 am

    It will happen at compile-time. No need to hardcode trivialities like this. However, this is not mentioned in the GLSL specification.

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

Sidebar

Related Questions

If I create an app, when I make an updated version will this replace
Will this code ever wait on the mutex inside the producer's void push(data) ?
My code approaches GLSL shader management in the way, that it creates each shader
Will this code: inline int funcA(int a) __attribute__((always_inline)) { return a + 1; }
This is my first time creating a PHP form that will run a MySQL
Why will this not compile in Delphi 2009? unit VistaFolders; interface uses Windows, ShellAPI,
If i use the code below will this restore text that has been input
Why will this loop not terminate? The program freezes after it prints out all
If I cant pass minimum time and distance in this method, what will happen?
will this repetitive animation code slow down my system?: @-webkit-keyframes animate {-webkit-animation-iteration-count:infinite;...} Are all

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.