博客
关于我
【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万字总结!超详细!
查看>>
Mysql下载以及安装(新手入门,超详细)
查看>>
MySQL中B+Tree索引原理
查看>>
mysql中cast() 和convert()的用法讲解
查看>>
mysql中datetime与timestamp类型有什么区别
查看>>
mysql中floor函数的作用是什么?
查看>>
MySQL中group by 与 order by 一起使用排序问题
查看>>
mysql中having的用法
查看>>
MySQL中interactive_timeout和wait_timeout的区别
查看>>
mysql中int、bigint、smallint 和 tinyint的区别、char和varchar的区别详细介绍
查看>>
mysql中json_extract的使用方法
查看>>
mysql中json_extract的使用方法
查看>>
mysql中null和空字符串的区别与问题!
查看>>
MySQL中ON DUPLICATE KEY UPDATE的介绍与使用、批量更新、存在即更新不存在则插入
查看>>
MYSQL中TINYINT的取值范围
查看>>
Mysql中varchar类型数字排序不对踩坑记录
查看>>
mysql中出现update-alternatives: 错误: 候选项路径 /etc/mysql/mysql.cnf 不存在 dpkg: 处理软件包 mysql-server-8.0的解决方法(全)
查看>>
MySQL中地理位置数据扩展geometry的使用心得
查看>>
Mysql中存储引擎简介、修改、查询、选择
查看>>
mysql中实现rownum,对结果进行排序
查看>>