Cg is a high-level shading language developed by Nvidia.
Questions tagged [cg]
300 questions
3
votes
1 answer
What is IN.worldRefl in surface shader Input struct?
The question is pretty straight-forward. I have no idea what IN.worldRefl stands for, I've seen some tutorials using it with cubemaps but I still have no clue.
Unity's description for it is very poor:
float3 worldRefl - contains world reflection…

Daniel
- 7,357
- 7
- 32
- 84
3
votes
1 answer
Unity surface shader not casting shadows on itself
I'm new to shaders and I'm trying to make a shader for some very simple low poly water. I have created this simple surface shader that changes the vertex heights.
The problem is that it doesn't receive shadows as you can see in the gif and there is…

Elbbard
- 2,064
- 6
- 30
- 53
3
votes
1 answer
Pixel scaling algorithm problems with GPU shader
So I'm working on some pixel shaders for good old emulators like Super Nintendo. You have the classic algorithms like HQnx, 2xSaI, etc, and they are definitely written to run on CPUs and be scaled exactly to twice the size before blitting to the…

Maister
- 4,978
- 1
- 31
- 34
3
votes
1 answer
Custom Shader not working on Android
I ported a Plasma ball shader from Shadertoy to Unity as Image Effect which is attached to the camera. It works fine on the Editor and Windows standalone build. It does not work on Android devices. It is flashing blue and black images on…

Programmer
- 121,791
- 22
- 236
- 328
3
votes
1 answer
Return a struct from function
Can structs in cg be used for anything outher than declaring pipeline semantics?
I'm using Unity3D and this code throws "Shader error in 'Implicit/Rose': redefinition of 'PetalData' at line 48 (on d3d11)".
How can I make it work? Am I missing…

Emilio Martinez
- 1,052
- 6
- 22
3
votes
2 answers
Fluctuate float value in an Unity shader
I'm trying to fluctuate between two values inside a shader to achieve a glowing effect.
I need it to be done inside the shader itself and not via C# scripting.
I've tried using the _Time value that Unity gives us for shader animation but it isn't…

user6385193
- 53
- 1
- 8
3
votes
0 answers
How to apply a postprocess effect to a UI element
I have a post-process effect that uses Unity's Graphics.Blit to pixelate or apply a crt-screen effect to a scene. There are some UI elements that display after the fact (basically making it not a true post process, but let's put that aside for a…

Aaron Hull
- 422
- 4
- 16
3
votes
1 answer
Output value vert is not completly initialized
I am getting the warning
Shader warning in 'Custom/NoobShader_02': Output value 'vert' is not
completely initialized at line 30 (on d3d11)
with the following code can anyone explain me why it is doing this?
Shader "Custom/NoobShader_02" {
…

anonymous-dev
- 2,897
- 9
- 48
- 112
3
votes
0 answers
unity custom shader not receiving Shadow
Shader "Custom/1_displayImageOnSlide" {
Properties {
_MainTex ("Texture", 2D) = "white" {}
_CutoffX("CutoffX", Range(0.0,1.0)) = 1
_CutoffY("CutoffY", Range(0.0,1.0)) = 1
}
Category {
Cull off
…

Mohammad Faizan khan
- 1,213
- 3
- 17
- 32
3
votes
2 answers
Shader programming with ShaderLab and CG in unity
I am trying to learn Shader programming using ShaderLab and CG in UNITY. Is there any step by step FREE guide (videos/book/tutorial)available ?
Please don't recommend me NVIDIA CG tutorials (it is extremely descriptive and difficult to understand)…

Mohammad Faizan khan
- 1,213
- 3
- 17
- 32
3
votes
1 answer
Shaders: What's the quickest way to get the highest value of a fixed3 or fixed4?
So I'm trying to do some shader work and I want use one color variable for two things: I want it to blend with the texture based on the "intensity" of the color, and I want the alpha of the color to blend the entirety of the…

MNerurkar
- 31
- 2
3
votes
1 answer
Accessing OpenGL state variables in Cg
I need to access the OpenGL state variables (such as the MVP matrices) in my Cg shader program. I'm passing these values to my Cg shader program manually using calls such as cgGLSetStateMatrixParameter() in my C/C++ code. Is there an easier way to…

Ashwin Nanjappa
- 76,204
- 83
- 211
- 292
3
votes
1 answer
What is the correct way to structure a Cg program?
This tutorial uses explicit OUT structures, e.g:
struct C3E1v_Output {
float4 position : POSITION;
float4 color : COLOR;
};
C3E1v_Output C3E1v_anyColor(float2 position : POSITION,
uniform float4 constantColor)
{
…

Mr. Boy
- 60,845
- 93
- 320
- 589
2
votes
0 answers
Write depth buffer from Cg and then read it from OpenGL
I'd like to create a shadow map with cg. I have written an opengl program and 2 pixel shaders (with 2 vertex shader). In the first pixel shader, I write the DEPTH register, and in the OpenGL program I read this to a texture. In the second pixel…

lyra42
- 365
- 1
- 3
- 11
2
votes
3 answers
Coordinates output from Cg Vertex shader
The article here says:
Dividing x, y, and z by w accomplishes this. The resulting coordinates
are called normalized device coordinates. Now all the visible
geometric data lies in a cube with positions between <-1, -1, -1> and
<1, 1, 1> in…

Mr. Boy
- 60,845
- 93
- 320
- 589