Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /// Который выводит позицию из текстуры
- varying vec2 v_vPosition;
- uniform sampler2D u_sTex_Position;
- uniform vec2 u_vResolution;
- uniform mat4 u_mIVP;
- void main()
- {
- vec2 uv = v_vPosition / u_vResolution;
- vec4 v_position = texture2D( u_sTex_Position, uv );
- vec3 pospo2 = v_position.xyz*2.0 - 1.0;
- vec4 posivp = (u_mIVP * vec4((uv * 2.0 - 1.0), v_position.z * 2.0 - 1.0, 1.0));
- vec3 pospos = posivp.xyz/posivp.w;
- gl_FragColor = vec4( pospos, 1.0 );
- }
- /// Который записывает позицию в текстуру
- /// VERT
- attribute vec3 in_Position;
- varying vec4 v_vPosition;
- void main()
- {
- vec4 object_space_pos = vec4( in_Position.x, in_Position.y, in_Position.z, 1.0);
- gl_Position = gm_Matrices[MATRIX_WORLD_VIEW_PROJECTION] * object_space_pos;
- v_vPosition = gl_Position;
- }
- /// FRAG
- varying vec4 v_vPosition;
- void main()
- {
- vec4 pos = v_vPosition;
- pos.xyz /= pos.w;
- pos.xyz *= 0.5;
- pos.xyz += 0.5;
- gl_FragColor = vec4( pos.xyz, 1.0 );
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement