Need help with shader...

I am making shader with lights and I need modified vertex positions for some reason it gets ignored.
Lights works fine and shadows too.

Shader "Custom/bend" {
	Properties {
		_Color ("Main Color", Color) = (1,1,1,1)
		_MainTex ("Base (RGB)", 2D) = "white" {}
	}
	SubShader {
		Tags { "LightMode" = "ForwardAdd" }
		Cull off
		Pass
		{
			CGPROGRAM
			#pragma vertex vert
			#pragma fragment frag
			#pragma multi_compile_fwdbase
			#include "UnityCG.cginc"
			#include "AutoLight.cginc"
			
			struct v2f
			{
				float4 pos : SV_POSITION;
				LIGHTING_COORDS(0,1)
			};
			
			v2f vert (appdata_full v)
			{
				v2f o;
				float4 vecx = mul(UNITY_MATRIX_MVP, v.vertex);  
				vecx.y -= vecx.x*vecx.x/20.0F;
				o.pos = vecx;
				TRANSFER_VERTEX_TO_FRAGMENT(o);
				return o;
			}
			
			float4 frag (v2f i) : COLOR
			{
				return LIGHT_ATTENUATION(i);
			}
			ENDCG
		}
	}
	FallBack "Diffuse"
}

Define ignored?

Also this line…
Tags { “LightMode” = “ForwardAdd” }
…has to go inside of the pass {} - it’s a Pass Tag, not a Shader Tag.

And this line…
#pragma multi_compile_fwdbase
… is telling it to compile to forward base, but your pass tag is telling it to get the light data from forward add. You’ll need to ensure both are forward base or both are forward add.

Not define ignore but i can’t edit position off vertex.
I made wat you said no change:

Shader "Custom/bend" {
	Properties {
		_Color ("Main Color", Color) = (1,1,1,1)
		_MainTex ("Base (RGB)", 2D) = "white" {}
	}
	SubShader {
		Pass
		{
			Tags { "LightMode" = "ForwardAdd" }
			CGPROGRAM
			#pragma vertex vert
			#pragma fragment frag
			#pragma multi_compile_fwdadd
			#include "UnityCG.cginc"
			#include "AutoLight.cginc"
			
			struct v2f
			{
				float4 pos : SV_POSITION;
				LIGHTING_COORDS(0,1)
			};
			
			v2f vert (appdata_full v)
			{
				v2f o;
				float4 vecx = mul(UNITY_MATRIX_MVP, v.vertex);  
				vecx.y -= vecx.x*vecx.x/20.0F;//i edit it there but it wont change???
				o.pos = vecx;
				TRANSFER_VERTEX_TO_FRAGMENT(o);
				return o;
			}
			
			float4 frag (v2f i) : COLOR
			{
				return LIGHT_ATTENUATION(i);
			}
			ENDCG
		}
	}
	FallBack "Diffuse"
}

Here you can see the object is still the same and the select in editor you can see lineff with modified object.

And what position exactly are you trying to change? model space? world space? clip space?

I want change clip space.

Well… the objects seem to be slanted a bit… Also, do you have multiple per-pixel lights? Your ForwardAdd pass might not even get run in that case.

I’m quite interested in what is the idea behind this. Modify clip space positions only for additional light passes?

The pass is running i se shandows on boxes and shades…
But the object is not bending, if I disable lights everything works but map look like white flat surface.
I want the geometry to bend like on picture(the part with blue lines).

Then why are you overwriting only the ForwardAdd pass? You need to change the base one as well.

k i made it and i need add not only base but alse shandowmapping passes…

ooo now thats trouble. You can’t do the same transformation for the shadowmaps. It’s rendered using a different camera, that won’t look right. If you want to support shadows, you’ll have to change the model / world space positions instead.

i made it and its look very good thats was not too hard :smile:
There are some macros in unity for this(no tutorial for this just found some ready shader and cuted out some parts).

here is link:
http://torquetest.googlecode.com/svn-history/r44/trunk/Shaders/light.shader
if you go there is more ready shaders compatible with unity:
http://torquetest.googlecode.com/svn-history/trunk/Shaders/