1 Star 0 Fork 0

wingsummer / colormap-shaders

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
克隆/下载
贡献代码
同步代码
取消
提示: 由于 Git 不支持空文件夾,创建文件夹后会生成空的 .keep 文件
Loading...
README
MIT

colormap-shaders

A collection of shaders to draw color map like this:

rainbow.

usage

Each *.frag shader sources provides a colormap function, which takes an float argument x (x should be: 0.0 <= x <= 1.0). The colormap function returns a vec4 value which represents an RGBA color.

vec4 colormap(float x);

void main() {
    gl_FragColor = colormap(gl_TexCoord[0].x);
}

/* include "shaders/rainbow.frag" here, for example. */

special case

gnuplot.frag

This shader emulates gnuplot's rgbformulae, and the signature of colormap is:

vec4 colormap(float x, int red_type, int green_type, int blue_type);

It takes additional 3 arguments, with same meanings to rgbformulae's 3 arguments respectively.

usage from c++

#include <colormap/colormap.h>
#include <iostream>

int main()
{
    using namespace colormap;

    // Print RGB table of MATLAB::Jet colormap.
    MATLAB::Jet jet;
    std::cout << "category: " << jet.getCategory() << std::endl;
    std::cout << "title:    " << jet.getTitle() << std::endl;
    int const size = 256;
    for (int i = 0; i < size; ++i) {
        float const x = i / (float)size;
        Color c = jet.getColor(x);
        std::cout << x << "\t" << c.r << "\t" << c.g << "\t" << c.b << std::endl;
    }

    // Dump category and title of all colormaps.
    for (std::shared_ptr<Colormap const> const& c : ColormapList::getAll()) {
        std::cout << c->getCategory() << " : " << c->getTitle() << std::endl;
    }
    return 0;
}

samples

MATLAB

name sample
MATLAB_autumn
MATLAB_bone
MATLAB_cool
MATLAB_copper
MATLAB_hot
MATLAB_hsv
MATLAB_jet
MATLAB_parula
MATLAB_pink
MATLAB_spring
MATLAB_summer
MATLAB_winter

gnuplot

name sample
rgbformulae(7, 5, 15)
rgbformulae(3, 11, 6)
rgbformulae(23, 28, 3)
rgbformulae(21, 22, 23)
rgbformulae(30, 31, 32)
rgbformulae(33, 13, 10)
rgbformulae(34, 35, 36)

IDL

name sample
IDL_Black-White_Linear
IDL_Blue-White_Linear
IDL_Green-Red-Blue-White
IDL_Red_Temperature
IDL_Blue-Green-Red-Yellow
IDL_Standard_Gamma-II
IDL_Prism
IDL_Red-Purple
IDL_Green-White_Linear
IDL_Green-White_Exponential
IDL_Green-Pink
IDL_Blue-Red
IDL_16_Level
IDL_Rainbow
IDL_Steps
IDL_Stern_Special
IDL_Haze
IDL_Blue-Pastel-Red
IDL_Pastels
IDL_Hue_Sat_Lightness_1
IDL_Hue_Sat_Lightness_2
IDL_Hue_Sat_Value_1
IDL_Hue_Sat_Value_2
IDL_Purple-Red+Stripes
IDL_Beach
IDL_Mac_Style
IDL_Eos_A
IDL_Eos_B
IDL_Hardcandy
IDL_Nature
IDL_Ocean
IDL_Peppermint
IDL_Plasma
IDL_Blue-Red_2
IDL_Rainbow_2
IDL_Blue_Waves
IDL_Volcano
IDL_Waves
IDL_Rainbow_18
IDL_Rainbow+White
IDL_Rainbow+Black
IDL_CB-Accent
IDL_CB-Dark2
IDL_CB-Paired
IDL_CB-Pastel1
IDL_CB-Pastel2
IDL_CB-Set1
IDL_CB-Set2
IDL_CB-Set3
IDL_CB-Blues
IDL_CB-BuGn
IDL_CB-BuPu
IDL_CB-GnBu
IDL_CB-Greens
IDL_CB-Greys
IDL_CB-Oranges
IDL_CB-OrRd
IDL_CB-PuBu
IDL_CB-PuBuGn
IDL_CB-PuRdn
IDL_CB-Purples
IDL_CB-RdPu
IDL_CB-Reds
IDL_CB-YIGn
IDL_CB-YIGnBu
IDL_CB-YIOrBr
IDL_CB-BrBG
IDL_CB-PiYG
IDL_CB-PRGn
IDL_CB-PuOr
IDL_CB-RdBu
IDL_CB-RdGy
IDL_CB-RdYiBu
IDL_CB-RdYiGn
IDL_CB-Spectral

transform

name sample
transform_rainbow
transform_apricot
transform_carnation
transform_ether
transform_grayscale_banded
transform_hot_metal
transform_lava_waves
transform_malachite
transform_seismic
transform_space
transform_morning_glory
transform_peanut_butter_and_jerry
transform_purple_haze
transform_rose
transform_saturn
transform_supernova

transform

name sample
kbinani_altitude

license

The MIT License. See 'LICENSE' file for detail.

The MIT License (MIT) Copyright (c) 2015 kbinani Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

简介

A collection of shaders to draw color maps. 展开 收起
C++ 等 4 种语言
MIT
取消

发行版

暂无发行版

贡献者

全部

近期动态

加载更多
不能加载更多了
C++
1
https://gitee.com/wingsummer/colormap-shaders.git
git@gitee.com:wingsummer/colormap-shaders.git
wingsummer
colormap-shaders
colormap-shaders
master

搜索帮助