Jump to content

Problem with shader

Snow Bars

Recommended Posts


I try apply shader to simple object but have webgl warning and black model. On http://www.babylonjs.com/cyos/#1UJ9WV shader is work. Please tell me where error?

I try place shaders in head of page like

<script type="application/vertexShader" id="vertexShaderCode">
    precision highp float;

    // Attributes
    attribute vec3 position;
    attribute vec2 uv;

    // Uniforms
    uniform mat4 worldViewProjection;

    // Normal
    varying vec2 vUV;

    void main(void) {
        gl_Position = worldViewProjection * vec4(position, 1.0);

        vUV = uv;

<script type="application/fragmentShader" id="fragmentShaderCode">
    precision highp float;
    varying vec2 vUV;

    uniform sampler2D textureSampler;

    void main(void) {
        gl_FragColor = texture2D(textureSampler, vUV);

and call it like

var amigaMaterial = new BABYLON.ShaderMaterial("amiga", $rootScope.scene, {
        vertexElement: "vertexShaderCode",
        fragmentElement: "fragmentShaderCode"
        attributes: ["position", "normal", "uv"],
        uniforms: ["world", "worldView", "worldViewProjection", "view", "projection"]

sphere1.material = amigaMaterial;

Strange but on http://www.babylonjs-playground.com/#25OIA it not work totaly...

Sory for my english...

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.


  • Recently Browsing   0 members

    • No registered users viewing this page.
  • Create New...