⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 polkadot3d.frag

📁 java 3d编程的一些例子源代码
💻 FRAG
字号:
//// Fragment shader for 3 dimensional polka dot shader.//// Author:  Joshua Doss//   // Copyright (C) 2002-2004  3Dlabs Inc. Ltd.//// See 3Dlabs-License.txt for license information//varying float LightIntensity;varying vec3 MCPosition;//Create uniform variables so dots can be spaced and scaled by user//uniform vec3 Spacing;//uniform float DotSize;const vec3 Spacing = vec3 (0.314, 0.36, 0.261);const float DotSize = 0.123;//Create colors as uniform variables so they can be easily changed//uniform vec3 ModelColor, PolkaDotColor;const vec3 ModelColor = vec3 (0.75, 0.2, 0.1);const vec3 PolkaDotColor = vec3 (1, 1, 1);void main(void){   float insidesphere, sphereradius, scaledpointlength;   vec3 scaledpoint, finalcolor;   // Scale the coordinate system   // The following line of code is not yet implemented in current drivers:   // mcpos = mod(Spacing, MCposition);   // We will use a workaround found below for now   scaledpoint       = MCPosition - (Spacing * floor(MCPosition/Spacing));   // Bring the scaledpoint vector into the center of the scaled coordinate system   scaledpoint       = scaledpoint - Spacing/2.0;   // Find the length of the scaledpoint vector and compare it to the dotsize   scaledpointlength = length(scaledpoint);   insidesphere      = step(scaledpointlength,DotSize);      // Determine final output color before lighting   finalcolor        = vec3(mix(ModelColor, PolkaDotColor, insidesphere));   // Output final color and factor in lighting   gl_FragColor      = clamp((vec4( finalcolor, 1.0 ) * LightIntensity), vec4(0.0), vec4(1.0));}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -