赞
踩
一,OBS openggl main 顶点着色器和片段着色器源码分析
核心的代码区域:
一个是顶点着色器,一个是片段,源码是通过字符串拼接的
在default.effect 着色器源码中:
拼接后的结果:,
1 , #version 330
const bool obs_glsl_compile = true;
uniform mat4x4 ViewProj;
in vec4 inputval_vert_in_pos;
in vec2 inputval_vert_in_uv;
out vec2 outputval_uv;
out gl_PerVertex {
vec4 gl_Position;
};
struct VertInOut {
vec4 pos;
vec2 uv;
};
VertInOut VSDefault(VertInOut vert_in)
{
VertInOut vert_out;
vert_out.pos = ((vec4(vert_in.pos.xyz, 1.0)) * (ViewProj));
vert_out.uv = vert_in.uv;
return vert_out;
}
VertInOut _main_wrap(VertInOut vert_in)
{
return VSDefault(vert_in);
}
void main(void)
{
VertInOut vert_in;
VertInOut outputval;
vert_in.pos = inputval_vert_in_pos;
vert_in.uv = inputval_vert_in_uv;
outputval = _main_wrap(vert_in);
gl_Position = outputval.pos;
outputval_uv = outputval.uv;
}
2,#version 330
const bool obs_glsl_compile = true;
uniform sampler2D image;
in vec2 _vertex_shader_attrib0;
out vec4 _pixel_shader_attrib0;
struct VertInOut {
vec4 pos;
vec2 uv;
};
vec4 PSDrawBare(VertInOut vert_in)
{
return texture(image, vert_in.uv);
}
vec4 _main_wrap(VertInOut vert_in)
{
return PSDrawBare(vert_in);
}
void main(void)
{
VertInOut vert_in;
vert_in.pos = gl_FragCoord;
vert_in.uv = _vertex_shader_attrib0;
_pixel_shader_attrib0 = _main_wrap(vert_in);
}
拼接地方:
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。