Questions tagged [cg]

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

300 questions
1
vote
1 answer

How do you implement an efficient parallel SIMD compare and select in Cg?

How do you do parallel selection efficiently ? For example, given this scalar code, is there a way to write it so the Cg compiler will make the code execute in parallel / SIMD (and potential using a branchfree selection as well). Out.x =…
Adisak
  • 6,708
  • 38
  • 46
1
vote
3 answers

How to construct a mesh from given edge points?

I have some points on the edge(left image), and I want to construct a mesh(right), Is there any good algorithm to achieve it? many thanks! image can see here http://ww3.sinaimg.cn/large/6a2c8e2bjw1dk8jr3t7eaj.jpg
Mesh008
  • 11
  • 2
1
vote
0 answers

How to find pair edge while building half-edge datastructure

I wrote my half-edge datastructure based on this webpage. The mesh is loaded from a .obj, contained info for each vertex and what 3 vertices compose a face. The only problem is: how do I know what's the pair edge for a specific edge? Right now I…
Ray Wu
  • 993
  • 16
  • 34
1
vote
0 answers

Unity. Tessellation Shader for Android/IOS

I'm trying to find any example of tessellation on web, but no luck. The shader I tried to implement is this: Shader "Custom/BzKovSoft/RollProgressedTest" { Properties { _Color ("Color", Color) = (1,1,1,1) _MainTex ("Albedo…
Stas BZ
  • 1,184
  • 1
  • 17
  • 36
1
vote
1 answer

Retrieving a struct parameter from a Cg shader

I find this annoying but is there a better way to retrieve a struct parameter from a Cg shader? In the 11_two_light_with_structs example (OpenGL), there's a struct Material in the shader: Cg shader: // From page 128 struct Material { float3 Ke; …
bobobobo
  • 64,917
  • 62
  • 258
  • 363
1
vote
1 answer

Why is the later version of Cg compiler producing shader using more instructions?

I have a shader that looks like this: void main( in float2 pos : TEXCOORD0, in uniform sampler2D data : TEXUNIT0, in uniform sampler2D palette : TEXUNIT1, in uniform float …
BЈовић
  • 62,405
  • 41
  • 173
  • 273
1
vote
1 answer

Issue with getting vertex colors from application to CGFX

Problem: I would like to work with vertex colors delivered by Maya in my cgfx shader. It should be a trivial problem but I have no luck so far. Attempt: Below I have written up a super simple shader which should just display the raw vertex colors.…
1
vote
2 answers

Downsampling an image without "dancing" pixels

Say I wanted to downsample an image in realtime (1280x720) to a very small scale (16x16) and not suffer from "dancing" pixels when the image moves, which technique would I use? This would be using XBox360/PS3 GPUs. Note that the 16x16 image only…
Jim
  • 13
  • 3
1
vote
0 answers

How to know when we have a texture in a fragment shader

I have a C++/OpenGL render engine that uses a library to do the character animation / rendering. Each character uses a mix of textures, no textures, vertex shaders, no vertex shaders etc. I want to be able to add a tint to some of the characters,…
GiantBen
  • 51
  • 4
1
vote
3 answers

What dose 1.-1 mean in all shader language

I saw glsl code like this: vec3 color = vec3(.0); float var = 0; color += 1.-step(0.2,var); What does color += 1.-step(0.2,var) mean, I found it also work for cg language.And it has other form: 1.-1, 1.-0, etc Is .- a operator?
hamma
  • 13
  • 1
  • 3
1
vote
1 answer

Making 2D water look like 3d

I don't know much about shader :( if someone could help I am using this free 2d water asset it contains a water shader. I want to edit that shader so it looks more like 2.5d or 3d. Currently, it looks like this I want to make it look like Adding a…
Maulik Lathiya
  • 153
  • 3
  • 14
1
vote
2 answers

Can vertex alpha be set for a surface shader appdata input?

My shader does some math to determine vertex alpha, so I've got a function to do that before the data gets passed into my surf function. #pragma surface surf Standard alpha #pragma target 3.0 struct Input { float2…
Nol
  • 344
  • 3
  • 15
1
vote
1 answer

Is there a better way than writing several different versions of your GLSL shaders for compatibility sake?

I'm starting to play with OpenGL and I'd like to avoid the fixed functions as much as possible as the trend seems to be away from them. However, my graphics card is old and only supports up to OpenGL 2.1. Is there a way to write shaders for GLSL…
user457586
1
vote
2 answers

Stucked on changing shader albedo alpha smoothness

I want to customize unity's standard shader, I have downloaded it's source code and just want to customize it, so that smoothness of albedo alpha property should change by x(for example 0.1f) per frame. Sorry if this is bad question, but I googled…
Chestera
  • 667
  • 2
  • 13
  • 22
1
vote
1 answer

i want to make a CFG in which letter b is never trippled

need help regarding context free grammar. I want a cfg in which letter b is never tripled. This means that no word contains the substring bbb in it. Language contains only letters {a,b}
Haris Akhtar
  • 13
  • 1
  • 5