Skip to content

View matrix not accessible in shader by default #5504

@Dawars

Description

@Dawars

By default a few useful uniforms don't get set for a shader.
The defaults are: MVP (transform), MV, P, (MV)^-1T (normalMat) and textureMat.

In addition it would be useful to set the view, viewInv matrices and the cameraPos vector.
For example when working in world space (reflection/refraction with env mapping).

It is possible to set them manually:

pg = (PGraphicsOpenGL) this.g;
...
shader.set("view", pg.camera);
shader.set("viewInv", pg.cameraInv);
shader.set("cameraPos", pg.modelviewInv.m03, pg.modelviewInv.m13, pg.modelviewInv.m23);

And then the model matrix can be calculated in the shader like this: viewInv * modelview

I'm going to make the required changes during the next week.
My question is, how should I call them according to the conventions (alternative names)?

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions