#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. JS与小程序页面生命周期

    Page({ /** * 页面的初始数据 */ data: { }, /** * 生命周期函数--监听页面加载 */ onLoad: function (options) { }, /** * 生命周 ...

  2. Zookeeper配置安装

    单机模式: 1:修改hosts文件 ​ 2:下载解压zookeeper.tar文件 3:创建data目录和logs目录 进入zookeeper目录下创建 ​ 4:复制一份zoo_sample.cfg配 ...

  3. Promise原理实现

    首先先看一下 promise 的调用方式: // 实例化 Promise: new MyPromise((resolve, reject) => { setTimeout(() => { ...

  4. .NET总结一

    因为考试的原因,总结一致拖到现在才写,但必须做一个总结,没有总结相当于没有学过.VB.NET主要是用面向对象的基础来进行程序设计,虽然之前总是能够听到面向对象,但从未真正接触面向对象技术,从VB.NE ...

  5. js获取此刻时间或者把日期格式时间转换成字符串格式的时间

    getTime(val){ if (val&val instanceof Date){ d = val; }else{ d = new Date(); }; var year = d.getF ...

  6. Kubernetes概览

    Kuberbetes这个名字是什么意思?k8s又是什么?Kubernetes这个名字源自希腊语,意思是“舵手”,也是“管理者”,“治理者”等词的源头.k8s是 Kubernetes的简称(用数字『8』 ...

  7. Java多线程下载初试

    一.服务端/客户端代码的实现 服务端配置config @ConfigurationProperties("storage") public class StoragePropert ...

  8. django 渲染模板与 vue 的 {{ }} 冲突解决方法

    如果不可避免的在同一个页面里既有 django 渲染又有 vue 渲染的部分,可有 2 种方式解决 方法一: 采用 vue 的 delimiters  分隔符. new Vue({ delimiter ...

  9. sql server 存储过程中,调用事务 tran

      Sql Server 2005/2008中提供了begin tran,commit tran和rollback tran来使用事务. begin tran表示开始事务, commit tran表示 ...

  10. Oracle ORA-00600[2662] 解决

    一.问题描述 1.数据库情况 1)数据库版本:11.2.0.4: 2)未开启归档: 3)没有备份:无RMAN备份.无DUMP备份: 4)数据库redo log 日志组,每组只有一个成员: 2.问题出现 ...