Tag Info

Hot answers tagged

4

Absolutely, But not as simple as taking a return value of a normal function. First I assume your question isn't about sharing variables between two shader stages (vertex, fragment..etc) but actually between two shader (programs). Shaders are part of the rendering pipeline, every input/output should pass through the rendering pipeline and its memory is ...


2

What you essentially want is the depth in camera coordinates, but relative to model, not camera. the easiest way to achieve that is to calculate the position of the origin of a model coordinate system in camera coordinates. ... vec4 cs_position = glModelViewMatrix * gl_Vertex; vec4 origin_position = glModelViewMatrix * vec4(0,0,0,1); distToOrigin = ...


1

calculate a bounding volume of the object (sphere, convex hull, box - depends on your speed/accuracy needs), this needs to be done only once - at initalization while rendering, for each object: transform camera (origin, direction) to object space project bounding volume on camera direction axis and subtract camera origin projection to retrieve min/max ...


1

It took quite a while but I've found the solution and am posting it here for anyone else who has the same issue. The draw code remains the same. Pixel Shader: // Texture sprite sheet. uniform extern texture ScreenTexture; sampler screen : register(s0) = sampler_state { Texture = <ScreenTexture>; MinFilter = POINT; // Stops pixels bleeding ...



Only top voted, non community-wiki answers of a minimum length are eligible