shader

Is there any way to apply shader effect on particular cell of a Grid

Hi, Is there any way to apply shader effect on particular cell of a Grid. BR ...

How to perform bit shift without ("<<" || ">>") operator efficiently?

Hi, I am working on a OpenGL ES 2.0 shader and I have tightly packed data e.g. three 5-bit unsigned integers within a block of two bytes. To unpack this data I obviously need bit-shifting, but this is not supported in OpenGL ES Shading Language (see page 29 http://www.opengl.org/registry/doc/GLSLangSpec.Full.1.20.8.pdf) Consequently I ...

GLSL - Why are bitwise operators reserved? What is a good alternative to using bitwise ops (floating point ops that emulate bitwise)

I'm running some experiments in WebGL, one of them being an XOR effect fragment shader. For some reason all the bitwise operators are reserved in GLSL and cause a compiler error when used. Why are these operators illegal? What can I use instead of | in this case? ...

HLSL: Using arrays inside a struct

I came across a weird behavior of HLSL. I am trying to use an array that is contained within a struct, like this (Pixel Shader code): struct VSOUT { float4 projected : SV_POSITION; float3 pos: POSITION; float3 normal : NORMAL; }; struct Something { float a[17]; }; float4 shMain (VSOUT input) : SV_Target { Someth...

Are there any shader inputs other than TEXCOORD that wpf supports

I know that you can tie constant registers to dependency properties as well as tie a brush to a sampler, but every example I have seen of a wpf shader uses the declaration main( float2 uv : TEXCOORD ) : COLOR I am a complete newbie to HLSL but I know there are other semantics than TEXCOORD. Can any of them be used with a WPF shader? ...

Vertex shading and calculating lighting vector effect

Given a triangle vertex defined with three 3D points, how do you calculate the angle between it and a given point. class Point3D { double x, y, z; } class Vertex { Point3D P1, P2, P3; } Point3D LightPoint; Light point in Red. Blue points - triangle with the surface normal shown. I need to calculate the surface normal, an...

HLSL Translucent Plastic Shader

Hi, I'm trying to produce a shader to replicate a white plastic object with a colored light inside. Either by having a shader that will be translucent and if I put a light inside the object the light will show through or by having a shader that fakes the effect of a light inside. The effect im going for is kinda like a light going thro...

Cg and OpenGL 3

Hi, I'm currently learning the differences between OpenGL 2 and 3, and I noticed that many functions like glVertex, glVertexPointer, glColor, glColorPointer, etc. have disappeared. I'm used to using Cg to handle shaders. For example I'd write this simple vertex shader: void main(in inPos : POSITION, out outPos : POSITION) { outPos...

How do you do nonlinear shading in OpenGL?

I am developing a visualization tool in OpenGL to visualize the output of a 3d finite element modeling application. The application uses a tetrahedral mesh (but I am only viewing the exterior facets, which are triangles). The output is a scalar variable, which I want to map to a color map (I already know how to do that). The tricky part ...

C++ Nvidia Cg question

Hello! I started using Nvidia Cg shaders recently and everything looks and works fine if I'm doing it on the Nvidia GPU (GTS250 in my case). I tried launching the same (my own test application) on ATI HD4650 and saw no output. Right after that I started experimenting with test examples (provided with Nvidia Cg 3.0) and 6/7 work, but th...

HDR Rendering Pipeline DIfferences

What's the difference between a typical HDR rendering pipeline and a normal rendering pipeline? (i.e. bpp differences? Some additional post processing step?) ...

Problem with shader/code

I have this basic 3d application and trying to write my own toon shader, but even if I remove the tooning part it still still just stays plain darkblue when I give a red color to it. shader code : struct VertexShaderInput { float4 Position : POSITION0; float3 Normal : NORMAL0; float4 Color : COLOR0; }; struct VertexShader...

Change color component

Hello, I'm writing graphic shader program. I wrote everything I need except the color changing. In cycle there is passing some counter variable to the shader and I have to change it's color from white to orange shade. What I have change to achive this? ...

C++ shader question

Hello! Does somebody know where I can find a sample of shader (HLSL / CG / GLSL / Backend-independent) class? Of course, standard API (like D3DXEffect or same in GL) exists, but it's kind of ugly and not what I'm looking for. I'm looking for a high-quality interface design, not "just yet another implementation sample". Ideally someth...

C++ shader question

Hello! Suppose I have some geometrical data and I wish to render it in wireframe mode. Obviously, this can be done using the API (for example, by setting some appropriate mode like D3DFILL_WIREFRAME in DirectX). But I was interested if that is possible to achieve using vertex / geometry / pixel shaders (combined, probably). Does some...

GLSL Shader multi-texture lookup with different texCoord (iPad)

I'm in GLSL texture hell: I load 4 different textures of the same size in uniform sampler2D variables in my fragment shader and try to access them with different texture coordinates: uniform sampler2D image0, image1, image2, image3; varying highp vec2 texCoord; void main() { highp vec2 tc = vec2(texCoord.x, mod(1.0-texCoord.y, 0.2) ...

Rendering depth in HLSL

Hi folks this should be an easy task but for some reason I do not get it worked out... I just want to get a visualization of the depth in my scene using a shader: float4x4 matViewProjection; float4x4 matWorld; float4 eyePos; struct VS_OUTPUT { float4 position : POSITION0; float depth : TEXCOORD0; }; VS_OUTPUT vs_main( VS_INPUT i...

Does someone know of some fixed pipeline shader tutorial or samples?

I am making a game with 3d gamestudio a8 free edition. The free edition doesn't support shader, it only supports fixed pipeline shaders. There are some samples in the wiki of 3d gamestudio (click here) but I want to know of there are more samples or tutorials. ...

Is there a lint tool for OpenGL Shading Language?

I've started working with OpenGL and writing shaders. My app checks for errors after loading and compiling shader programs, and if there is a problem it prints out the info log. This is great for catching errors (and I'm a newbie so I'm making a lot), but what I'd really like is to catch these errors at build time. If I had a lint tool ...

OpenGL ES 2.0 multiple meshes? (just Real World Examples)

Hi guys! I`m a little confused about this point. Everything that I found in books, blogs, forums and even in OpenGl specs just talk about a very abstract techniques. Nothing about real world examples. And I`m going crazy with this: How to put and manage multiple objects (meshes) with OpenGL ES 2.x? In theory seems simple. You have a ...