Questions tagged [cg]

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

300 questions
0
votes
1 answer

Having trouble projecting a ShadowMap on to a surface

So I am having trouble rendering a shadow map in a shader I'm kind of new to shader coding(roughly 3 months), I'll talk you through what I am doing(well what I think I am doing). So to start off by creating a script(ShadowCopy.cs) which copies the…
Durdle
  • 3
  • 4
0
votes
1 answer

Implement fast smooth cg blur shader on mobile devices in unity

I would like to implement a fast smooth blur shader using CG shader language in unity. What is the best and standard way to implement it on mobile devices? The king of thieves game has used it
Mahdi GB
  • 65
  • 2
  • 9
0
votes
0 answers

SceneKit: how to tell SCNNode that geometry shader modifier performed transformations?

My question is related to SceneKit framework. I have a geometry shader modifier that does some deformation that involves rotation of the whole geometry. In my specific case it is important to deform and then rotate a vertex inside the shader.…
0
votes
0 answers

Merging 2 shaders in Unity using CG programming and Shaderlab

I want to merge the functionality of these two shaders for Unity. First shader is main shader that adds a glitch hologram effect. The Second shader is making a surface texture flimmer for added visual effect. I am trying to merge my versions of…
user4626838
0
votes
1 answer

Blur shader(Grab pass) showed pink in editor but work in mobile

This shader work on mobile, but in editor it showed as pink. Previously it work fine, but somehow after I build on mobile, Then it start to showed as pink. No error but It give me warning. I am using Unity 2017.2. I also try to reopen project. but…
Tengku Fathullah
  • 1,279
  • 1
  • 18
  • 43
0
votes
0 answers

Shader showing as black from one scene to another

I have a small question on Unity. I have 2 scenes; one is a 'menu' with a simple button, and the other one is my scene with an object that has a custom terrain shader with it. You can see the code for the custom shader here: Unity shader error,…
0
votes
0 answers

Shader that can sense intersection with other objects

I am a beginner shader worlds, it is much difficult to learn(anyhow i try sometime).I am searching a shader that can sense collision/intersection with other objects so that i can stop its rendering at that intersection point. I currently get this…
Muhammad Faizan Khan
  • 10,013
  • 18
  • 97
  • 186
0
votes
1 answer

Different between multi_pragma vs shader_feature

I go through a lot of documentation and google but still unclear. As state here, in unity doc, pragma_multi #pragma multi_compile A B C #pragma multi_compile D E This would produce three variants for first line, and two for the second line, or in…
Tengku Fathullah
  • 1,279
  • 1
  • 18
  • 43
0
votes
1 answer

How do I check if an array element is empty in Cg? (Unity shader development)

In my shader, I declare a non-serialized array of float4s and execute a block of code on the elements: uniform float4 _HandPos[5]; v2f vert(appdata v) { float distH; for (float i = 0; i < _HandPos.Length; i++) { /*if element…
Blando
  • 55
  • 1
  • 1
  • 5
0
votes
1 answer

Cg Shaders Alpha Blending

I want to use Alpha Blending (SRC_ALPHA, ONE_MINUS_SRC_ALPHA), which basically is this: frag_out.aaaa * frag.out + ((1.0, 1.0, 1.0, 1.0) - frag_out.aaaa) * pixel_color Let's say the pixel color already on screen is (1.0, 1.0, 1.0, 1.0) The color I…
Terko
  • 155
  • 1
  • 1
  • 5
0
votes
1 answer

How do I get a Light's Range value in Shader?

I'm trying to write a simple frag/vert shader that, depending on whether it is in the range of a light, will paint the appropriate colour from either the 'lit' texture or from the 'unlit' texture. Therefore, I need to compare the distance between…
LeftRight92
  • 256
  • 3
  • 14
0
votes
0 answers

What is f4texRECT?

I'm reviewing a code and I see this function: void f4texRECTneighbors(samplerRECT tex, float2 s, out float4 left , out float4 right, out float4 top, out float4 bottom) { left = f4texRECT(tex, s - float2(1, 0)); right = f4texRECT(tex, s +…
morteza khosravi
  • 1,599
  • 1
  • 20
  • 36
0
votes
1 answer

Basic openGL 3.2 Setup with lwjgl - Object not rendered

I am little bit desperate here. I am trying to update/refactor an existing code written in legacy opengl to make use of the "modern way" of opengl version 3.2+. It is written in Java with lwjgl. I already stripped away most of the functionality to…
amaridev
  • 31
  • 4
0
votes
0 answers

Access vertex via ID given by VERTEXID semantic in NVIDIA's CG?

is there a way to access the actual vertex-data with its VERTEXID? You can access it in CG inside the geometry shader like this: AttribArray vertexID : VERTEXID My idea was to store the ID of a vertex as an attribute of another vertex and…
user6190510
0
votes
1 answer

Shader error : incorrect number of arguments to numeric-type constructor - Unity3D

I was implementing a lightmap into my shader and then I got this error and I can't figure out what it means. Does any one know how I can fix this? It started happening since I added the light map in. Shader error in 'Custom/HauntedHouseShader':…
anonymous-dev
  • 2,897
  • 9
  • 48
  • 112