write a glsl shader
- User
write a glsl shader
- Assistant
Certainly! Here's a simple GLSL shader that creates a smooth color gradient across a 2D plane:
c++// Vertex Shader attribute vec2 position; void main() { gl_Position = vec4(position, 0.0, 1.0); } // Fragment Shader precision mediump float; uniform float time; uniform vec2 resolution; void main() { vec2 uv = gl_FragCoord.xy / resolution.xy; vec3 color = vec3(0.5 * sin(time), 0.5 * cos(time), 0.5); gl_FragColor = vec4(color, 1.0); }This shader uses the position attribute to pass in the coordinates of each vertex in the 2D plane, and uses those coordinates to set the gl_Position variable, which determines where each vertex is positioned on the screen.
The fragment shader then calculates the color of each pixel on the screen based on its position (gl_FragCoord) and the current time (time). The resolution uniform is used to convert the pixel coordinates into normalized UV coordinates (ranging from 0.0 to 1.0).
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.
Identical first prompt
- Human-written demonstration (OpenAssistant volunteers)Compare side by side →
- Human-written demonstration (OpenAssistant volunteers)Compare side by side →
- Human-written demonstration (OpenAssistant volunteers)Compare side by side →
- Human-written demonstration (OpenAssistant volunteers)Compare side by side →
- Human-written demonstration (OpenAssistant volunteers)Compare side by side →
- Human-written demonstration (OpenAssistant volunteers)Compare side by side →
- Human-written demonstration (OpenAssistant volunteers)