![]() |
#1 | |
Junior Member
Join Date: Jul 2011
Posts: 11
|
Shader clarification
Hi all,
I've been playing with preset editing for a while now, and am feeling like I have a pretty solid understanding of Milkdrop's fundamental components. I would like to dive into the realm of shaders now, but am having trouble understanding a piece of the wiki regarding the different kinds of textures and the tex2D and tex3D functions. The wiki states Quote:
Syntax for tex2D seems straightforward: the first argument defines the texture from which to sample, the second, a float2, specifies a location on that texture. The tex3D function, however, is never used, nor clearly explained. I assume the difference is that the input for the second argument should be a float3? I imagine the usefulness of tex3D will be more apparent when I understand the other textures... Thanks for any assistance you can render; it's very much appreciated! |
|
![]() |
![]() |
![]() |
#2 |
Major Dude
Join Date: Mar 2008
Location: Erlangen
Posts: 867
|
Hi Psyne
MD has three predefined noise textures: sampler_noise_lq, _mq, and _hq. Call them like this ret = tex2D (sampler_noise_hq,uv); As sampler_main, they can be called using the modifiers _pc_, _pw_, _fw_ and _fc_ which affect the smoothing and folding. Example ret = tex2D (sampler_pw_noise_lq,uv); The default is _fw_, to use the other versions you need to specify them in the shader header first sampler sampler_pw_noise_lq; Custom texture is simply a picture, jpg or pcx or whatever formats are supported. You need to define it in the header first sampler sampler_mypicture; and can then use it within the shader body by ret = tex2D (sampler_mypicture, uv); Normally the picture will not have the same aspect ratio as your screen so you'll may want to adjust this as specified in the authoring guide. Martin |
![]() |
![]() |
![]() |
#3 |
Junior Member
Join Date: Jul 2011
Posts: 11
|
Ah, that makes sense. Pardon me for the barrage of questions; just trying to wrap my head around this...
Edit: never mind the crossed-out questions, after looking around a little bit, I have realized that I am obviously blind.
Last edited by Psyne; 24th August 2011 at 23:28. Reason: Answered some of the questions asked by myself! |
![]() |
![]() |
![]() |
#4 |
Major Dude
Join Date: Mar 2008
Location: Erlangen
Posts: 867
|
As a beginner, you won't need more than the basic syntax, how to declare variables etc. We have float, float2 (for x-y-coordinates such as uv), float3 (mainly for colours, i.e. red, green and blue), and float4.
Some elementary functions are useful such as length(x) which gives you the length of a vector; you can use trigonometric functions sin, cos, etc. with all types of variables. For a complete list you may refer to the microsoft guide http://msdn.microsoft.com/en-us/libr...=VS.85%29.aspx |
![]() |
![]() |
![]() |
|
Thread Tools | Search this Thread |
Display Modes | |
|
|