> For the complete documentation index, see [llms.txt](https://docs.hology.app/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.hology.app/shaders/typescript-shaders/scene-color.md).

# Scene color

You can access the color in the scene behind object for certain effects like screen space refraction. This is especially useful in visual effects to create the effects like shockwaves or heat distortion.

The code below shows how we can get the color from the scene behind the fragment we render. By using the screenUV coordinate, we get the color immediately behind the object from the direction of the camera. If we output this color, the object would appear completely transparent.

```typescript
import { sampleSceneColor, screenUV, RgbaNode } from "@hology/core/shader-nodes";

const color: RgbaNode = sampleSceneColor(screenUV)
```

To create various effects like heat distortions of shockwaves, you would simply add an offset to this coordinate which is demonstrated in the example below.

## Example - Shockwave sprite

We can create the effect shown in the image below using a sprite and sample the color behind it with an animated offset.

<figure><img src="/files/wxjuwLo3fYDc2VdiAuLc" alt=""><figcaption></figcaption></figure>

```typescript

import { SpriteNodeShader } from '@hology/core';
import { distance, normalize, oneMinus, particleUniforms, sampleSceneColor, screenUV, sin, smoothstep, timeUniforms, varyingAttributes, vec2 } from "@hology/core/shader-nodes";
import { NodeShaderOutput, Parameter } from "@hology/core/shader/shader";

export default class ShockwaveShader extends SpriteNodeShader {

  @Parameter()
  distortionStrength: number = 0.05
  
  @Parameter() 
  waveScale: number = 20

  @Parameter()
  waveSpeed: number = 0.2

  @Parameter()
  fadeDistance: number = 0.1
  

  output(): NodeShaderOutput {

    const center = vec2(0.5)
    const dir = normalize(varyingAttributes.uv.subtract(center))
    const dist = distance(varyingAttributes.uv, center)
    
    const alpha = smoothstep(0.5, 0.5 + this.fadeDistance, oneMinus(dist))

    const wave = sin(
      dist.subtract(timeUniforms.elapsed.multiply(this.waveSpeed)).multiply(this.waveScale)
    ).multiply(this.distortionStrength).multiply(alpha)

    const offset = dir.multiplyScalar(wave)

    const sample = sampleSceneColor(screenUV.add(offset)).rgb
    
    return {
      color: sample.rgba(alpha.multiply(particleUniforms.opacity)),
      transparent: false
    }
  } 
}

```


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://docs.hology.app/shaders/typescript-shaders/scene-color.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
