Skip navigation
XColomer
Currently Being Moderated

Weird Shader Behavior

Mar 6, 2013 10:28 AM

Tags: #stage3d #shaders

Hi There,

 

This question has also been posted in SO:

http://stackoverflow.com/questions/15255004/weird-shader-behavior-in-s tage3d

 

I am using this vertex Shader:

 

<script id="per-fragment-lighting-vs" type="x-shader/x-vertex">

    attribute vec3 aVertexPosition;

    attribute vec3 aVertexNormal;

    attribute vec2 aTextureCoord;

 

 

    uniform mat4 uMVMatrix;

    uniform mat4 uPMatrix;

    uniform mat3 uNMatrix;

 

 

    varying vec2 vTextureCoord;

    varying vec3 vTransformedNormal;

    varying vec4 vPosition;

 

 

 

 

    void main(void) {

        vPosition = uMVMatrix * vec4(aVertexPosition, 1.0);

        gl_Position = uPMatrix * vPosition;

        vTextureCoord = aTextureCoord;

        vTransformedNormal = uNMatrix * aVertexNormal;

    }

</script>

 

But all I can see is tiles instead the object correctly textured.

 

If I edit the shader like this:

 

<script id="per-fragment-lighting-vs2" type="x-shader/x-vertex">

    attribute vec3 aVertexPosition;

    attribute vec3 aVertexNormal;

    attribute vec2 aTextureCoord;

 

 

    uniform mat4 uMVMatrix;

    uniform mat4 uPMatrix;

    uniform mat3 uNMatrix;

 

 

    varying vec2 vTextureCoord;

    varying vec3 vTransformedNormal;

    varying vec4 vPosition;

 

    void main(void) {

        gl_Position = uMVMatrix * vec4(aVertexPosition, 1.0);

        vTextureCoord = aTextureCoord;

        vTransformedNormal = uNMatrix * aVertexNormal;

    }

</script>

 

And premultiply the perspective in actionsctript I can see the object correctly mapped although it has a different perspective

 

Any suggestion?

 
Replies

More Like This

  • Retrieving data ...

Bookmarked By (0)

Answers + Points = Status

  • 10 points awarded for Correct Answers
  • 5 points awarded for Helpful Answers
  • 10,000+ points
  • 1,001-10,000 points
  • 501-1,000 points
  • 5-500 points