javascript - Gradation color in WebGL with GLSL shader -
i have black color in middle of disk gradation outside. 2 first parts glsl code make shader, problem when : "gl_fragcolor = vec4( vec3( vuv, 0.17 ), 1. ); "
`
varying vec2 vuv; void main() { vuv = uv; gl_position = projectionmatrix * modelviewmatrix * vec4(position, 0.8); }
' '
varying vec2 vuv; void main() { gl_fragcolor = vec4( vec3( vuv, 0.17 ), 1. ); }
'
var scene = new three.scene(); var camera = new three.perspectivecamera( 45, 1024 / 860, 0.1, 1000 ); var renderer = new three.webglrenderer({ antialias: true}); camera.position.z = 30; var my_shad = new three.shadermaterial({ vertexshader: document.getelementbyid( 'vertex' ).textcontent, fragmentshader: document.getelementbyid( 'frag' ).textcontent }); var radius = 8; var segments = 80; var circlegeometry = new three.circlegeometry( radius, segments ); var disk = new three.mesh(circlegeometry, my_shad); scene.add(disk); renderer.setsize( 1024, 860 ); document.body.appendchild( renderer.domelement ); function render() { requestanimationframe(render); renderer.render(scene, camera); } render();
'
try doing starters:
void main(){ float uvd = length(vuv); vec3 gradient = mix(color1, color2, uvd); gl_fragcolor = vec4(gradient,1.); }
Comments
Post a Comment