zoukankan      html  css  js  c++  java
  • ogre 中的 shader

    shader可以用在material里 被setmaterial到entity

    那 用于全屏的 shader要怎样使用呢?

    是通过 compositot  。

    compositot是对viewport进行处理的  

    这是一个compositor脚本的粒子 from wikiogre

    对了这里介绍下 wikiogre 除了 basicturtorial和intermediateturtorial

      还有 DCCTurtorial 里面的materail和HDR什么的都能抄

      还有 snippets     http://www.ogre3d.org/tikiwiki/Snippets  里面对ogre介绍很多  

                    包括shader particle animation sound physics system....

      这是一个老版本的manual 杨延平翻译http://www.ogre3d.cn/wiki/index.php?title=%E6%96%87%E6%A1%A3:%E6%89%8B%E5%86%8C:1-4-0


    compositor Bloom
    {    
         technique    
                 {       
                          // Temporary textures
            texture scene target_width target_height PF_A8R8G8B8
            texture rt0 128 128 PF_A8R8G8B8
            texture rt1 128 128 PF_A8R8G8B8
             target scene
            {
                // Render output from previous compositor (or original scene)
                input previous
            }
            target rt0
            {
                // Start with clear texture
                input none
                // Vertical blur pass
                pass render_quad
                {
                    // Renders a fullscreen quad with a material
                    material PostFilters/Blur0
                    input 0 scene
                }
            } 
           target rt1
            { 
               // Start with clear texture
                input none 
               // Horizontal blur pass
                pass render_quad
                {
                    // Renders a fullscreen quad with a material
                    material PostFilters/Blur1
                    input 0 rt0
                }        }
            target_output
            {
                // Start with clear output
                input none
                // Draw a fullscreen quad
                pass render_quad 
               { 
                   // Renders a fullscreen quad with a material 
                   material PostFilters/BloomBlend 
                   input 0 scene 
                   input 1 rt1
                } 
           }
        }
    }//这些空格好难排啊

    使用

    CompositorManager::getSingleton().addCompositor(viewport, compositorName);
    CompositorManager::getSingleton().setCompositorEnabled(viewport, compositorName, enabledOrDisabled);
    这是一个bloom的compositor里面包含一个technique
     technique里面包含三个target在开始的地方有声明格式
    第一个target scene根据input参数
    previous 表示 是从上个viewport自动获取 (或者啥啥的自己google)
    第二个target rt0 input为空但是它的pass的input 为scene 采用material
    PostFilters/Blur0后面介绍 shader就在这里面和material脚本那套一样

    第三个 target rt1 input为空 它的pass以rt1如输入 用materail的
    PostFilters/Blur1实现
    最后一个target 输出了不用指定格式  套路同上 
    下面分析一个 这是新版本里面的blur的material不是一套的
    material Ogre/Compositor/BlurH
    {
     technique{pass
    {
    cull_hardware nonecull_software nonedepth_check off

    fragment_program_ref BlurH_ps
    {}
    vertex_program_ref Blur_vs
    {}
    texture_unit
    {
    tex_coord_set 0
    tex_address_mode
     clampfiltering trilinear}}}}
    这里面加了两个shader
    BlurH_ps 
    Blur_vs

  • 相关阅读:
    mysql 查询优化 ~ select count 知多少
    mongodb 案例 ~ 经典故障案例
    printk 驱动调试
    21天学通C++学习笔记(七):函数
    OPC UA
    MQTT
    分库分表
    水平、垂直权限问题(横向越权与纵向越权)
    数据库中的行转列和列转行
    面试知识点
  • 原文地址:https://www.cnblogs.com/minggoddess/p/1907261.html
Copyright © 2011-2022 走看看