#ifdef _WIN32
#include <Windows.h>
#endif // _WIN32 #include <osg/Group>
#include <osg/Camera>
#include <osgDB/ReadFile>
#include <osg/Node> #include <osg/Geometry>
#include <osg/Image>
#include <osg/ShapeDrawable>
#include <osg/Texture2D> #include <osg/MatrixTransform>
#include <osg/AnimationPath> #include <osgViewer/Viewer>
#include <osgViewer/ViewerEventHandlers> #include <osgGA/DriveManipulator>
#include <osgGA/GUIEventHandler>
#include <osgGA/GUIEventAdapter>
#include <osgGA/GUIActionAdapter> #include <osgGA/AnimationPathManipulator>
#include <osgGA/KeySwitchMatrixManipulator> #include <osgUtil/LineSegmentIntersector> #include <iostream>
using namespace std; //顶点着色器
static const char* vertShader = {
"varying vec4 color;\n"
"void main(void)\n"
"{\n"
"color = gl_Vertex;\n"
"gl_Position=gl_ModelViewProjectionMatrix*gl_Vertex;\n"
"}\n"
}; //片元着色器
static const char* fragShader = {
"varying vec4 color;\n"
"void main(void)\n"
"{\n"
" gl_FragColor = clamp(color,0.1,0.8);\n"
"}\n"
}; int main()
{
osg::ref_ptr<osgViewer::Viewer> viewer1 = new osgViewer::Viewer;
osg::ref_ptr<osg::Group> group1 = new osg::Group;
osg::ref_ptr<osg::Program> program1 = new osg::Program;
//osg::ref_ptr<osg::Node> node1 = osgDB::readNodeFile("D:\\参考手册\\BIM\\osg\\四合院2019.osgb");
osg::ref_ptr<osg::Node> node1 = osgDB::readNodeFile("D:\\参考手册\\BIM\\obj\\person1.obj"); osg::ref_ptr<osg::StateSet> stateset1 = node1->getOrCreateStateSet(); program1->addShader(new osg::Shader(osg::Shader::VERTEX, vertShader));
program1->addShader(new osg::Shader(osg::Shader::FRAGMENT, fragShader));
stateset1->setAttributeAndModes(program1, osg::StateAttribute::ON); group1->addChild(node1.get());
viewer1->setSceneData(group1);
viewer1->setUpViewInWindow(, , , , ); return viewer1->run();
}

osg Shader 着色器的更多相关文章

  1. Unity3D学习笔记(三十四):Shader着色器(1)

    一.GPU:图形处理器,Graphics Processing Unit 显卡的处理器就是图形处理器.与CPU类似.   GPU和CPU的区别? 1.CPU主要是为了串行指令设计,GPU则是为了大规模 ...

  2. Unity Shader着色器优化

    https://mp.weixin.qq.com/s?__biz=MzU5MjQ1NTEwOA==&mid=2247493518&idx=1&sn=c51b92e9300bcf ...

  3. [Unity] Shader(着色器)输入输出和语义

    在Unity5.x后, 已经支持了基于物理的光照模型,也就是常说的次时代引擎所必须具备的功能. 如果在Properties使用2D,CG里要用sampler2D,代表使用的是2维纹理 如果在Prope ...

  4. [Unity] Shader(着色器)之纹理贴图

    在Shader中,我们除了可以设定各种光线处理外,还可以增加纹理贴图. 使用 settexture 命令可以为着色器指定纹理. 示例代码: Shader "Sbin/ff2" { ...

  5. OpenGL之shader着色器的应用,三色渐变的三角形

    学习自: https://learnopengl-cn.github.io/01%20Getting%20started/05%20Shaders/#_7 首先放一张效果图: 本次教程,将着色器单独定 ...

  6. Unity3D学习笔记(三十五):Shader着色器(2)- 顶点片元着色器

    Alpha测试 AlphaTest Great:大于 AlphaTest Less:小于 AlphaTest Equal:等于 AlphaTest GEqual:大于等于 AlphaTest LEqu ...

  7. [Shader 着色器]冰霜效果的思考和实现

    http://game.ceeger.com/forum/read.php?tid=23209&fid=2 由于最近要做一个冰系的角色,就想能不能做一些冰霜效果.那么就试试吧,先弄一张原图: ...

  8. [Unity] Shader(着色器)之固定管线

    在Unity中,固定管线Shader的性能是最好的. 什么是固定管线呢? 固定渲染管线 —— 这是标准的几何&光照(T&L)管线,功能是固定的,它控制着世界.视.投影变换及固定光照控制 ...

  9. Unity3D学习笔记(三十六):Shader着色器(3)- 光照

    光照模型:用数学的方法模拟现实世界中的光照效果.   场景中模型身上的光反射到相机中的光线: 1.漫反射:产生明暗效果 2.高光反射:产生镜面反射,物体中有最亮且比较耀眼的一部分 3.自发光: 4.环 ...

随机推荐

  1. 上传文件(lrzsz)

    执行命令:yum -y install lrzsz 现在就可以正常使用rz.sz命令上传.下载数据了. 上传文件,执行命令rz,会跳出文件选择窗口,选择好文件,点击确认即可. 下载文件,执行命令sz

  2. python-selenium安装笔记

    python-selenium操作火狐,谷歌,360,ie 亲测可用,windows环境 python3.6 由于python2到2020年不进行维护所有都用python3 selenium pip ...

  3. php中危险的木马函数-eval()函数

    eval() 函数可将字符串转换为代码执行,并返回一个或多个值. 如果eval函数在执行时遇到错误,则抛出异常给调用者. 类似的函数是loadcode ,loadcode并不立即执行代码,而是返回一个 ...

  4. jQuery toast 淡入淡出提示

    #toast{ position: fixed; top: 44%;left:50%;transform: translateX(-50%); min-width: 80px; max-width: ...

  5. vue 自定义全局组件

  6. GBDT算法梳理

    1.GBDT(Gradient Boosting Decision Tree)思想 Boosting : 给定初始训练数据,由此训练出第一个基学习器: 根据基学习器的表现对样本进行调整,在之前学习器做 ...

  7. bootstrap Table 的使用方法

    然后添加css  找到bootstrap-table.min.css 添加进去 再添加JS Js添加时  按照顺序添加 然后初始化bootstrap-table <script type=&qu ...

  8. Wireshark抓取本地回环接口数据包 RawCap.exe

    Wireshark提供了winpcap可以抓取远程网卡数据包...但我尝试了不成功.后来发现RawCap.exe不仅可以抓取回环接口数据包,远程跑了拿到pcap文件再打开用起来比winpcap更方便最 ...

  9. Bzoj 2282: [Sdoi2011]消防(二分答案)

    2282: [Sdoi2011]消防 Time Limit: 10 Sec Memory Limit: 512 MB Description 某个国家有n个城市,这n个城市中任意两个都连通且有唯一一条 ...

  10. 特征工程学习01-sklearn单机特征工程

    特征工程学习01-sklearn单机特征工程 小书匠 kindle  0.数据的导入 from sklearn.datasets import load_iris  #导入IRIS数据集  iris= ...