AnNE DoM.ini

08-15-2015, 07:01 PM

I have some textured object and image. I need to project this image on object.

Also i have

"rayStart" - vector3, the point i'm looking from.

"rayEnd" - vector3, the point i'm looking at.

"rayRot" - vector3, wihch defines rotation of image

And i cant figure out how to write vert and frag shaders, and looking for help to get this working. I was trynig make some use of tutorial from ozone3d.net, but stuck at the very beginning with "TexGenMatrix" For now i only have basiс code:

VERT:

uniform mat4 modelViewProjectionMatrix;

attribute vec4 position;

attribute vec2 texture0;

attribute vec2 texture1;

varying vec2 texCoord1;

varying vec2 texCoord2;

varying vec2 tc;

void main() {

texCoord1 = texture0;

texCoord2 = texture1;

tc = texCoord1;

gl_Position = modelViewProjectionMatrix * position;

}

FRAG:

precision highp float;

uniform sampler2D textureUnit0;

uniform sampler2D textureUnit1;

varying vec2 texCoord1;

varying vec2 texCoord2;

uniform vec3 rayStart;

uniform vec3 rayEnd;

uniform vec3 rayRot;

void main() {

vec4 texColor = texture2D(textureUnit0, texCoord1);

vec3 decalColor = texture2D(textureUnit1, texCoord1).rgb;

gl_FragColor = texColor;

}

Also i have

"rayStart" - vector3, the point i'm looking from.

"rayEnd" - vector3, the point i'm looking at.

"rayRot" - vector3, wihch defines rotation of image

And i cant figure out how to write vert and frag shaders, and looking for help to get this working. I was trynig make some use of tutorial from ozone3d.net, but stuck at the very beginning with "TexGenMatrix" For now i only have basiс code:

VERT:

uniform mat4 modelViewProjectionMatrix;

attribute vec4 position;

attribute vec2 texture0;

attribute vec2 texture1;

varying vec2 texCoord1;

varying vec2 texCoord2;

varying vec2 tc;

void main() {

texCoord1 = texture0;

texCoord2 = texture1;

tc = texCoord1;

gl_Position = modelViewProjectionMatrix * position;

}

FRAG:

precision highp float;

uniform sampler2D textureUnit0;

uniform sampler2D textureUnit1;

varying vec2 texCoord1;

varying vec2 texCoord2;

uniform vec3 rayStart;

uniform vec3 rayEnd;

uniform vec3 rayRot;

void main() {

vec4 texColor = texture2D(textureUnit0, texCoord1);

vec3 decalColor = texture2D(textureUnit1, texCoord1).rgb;

gl_FragColor = texColor;

}