Object Matrix on Custom Shader _ new Question (how to flip it)

In the following code if I was doing a conversion what would the objectMatrix be with BJS?

#ifdef GL_ES
precision highp float;
#endif

varying vec2 vUv;
varying vec3 vPos0;
varying vec3 vPos1;
varying vec3 vPos1n;
varying mat4 vObjMatInv;

void main()
{
vUv = uv;

gl_Position = projectionMatrix *
modelViewMatrix *
vec4(position,1.0);

vPos0 = ( objectMatrix * vec4(position, 1.0) ).xyz;
vPos1 = position;
vPos1n = position+vec3(0.5);

//vObjMatInv = inverse(objectMatrix);
}

Right now I have:

attribute vec3 position;
attribute vec3 normal;
attribute vec2 uv;

uniform mat4 worldViewProjection;
uniform float time;
uniform vec2 depthValues;

varying vec3 vPosition;
varying vec3 vPosition1;
varying vec3 vPosition1n;
varying vec2 vUV;
varying float vDepthMetric;

void main() {
vec4 p = vec4( position, 1. );
vPosition = p.xyz;
vUV = uv;
gl_Position = worldViewProjection * p;

vPosition = ( objectMatrix * vec4(position, 1.0) ).xyz;
vPosition1 = position;
vPosition1n = position+vec3(0.5);

vDepthMetric = ((gl_Position.z + depthValues.x) / (depthValues.y));

}

And am just not sure what to replace objectMatrix with.

I think it is just the gl_position, now that I tried that.

Now that I have the basic volume being displayed, I have noticed that my coordinate system is flipped?
https://playground.babylonjs.com/#MXZZ2V

Anyone have any good ideas on how to fix this? I tried flipping the y of the ray origin and that kinda fixed it but made glitches.

I figured it out.

3 Likes