Stop shader values from being clamped

Hi there,

I’m developing a shader that has the following requirements:

  1. A vector of at least length 3 must be passed in from the Unity engine
  2. That value must be passed into and interpolated by the fragment shader

Currently, I’m accomplishing #1 by attaching the data I’d like to pass in as a vertex color. I would do it as a texture coordinate, but they’re only float2 within Unity. They seem to be float4 inside the shader though, which is confusing.

When I pass the data through the color, the problem is that it seems to get clamped. I’m not sure if it happens at the vertex or fragment shade. Either way, I’d like to turn it off, because it’s ruining the shader. I kind of have a bunch of related questions here:

  1. Which values are interpolated inside the fragment shader and which ones are not?
  2. Are all values interpolated that are passed to the fragment shader?
  3. Why is the texture coordinate for the mesh (uv, uv1, uv2) a float2, but seems to be a float4 inside the shader?
  4. Is there a way to stop clamping from happening on the color values passed to a fragment shader?

Thanks!

  1. AFAIK only color data is clamped (not interpolated) to 0…1 range
  2. look 1
  3. uv coordinate is always float2, but it’s one more important texture mapping data - tiling and offset. both are float2 so they stored in a single float4 vector. before you get a pixel from texture you should calculate texture’s uv based on tiling and offset from material and then get a pixel using float2 coordinate.
  4. AFAIK no. for color data type - no.