Questions tagged [cg]

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

300 questions
0
votes
2 answers

Smooth shader in OpenGL for OBJ import?

I'm using the OpenGL OBJ loader, which can be downloaded here! I exported an OBJ model from Blender. The problem is that I want to achieve a smooth shading. As you can see, it is not smooth here. How do I achieve this? Maybe something is wrong at…
Bachey
  • 35
  • 4
0
votes
1 answer

Shader and Texture Scrolling depending on Direction

I am trying to scroll a texture using its uv in Unity but I don't get the result I need. The aim is to have two components, the speed and the direction. I would like to define the direction in normalized values and the speed should influence the…
MaT
  • 1,556
  • 3
  • 28
  • 64
0
votes
1 answer

No subshaders can run on this graphics card

This works fine on a PC but I'm using a Mac and it brings up the warning No subshaders can run on this graphics card Which for shaders then brings up the pink error shader. Shader "Custom/wireframeShaderWithLambert" { Properties { _Glossiness…
normyp
  • 184
  • 1
  • 11
0
votes
1 answer

How do I know if I need world or object space when I am writing shader in cg?

So I am writing a shader and I was setting up the light direction and normal direction to make a lambert shader. VOUT.normalDirection = normalize( mul(float4(i.normal,0.0),_World2Object).xyz); float3 lightDirection =…
anonymous-dev
  • 2,897
  • 9
  • 48
  • 112
0
votes
1 answer

Get the tangent from a normal direction cg unity3d

I am writing a shader in cg where I displace the vertexes. Because I displace the vertexes, I recalculate the normals so they point away from the surface and give that information to the fragment function. In the shader I also implemented a normal…
anonymous-dev
  • 2,897
  • 9
  • 48
  • 112
0
votes
1 answer

Why the final color value is the product of two other color values in shader program?

in the diffuse lighting model or other models,the final color value of a pixel should be a product of other two light color value,and i don't quite understand. like this: float4 c; c.rgb = (s.Albedo * _LightColor0.rgb*diff);
Parker Song
  • 151
  • 10
0
votes
1 answer

some questions about cg shader program (Depth Shadow Mapping in OGRE)

I am now doing with depth shadow mapping,and learning from this tutorial (http://www.ogre3d.org/tikiwiki/Depth+Shadow+Mapping) I have 3 questions as following: (1)Is it right that when I use custom shadow caster,I can get depth in shadow …
user3094631
  • 425
  • 3
  • 13
0
votes
1 answer

No shadows on my mesh becuase of a mistake in my shader Unity3D

I am writing a toon water shader, and I want it to be lit by a directional light. I got it working but I think there is somthing wrong with the normals because there are no shadows between the wave. I hope that someone can find the mistake I made…
anonymous-dev
  • 2,897
  • 9
  • 48
  • 112
0
votes
1 answer

Why passing parameter is OK between Vertex and Fragment shader

A typical shader is like this: struct vin_vct { float4 vertex : POSITION; float4 color : COLOR; float2 texcoord : TEXCOORD0; }; struct v2f_vct { float4 vertex :…
1hunch1kill
  • 522
  • 4
  • 12
0
votes
1 answer

Cant understand CG semantic

I am beginner in CG and do simple shader. I can't understand what means this code float4 vert(float4 vertexPos : POSITION) : SV_POSITION { ... } Rather this moment: We announced parameter with type float4.Question: what do this ": POSITION" and…
Coffeeman
  • 285
  • 1
  • 6
  • 17
0
votes
1 answer

How to run Cg vertex/fragment shader on CPU?

I'm playing about with some vertex and fragment shaders using Cg on my little netbook (running Linux). Clearly I'm going to frequently hit resource limits for my graphics controller, so was wondering if there's a nice way to run the shaders on the…
Andy
  • 331
  • 2
  • 12
0
votes
1 answer

Unity Shader RGBA Color mask

I am working on a shader for Unity in which I want to change the color based on an mask image. In this mask image the RGB channels stand for a color that can be choosen in the shader. The idea behind the shader is that it is easy to change the look…
Neok
  • 13
  • 1
  • 4
0
votes
1 answer

Fastest way to write sampler2D * 0 and sampler2D * 1 to add many together? (glsl/cg)

I would like to mix many sampler2Ds into one shader, without "if" conditions, using variable m1,m2,m3 equals to 0 / 1 for each sampler2D to say if it is active or not, and multiply by 1 the sampler2Ds active at one time. I naively wrote this…
bandybabboon
  • 2,210
  • 1
  • 23
  • 33
0
votes
1 answer

How to compile in multiple platform a CGProgram in unity?

When I tried building my works from unity to phone, the shining effect only working on editor but not on the build? How can I resolve this one? I've heard about compilation of shaders but it confuse me more.
ky-chan
  • 101
  • 1
0
votes
1 answer

OpenGL Cg Geometry Shader

I'm getting a compiler error when trying to initialize a geometry shader using OpenGL. I'm using VS2013. Here is how I initialize it on OpenGL myCgContext = cgCreateContext(); cgGLSetDebugMode(CG_FALSE); cgSetParameterSettingMode(myCgContext,…