• FEATURED

View more

View more

View more

### Image of the Day Submit

IOTD | Top Screenshots

### The latest, straight to your Inbox.

Subscribe to GameDev.net Direct to receive the latest updates and exclusive content.

Old topic!

Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.

4 replies to this topic

### #1YuemariSan  Members

Posted 07 November 2012 - 10:46 AM

Hi, I got a question about a shader I´ve found at Unity forums, I´m starting to get involve in the world of shaders and computer graphics, but
can´t find any guides to understand why this shader gets that effect:
v2f vert (appdata_base v)
{
v2f o;
// The vertex position in view-space (camera space)
float4 vPos = mul (UNITY_MATRIX_MV, v.vertex);
// Get distance from camera and scale it down with the global _Dist parameter
float zOff = vPos.z/_Dist;
// Add the offset with a quadratic curve to the vertex position
vPos += _QOffset*zOff*zOff;
o.pos = mul (UNITY_MATRIX_P, vPos);
o.uv = v.texcoord;
return o;
}

Could someone explain the part of the quadratic curve?, its the part that I really don´t get it.
Here is the link to the forum post:
Thanks in advance for any references or guides to understand the effect, so I can try a shader of this sort on my own.

### #2phil_t  Members

Posted 08 November 2012 - 01:01 PM

### #3YuemariSan  Members

Posted 09 November 2012 - 08:25 PM

### #4ic0de  Members

Posted 09 November 2012 - 10:30 PM

vPos += _QOffset*zOff*zOff;


This is the quadratic curve here zOff*zOff is the same as zOff^2, creating a parabola. _QOffset is probably a constant defining how pronounced the curve will be.

zOff is the distance from the viewer, basically vPos( the position of the vertex) is being offset by distance^2.
Currently working on new DOS game, Chuck Jones: Space Cop of the Future, Check out my Dev Blog

you know you program too much when you start ending sentences with semicolons;

### #5YuemariSan  Members

Posted 10 November 2012 - 09:44 AM

Thanks a lot, it sounds pretty easy now. If I understand this, well enough, then I can change the aspect of the effect by changing it with other mathematical function right?, something like using Sin or Cos would make the plane to ondulate with the distance (Im making obvious that my mesh have enough vertexes).

Old topic!

Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.