Questions tagged [cg]

Cg is a high-level shading language developed by Nvidia.

300 questions
0
votes
1 answer

Get the vertex_id variable in a NVIDIA CG vertex shader to create Index Map

I need to generate an Index Map (Index list) containing the id of each projected vertex. My shader code is based on NVIDIA CG 3.0 and I can't find in the documentation the build-in variable name to extract the id of each vertex. In GLSL is something…
tat0
  • 133
  • 1
  • 5
0
votes
1 answer

Default parameter values via semantics in GLSL

I know little to nothing about the actual writing of shaders although I have a basic understanding of their place in the rendering pipeline. I have a CG shader that I have aquired from here and here. I am attempting to convert these shaders to…
Mako_Energy
  • 352
  • 2
  • 19
0
votes
2 answers

Can a distortion matrix be a combination of a rotation and a scale?

Consider the following transformation matrix for distortion in a 2D space. [1 a 0] M=[b 1 0] [0 0 1] Is it possible to obtain the same transformation by combinating a rotation and a scale?
andrepcg
  • 1,301
  • 7
  • 26
  • 45
0
votes
1 answer

Shader of pressure card

I need to write a shader of pressure map. Similar to the following: Card It is necessary to provide closed lines with borders, which shows tonality of pressure and the corresponding color gradation areas with different pressures. Maybe in future it…
0
votes
2 answers

SkyBox texture not showing (NVIDIA CG)

This is my Box.cpp code: using namespace std; #include #include "Box.h" void MyErrorCallback(void) { const char* errorString = cgGetErrorString(cgGetError()); printf("Cg error: %s", errorString); } Box::Box(CGcontext cgContext,…
Itzik984
  • 15,968
  • 28
  • 69
  • 107
0
votes
1 answer

Cg: omit depth write

I am outputting depth in Cg in a branch, like so: ZWrite On .. void frag(v2f IN, out color : COLOR, out depth : DEPTH) { if (statement) { color = float4(1); } else { color = float4(0); depth = 0; } } However as you see I omit writing the…
RobotRock
  • 4,211
  • 6
  • 46
  • 86
0
votes
1 answer

Random value in nVidia CG language shader (Unity)

I'm diving into CG shaders. I'm baking a vertex shader that needs one random constant (computed just once at start time). I know that in Unity it's pretty easy to pass a value from a script to the shader, but I'd like to know if there is any way to…
Steak Overflow
  • 7,041
  • 1
  • 37
  • 59
0
votes
1 answer

Encoding data in an 8-bit float (cg)

The language is cg. I have an 8-bit float that must be between 0 and 1 (it's the 'a' component of a float4 rgba color value). I want to store a 6-bit unsigned integer and a 2-bit unsigned integer in that. How can I safely store these two values in…
lifeformed
  • 525
  • 4
  • 16
0
votes
1 answer

CG shader threshold function

Is there some builtin fragment function in CG that allows me to compute the following without conditionals? y = x>bias?1.0f:0.0f;
matthias_buehlmann
  • 4,641
  • 6
  • 34
  • 76
0
votes
1 answer

shader - CG/GLSL/HLSL how to implement jittering

In computer graphics it's a common technique to apply jittering to sampling positions in order to avoid visible sampling patterns. What's the proper way to apply jittering to sampl-positions in a fragment shader? One way I could think of would be to…
matthias_buehlmann
  • 4,641
  • 6
  • 34
  • 76
0
votes
1 answer

CG runtime linker error with cmake project (g++)

I'm getting these linker errors: /usr/bin/ld: cannot find -lCg /usr/bin/ld: cannot find -lCgGL I'm using the FindCg.cmake frome here: http://code.google.com/p/nvidia-texture-tools/source/browse/branches/2.0/cmake/FindCg.cmake?r=452 Then adding the…
bitgregor
  • 1,085
  • 2
  • 14
  • 17
0
votes
1 answer

Ogre3d / Compositor related issue

I killed my whole day trying to figure out, why the code below is not working: I have this .compositor script: compositor BW { technique { texture rt0 target_width target_height PF_A8R8G8B8 target rt0 { …
Anon
  • 1,274
  • 4
  • 17
  • 44
0
votes
1 answer

Non-constant index into uniform array CG Shader

According to this nVidia CG tutorial (and my own experience) accessing uniform arrays in CG shaders with a non-constant index is either inefficient or unsupported (more often than not, unsupported it seems). My question is; how can I circumvent this…
DAVco
  • 325
  • 2
  • 3
  • 10
0
votes
2 answers

CG to GLSL: f3texRECT equivalent?

I'm trying to convert a CG program to a GLSL program. What I've done so far seems correct, but the GLSL shader outputs an incorrect output. The incorrect behavior is defined by a set of test images. The only dark point on which I'm investigating is…
Luca
  • 11,646
  • 11
  • 70
  • 125
0
votes
1 answer

3D model rendering and shaders

I have a 3D model and while rendering i am using shaders to calculate the vertex color(computationally intensive task), based on some parameters. These parameters change with time. So basically i need to calculate the vertex color based on the…
rps
  • 221
  • 2
  • 6
1 2 3
19
20