Stack Exchange Network

Stack Exchange network consists of 174 Q&A communities including Stack Overflow, the largest, most trusted online community for developers to learn, share their knowledge, and build their careers.

Visit Stack Exchange

Questions tagged [cg]

CG is a programming language for 3D graphics that runs on the GPU. It was designed by NVIDIA and Microsoft. It stands for "C for graphics"

0
votes
0answers
21 views

Blinking color shader

Currently i'm using Unity3D, and i want to make one variable blink along time in a fragment shader. Now i have code like this: ...
1
vote
1answer
32 views

What does vertex:disp and tessellate:tessEdge mean? [Shader] [Unity]

I came across the following declaration on unity tutorial #pragma surface surf BlinnPhong addshadow fullforwardshadows vertex:disp tessellate:tessEdge nolightmap ...
0
votes
2answers
105 views

GPU Gems Chapter 1, update normal

Had plans to follow GPU Gems to gain knowledge in Shaders - but my journey came to an abrupt end. ...
0
votes
1answer
130 views

How can I write a dots effect shader when the character is behind an object?

I watched an interesting effect while I was playing Super Mario Odyssey: when Mario or another character was behind an obstacle (walls, etc), a tiny gray silhouette mesh appears. I tried to build ...
1
vote
1answer
699 views

Surface Depth Intersection Shader

I recently asked a question about the creating an accurate Depth Intersection Shader. When creating this in a fragment / vertex shader it could be achieved by the following code ...
2
votes
1answer
2k views

Depth Intersection Shader

I am trying to create a shader in Unity that shows where intersections occur between objects. Most of the shader I have so far is based off of this youtube tutorial. However, I have made some slight ...
0
votes
1answer
70 views

What does declaring a const float within a function do? (CGFX)

I've been working with this piece of code to get the mip map level that I should sample for a texture that I got off a forum somewhere. I noticed that they use a const float. Now from what I ...
1
vote
0answers
237 views

How to create inline glow shader for 2d polygon in CG using Unity Shader Lab?

So here is what I am trying to do. Given irregular polygon (on the left) I would like to be able to create a shader that would resemble Photoshop inline glow effect with opaque fill (on the right). ...
1
vote
1answer
504 views

Modifying Alpha in Unity Standard Shader

I'm trying to create a shader in Unity with a slider that can adjust the transparency. (This is the first step toward something more sophisticated.) I try to do this by setting the alpha of the ...
2
votes
1answer
369 views

UI Billboard Shader - Wrong rotation pivot - Unity

I'm trying to display several Images as billboards. All the Images are under the same Canvas. I'm using a billboard shader I've been working on: ...
0
votes
0answers
176 views

Unity shader transparency broken

In my voxel engine I use a single Material for everything. That material uses a custom shader. It works fine except when it comes to transparency: In the top left of this image you can see just a ...
5
votes
1answer
4k views

How to make a 2D neon-like trail effect in Unity

Recently I've been toying around with neon-ish effects for a game I'm making and wanted to share my results with you. If you guys have any other methods of achieving this result, please be sure to ...
0
votes
0answers
688 views

Adding an extra Pass to the Unity Standard Shader

I'm experimenting with adding some procedural textures to the unity standard shader. I'd like to add an extra pass (with vert and frag functions), but am unsure about where in the sequence this should ...
0
votes
1answer
59 views

Identify shading language in Trove

I'm playing this voxel game named Trove, running it in DirectX, their requirements are DirectX 10 and OpenGL 3.2 The character entity in this game emits light when it gets close to any surfaces (...
0
votes
1answer
550 views

Unity Vertex shader recalculate renderer bounds

I've made a simple billboard gpu instancing vertex shader that manipulates the verticies of an object based on the projection matrix. The problem is that the renderer bounds does not update to ...
1
vote
0answers
307 views

Shaderlab and Cg API reference [closed]

