Rajawali Tutorial 7: Creating a Custom Material / GLSL Shader

Posted by on Feb 22, 2012 in 3D, Android, Rajawali8 comments

This tutorial has moved to the Rajawali Wiki



Tags: , , , ,


8 comments

» Comments RSS Feed
  1. [...] to Rajawali Tutorial 7: Creating a Custom Material / GLSL Shader. Tags: 3D, Android, OpenGL ES, [...]

  2. [...] To demonstrate this, I’m gonna use the custom material that I blogged about earlier today. [...]

  3. [...] Rajawali Tutorial 7: Creating a Custom Material / GLSL Shader [...]

  4. Hi, I’m using your engine and really like it! :) I tested the custom material example, but I get a “-1″ when I initialize my own uniform handles with e.g. “GLES20.glGetUniformLocation(mProgram, ‘uLightMVPMatrix’);”. Do you know what to do? I inserted the variable in the vertex shader as well and “checkGlError” doesn’t moan any thing…

    Thanks

  5. Hi Ammo,
    I’m glad you like the engine :-)
    Could you possibly show me some code so I can figure out where things go wrong?
    You could also log this issue here: https://github.com/MasDennis/Rajawali/issues
    Cheers,
    Dennis

  6. Dennis, there is a problem with the following code:

    mTime += .1f;
    mCustomMaterial.setTime(mTime);

    Sonner or later the variable will overflow (both the java variable and the shader variable).

  7. hi!,
    Dennis, there is a problem….,

    i’m use below code in my wallpaper

    public class CustomMaterial extends SimpleMaterial {
    protected static final String mCustomFShader =
    “precision mediump float;\n” +

    “uniform float uTime;\n” +
    “varying vec2 vTextureCoord;\n” +

    “void main() {\n” +
    ” vec4 newColor = vec4(1.0,1.0,0,1.0);\n” +
    ” float x = max(vTextureCoord.s, 4.0 – vTextureCoord.s);” +
    ” float z = vTextureCoord.t;” +
    ” newColor.g = cos(z * sin(uTime*0.1) * 120.0) + ” +
    ” sin(x * cos(uTime*0.0666) * 120.0) + ” +
    ” sin(sqrt(z * z + x * x) * 40.0);\n” +
    ” gl_FragColor = newColor;\n” +
    “}\n”;

    But i want to changes in shader view…So please help me.

  8. hi~ It’s the best 3d engine i have used based on OpenGL ES. Right now I am focusing on the a Double Sided Leaf. I used 3D max to get a double sided leaf with two different materials. how can i import the materials into Rajawali?? i.e. import two materials for a object, and displays them in order.

Leave a comment