Kahrabaa
Member
Hi,
I am semi-beginner in shaders and have normal mapping setup and working (from a tutorial).
The problem is that Im using seperate texture pages for all sprites in the project which causes a ton of texture swaps.
What i've understood is that if I turn off "seperate texture page", I need to send in the info about the normal map's uvs on the texture page.
This is how the shader works with 0-1 uvs (seperate texture page)
So I get the uvs now with sprite_get_uvs and send in the info as a vec4 uniform, but how do I calculate the correct position to be used?
Ive tried putting the left and top uv coords instead of v_vTexcoord:
vec3 NormalMap = texture2D(Normal, NormalUVS.xy ).rgb;
Didn't work.
I also tried to enter the center of the coordinates: NormalUVS.xy+ ( NormalUVS.zw - NormalUVS.xy) *0.5;
But that also didn't work.
I have no clue how to move forward here and am just guessing away.
If only I could do show_message inside the shader I could gradually understand more.
I hope my problem is clear.
Thanks for any help.
Ps. Will scaling the image using image_xscale,yscale mess up the uv's sent in? If so where do I multiply for correct transformation. I already have a vec3 Transform uniform sent in with xscale,yscale and angle.
I am semi-beginner in shaders and have normal mapping setup and working (from a tutorial).
The problem is that Im using seperate texture pages for all sprites in the project which causes a ton of texture swaps.
What i've understood is that if I turn off "seperate texture page", I need to send in the info about the normal map's uvs on the texture page.
This is how the shader works with 0-1 uvs (seperate texture page)
GML:
vec3 NormalMap = texture2D(Normal, v_vTexcoord).rgb;
vec3 N = normalize( NormalMap * 2.0 - 1.0 );
vec3 LightDir =LightPos.xyz;
vec3 L= normalize(LightDir);
vec3 Diffuse = LightColor.rgb * max(dot(N, L), 0.0);
gl_FragColor = Diffuse;
Ive tried putting the left and top uv coords instead of v_vTexcoord:
vec3 NormalMap = texture2D(Normal, NormalUVS.xy ).rgb;
Didn't work.
I also tried to enter the center of the coordinates: NormalUVS.xy+ ( NormalUVS.zw - NormalUVS.xy) *0.5;
But that also didn't work.
I have no clue how to move forward here and am just guessing away.
If only I could do show_message inside the shader I could gradually understand more.
I hope my problem is clear.
Thanks for any help.
Ps. Will scaling the image using image_xscale,yscale mess up the uv's sent in? If so where do I multiply for correct transformation. I already have a vec3 Transform uniform sent in with xscale,yscale and angle.