-
-
Notifications
You must be signed in to change notification settings - Fork 26
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
3 changed files
with
21 additions
and
64 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
--- | ||
"shader-composer": patch | ||
--- | ||
|
||
`Fresnel` was returning wrong results for scaled geometries. This has now been fixed. |
75 changes: 13 additions & 62 deletions
75
apps/material-composer-examples/src/examples/Playground.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,74 +1,25 @@ | ||
import { PatchedMaterialMaster } from "@material-composer/patch-material" | ||
import { useControls } from "leva" | ||
import { patched } from "material-composer-r3f" | ||
import { Lerp, NormalizePlusMinusOne, Sin, Time } from "shader-composer" | ||
import { useShader } from "shader-composer-r3f" | ||
import { composable, Layer, modules } from "material-composer-r3f" | ||
import { Fresnel } from "shader-composer" | ||
import { Color } from "three" | ||
|
||
export default function Playground() { | ||
useControls({ foo: { value: 1, min: 0, max: 2 } }) | ||
|
||
const shader = useShader(() => { | ||
return PatchedMaterialMaster({ | ||
color: Lerp( | ||
new Color("white"), | ||
new Color("blue"), | ||
NormalizePlusMinusOne(Sin(Time())) | ||
), | ||
metalness: 0.5, | ||
roughness: 0.5 | ||
}) | ||
}, []) | ||
|
||
const otherShader = useShader(() => { | ||
return PatchedMaterialMaster({ | ||
color: Lerp( | ||
new Color("red"), | ||
new Color("green"), | ||
NormalizePlusMinusOne(Sin(Time())) | ||
), | ||
metalness: 0.5, | ||
roughness: 0.5 | ||
}) | ||
}, []) | ||
const controls = useControls({ scale: { value: 1, min: 0, max: 2 } }) | ||
|
||
return ( | ||
<group position-y={1.5}> | ||
<mesh castShadow position-x={-1.5}> | ||
<patched.meshStandardMaterial {...shader} /> | ||
<sphereGeometry /> | ||
</mesh> | ||
<mesh scale={controls.scale}> | ||
<sphereGeometry args={[1, 32, 32]} /> | ||
|
||
<composable.meshStandardMaterial> | ||
<modules.Color color={new Color("hotpink")} /> | ||
{/* <modules.Fresnel /> */} | ||
|
||
<mesh castShadow position-x={+1.5}> | ||
<patched.meshStandardMaterial {...otherShader} /> | ||
<sphereGeometry /> | ||
<Layer opacity={Fresnel()}> | ||
<modules.Color color={new Color("white")} /> | ||
</Layer> | ||
</composable.meshStandardMaterial> | ||
</mesh> | ||
</group> | ||
) | ||
} | ||
|
||
// import { useControls } from "leva" | ||
// import { composable, modules } from "material-composer-r3f" | ||
// import { ModuleRegistrationContext } from "material-composer-r3f/src/moduleRegistration" | ||
|
||
// export default function Playground() { | ||
// useControls({ foo: { value: 1, min: 0, max: 2 } }) | ||
|
||
// return ( | ||
// <group position-y={1.5}> | ||
// <mesh castShadow position-x={-1.5}> | ||
// <composable.meshStandardMaterial> | ||
// <modules.Color color="yellow" /> | ||
// </composable.meshStandardMaterial> | ||
// <sphereGeometry /> | ||
// </mesh> | ||
|
||
// <mesh castShadow position-x={+1.5}> | ||
// <composable.meshStandardMaterial> | ||
// <modules.Color color="red" /> | ||
// </composable.meshStandardMaterial> | ||
// <sphereGeometry /> | ||
// </mesh> | ||
// </group> | ||
// ) | ||
// } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters