CG is a programming language for 3D graphics that runs on the GPU. It was designed by NVIDIA and Microsoft. It stands for "C for graphics"

learn more… | top users | synonyms

38
votes
6answers
16k views

What are the pros and cons of HLSL vs GLSL vs cg? [closed]

What are the pros / cons of the three?
5
votes
2answers
1k views

OpenGL equivalent of .fx files in GLSL or Cg?

There's a lot of learning material in the DirectX world that uses .fx files to manage shaders, and .fx seems to be well integrated with 3D packages such as Maya and 3D Studio Max What do larger ...
4
votes
1answer
1k views

Custom shadow mapping in Unity 3D Free Edition

Since real time hard and soft shadows are Unity 3D Pro only features I thought I will learn Cg programming and create my own shadow mapping shader. But after some digging I found that the shadow ...
3
votes
1answer
576 views

Issue with interpolation on a burn shader (lerp and smoothstep)

I'm trying to create a simple burn shader. See here for more info on the method I'm using. However, I don't get why replacing the smoothstep with a lerp results in completely different results. Am I ...
2
votes
1answer
958 views

Shader optimization - Cg/HLSL pseudo and via multiplication

HLSL/Cg do not allow texture fetching inside conditional blocks. To get around this I am first checking a variable and performing some computations, afterwards I set a float flag to 0.0 or 1.0, ...
2
votes
1answer
3k views

Unity custom shaders and z-fighting

I've just readed a chapter of Unity iOS Essential by Robert Wiebe. It shows a solution for handling z-figthing problem occuring while rendering a street on a plane with the same y offset. Basically ...
2
votes
1answer
667 views

shader coding: calculate screen coordinates of fragment

Good morning, I'm new to shader coding and trying to implement some visual effects code in shaders using billboards. (Yes, I couldn't have picked anything harder to start with, but I'm lucky that way) ...
2
votes
1answer
282 views

Alpha Blending: use the pixel with the smallest alpha

I'm writing a transparency shader where I need any intersecting textures to, wherever they overlap, take the texture pixel with the smallest alpha value and render only that, discarding the other ...
2
votes
1answer
116 views

Possible to create transparency shader which doesn't stack alpha values

The image above best demonstrates what I'm trying to achieve. It's a transparent shader for objects, but wherever the objects with this shader intersect they don't add together but simply merge with ...
2
votes
1answer
532 views

Doubt about texture waves in CG Ocean Shader

I'm new on graphical programming, and I'm having some trouble understanding the Ocean Shader described on "Effective Water Simulation from Physical Models" from GPU Gems. The source code associated to ...
2
votes
0answers
264 views

Kinect User Silhouette Shader

I have this usermap from kinect's depth data (size is 320x280) and i want to display it on my game. The problem, of course it's ugly (first image) and i want to have beautiful effect like in the ...
1
vote
2answers
123 views

GLSL to Cg: why is the effect different?

With reference to this question, where I was trying to make the shader compile, I am now trying to make an effect appear. The effect can be shown here, through a GLSL shader: But when I use the ...
1
vote
1answer
1k views

Shader which supports vertex colors and pixel lights?

From my question at Unity Answers: Hello everyone, I'm facing a bit of a problem here: I need a shader which has the ability to colour individual vertices and be lit pixel by pixel. Until recently, I ...
1
vote
1answer
262 views

My game works on the emulator and the PSVita, but crashes on Android

I made a game on PSM, ported from a previous iOS/Android game. I test it on the emulator and PSVita and runs fine. However, as I test it on a PlayStation Certified Android device, it crashes on load. ...
1
vote
1answer
1k views

What kind of shader is this?

Cube World uses a pretty good looking shader, I especially like the shading of the characters: Is this soft shading? I'd like to achieve this effect in Unity 3D Free, but since the free version ...
1
vote
2answers
72 views

Accessing uniform variables from a Cg shader in OpenGL

I am trying to implement a simple PC program with OpenGL, using mandatorily Cg shaders (no Unity whatsoever). I have found some tips on this page http://bobobobo.wordpress.com/2008/10/05/cg-1/ and ...
1
vote
1answer
132 views

In Unity, how can I read the color from _LightColor0 in a shader?

I have a scene with a point light and alpha textured (RGBA) triangle strips. I want to apply the point light color with a shader. Shader "Custom/Test02" { Properties { _MainTex("Texture ...
1
vote
1answer
1k views

How to do Triplanar Texturing

Ok maybe i'm missing something because its getting late and i've been programming now for about 72 hours straight (minus a nap or 2) ... I'm trying to write a shader for unity that will apply ...
1
vote
0answers
498 views

TEXCOORD0 vs COLOR in a Cg shader

I started to learn Cg shader programming, following the Panda3d shader tutorials. Having a scene with only a cube shown, each vertex of the model with a different color, I can successfully use the ...
1
vote
0answers
146 views

Correct order of operations when enabling/disabling Cg shaders in OpenG

I've started writing an Effect class which uses Cg shaders in OpenGL and I'm a bit confused about the order of operations when creating and rendering using Cg. Currently, my Effect class contains ...
0
votes
1answer
503 views

Nvidia Cg 3.0 Manual/Documentation?

I can only find a user's manual for Cg 1.4 from Sept 2005, and the Cg Tutorial from earlier than that. Cg is now on version 3 and I'm wondering about all the new profiles and tech that must be in ...
0
votes
1answer
57 views

GLSL to Cg fragment shader

I have found very useful resource on the Swiftless website on OpenGL. Unfortunately, I cannot manage to adapt a GLSL fragment shader to my project, which uses Cg. Here it is: uniform sampler2D ...
0
votes
1answer
597 views

Calculating distance from viewer to object in a shader

Good morning, I'm working through creating the spherical billboards technique outlined in this paper. I'm trying to create a shader that calculates the distance from the camera to all objects in the ...
0
votes
1answer
786 views

CG/CGFX to GLSL

So, I'm making the painful move from my beloved XNA to OpenTK, and I'm stuck: Since I've got a LOT of existing shaders written in HLSL, NVidia's CG compiler seems like a natural way to minimize the ...
0
votes
1answer
608 views

Custom made depth bias (vertex) shader

As most of intermediate graphics programmers know, z-fighting can be a problem. That's why most game engines prevent this from happening by using a slope depth bias algorithm. As there's no direct ...