I am looking for definitive information on Shaderlab's API and the Cg language. The documentation I have found so far has been by way of example programs rather than a definition of APIs. Also, ...
0
votes
2answers
113 views

Determining which point is further along a direction vector

I am attempting to write a frustum culling algorithm simply by testing axis aligned boxes against a plane, while researching this i came across an article here: enter link description here The trouble ...
1
vote
2answers
703 views

CG: 4+ color gradient

I am trying to write a shader that takes multiple colors and applies them to a B&W texture. Now, 3 colors works just fine, but i will need 6 in order for this to function. If somebody could please ...
3
votes
2answers
503 views

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. ...
1
vote
1answer
51 views

What is an animated surface mesh?

I am reading the paper Animated Mesh Approximation With Sphere-Meshes . The input of the algorithm mentioned in the paper is an animated surface mesh, but I do not know what an animated surface mesh ...
5
votes
1answer
249 views

Simple square vertex lifting shader

I am trying to rebuild the fur effect in Viva Pinata. Here each square becomes a pattern of fur I imagine the process to be like this... U lift one end of the triangles. Now I need to achieve "...
0
votes
0answers
105 views

Linear gradient shader ( Photoshop-like)

I'm searching a way to implement a linear gradient shader that behaves as the linear gradient in Photoshop (only the vertical case is necessary). It will be applied to 2D sprites. Currently I'm ...
5
votes
1answer
10k views

Why can't I sample a texture in a vertex shader?

I'm old in Game Development but very new in shader writing. I just want a shader that transform from 1 texture to another. So I did start learning shader writing and wrote my desired shader. But ...
0
votes
2answers
483 views

Unity - Access to svPosition in fragment shader

I am trying to access to the svPosition in my fragment program in Unity but I keep having this error. invalid input semantic 'POSITION': Legal indices are in <...
3
votes
1answer
2k views

Writing a glow shader

I'm trying to learn writing shaders. And I've pieced together something that is kinda working. I want to create a transparent glow around a sphere. The problem I have is that I can't seem to alter the ...
1
vote
1answer
1k views

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 ...
1
vote
0answers
1k views

Creating lightning effect with glow effect

I am trying to recreate Drilian's lightning bolt in unity and I have faced a problem in the "Adding Some Glow" part. I am missing glow effect (and/ or "rounded beams"). Here is what I am doing: I ...
3
votes
1answer
332 views

Why is addressing an array of vectors more efficient than addressing an array of matrices in Cg?

According to Nvidia's Cg tutorial (in the note section right under 6.5.2), addressing an array of vectors seems to be more efficient than addressing an array of matrices. The reason it mentions is ...
1
vote
1answer
569 views

Unity: cg fragment shader processing array of points

I need to write a fragment shader which would somehow be aware of N points that are in the scene and darken pixels based on their world coord distance to the points. I'm looking for a method that ...
1
vote
1answer
2k views

Share a function between two passes inside CG Shader for unity3d

I'm writing a shader in CG language for Unity3d. When making transparent object you need to create two similar passes in SubShader. First to render only back faces (with ...
1
vote
1answer
1k views

Tile Map Shader?

I'm trying to write a shader in unity that will take tiles from a sprite sheet and draw them onto a tile map. I'm new to shaders so this might be totally wrong, I think it might just be a math error ...
2
votes
1answer
1k views

Why encode floats in RGBA?

Working on some effects that require depth (Z) data in Unity, I saw that these use a method to store the depth data encoded in the RGBA channels of a regular texture. ...
1
vote
3answers
2k views

How to prevent intepolated texture in fragment shader (Unity CG)

Think about minecraft - all the textures in minecraft have a very nice crisp pixelated look. Well, I'm trying to write a shader that will do this but it appears "sampler2d" returns some sort of ...
3
votes
1answer
2k views

Shader that draws just vertex points

The game I am developing is in unity and I want to make a shader which can be put on a mesh that only 'draws' color on each vertex point. I am not proficient with shaders, and out of all my searching ...
1
vote
2answers
466 views

