Questions tagged [cg]

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

300 questions
162
votes
5 answers

Vertex shader vs Fragment Shader

I've read some tutorials regarding Cg, yet one thing is not quite clear to me. What exactly is the difference between vertex and fragment shaders? And for what situations is one better suited than the other?
adivasile
  • 2,377
  • 3
  • 24
  • 32
42
votes
5 answers

Include Headers from added frameworks on Xcode

I want to work with some frameworks like glew and cg so i manually added the needed frameworks to my project by right clicking the project -> Add files to ... and choosing the correct framework. The problem is, when i try to include the header…
Itzik984
  • 15,968
  • 28
  • 69
  • 107
30
votes
3 answers

CoreGraphics for retina display

I am using the following code to perform some manipulations on the image that I loaded, but I find that the display becomes blurry when it is on the retina display - (UIImage*)createImageSection:(UIImage*)image section:(CGRect)section { float…
DKV
  • 303
  • 1
  • 3
  • 4
13
votes
2 answers

how to set a boolean property in unity3d CGprogram shader?

I am writing a shader for unity3d and I want to specify the properties of the shader in i.e like - Shader "GraphicsQuality/MediumScan" { Properties { _Color ("Main Color", Color) = (1,1,1,1) _SpecColor ("Specular Color", Color) =…
Gkills
  • 587
  • 1
  • 6
  • 28
12
votes
2 answers

Coding unity shaders with unity visual studio

Recently I've been coding shaders for unity in visual studio and I've noticed that since unity shaders are written in a combination of unity's shader lab language and CG, visual studio 2015 doesn't seem to recognize the languages. Because of this,…
Enryu
  • 1,406
  • 1
  • 14
  • 26
11
votes
2 answers

How to get full list of Unity shader properties

I am quite new to shaders and have been searching for a full list of Unity shader properties. I haven't found any such documentation. What I found was SL-Properties. Where can I find a full list of properties and their functions? UPDATE An example…
Nullititiousness
  • 361
  • 1
  • 4
  • 14
7
votes
1 answer

Unity Shader - How to efficiently recolor specific coordinates?

First, please allow me to explain what I've got and then I'll go over what I'm trying to figure out next. What I've got I've got a textured custom mesh with some edges that exactly align with integer world coordinates in Unity. To the mesh I've…
Mir
  • 305
  • 8
  • 24
7
votes
2 answers

What does #pragma vertex vert_img do in a Unity shader?

While I built an idea of what vert_img does by observing results, I would like to read a more theoretical explanation that I couldn't find online. For context, I found this vert_img in some shaders that use floating point textures to compute the…
Steak Overflow
  • 7,041
  • 1
  • 37
  • 59
7
votes
1 answer

Am I doing something wrong with this CG program?

I am using Ogre3D as the graphics engine. I create a mesh manually which works fine, uvs are correct and are set to represent grid coordinates (for this example the grid is a 10 x 10) I do nothing in the vertex program and have a very simple…
Jon Taylor
  • 7,865
  • 5
  • 30
  • 55
6
votes
1 answer

Is it possible to access all vertices in a polygon in a vertex shader?

I'm trying to create a wireframe vertex/fragment shader in Unity. It seems possible according to this paper. The general ideas seems to be that you pass a distance vector calculated in the vertex shader to each fragment in the fragment shader, which…
aardvarkk
  • 14,955
  • 7
  • 67
  • 96
6
votes
2 answers

Dot product vs Direct vector components sum performance in shaders

I'm writing CG shaders for advanced lighting calculation for game based on Unity. Sometimes it is needed to sum all vector components. There are two ways to do it: Just write something like: float sum = v.x + v.y + v.z; Or do something like: float…
Crabonog
  • 423
  • 3
  • 12
6
votes
2 answers

Why are dFdx/ddx and dFdy/ddy 2 dimension variables when quering a 2d texture?

I cannot seem to understand this, shouldn't the derivative/change along the U or V coordinate in a 2d texture/array be single dimension variable as we are checking it only along ddx (U coordinate) or ddy (V coordinate)?
Nims
  • 477
  • 1
  • 5
  • 12
6
votes
3 answers

Is it viable to replace GLSL with CG?

http://http.developer.nvidia.com/Cg/TessellationControlShader.html I have some questions regarding CG. What OpenGL version does CG support? On their site they state Opengl Functionality Requirements OpenGL 1.0 Which seems a little bit odd to me.…
Maik Klein
  • 15,548
  • 27
  • 101
  • 197
6
votes
1 answer

Image resizing: what is a "filter"?

I'm trying to understand how image resizing works - please, can someone explain to me what is a "filter" good for? does a filter calculates how much a source pixel contributes to a destination pixel? there are filters like "box" and "gaussian", but…
Ecir Hana
  • 10,864
  • 13
  • 67
  • 117
5
votes
2 answers

How to set the saturation level of an entire color channel in Unity

I would like to set the saturation of an entire color channel in my main camera. The closest option that I've found was the Hue vs. Sat(uration) Grading Curve. In the background of the scene is a palm tree that is colored teal. I want the green…
Rickest Rick
  • 1,519
  • 1
  • 15
  • 28
1
2 3
19 20