Why the height obtained by raytrace in postProcessStages is not equal to the height texture obtained by orthographic projection camera?

Hi,
This is a practice program aiming at testing the ray trace coordinate accuracy in postProcessStage, I compare it to the height obtained by an orthographic projection camera rendering texture, but strangely, it is not equal and have more than thousand meters difference, why?
Here is the sandcastle code I use, toggle show and adjust minheight and maxheight, you can see the difference is big(tip: I put the abs difference meter in a smoothstep function between minheight&maxheight). Is there any problems that I didn’t detect before? I have to get the height texture precisely and pass it to postProcessStage so it could be used as a height base map in fragment, it seemed that this difference error couldn’t acceptable, did I miss something?

sandcastle

Thank you.

Hi @wangqiuyan,

Could you help me understand which two things you are comparing? From your sandcastle and description, it sounds like you’re comparing the height obtained from Picking with… what?

Also, I’ll just point out - this sandcastle demo is pretty complex. It’s going to be hard for me to give valuable feedback. I was able to remove nearly ~100 lines of unused code (unused variables, redefinitions of Cesium classes, whitespace, etc). But it’s still very complex (here’s my version); I would suggest going through it and seeing what else can be removed, and if you can create a minimal demo.

I’ll look out for your response.

Best,
Matt

Hi @mzschwartz5 ,

Thanks to help.

Your modifying sandcastle is pretty right, I remove more code that is about reference entity point and line.(here’s my version), could we start from this?

In this example, picking is just for getting a height map texture, then pass the texture to postprocessStage , in the stage (which is bufferA in code), compare two heights from the same frag point :1.height obtained through texture. 2.height obtained through ray trace.(computed by ray origin and ray direction&ray length). They are supposed to be equal to each other, but not.

Please tell me if there is any questions.

Best

Qiuyan W

Okay so when I’m looking at the viewport, there are two views - the main one and the mini view in the bottom right. What does each of those represent? Is the main one visualizing the height map texture, and the mini one visualizing height from a ray trace?

Hi @mzschwartz5

The main view represent the difference between two height, and the difference is visulized by minheight and maxheight , the val ‘a’ is height obtained through texture, the height p.z is height obtained through ray trace.

 vec3 p=ro+rd*lentofrag;
//this val should be equal to p.z, but it is not equal to 
 float a=getPosHeight(p); 
 out_FragColor.rgb=vec3(smoothstep(u_minheight,u_maxheight,abs(a-p.z)));

The mini view represent the height obtained by texture, I remove it in this version sandcastle. Hope that will be more concise.

Best

Qiuy