Twinklebear / webgl-volume-raycaster

A WebGL Volume Raycaster
MIT License
252 stars 30 forks source link

> My guess is that mapboxgl is applying some y-flip the image, which you need to apply to the volume as well either when you render it or when you display the volume rendering above the map (if you're rendering to a texture and compositing that on top of the map) #6

Closed kt7456 closed 2 years ago

kt7456 commented 2 years ago

My guess is that mapboxgl is applying some y-flip the image, which you need to apply to the volume as well either when you render it or when you display the volume rendering above the map (if you're rendering to a texture and compositing that on top of the map)

i dont know how to do ,please help me

Originally posted by @kt7456 in https://github.com/Twinklebear/webgl-volume-raycaster/issues/5#issuecomment-1242593639

Twinklebear commented 2 years ago

The simplest way to do it (ie avoiding modifying the volume renderer) would be to have the volume raycaster render the image to an RGBA texture the same size as the canvas. Then you'd draw a quad on top of the mapbox rendering to display this texture, and just invert the y coordinates when you sample values from the texture to flip it upside down. When you render the quad you want to set the blending mode so that it'll blend over the mapbox image properly (src factor ONE and dst factor ONE_MINUS_SRC_ALPHA)