Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
See more: XNA XNA4.0
I'm beginner in HLSL(High Level Shader Language XNA 4.0). Write code HLSL is very hard beause it's not have function Visual Intelligence and formula's optical is very hard . Write code HLSL in Visual Studio like write in notepad. Can you tell me program write code HLSL best and explain formula's optical . Thanks!
Posted 14-Oct-12 9:20am
Edited 15-Oct-12 1:24am
v4

1 solution

Rate this: bad
good
Please Sign up or sign in to vote.

Solution 1

Sorry, but it's not quite clear what you are looking for. My best guess is that you want a visual editor for shaders that gives you a sample of what the result looks like.
 
Wow. I just searched for HLSL editors and only got results for text editors with syntax highlighting or intellisense. This is probably for a very good reason. While it's possible to display the code of a shader as some kind of graph with editable properties, this would not take away the need for the user to understand the algorithm that is implemented by the shader. The ability to edit some values and see the results would only by luck lead to anything useful without that understanding.
 
I'm afraid you have little choice than going the hard way like everybody else. Shaders are short and usually linear procedures. In most cases there are no loops or other confusing things.
 
Vertex shaders are used to transform the data from 3D object space to 3D world space and then to 2D view space. Those things usually are explained in a good book about computer graphics, along with the basics of linear algebra. The code of the shader by itself may be simple, but you will have little chance of understanding its purpose without knowing about those 3D and 2D spaces and the math which is involved.
 
Pixel shaders are about determining the color of each pixel of a polygon. The polygons are actually triangles, formed by three of the vertices. At this point we already know the 2D screen coordinates of the vertices, thanks to the vertex shader. But the vertices are only the corner points. What about the pixels inside this triangle?
 
The color of a pixel may be a constant, interpolated between color values attached to each vertex, sampled from a texture map and in many more ways. You can even combine those techniques or invent new ones. Again I would suggest you start by consulting a book about computer graphics and understanding some of the basic techniques. Then you will be able to understand vertex shaders that implement them and eventually also be able to modify them.
 
The same goes for light calculations, which are also done in the pixel shader. Basically it's just making the calculated color for the pixel lighter or darker, according to how much light from one or more light sources reaches that pixel. But once again there are many simple or more advanced ways to accomplish this and only studying them will help you.
 
Bottom line: Get yourself a good book that covers the basics of 3D graphics. It does not matter if the book is a little older. Those things have not really changed since the days when all this was still done in software. Those powerful graphics processors only allow us to do much more of it every second.
 
Take your knowledge from the book (like how to apply a texture to a polygon) and get yourself a sample shader that implements exactly this technique. Once you have understood the theory, the shader will not be mysterious at all for you anymore.
  Permalink  

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
0 Sergey Alexandrovich Kryukov 392
1 OriginalGriff 370
2 CPallini 190
3 Abdul Samad KP 145
4 George Jonsson 119
0 OriginalGriff 6,329
1 Sergey Alexandrovich Kryukov 5,700
2 CPallini 4,940
3 George Jonsson 3,469
4 Gihan Liyanage 2,522


Advertise | Privacy | Mobile
Web03 | 2.8.140916.1 | Last Updated 15 Oct 2012
Copyright © CodeProject, 1999-2014
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100