osg Shader 着色器
#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 着色器的更多相关文章
- Unity3D学习笔记(三十四):Shader着色器(1)
一.GPU:图形处理器,Graphics Processing Unit 显卡的处理器就是图形处理器.与CPU类似. GPU和CPU的区别? 1.CPU主要是为了串行指令设计,GPU则是为了大规模 ...
- Unity Shader着色器优化
https://mp.weixin.qq.com/s?__biz=MzU5MjQ1NTEwOA==&mid=2247493518&idx=1&sn=c51b92e9300bcf ...
- [Unity] Shader(着色器)输入输出和语义
在Unity5.x后, 已经支持了基于物理的光照模型,也就是常说的次时代引擎所必须具备的功能. 如果在Properties使用2D,CG里要用sampler2D,代表使用的是2维纹理 如果在Prope ...
- [Unity] Shader(着色器)之纹理贴图
在Shader中,我们除了可以设定各种光线处理外,还可以增加纹理贴图. 使用 settexture 命令可以为着色器指定纹理. 示例代码: Shader "Sbin/ff2" { ...
- OpenGL之shader着色器的应用,三色渐变的三角形
学习自: https://learnopengl-cn.github.io/01%20Getting%20started/05%20Shaders/#_7 首先放一张效果图: 本次教程,将着色器单独定 ...
- Unity3D学习笔记(三十五):Shader着色器(2)- 顶点片元着色器
Alpha测试 AlphaTest Great:大于 AlphaTest Less:小于 AlphaTest Equal:等于 AlphaTest GEqual:大于等于 AlphaTest LEqu ...
- [Shader 着色器]冰霜效果的思考和实现
http://game.ceeger.com/forum/read.php?tid=23209&fid=2 由于最近要做一个冰系的角色,就想能不能做一些冰霜效果.那么就试试吧,先弄一张原图: ...
- [Unity] Shader(着色器)之固定管线
在Unity中,固定管线Shader的性能是最好的. 什么是固定管线呢? 固定渲染管线 —— 这是标准的几何&光照(T&L)管线,功能是固定的,它控制着世界.视.投影变换及固定光照控制 ...
- Unity3D学习笔记(三十六):Shader着色器(3)- 光照
光照模型:用数学的方法模拟现实世界中的光照效果. 场景中模型身上的光反射到相机中的光线: 1.漫反射:产生明暗效果 2.高光反射:产生镜面反射,物体中有最亮且比较耀眼的一部分 3.自发光: 4.环 ...
随机推荐
- celery timeout的拦截
0X01 场景 celery任务超时报错,想查看是传入哪一类数据运行时导致的超时(哪一个插件),但是该报错难以拦截. [2019-06-30 17:23:21,070: ERROR/MainProce ...
- DYNAMIC LINK LIBRARY - DLL
https://www.tenouk.com/ModuleBB.html MODULE BB DYNAMIC LINK LIBRARY - DLL Part 1: STORY What do we h ...
- 【CSP模拟赛】God knows (李超线段树)
题面 CODE 稍微分析一下,发现把(i,pi)(i,p_i)(i,pi)看做二维数点,就是求极长上升子序列的权值最小值. 直接李超线段树 #include <bits/stdc++.h> ...
- Second Max of Array
Find the second max number in a given array. Example Given [1, 3, 2, 4], return 3. Given [1, 2], ret ...
- 03_Tutorial 3: Class-based Views 基于类的视图(CBV)
1.CBV 0.文档 https://q1mi.github.io/Django-REST-framework-documentation/tutorial/3-class-based-views_z ...
- [NgRx] NgRx Runtime Checks
Turn on runtime check: @NgModule({ declarations: [AppComponent], imports: [ ..., StoreModule.forRoot ...
- 通用分页jsp页面显示
注:本章内容都是在上一篇文章 通用分页后台显示:https://www.cnblogs.com/ly-0919/p/11058942.html 的基础上进行改进,所以有许多的类都在上一篇, 带来不便 ...
- Python爬虫:BeautifulSoup用法总结
原文 BeautifulSoup是一个解析HTML或XML文件的第三方库.HTML或XML文件可以用DOM模型解释.一般包含三种节点: 元素节点 - 通常指HTML 或 XML的标签 文本节点 - 标 ...
- hbase的region
一.Region 概念 Region是表获取和分布的基本元素,由每个列族的一个Store组成.对象层级图如下: Table (HBase table) Region (Regions for the ...
- 063_显示本机 Linux 系统上所有开放的端口列表
#!/bin/bash#从端口列表中观测有没有没用的端口,有的话可以将该端口对应的服务关闭,防止意外的攻击可能性 ss -nutlp |awk '{print $1,$5}' | awk -F&quo ...