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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T02:15:15+00:00 2026-05-30T02:15:15+00:00

I’ve recently picked up renderscript and really loving it but the lack of documentation

  • 0

I’ve recently picked up renderscript and really loving it but the lack of documentation and examples isn’t helping. I’ve managed to use the live wallpapers and examples to get my own live wallpaper running but have been for texturing I have been using the fixed function shaders.

I’ve looked at GLSL tutorials but it doesn’t seem to translate over exactly. I’ve looked into the renderscript source code but it still hasn’t been of too much help either.

Here is some code that I dug up from the renderscript sources that seems like what the fixed function is doing:

Program vertex

shaderString.append("varying vec4 varColor;\n");
shaderString.append("varying vec2 varTex0;\n");
shaderString.append("void main() {\n");
shaderString.append("  gl_Position = UNI_MVP * ATTRIB_position;\n");
shaderString.append("  gl_PointSize = 1.0;\n");
shaderString.append("  varColor = ATTRIB_color;\n");
shaderString.append("  varTex0 = ATTRIB_texture0;\n");
shaderString.append("}\n");

Program fragment

shaderString.append("varying lowp vec4 varColor;\n");
shaderString.append("varying vec2 varTex0;\n");
shaderString.append("void main() {\n");
shaderString.append("  lowp vec4 col = UNI_Color;\n");
shaderString.append("  gl_FragColor = col;\n");
shaderString.append("}\n");

I don’t think these are the best examples because the fragment doesn’t seem to touch the varTex0 variable. I’ve tried to write my own program fragment and use the fixed function vertex shader.

Here’s my fragment shader:

ProgramFragment.Builder b = new ProgramFragment.Builder(mRS);
    String s = "void main() {" +
       " gl_FragColor = vec4(1.0,1.0,1.0,0.5);" +
       "}";
    b.setShader(s);
    pf = b.create();
    mScript.set_gPFLights(pf);

Extremely basic but any attempt at binding a texture has failed. I don’t know what variable is needed for the texture.

Could anyone provide an example of a basic program vertex and program fragment that uses textures? Thanks in advance.

  • 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-30T02:15:16+00:00Added an answer on May 30, 2026 at 2:15 am

    I finally managed to find the sources for the FixedFunction classes that are used to create GLSL shaders. There are located within “android_frameworks_base / graphics / java / android / renderscript”.

    Here is what the fragment shader with these FixedFunction settings :

    ProgramFragmentFixedFunction.Builder builder = new ProgramFragmentFixedFunction.Builder(mRS);
        builder.setTexture(ProgramFragmentFixedFunction.Builder.EnvMode.REPLACE,
                           ProgramFragmentFixedFunction.Builder.Format.RGBA, 0); //CHANGED
        ProgramFragment pf = builder.create(); //RENAMED
        pf.bindSampler(Sampler.WRAP_NEAREST(mRS), 0);
    

    would look like :

    ProgramFragment.Builder pfBuilder = new ProgramFragment.Builder(mRS);
        String s = "varying vec2 varTex0;" +
                           "void main() {" +
                           " lowp vec4 col;" +
                           " vec2 t0 = varTex0;" +
                           " col.rgba = texture2D(UNI_Tex0, t0).rgba;" +
                           " gl_FragColor = col;" +
                       "}";
        pfBuilder.setShader(s);
        pfBuilder.addTexture(TextureType.TEXTURE_2D);
        pf = pfBuilder.create();
    

    This fragment shader works with the ProgramVertexFixedFunction.

    I haven’t gotten around to seeing what the FixedFunction vertex shader looks like but I will update this answer when I do.

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

Sidebar

Related Questions

link Im having trouble converting the html entites into html characters, (&# 8217;) i
I want to count how many characters a certain string has in PHP, but
I am trying to understand how to use SyndicationItem to display feed which is
I have a string like this: La Torre Eiffel paragonata all’Everest What PHP function
Seemingly simple, but I cannot find anything relevant on the web. What is the
I have a French site that I want to parse, but am running into
I want use html5's new tag to play a wav file (currently only supported
I'm parsing an RSS feed that has an ’ in it. SimpleXML turns this
I need to clean up various Word 'smart' characters in user input, including but
I'm trying to use string.replace('’','') to replace the dreaded weird single-quote character: ’ (aka

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.