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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 12, 20262026-05-12T05:10:06+00:00 2026-05-12T05:10:06+00:00

I’m trying to draw lots of circles on a sphere using shaders. The basic

  • 0

I’m trying to draw lots of circles on a sphere using shaders. The basic alogrith is like this:

  1. calculate the distance from the fragment (using it’s texture coordinates) to the location of the circle’s center (the circle’s center is also specified in texture coordinates)
  2. calculate the angle from the fragent to the center of the circle.
  3. based on the angle, access a texture (which has 360 pixels in it and the red channel specifies a radius distance) and retrieve the radius for the given angle
  4. if the distance from the fragment to the circle’s center is less than the retrieved radius then the fragment’s color is red, otherwise blue.

I would like to draw … say 60 red circles on a blue sphere. I got y shader to work for one circle, but how to do 60? Here’s what I’ve tried so far….

  1. I passed in a data texture that specifies the radius for a given angle, but I notice artifacts creep in. I believe this is due to linear interpolation when I try to retrieve information from the data texture using:

    float returnV = texture2D(angles, vec2(x, y)).r; 
    

    where angles is the data texture (Sampler2D) that contains the radius for a given angle, and x = angle / 360.0 (angle is 0 to 360) and y = 0 to 60 (y is the circle number)

  2. I tried passing in a Uniform float radii[360], but I cannot access radii with dynamic indexing. I even tried this mess …

    getArrayValue(int index) {
      if (index == 0) {
        return radii[0];
      }
      else if (index == 1) {
        return radii[1];
      }
    

    and so on …

If I create a texture and place all of the circles on that texture and then multi-texture the blue sphere with the one containing the circles it works, but as you would expect, I have really bad aliasing. I like the idea of proceduraly generating the circles based on the position of the fragment and that of the circle because of virtually no aliasing. However, I do I do ore than one?

Thx!!!

~Bolt

  • 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-12T05:10:06+00:00Added an answer on May 12, 2026 at 5:10 am

    i have a shader that makes circle on the terrain. It moves by the mouse moves.
    maybe you get an inspiration?

    this is a fragment program. it is not the main program but you can add it to your program.
    try this…

    for now you can give some uniform parameters in hardcode.

    uniform float showCircle;
    uniform float radius;
    uniform vec4 mousePosition;
    
    varying vec3 vertexCoord;
    
    void calculateTerrainCircle(inout vec4 pixelColor)
    {
     if(showCircle == 1)
     {  
        float xDist = vertexCoord.x - mousePosition.x;
        float yDist = vertexCoord.y - mousePosition.y;
    
        float dist = xDist * xDist + yDist * yDist;
        float radius2 = radius * radius;
    
        if (dist < radius2 * 1.44f && dist > radius2 * 0.64f)
        {
            vec4 temp = pixelColor;
    
            float diff;
            if (dist < radius2)
                diff = (radius2 - dist) / (0.36f * radius2);
            else
                diff = (dist - radius2) / (0.44f * radius2);
    
            pixelColor = vec4(1, 0, 0, 1.0) * (1 - diff) + pixelColor * diff;   
    
            pixelColor = mix(pixelColor, temp, diff);
        }               
    }   
    }
    

    and in vertex shader you add:

    varying vec3 vertexCoord;
    
    void main()
    {
        gl_Position = ftransform();
    
        vec4 v = vec4(gl_ModelViewMatrix * gl_Vertex);
        vertexCoord = vec3(gl_ModelViewMatrixInverse * v);
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying to decode HTML entries from here NYTimes.com and I cannot figure out
Does anyone know how can I replace this 2 symbol below from the string
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
I have some data like this: 1 2 3 4 5 9 2 6
I am trying to understand how to use SyndicationItem to display feed which is
Basically, what I'm trying to create is a page of div tags, each has
I'm new to using the Perl treebuilder module for HTML parsing and can't figure
link Im having trouble converting the html entites into html characters, (&# 8217;) i
this is what i have right now Drawing an RSS feed into the php,
That's pretty much it. I'm using Nokogiri to scrape a web page what has

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.