View Single Post
Old 19th June 2020, 11:22   #6
Nitorami
Major Dude
 
Join Date: Mar 2008
Location: Erlangen
Posts: 885
Hi NeonAngel
I myself have never dealt with sprites, and am curious what you will come up with.

Nestdrop was announced recently on this forum in a different thread.

For your texture mapping:
You don't need the warp shader. Do it in the comp shader directly. The comp shader's "ret" is effectivels what you'll see on the screen.
What you need is the aspect ratio of your image; just define it above the shader body, and then use it for sampling. Here is the relevant part of the authoring guide:

If your shader wants to know how big the texture is, declare this
(also above the shader_body section):

float4 texsize_billy; // .xy = (w,h); .zw = (1/w, 1/h)

MilkDrop will see the "texsize_" prefix and automatically know what
to do. (You don't have to include the //comment, of course.)

To stretch this texture to cover the screen, do this (in the shader
body):

ret = tex2D(sampler_billy, uv).xyz;

Or to map it fitted to the screen, aspect-aware:

ret = tex2D(sampler_billy, uv * aspect.xy).xyz;

Or to tile it so the pixels are represented 1:1:

ret = tex2D(sampler_billy, uv * texsize.xy * texsize_billy.zw).xyz;

Or to map it tiled exactly 5 times:

ret = tex2D(sampler_billy, uv * 5).xyz;

Or to zoom into the center 20% of the image:

ret = tex2D(sampler_billy, (uv-0.5)*0.2 + 0.5 ).xyz;

Of course, you could also declare sampler_pw_billy, to do point
sampling, or sampler_fc_billy, for clamping, and so on.
Nitorami is offline   Reply With Quote