Cg is a high-level shading language developed by Nvidia.
Questions tagged [cg]
300 questions
2
votes
0 answers
running pandoc from python returns error when run from web but not when run from console
I'm running the following python code to test the automation of the production of epub/html files from pandoc's variant of markdown. When I run this from the web (i.e. using python and cgi), I get a fail and a return code of 83. When I run this from…

user3892196
- 161
- 1
- 5
2
votes
1 answer
Embedding cg shaders in C++ GPGPU library
I'm writing a GPGPU Fluid simulation, which runs using C++/OpenGL/Cg. At the moment, the library requires that the user specify a path to the shaders, which is will then read it from.
I'm finding it extremely annoying to have to specify that in my…

XwipeoutX
- 4,765
- 4
- 29
- 41
2
votes
1 answer
Packing attributes in a texture, deferred rendering
I'm rolling a deferred shader pipe, and due to the need to keep the G-buffers in a unified format a need to compress attributes is needed. I've sadly been unable to find some good information on how this actually is done.
I have a G-buffer format…

Ylisar
- 4,293
- 21
- 27
2
votes
1 answer
Transforming Vertices onto Sphere in Vertex Shader
I'm programming a (hopefully) planetary shader for a Unity project. I'm relatively new to shaders, and as I understand the language here is a subset of CG Shader called ShaderLab.
My question is can this be done in a shader? I have the formulas to…

Krizzen
- 46
- 4
2
votes
4 answers
CGRectIntersectsRect: how change the detection to the edge of the picture inside UIImageView
Here is the code i'm using to detect if 2 UIImageViews hit each other.
if (CGRectIntersectsRect(Appy.frame, Bottom.frame)) {
[self GameOver];
}
At the moment its detecting the edge of the object.
How do i change it to detect the edge of the…

C.Wetherell
- 215
- 2
- 14
2
votes
1 answer
unity3d shaderlab: How to set up some simple variables in my shader
I'm writing one of my first shaders. I'm editing a metaball shader I found.
I'm new to shaders and I'd just like to set up some variables.
I want these variables to be calculated when the shader initialises
Heres my whole shader.. You can see what I…

Guye Incognito
- 2,726
- 6
- 38
- 72
2
votes
1 answer
How can I deterministically detect the shader fragment location in its 2x2 pixel quad?
I've been trying to utilize the techniques in Eric Penner's "Shader Amortization using
Pixel Quad Message Passing" from GPU Pro 2, Chapter VI.2. The basic idea is that modern GPU's process fragment shaders in 2x2 fragment quads, and you can use…

Mike S
- 531
- 4
- 14
2
votes
3 answers
Screen coordinates in fragment shader
In a fragment shader like the below:
Shader "ColorReplacement" {
Properties {
_MainTex ("Greyscale (R) Alpha (A)", 2D) = "white" {}
}
SubShader {
ZTest LEqual
ZWrite On
Pass {
Name…

Roberto
- 11,557
- 16
- 54
- 68
2
votes
1 answer
Cg shaders not being applied after switch to glVertexPointer
My renderer used to render geometry with the old fixed function stuff using glBegin/glEnd. After switching it to use vertex arrays via glVertexPointer et. al., my Cg shaders stopped showing up. If i just do a regular texture binding, it works fine,…

toastie
- 1,934
- 3
- 22
- 35
2
votes
1 answer
Can you control how vertex-shader outputs are interpolated over a polygon?
It's a common problem that outputs from a vertex shader are linearly interpolated as 3D/4D vector values, which leads to artifacts. For instance if a vertex shader outputs a normalised vector, you still typically need to renormalise it in your…

Mr. Boy
- 60,845
- 93
- 320
- 589
2
votes
2 answers
How do I pass a GameObject's transform's position to my CG shader?
So I'm making a vertex shader to make a GameObject look like it's shrinking/expanding (pulsating?) continuously.
I am using a normal scale matrix to multiply the position of every vertex, but I want to keep the object appearing centered in the same…

Martin
- 93
- 1
- 6
2
votes
1 answer
Potential Leak of an Object while using CGGraphics in a Loop
I don't get it, how to solve the problem?
I used "analyze" cause my program crashes due memory problems and the first one of seven similar notations is "Potential Leak of an Object stored into signalline" conected to…

eddy white
- 301
- 2
- 24
2
votes
3 answers
3D Texture emulation in shader (subpixel related)
I am working on a Unity3D project which relies on a 3D texture momentarily.
The problem is, Unity only allows Pro users to make use of Texture3D. Hence I'm looking for an alternative to Texture3D, perhaps a one dimensional texture (although not…

RobotRock
- 4,211
- 6
- 46
- 86
2
votes
0 answers
How to correct error of floating point modulo operation
Some mobile GPU doesn't support integral modulo operation. So I have to implement modulo operation using floating-point precision.
Implementation of fmod in Cg standard library is as follows.
float2 fmod(float2 a, float2 b)
{
float2 c =…

wflwfl
- 77
- 3
2
votes
2 answers
converting hybrid cg/hlsl shaders to glsl es
I am looking for a tool that can convert cg/hlsl hybrid shaders to glsl es shaders. I have tried hlsl2glsl which doesnt understand the keyword 'extern' although it is a viable hlsl keyword and have looked to cgc but have found no documentation on…

aerlfredith
- 1,123
- 4
- 12
- 18