Hot answers tagged hlsl
This is my fault - the 0 values are caused by a bug in RenderDoc v0.20 - the x0 indexable temp register being used there which contains your kernel data wasn't implemented in the shader debugging at the time of that release - I implemented it a few months ago. I'm hoping to get v0.21 with all the latest fixes out this week-ish.
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 = ...
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 ...
Only top voted, non community-wiki answers of a minimum length are eligible