Tag Info

Hot answers tagged

27

coderanger is right about HLSL targeting DirectX, GLSL targeting OpenGL and CG being available with both interfaces. However there are other things to consider (learned on the OGRE forum) : CG will not allow you to use the latest features of GLSL (I'm not sure about HLSL). It's a middle ground so you'll not be able to fully exploit the GLSL features, only ...


13

I can only talk about CG vs HLSL because those are the 2 I have used so far. Cg is not the same as HLSL. In Cg, NVIDIA did an excellent job in creating a very clean shader syntax. Its very similar to HLSL. But, tie-together with D3D9/D3D11 (init code, shader compilation code) is much cleaner on HLSL than Cg. -1 Cg. Cg has a nasty bit of start up code ...


8

Another crucial difference between HLSL and GLSL (I don't know CG so I can't speak for it) is that with HLSL Microsoft provide the shader compiler as part of the D3D runtime whereas with GLSL your hardware vendor provides it as part of their driver. This has advantages and disadvantages on both sides. With the GLSL method the vendor can tune the compiler ...


6

Firstly you can do texture fetching inside conditional blocks in HLSL. tex2Dlod() and tex2Dgrad() will work fine inside one. It's just tex2D() that won't compile, and you can work round that by computing ddx() and ddy() outside the conditional and using tex2Dgrad(). To reliably stop the texture fetch (or any other block of code) being executed in HLSL, use ...


4

CG (as your tags indicate) supports the WPOS semantic in some profiles, for example this one. An input parameter bound to the WPOS semantic will get the window position (with the origin in the lower-left) of the fragment. Other languages, like GLSL, have similar predefined uniforms or inputs (gl_FragCoord for example), although the specifics of their value ...


3

If nothing else, you can manually calculate shadows using techniques similar to low-resolution ray tracing, then somehow put them on screen. I think this would be fairly easy, since unity supports hit detection with custom rays and all scene objects that have a collider, but of course this is highly inefficient. If you can't afford unity pro (not even the ...


3

I don't see any special shaders there, just some vertex colors that are generated with an ambient occlusion (or similar) calculation algorithm and perhaps some differently calculated vertex normals. The results remind me of a demo I've seen some time ago which simulated global illumination by "bending" vertex normals and generating occlusion values for ...


3

It appears to be a slightly misleading book. Offset does not change drawing order or even the 3D position of pixels. It simply adds some numbers to the Z value (the one that's going to the Z tests and Z-buffer) of a pixel (hence the term "offset"), making it appear above or below other triangles. This is generally used to prioritize visibility of triangles ...


3

The answer is in the documentation, in "API Overview/Graphics Overview": Shader descriptions have the following restrictions in comparison with standard Cg language. Variables and functions with the same names as GLSL and Cg reserved words cannot be used. It turns that the emulator, the PSVita and Android devices all have very different ...


2

The Cg toolkit supports its own version of effect files, CgFX. These support techniques, states, annotations... I don't have any experience with them personally, but they are supported by FX Composer, at least. CGeffect cgCreateEffectFromFile( CGcontext context, const char * filename, const ...


2

The reference manual is up to date in the nvidia site Cg 3.0 Reference Manual, which i believe is where you can get most of the information you want. It does contain very detailed data of everything you can do with Cg, I don't think there's something missing there, but it may be hard to read at first as it's just a reference for all the technical aspects of ...


1

Yes, the position sent to the vertex shader is generally the local coordinates of the object's vertex. Your multiplication by worldViewProjMatrix in the vertex shader is what handles the transformation from world space to camera space to projection space, all in one shot. The GPU will interpolate any out variables from your vertex shader across the face of ...


1

CgFX files are not shaders. They are FX files. Shaders are a lower-level construct; a shader is just the source code for a particular shading stage. Techniques, passes, etc are all higher level than Cg. You cannot process CgFX's FX data into GLSL because GLSL has no equivalent constructs (just as Cg itself doesn't). You can process the files themselves with ...


1

The simplest option to get a depth bias is to move the near and far clip planes. See http://tomsdxfaq.blogspot.com/2002_07_01_archive.html#79344425#79344425 You could do that in a vertex shader if you wanted to, but it's easier to do it from the calling code.


1

The point of the waves generated in a texture is to use them as normal maps, allowing the appearance of more detail to the waves than would be possible without spending a lot of actual geometry on the water surface. It's been a while since I did much actual graphics work, but I believe the point regarding the wave parameterization is just mentioned as a ...


1

You might want to look into the RTSS (Run Time Shader System) that comes with Ogre as well. It is fairly new, but you basically write shaders in code rather than external files. I have not implemented it yet, but definitely plan to use this when the time comes. Here is a huge series of tutorials on the Ogre wiki as well for writing shaders. ...



Only top voted, non community-wiki answers of a minimum length are eligible