Skip to content

Vertex attributes are passed in view space instead of model space to the vertex shader #2904

Description

@P0ulp

Relating to this topic : http://forum.processing.org/two/discussion/7484/vertex-attribute-bug-#Item_5

I just set a color if the vertex X position is > 0 or not. So if the vertex is really in world space, not in view, if i move the camera the color would stay at the same position on the box. Here, the color move on the box when i move the camera not the world(so the view matrix ?)

Is-it a normal behaviour ?

PDE

import peasy.*;

PShader cubemapShader; PeasyCam cam;

void setup() { size(800, 640, P3D); frameRate(60);

// Load cubemap shader. cubemapShader = loadShader("cubemapfrag.glsl", "cubemapvert.glsl"); cam = new PeasyCam(this, 0, 0, 0, 180); cam.setYawRotationMode(); }

void draw() { background(0); shader(cubemapShader); box(50); resetShader(); }

Vertex


uniform mat4 transform;

attribute vec4 position;

varying vec4 pos;

void main() {

pos = position;

gl_Position = transform * position;

}

Fragment


varying vec4 pos;

void main() { if(pos.x > 0.0){ gl_FragColor = vec4(1,0,0,1); } else{ gl_FragColor = vec4(0,0,1,1); } }

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions