博客
关于我
【OpenGL】高级片段着色器——discard舍弃片段
阅读量:490 次
发布时间:2019-03-07

本文共 804 字,大约阅读时间需要 2 分钟。

在这篇文章基础上进行改进片段着色器代码,效果一样。

// Julia set renderer// Fragment Shader// Graham Sellers// OpenGL SuperBible#version 150precision highp float;out vec4 color;in vec2 initial_z;uniform sampler1D tex_gradient;uniform vec2 C;void main(void){    vec2 Z = initial_z;    int iterations = 0;    const float threshold_squared = 16.0;    const int max_iterations = 1000;    while (iterations < max_iterations && dot(Z, Z) < threshold_squared) {        vec2 Z_squared;        Z_squared.x = Z.x * Z.x - Z.y * Z.y;        Z_squared.y = 2.0 * Z.x * Z.y;        Z = Z_squared + C;        iterations++;    }		if (iterations == max_iterations)		discard;    //if (iterations == max_iterations)    //    color = vec4(0.0, 0.0, 0.0, 1.0);    //else        color = texture(tex_gradient, float(iterations) / float(max_iterations));}

 

转载地址:http://akycz.baihongyu.com/

你可能感兴趣的文章
MySQL的错误:No query specified
查看>>
mysql监控工具-PMM,让你更上一层楼(上)
查看>>
mysql监控工具-PMM,让你更上一层楼(下)
查看>>
MySQL相关命令
查看>>
mysql社工库搭建教程_社工库的搭建思路与代码实现
查看>>
Warning: Can't perform a React state update on an unmounted component. This is a no-
查看>>
mysql笔记 (早前的,很乱)
查看>>
MySQL笔记:InnoDB的锁机制
查看>>
mysql第一天~mysql基础【主要是DDL、DML、DQL语句,以及重点掌握存存引擎、查询(模糊查询)】
查看>>
mysql第二天~mysql基础【查询排序、分页查询、多表查询、数据备份与恢复等】
查看>>
MySQL简介和安装
查看>>
MySQL简单查询
查看>>
MySQL管理利器 MySQL Utilities 安装
查看>>
MySQL篇(管理工具)
查看>>
mysql类型转换函数convert与cast的用法
查看>>
mysql系列一
查看>>
MySQL系列之数据授权(安全)
查看>>
MySQL系列之数据类型(Date&Time)
查看>>
MySQL系列之数据类型(Date&Time)
查看>>
Mysql系列之锁机制
查看>>