当前位置:   article > 正文

【基于obs开发推流工具教程】-opengl着色器源码分析_default.effect obs源码解析

default.effect obs源码解析

一,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;
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7

}

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);
  • 1

}
拼接地方:
在这里插入图片描述

声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/很楠不爱3/article/detail/194917
推荐阅读
相关标签
  

闽ICP备14008679号