WARNING: Output of vertex shader 'v_gradient' not read by fragment shader
Answer
One of the situations where you might get this warning in Xcode is when using an app that uses shaders such as the Maps app with an MKMapView
. You'll find that the map view works as expected without that warning on a real device with real hardware/native OS.
In the sim the SolidRibbonShader
fragment shader is not able to read the output of the v_gradient
vertex shader probably because it's in beta or there might be an incompatibility between Xcode version and SIM version. However the shaders are recognized on a real device.
Explanation
Those shaders belong to the OpenGL Rendering Pipeline. The Rendering Pipeline is the sequence of steps that OpenGL takes when rendering objects.
The rendering pipeline is responsible for things like applying texture, converting the vertices to the right coordinate system and displaying the character on the screen etc.
There are six stages in this pipeline.
- Per-Vertex Operation
- Primitive Assembly
- Primitive Processing
- Rasterization
- Fragment Processing
- Per-Fragment Operation
Finally, an image appears on the screen of your device. These six stages are called the OpenGL Rendering Pipeline and all data used for rendering must go through it.
What is a shader?
A shader is a small program developed by you that lives in the GPU. A shader is written in a special graphics language called OpenGL Shading Language(GLSL).
A shader takes the place of two important stages in the OpenGL Rendering Pipeline: Per-Vertex Processing and Per-Fragment Processing stage. There is one shader for each of these two stages.
The ultimate goal of the Vertex Shader
is to provide the final transformation of the mesh vertices to the rendering pipeline. The goal of the Fragment shader
is to provide Coloring and Texture data to each pixel heading to the framebuffer.
Vertex shaders
transform the vertices of a triangle from a local model coordinate system to the screen position. Fragment shaders
compute the color of a pixel within a triangle rasterized on screen.
Separate Shader Objects Speed Compilation and Linking
Many OpenGL ES apps use several vertex and fragment shaders, and it is often useful to reuse the same fragment shader with different vertex shaders or vice versa. Because the core OpenGL ES specification requires a vertex and fragment shader to be linked together in a single shader program, mixing and matching shaders results in a large number of programs, increasing the total shader compile and link time when you initialize your app.
Screen is blank white when started on the Xcode simulator [swift 3.0]
Vertex Shaders
generally run directly on the GPU for which it's compiled. In this case the iOS
simulator doesn't physically have the GPU it needs to work with, hence the white screen.
Usually if you run the code on the physical device it should work, so try running there. Also check out this other question/answer with a similar error that might be of interest.
A vertex shader is simply a tiny program that runs on the GPU, written
in a C++ like language called the Metal Shading Language.
↳ Metal Shading Language Specification
Metal fragment shader uv coordinates change when reading in vertex color
Why are you using [[point_coord]]
? What do you think it represents?
Unless you're drawing point primitives, you shouldn't be using that. Since you're drawing a "quad", and given the screenshots, I assume you're not drawing point primitives.
I suspect [[point_coord]]
is simply undefined and subject to random-ish behavior when you're drawing triangles. The randomness is apparently affected by the specifics (such as stack layout) of the fragment shader.
You should either be using [[position]]
and scaling by the window size or using an interpolated field within your ColoredVertex
struct to carry "texture" coordinates.
MKMapView hang/freeze app after leave viewcontroller in iPhone 5c
I just discovered it works fine when I unplug iPhone from xcode.
Related Topics
Presenting Uiviewcontroller from Skscene
What Is Most Common and Correct Practice to Get a Cgfloat from an Nsnumber
Swift Override Function in Extension
Set Custom Images to the Uibarbuttonitem But It Doesn't Show Any Image
What Is Build Object File Extension in iOS
Back Button Callback in Navigationcontroller in iOS
How to Add Older Version of iOS Sdk in Xcode 4.5
What Exactly Is Init Coder Adecoder
Access Files in /Var/Mobile/Containers/Data/Application Without Jailbreaking Iphone
iPhone Sdk Internet Connection Detection
"Too Many Symbol Files" After Successfully Submitting My Apps
Run iPhone as an Ibeacon in the Background
How to Invoke iPhone Maps for Directions with Current Location as Start Address
Is There Any Way of Asking an iOS View Which of Its Children Has First Responder Status
How to Hide 'Back' Button on Navigation Bar on Iphone
How to Present View Controller from Right to Left in iOS Using Swift
How to Calculate the Uilabel Height Dynamically
How to Display the Standard Checkmark on a Uicollectionviewcell