cg

Vertex position relative to normal

心已入冬 提交于 2019-12-23 13:35:14
问题 In a surface shader , given the world's up axis (and the others too), a world space position and a normal in world space, how can we rotate the worldspace position into the space of the normal? That is, given a up vector and a non-orthogonal target-up vector, how can we transform the position by rotating its up vector? I need this so I can get the vertex position only affected by the object's rotation matrix, which I don't have access to. Here's a graphical visualization of what I want to do:

Receive and cast shadows (custom GEOMETRY Grass Shader) - Unity C#

ぃ、小莉子 提交于 2019-12-13 03:19:27
问题 I was following a tutorial made by Sam Wronski aka. World of Zero (Tutorial by World of Zero) where he codes a geometry shader for a point cloud grass generator. Great tutorial but I am wondering (and didn't find a proper solution after days of research) how I could implement shadows to the shader (casting and receiving shadows). I am trying to dig deeper into shaders, but this is a level to high for me yet. My question is : how can I implement shadow casting and receiving for this grass

Why my shader doesn't render the subshader with the color?

一世执手 提交于 2019-12-11 19:47:22
问题 I found a shader and it's a Wireframe shader with no diagonals (see ref. here). I'd like to fill is with color so I added a subshader that will render the color (taking from here). Both shaders work great independently, however when I try to combine them the color from the second shader is not rendering. What can the problem be? This is the code I have: Shader "Custom/TransparentSingleColorShader" { Properties{ _Color("Color", Color) = (1.0, 1.0, 1.0, 1.0) [PowerSlider(3.0)] _WireframeVal(

Embedding cg shaders in C++ GPGPU library

笑着哭i 提交于 2019-12-11 09:52:35
问题 I'm writing a GPGPU Fluid simulation, which runs using C++/OpenGL/Cg. At the moment, the library requires that the user specify a path to the shaders, which is will then read it from. I'm finding it extremely annoying to have to specify that in my own projects and testing, so I want to make the shader contents linked in with the rest. Ideally, my .cg files would still be browsable seperately, but a post-build step or pre-processor directive would include it in the source when required. To

Cg problems with OpenGL

我怕爱的太早我们不能终老 提交于 2019-12-10 15:54:16
问题 I'm working on an OpenGL project on Windows, using GLEW to provide the functionality the provided Windows headers lack. For shader support, I'm using NVIDIA's Cg. All the documentation and code samples I have read indicate that the following is the correct method for loading an using shaders, and I've implemented things this way in my code: Create a Cg context with cgCreateContext . Get the latest vertex and pixel shader profiles using cgGLGetLatestProfile with CG_GL_VERTEX and CG_GL_FRAGMENT

Does CG 3.0 leak?

谁说我不能喝 提交于 2019-12-10 15:45:02
问题 I'm finding CG appears to have a memory leak. I submitted a report via nvidia.com, but if you try this here: If you remove the line that says cgD3D11SetTextureParameter( g.theTexture, g.sharedTex ) ; The leak stops. Does CG 3.0 really leak? Using ATI Radeon 5850 GPU / Windows 7 64-bit. 回答1: Yes, it leaks. Internally it creates a ShaderResourceView on every call, and never releases it. I think the API is ill-designed, they should have taken a ShaderResourceView* as a parameter to this function

How to modify/displace pixel position in a Cg fragment shader?

左心房为你撑大大i 提交于 2019-12-08 06:05:21
问题 Is it possible to modify pixel coordinates in a fragment (pixel) shader using Cg? I'm sure such functionality became available in 2nd/3rd-generation shaders but I don't know what profiles exactly, or how to do it. 回答1: No, it is not possible. The only coordinate you can modify in a fragment shader is the Z, going into the Z-buffer. And even that has performance implications, as it defeats some optimizations (like Hierarchical Z). the X and Y positions are set before the fragment shader is

OpenGL: How do I get the coordinates of a specific point after transformation?

人走茶凉 提交于 2019-12-07 14:49:33
问题 Suppose I have a point at (250,125,-20). After the following transformation, glMatrixMode(GL_MODELVIEW); glLoadIdentity(); glTranslatef(100.0, 50.0, 0.0); glRotatef(-25.0, 0.0, 1.0, 0.0); How can I get the value of current coordinates of that point? Need I write a subroutine to multiply a matrix to a vector? Are there any built-in solutions? 回答1: You can't get the coordinates for a specific vertex (point) after a transformation, however for this particular case you can get the ModelViewMatrix

How to modify/displace pixel position in a Cg fragment shader?

房东的猫 提交于 2019-12-07 03:11:27
Is it possible to modify pixel coordinates in a fragment (pixel) shader using Cg? I'm sure such functionality became available in 2nd/3rd-generation shaders but I don't know what profiles exactly, or how to do it. No, it is not possible. The only coordinate you can modify in a fragment shader is the Z, going into the Z-buffer. And even that has performance implications, as it defeats some optimizations (like Hierarchical Z). the X and Y positions are set before the fragment shader is ever executed (in the Rasterizer ). Typical rasterizers actually generate at the very least 2x2 chunks of

OpenGL: How do I get the coordinates of a specific point after transformation?

孤街浪徒 提交于 2019-12-05 20:41:42
Suppose I have a point at (250,125,-20). After the following transformation, glMatrixMode(GL_MODELVIEW); glLoadIdentity(); glTranslatef(100.0, 50.0, 0.0); glRotatef(-25.0, 0.0, 1.0, 0.0); How can I get the value of current coordinates of that point? Need I write a subroutine to multiply a matrix to a vector? Are there any built-in solutions? Cristina You can't get the coordinates for a specific vertex (point) after a transformation, however for this particular case you can get the ModelViewMatrix after the translate/rotate is applied. glMatrixMode(GL_MODELVIEW); glLoadIdentity(); glTranslatef