GLSL to Cg: why is the effect different?

With reference to this question, where I was trying to make the shader compile, I am now trying to make an effect appear. The effect can be shown here, through a GLSL shader: But when I use the ...
0
votes
1answer
548 views

GLSL to Cg fragment shader

I have found very useful resource on the Swiftless website on OpenGL. Unfortunately, I cannot manage to adapt a GLSL fragment shader to my project, which uses Cg. Here it is: ...
1
vote
2answers
191 views

Accessing uniform variables from a Cg shader in OpenGL

I am trying to implement a simple PC program with OpenGL, using mandatorily Cg shaders (no Unity whatsoever). I have found some tips on this page http://bobobobo.wordpress.com/2008/10/05/cg-1/ and ...
3
votes
2answers
1k views

Possible to create transparency shader which doesn't stack alpha values

The image above best demonstrates what I'm trying to achieve. It's a transparent shader for objects, but wherever the objects with this shader intersect they don't add together but simply merge with ...
2
votes
1answer
2k views

In Unity, how can I read the color from _LightColor0 in a shader?

I have a scene with a point light and alpha textured (RGBA) triangle strips. I want to apply the point light color with a shader. ...
4
votes
1answer
2k views

Alpha Blending: use the pixel with the smallest alpha

I'm writing a transparency shader where I need any intersecting textures to, wherever they overlap, take the texture pixel with the smallest alpha value and render only that, discarding the other ...
5
votes
1answer
3k views

Issue with interpolation on a burn shader (lerp and smoothstep)

I'm trying to create a simple burn shader. See here for more info on the method I'm using. However, I don't get why replacing the smoothstep with a lerp results in completely different results. Am I ...
1
vote
1answer
7k views

Shader which supports vertex colors and pixel lights?

From my question at Unity Answers: Hello everyone, I'm facing a bit of a problem here: I need a shader which has the ability to colour individual vertices and be lit pixel by pixel. Until recently, I ...
1
vote
0answers
1k views

TEXCOORD0 vs COLOR in a Cg shader [closed]

I started to learn Cg shader programming, following the Panda3d shader tutorials. Having a scene with only a cube shown, each vertex of the model with a different color, I can successfully use the ...
1
vote
1answer
5k views

How to do Triplanar Texturing

Ok maybe i'm missing something because its getting late and i've been programming now for about 72 hours straight (minus a nap or 2) ... I'm trying to write a shader for unity that will apply ...
1
vote
1answer
349 views

My game works on the emulator and the PSVita, but crashes on Android

I made a game on PSM, ported from a previous iOS/Android game. I test it on the emulator and PSVita and runs fine. However, as I test it on a PlayStation Certified Android device, it crashes on load. ...
2
votes
1answer
2k views

shader coding: calculate screen coordinates of fragment

Good morning, I'm new to shader coding and trying to implement some visual effects code in shaders using billboards. (Yes, I couldn't have picked anything harder to start with, but I'm lucky that way) ...
0
votes
1answer
2k views

Calculating distance from viewer to object in a shader

Good morning, I'm working through creating the spherical billboards technique outlined in this paper. I'm trying to create a shader that calculates the distance from the camera to all objects in the ...
7
votes
1answer
3k views

Custom shadow mapping in Unity 3D Free Edition

Since real time hard and soft shadows are Unity 3D Pro only features I thought I will learn Cg programming and create my own shadow mapping shader. But after some digging I found that the shadow ...
1
vote
1answer
3k views

What kind of shader is this?

Cube World uses a pretty good looking shader, I especially like the shading of the characters: Is this soft shading? I'd like to achieve this effect in Unity 3D Free, but since the free version doesn'...
2
votes
1answer
9k views

Unity custom shaders and z-fighting

I've just readed a chapter of Unity iOS Essential by Robert Wiebe. It shows a solution for handling z-figthing problem occuring while rendering a street on a plane ...