├── ViewerAssets
├── Update.bat
├── ViewerAssets.pak
└── RawAssets
│ ├── Techniques
│ ├── Water.xml
│ ├── DiffSkybox.xml
│ ├── DiffSkydome.xml
│ ├── DiffSkyplane.xml
│ ├── DiffAdd.xml
│ ├── NoTextureAdd.xml
│ ├── DiffAddAlpha.xml
│ ├── DiffMultiply.xml
│ ├── DiffUnlitAlpha.xml
│ ├── NoTextureUnlitAlpha.xml
│ ├── NoTextureAddAlpha.xml
│ ├── NoTextureMultiply.xml
│ ├── NoTextureOverlay.xml
│ ├── DiffOverlay.xml
│ ├── DiffVColAdd.xml
│ ├── NoTextureVColAdd.xml
│ ├── DiffVColAddAlpha.xml
│ ├── DiffVColMultiply.xml
│ ├── DiffVColUnlitAlpha.xml
│ ├── NoTextureVColAddAlpha.xml
│ ├── NoTextureVColMultiply.xml
│ ├── BasicVColUnlitAlpha.xml
│ ├── DiffUnlit.xml
│ ├── NoTextureUnlit.xml
│ ├── DiffAlpha.xml
│ ├── NoTextureAlpha.xml
│ ├── DiffUnlitAlphaMask.xml
│ ├── DiffLitParticleAlpha.xml
│ ├── NoTextureAOAlpha.xml
│ ├── NoTextureUnlitVCol.xml
│ ├── DiffSpecAlpha.xml
│ ├── DiffAOAlpha.xml
│ ├── DiffEmissiveAlpha.xml
│ ├── NoTextureEnvCubeAlpha.xml
│ ├── NoTextureNormalAlpha.xml
│ ├── PBR
│ │ ├── PBRDiffAlpha.xml
│ │ ├── PBRNoTextureAlpha.xml
│ │ ├── PBRDiffNormalAlpha.xml
│ │ ├── DiffNormalSpecEmissiveAlpha.xml
│ │ ├── PBRMetallicRoughDiffSpecAlpha.xml
│ │ ├── PBRDiffNormalEmissiveAlpha.xml
│ │ ├── PBRMetallicRoughDiffNormalSpecEmissiveAlpha.xml
│ │ ├── PBRDiff.xml
│ │ ├── DiffNormalSpecEmissive.xml
│ │ ├── PBRDiffNormalEmissive.xml
│ │ ├── PBRDiffNormal.xml
│ │ ├── PBRMetallicRoughDiffSpec.xml
│ │ ├── PBRMetallicRoughDiffNormalSpec.xml
│ │ ├── PBRNoTexture.xml
│ │ └── PBRMetallicRoughDiffNormalSpecEmissive.xml
│ ├── DiffAlphaTranslucent.xml
│ ├── NoTextureEnvCubeAOAlpha.xml
│ ├── DiffEnvCubeAlpha.xml
│ ├── DiffLightMapAlpha.xml
│ ├── DiffNormalAlpha.xml
│ ├── NoTextureNormalPackedAlpha.xml
│ ├── DiffEnvCubeAOAlpha.xml
│ ├── DiffNormalSpecAlpha.xml
│ ├── DiffNormalPackedAlpha.xml
│ ├── DiffNormalAOAlpha.xml
│ ├── DiffNormalEmissiveAlpha.xml
│ ├── DiffNormalPackedSpecAlpha.xml
│ ├── DiffNormalAlphaTranslucent.xml
│ ├── DiffNormalSpecAOAlpha.xml
│ ├── DiffNormalSpecEmissiveAlpha.xml
│ ├── DiffNormalPackedAOAlpha.xml
│ ├── DiffNormalPackedEmissiveAlpha.xml
│ ├── DiffNormalPackedSpecAOAlpha.xml
│ ├── DiffNormalPackedSpecEmissiveAlpha.xml
│ ├── DiffNormalPackedAlphaTranslucent.xml
│ ├── VegetationDiffUnlit.xml
│ ├── DiffNormalEnvCubeAlpha.xml
│ ├── DiffNormalPackedEnvCubeAlpha.xml
│ ├── VegetationDiffUnlitAlphaMask.xml
│ ├── Diff.xml
│ ├── NoTextureAO.xml
│ ├── TerrainBlend.xml
│ ├── DiffEmissive.xml
│ ├── NoTexture.xml
│ ├── DiffAO.xml
│ ├── VegetationDiff.xml
│ ├── DiffVCol.xml
│ ├── NoTextureVCol.xml
│ ├── NoTextureEnvCube.xml
│ ├── DiffLightMap.xml
│ ├── DiffSpec.xml
│ ├── DiffEnvCube.xml
│ ├── NoTextureEnvCubeAO.xml
│ ├── DiffAlphaMask.xml
│ ├── DiffEnvCubeAO.xml
│ ├── DiffAOAlphaMask.xml
│ ├── VegetationDiffAlphaMask.xml
│ ├── DiffNormalAO.xml
│ ├── DiffNormalEmissive.xml
│ ├── DiffAlphaMaskTranslucent.xml
│ ├── NoTextureNormal.xml
│ ├── DiffSpecAlphaMask.xml
│ ├── DiffNormal.xml
│ ├── DiffNormalSpecAO.xml
│ ├── DiffNormalSpecEmissive.xml
│ ├── DiffNormalPackedAO.xml
│ ├── DiffNormalPackedEmissive.xml
│ ├── DiffNormalSpec.xml
│ ├── NoTextureNormalPacked.xml
│ ├── DiffNormalAOAlphaMask.xml
│ ├── DiffNormalPackedSpecAO.xml
│ ├── DiffNormalPackedSpecEmissive.xml
│ ├── DiffNormalPacked.xml
│ ├── DiffNormalEnvCube.xml
│ ├── DiffNormalAlphaMask.xml
│ ├── DiffNormalSpecAOAlphaMask.xml
│ ├── DiffNormalPackedAOAlphaMask.xml
│ ├── DiffNormalPackedSpec.xml
│ ├── DiffNormalSpecAlphaMask.xml
│ ├── DiffNormalAlphaMaskTranslucent.xml
│ ├── DiffNormalPackedSpecAOAlphaMask.xml
│ ├── DiffNormalPackedAlphaMask.xml
│ ├── DiffNormalPackedEnvCube.xml
│ ├── DiffNormalPackedSpecAlphaMask.xml
│ └── DiffNormalPackedAlphaMaskTranslucent.xml
│ ├── Models
│ ├── Box.mdl
│ ├── Cone.mdl
│ ├── Dome.mdl
│ ├── Plane.mdl
│ ├── Torus.mdl
│ ├── Pyramid.mdl
│ ├── Sphere.mdl
│ ├── TeaPot.mdl
│ └── Cylinder.mdl
│ ├── Textures
│ ├── UI.png
│ ├── UI.xml
│ ├── Ramp.png
│ ├── Spot.png
│ ├── RampWide.png
│ ├── SpotWide.png
│ ├── LUTIdentity.png
│ ├── RampExtreme.png
│ ├── LUTIdentity.xml
│ ├── RampWide.xml
│ ├── Ramp.xml
│ ├── RampExtreme.xml
│ ├── SpotWide.xml
│ └── Spot.xml
│ ├── Fonts
│ └── Anonymous Pro.ttf
│ ├── RenderPaths
│ ├── PrepassHDR.xml
│ ├── Forward.xml
│ ├── ForwardDepth.xml
│ ├── ForwardHWDepth.xml
│ ├── Deferred.xml
│ ├── Prepass.xml
│ ├── PrepassHWDepth.xml
│ ├── DeferredHWDepth.xml
│ ├── PBRDeferred.xml
│ └── PBRDeferredHWDepth.xml
│ ├── Shaders
│ ├── GLSL
│ │ ├── Constants.glsl
│ │ ├── Stencil.glsl
│ │ ├── Skybox.glsl
│ │ ├── CopyFramebuffer.glsl
│ │ ├── Skydome.glsl
│ │ ├── GammaCorrection.glsl
│ │ ├── Urho2D.glsl
│ │ ├── ColorCorrection.glsl
│ │ ├── GreyScale.glsl
│ │ ├── Depth.glsl
│ │ ├── Fog.glsl
│ │ ├── VegetationShadow.glsl
│ │ ├── VegetationDepth.glsl
│ │ ├── Shadow.glsl
│ │ ├── ShadowBlur.glsl
│ │ ├── Tonemap.glsl
│ │ ├── Blur.glsl
│ │ ├── Basic.glsl
│ │ ├── ScreenPos.glsl
│ │ ├── Text.glsl
│ │ ├── Unlit.glsl
│ │ ├── Bloom.glsl
│ │ ├── Water.glsl
│ │ ├── BloomHDR.glsl
│ │ ├── Samplers.glsl
│ │ ├── AutoExposure.glsl
│ │ └── PostProcess.glsl
│ └── HLSL
│ │ ├── Constants.hlsl
│ │ ├── Stencil.hlsl
│ │ ├── ClearFramebuffer.hlsl
│ │ ├── CopyFramebuffer.hlsl
│ │ ├── Skybox.hlsl
│ │ ├── Skydome.hlsl
│ │ ├── Fog.hlsl
│ │ ├── GammaCorrection.hlsl
│ │ ├── GreyScale.hlsl
│ │ ├── Urho2D.hlsl
│ │ ├── ColorCorrection.hlsl
│ │ ├── Depth.hlsl
│ │ ├── VegetationShadow.hlsl
│ │ ├── VegetationDepth.hlsl
│ │ ├── ShadowBlur.hlsl
│ │ ├── Tonemap.hlsl
│ │ ├── Shadow.hlsl
│ │ ├── ScreenPos.hlsl
│ │ ├── Text.hlsl
│ │ ├── Blur.hlsl
│ │ ├── Bloom.hlsl
│ │ └── Basic.hlsl
│ ├── Materials
│ ├── DefaultGrey.xml
│ └── DefaulPreviewerMaterial.xml
│ └── PostProcess
│ ├── FXAA3.xml
│ └── FXAA2.xml
├── Icon.ico
├── Screenshots
├── wpf.gif
└── Screenshot2.png
├── UrhoSharp.Viewer.Wpf
├── Icon.ico
├── packages.config
├── App.xaml.cs
├── App.xaml
├── Properties
│ ├── Settings.settings
│ ├── Settings.Designer.cs
│ ├── AssemblyInfo.cs
│ └── Resources.Designer.cs
├── UrhoSharpReadme.txt
├── SolutionItem.cs
├── App.config
└── ItemIconConverter.cs
├── UrhoSharp.Viewer.Cocoa
├── Assets.xcassets
│ ├── Contents.json
│ └── AppIcon.appiconset
│ │ ├── AppIcon-128.png
│ │ ├── AppIcon-16.png
│ │ ├── AppIcon-256.png
│ │ ├── AppIcon-32.png
│ │ ├── AppIcon-512.png
│ │ ├── AppIcon-128@2x.png
│ │ ├── AppIcon-16@2x.png
│ │ ├── AppIcon-256@2x.png
│ │ ├── AppIcon-32@2x.png
│ │ ├── AppIcon-512@2x.png
│ │ └── Contents.json
├── packages.config
├── Entitlements.plist
├── Main.cs
├── PreviewerApplication.cs
├── AppDelegate.cs
├── ViewController.designer.cs
├── Info.plist
└── ViewController.cs
├── UrhoSharp.Viewer.Core
├── packages.config
├── IConfig.cs
├── IEditor.cs
├── Previewers
│ ├── ScenePreviewer.cs
│ ├── TmxPreviewer.cs
│ ├── TexturePreviewer.cs
│ ├── UIPreviewer.cs
│ ├── SdfFontsPreviewer.cs
│ ├── AnimationSet2DPreviewer.cs
│ ├── Particle3DPreviewer.cs
│ ├── RenderPathPreviewer.cs
│ ├── Particle2DPreviewer.cs
│ ├── AbstractPreviewer.cs
│ ├── StaticModelPreviewer.cs
│ ├── AnimatedModelPreviewer.cs
│ └── MaterialPreviewer.cs
├── Utils
│ ├── NodeUtils.cs
│ ├── StringUtils.cs
│ ├── ProcessUtils.cs
│ └── FsUtils.cs
├── Asset.cs
├── Components
│ ├── Gizmo.cs
│ └── WirePlane.cs
├── Properties
│ └── AssemblyInfo.cs
└── AssimpTool.cs
├── README.md
├── LICENSE
└── UrhoSharp.Viewer.sln
/ViewerAssets/Update.bat:
--------------------------------------------------------------------------------
1 | PackageTool.exe RawAssets ViewerAssets.pak -q
--------------------------------------------------------------------------------
/Icon.ico:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/EgorBo/UrhoAssetImporter/HEAD/Icon.ico
--------------------------------------------------------------------------------
/Screenshots/wpf.gif:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/EgorBo/UrhoAssetImporter/HEAD/Screenshots/wpf.gif
--------------------------------------------------------------------------------
/Screenshots/Screenshot2.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/EgorBo/UrhoAssetImporter/HEAD/Screenshots/Screenshot2.png
--------------------------------------------------------------------------------
/UrhoSharp.Viewer.Wpf/Icon.ico:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/EgorBo/UrhoAssetImporter/HEAD/UrhoSharp.Viewer.Wpf/Icon.ico
--------------------------------------------------------------------------------
/ViewerAssets/ViewerAssets.pak:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/EgorBo/UrhoAssetImporter/HEAD/ViewerAssets/ViewerAssets.pak
--------------------------------------------------------------------------------
/ViewerAssets/RawAssets/Techniques/Water.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
--------------------------------------------------------------------------------
/UrhoSharp.Viewer.Cocoa/Assets.xcassets/Contents.json:
--------------------------------------------------------------------------------
1 | {
2 | "info" : {
3 | "version" : 1,
4 | "author" : "xcode"
5 | }
6 | }
--------------------------------------------------------------------------------
/ViewerAssets/RawAssets/Models/Box.mdl:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/EgorBo/UrhoAssetImporter/HEAD/ViewerAssets/RawAssets/Models/Box.mdl
--------------------------------------------------------------------------------
/ViewerAssets/RawAssets/Models/Cone.mdl:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/EgorBo/UrhoAssetImporter/HEAD/ViewerAssets/RawAssets/Models/Cone.mdl
--------------------------------------------------------------------------------
/ViewerAssets/RawAssets/Models/Dome.mdl:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/EgorBo/UrhoAssetImporter/HEAD/ViewerAssets/RawAssets/Models/Dome.mdl
--------------------------------------------------------------------------------
/ViewerAssets/RawAssets/Models/Plane.mdl:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/EgorBo/UrhoAssetImporter/HEAD/ViewerAssets/RawAssets/Models/Plane.mdl
--------------------------------------------------------------------------------
/ViewerAssets/RawAssets/Models/Torus.mdl:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/EgorBo/UrhoAssetImporter/HEAD/ViewerAssets/RawAssets/Models/Torus.mdl
--------------------------------------------------------------------------------
/ViewerAssets/RawAssets/Textures/UI.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/EgorBo/UrhoAssetImporter/HEAD/ViewerAssets/RawAssets/Textures/UI.png
--------------------------------------------------------------------------------
/ViewerAssets/RawAssets/Textures/UI.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
--------------------------------------------------------------------------------
/ViewerAssets/RawAssets/Models/Pyramid.mdl:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/EgorBo/UrhoAssetImporter/HEAD/ViewerAssets/RawAssets/Models/Pyramid.mdl
--------------------------------------------------------------------------------
/ViewerAssets/RawAssets/Models/Sphere.mdl:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/EgorBo/UrhoAssetImporter/HEAD/ViewerAssets/RawAssets/Models/Sphere.mdl
--------------------------------------------------------------------------------
/ViewerAssets/RawAssets/Models/TeaPot.mdl:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/EgorBo/UrhoAssetImporter/HEAD/ViewerAssets/RawAssets/Models/TeaPot.mdl
--------------------------------------------------------------------------------
/ViewerAssets/RawAssets/Textures/Ramp.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/EgorBo/UrhoAssetImporter/HEAD/ViewerAssets/RawAssets/Textures/Ramp.png
--------------------------------------------------------------------------------
/ViewerAssets/RawAssets/Textures/Spot.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/EgorBo/UrhoAssetImporter/HEAD/ViewerAssets/RawAssets/Textures/Spot.png
--------------------------------------------------------------------------------
/ViewerAssets/RawAssets/Models/Cylinder.mdl:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/EgorBo/UrhoAssetImporter/HEAD/ViewerAssets/RawAssets/Models/Cylinder.mdl
--------------------------------------------------------------------------------
/ViewerAssets/RawAssets/Textures/RampWide.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/EgorBo/UrhoAssetImporter/HEAD/ViewerAssets/RawAssets/Textures/RampWide.png
--------------------------------------------------------------------------------
/ViewerAssets/RawAssets/Textures/SpotWide.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/EgorBo/UrhoAssetImporter/HEAD/ViewerAssets/RawAssets/Textures/SpotWide.png
--------------------------------------------------------------------------------
/ViewerAssets/RawAssets/Fonts/Anonymous Pro.ttf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/EgorBo/UrhoAssetImporter/HEAD/ViewerAssets/RawAssets/Fonts/Anonymous Pro.ttf
--------------------------------------------------------------------------------
/ViewerAssets/RawAssets/Techniques/DiffSkybox.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
--------------------------------------------------------------------------------
/ViewerAssets/RawAssets/Textures/LUTIdentity.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/EgorBo/UrhoAssetImporter/HEAD/ViewerAssets/RawAssets/Textures/LUTIdentity.png
--------------------------------------------------------------------------------
/ViewerAssets/RawAssets/Textures/RampExtreme.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/EgorBo/UrhoAssetImporter/HEAD/ViewerAssets/RawAssets/Textures/RampExtreme.png
--------------------------------------------------------------------------------
/ViewerAssets/RawAssets/Techniques/DiffSkydome.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
--------------------------------------------------------------------------------
/ViewerAssets/RawAssets/Techniques/DiffSkyplane.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
--------------------------------------------------------------------------------
/UrhoSharp.Viewer.Cocoa/packages.config:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
--------------------------------------------------------------------------------
/ViewerAssets/RawAssets/Techniques/DiffAdd.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
--------------------------------------------------------------------------------
/ViewerAssets/RawAssets/Textures/LUTIdentity.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
--------------------------------------------------------------------------------
/ViewerAssets/RawAssets/Techniques/NoTextureAdd.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
--------------------------------------------------------------------------------
/ViewerAssets/RawAssets/Techniques/DiffAddAlpha.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
--------------------------------------------------------------------------------
/ViewerAssets/RawAssets/Techniques/DiffMultiply.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
--------------------------------------------------------------------------------
/ViewerAssets/RawAssets/Techniques/DiffUnlitAlpha.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
--------------------------------------------------------------------------------
/ViewerAssets/RawAssets/Techniques/NoTextureUnlitAlpha.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
--------------------------------------------------------------------------------
/ViewerAssets/RawAssets/Techniques/NoTextureAddAlpha.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
--------------------------------------------------------------------------------
/ViewerAssets/RawAssets/Techniques/NoTextureMultiply.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
--------------------------------------------------------------------------------
/ViewerAssets/RawAssets/Techniques/NoTextureOverlay.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
--------------------------------------------------------------------------------
/UrhoSharp.Viewer.Cocoa/Assets.xcassets/AppIcon.appiconset/AppIcon-128.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/EgorBo/UrhoAssetImporter/HEAD/UrhoSharp.Viewer.Cocoa/Assets.xcassets/AppIcon.appiconset/AppIcon-128.png
--------------------------------------------------------------------------------
/UrhoSharp.Viewer.Cocoa/Assets.xcassets/AppIcon.appiconset/AppIcon-16.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/EgorBo/UrhoAssetImporter/HEAD/UrhoSharp.Viewer.Cocoa/Assets.xcassets/AppIcon.appiconset/AppIcon-16.png
--------------------------------------------------------------------------------
/UrhoSharp.Viewer.Cocoa/Assets.xcassets/AppIcon.appiconset/AppIcon-256.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/EgorBo/UrhoAssetImporter/HEAD/UrhoSharp.Viewer.Cocoa/Assets.xcassets/AppIcon.appiconset/AppIcon-256.png
--------------------------------------------------------------------------------
/UrhoSharp.Viewer.Cocoa/Assets.xcassets/AppIcon.appiconset/AppIcon-32.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/EgorBo/UrhoAssetImporter/HEAD/UrhoSharp.Viewer.Cocoa/Assets.xcassets/AppIcon.appiconset/AppIcon-32.png
--------------------------------------------------------------------------------
/UrhoSharp.Viewer.Cocoa/Assets.xcassets/AppIcon.appiconset/AppIcon-512.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/EgorBo/UrhoAssetImporter/HEAD/UrhoSharp.Viewer.Cocoa/Assets.xcassets/AppIcon.appiconset/AppIcon-512.png
--------------------------------------------------------------------------------
/ViewerAssets/RawAssets/RenderPaths/PrepassHDR.xml:
--------------------------------------------------------------------------------
1 |
2 | rgba16f
3 |
4 |
--------------------------------------------------------------------------------
/UrhoSharp.Viewer.Cocoa/Assets.xcassets/AppIcon.appiconset/AppIcon-128@2x.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/EgorBo/UrhoAssetImporter/HEAD/UrhoSharp.Viewer.Cocoa/Assets.xcassets/AppIcon.appiconset/AppIcon-128@2x.png
--------------------------------------------------------------------------------
/UrhoSharp.Viewer.Cocoa/Assets.xcassets/AppIcon.appiconset/AppIcon-16@2x.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/EgorBo/UrhoAssetImporter/HEAD/UrhoSharp.Viewer.Cocoa/Assets.xcassets/AppIcon.appiconset/AppIcon-16@2x.png
--------------------------------------------------------------------------------
/UrhoSharp.Viewer.Cocoa/Assets.xcassets/AppIcon.appiconset/AppIcon-256@2x.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/EgorBo/UrhoAssetImporter/HEAD/UrhoSharp.Viewer.Cocoa/Assets.xcassets/AppIcon.appiconset/AppIcon-256@2x.png
--------------------------------------------------------------------------------
/UrhoSharp.Viewer.Cocoa/Assets.xcassets/AppIcon.appiconset/AppIcon-32@2x.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/EgorBo/UrhoAssetImporter/HEAD/UrhoSharp.Viewer.Cocoa/Assets.xcassets/AppIcon.appiconset/AppIcon-32@2x.png
--------------------------------------------------------------------------------
/UrhoSharp.Viewer.Cocoa/Assets.xcassets/AppIcon.appiconset/AppIcon-512@2x.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/EgorBo/UrhoAssetImporter/HEAD/UrhoSharp.Viewer.Cocoa/Assets.xcassets/AppIcon.appiconset/AppIcon-512@2x.png
--------------------------------------------------------------------------------
/ViewerAssets/RawAssets/Shaders/GLSL/Constants.glsl:
--------------------------------------------------------------------------------
1 | #define M_PI 3.14159265358979323846
2 | #define M_EPSILON 0.0001
3 |
4 | #ifdef PBR
5 | #define ROUGHNESS_FLOOR 0.04
6 | #define METALNESS_FLOOR 0.05
7 | #endif
8 |
--------------------------------------------------------------------------------
/ViewerAssets/RawAssets/Shaders/HLSL/Constants.hlsl:
--------------------------------------------------------------------------------
1 | #define M_PI 3.14159265358979323846
2 | #define M_EPSILON 0.0001
3 |
4 | #ifdef PBR
5 | #define ROUGHNESS_FLOOR 0.04
6 | #define METALNESS_FLOOR 0.05
7 | #endif
8 |
--------------------------------------------------------------------------------
/ViewerAssets/RawAssets/Techniques/DiffOverlay.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
--------------------------------------------------------------------------------
/ViewerAssets/RawAssets/Textures/RampWide.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
--------------------------------------------------------------------------------
/ViewerAssets/RawAssets/Techniques/DiffVColAdd.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
--------------------------------------------------------------------------------
/ViewerAssets/RawAssets/Techniques/NoTextureVColAdd.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
--------------------------------------------------------------------------------
/ViewerAssets/RawAssets/Textures/Ramp.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
--------------------------------------------------------------------------------
/ViewerAssets/RawAssets/Textures/RampExtreme.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
--------------------------------------------------------------------------------
/ViewerAssets/RawAssets/Techniques/DiffVColAddAlpha.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
--------------------------------------------------------------------------------
/ViewerAssets/RawAssets/Techniques/DiffVColMultiply.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
--------------------------------------------------------------------------------
/ViewerAssets/RawAssets/Techniques/DiffVColUnlitAlpha.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
--------------------------------------------------------------------------------
/ViewerAssets/RawAssets/Techniques/NoTextureVColAddAlpha.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
--------------------------------------------------------------------------------
/ViewerAssets/RawAssets/Techniques/NoTextureVColMultiply.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
--------------------------------------------------------------------------------
/ViewerAssets/RawAssets/Techniques/BasicVColUnlitAlpha.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
--------------------------------------------------------------------------------
/UrhoSharp.Viewer.Wpf/packages.config:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
--------------------------------------------------------------------------------
/UrhoSharp.Viewer.Cocoa/Entitlements.plist:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
--------------------------------------------------------------------------------
/ViewerAssets/RawAssets/Materials/DefaultGrey.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
--------------------------------------------------------------------------------
/ViewerAssets/RawAssets/Textures/SpotWide.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
--------------------------------------------------------------------------------
/UrhoSharp.Viewer.Core/packages.config:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
--------------------------------------------------------------------------------
/UrhoSharp.Viewer.Wpf/App.xaml.cs:
--------------------------------------------------------------------------------
1 | using System.Windows;
2 |
3 | namespace UrhoSharp.Viewer.Wpf
4 | {
5 | ///
6 | /// Interaction logic for App.xaml
7 | ///
8 | public partial class App : Application
9 | {
10 | }
11 | }
12 |
--------------------------------------------------------------------------------
/ViewerAssets/RawAssets/Textures/Spot.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
--------------------------------------------------------------------------------
/ViewerAssets/RawAssets/PostProcess/FXAA3.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
--------------------------------------------------------------------------------
/UrhoSharp.Viewer.Cocoa/Main.cs:
--------------------------------------------------------------------------------
1 | using AppKit;
2 |
3 | namespace UrhoSharp.Viewer.Cocoa
4 | {
5 | static class MainClass
6 | {
7 | static void Main(string[] args)
8 | {
9 | NSApplication.Init();
10 | NSApplication.Main(args);
11 | }
12 | }
13 | }
14 |
--------------------------------------------------------------------------------
/ViewerAssets/RawAssets/Techniques/DiffUnlit.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
--------------------------------------------------------------------------------
/ViewerAssets/RawAssets/Techniques/NoTextureUnlit.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
--------------------------------------------------------------------------------
/ViewerAssets/RawAssets/PostProcess/FXAA2.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
--------------------------------------------------------------------------------
/UrhoSharp.Viewer.Cocoa/PreviewerApplication.cs:
--------------------------------------------------------------------------------
1 | namespace UrhoSharp.Viewer.Cocoa
2 | {
3 | class PreviewerApplication
4 | {
5 | AssetsResolver assetsResolver;
6 |
7 | public PreviewerApplication(AssetsResolver assetsResolver)
8 | {
9 | this.assetsResolver = assetsResolver;
10 | }
11 | }
12 | }
--------------------------------------------------------------------------------
/ViewerAssets/RawAssets/Techniques/DiffAlpha.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
--------------------------------------------------------------------------------
/UrhoSharp.Viewer.Core/IConfig.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Text;
5 | using System.Threading.Tasks;
6 |
7 | namespace UrhoSharp.Viewer.Core
8 | {
9 | public interface IConfig
10 | {
11 | string LastUsedPath { get; set; }
12 | }
13 | }
14 |
--------------------------------------------------------------------------------
/ViewerAssets/RawAssets/Techniques/NoTextureAlpha.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
--------------------------------------------------------------------------------
/ViewerAssets/RawAssets/Techniques/DiffUnlitAlphaMask.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
--------------------------------------------------------------------------------
/ViewerAssets/RawAssets/Techniques/DiffLitParticleAlpha.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
--------------------------------------------------------------------------------
/ViewerAssets/RawAssets/Techniques/NoTextureAOAlpha.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
--------------------------------------------------------------------------------
/ViewerAssets/RawAssets/Techniques/NoTextureUnlitVCol.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
--------------------------------------------------------------------------------
/ViewerAssets/RawAssets/Techniques/DiffSpecAlpha.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
--------------------------------------------------------------------------------
/ViewerAssets/RawAssets/Techniques/DiffAOAlpha.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
--------------------------------------------------------------------------------
/ViewerAssets/RawAssets/Techniques/DiffEmissiveAlpha.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
--------------------------------------------------------------------------------
/ViewerAssets/RawAssets/Techniques/NoTextureEnvCubeAlpha.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
--------------------------------------------------------------------------------
/ViewerAssets/RawAssets/Techniques/NoTextureNormalAlpha.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
--------------------------------------------------------------------------------
/ViewerAssets/RawAssets/Techniques/PBR/PBRDiffAlpha.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
--------------------------------------------------------------------------------
/ViewerAssets/RawAssets/Techniques/PBR/PBRNoTextureAlpha.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
--------------------------------------------------------------------------------
/ViewerAssets/RawAssets/Shaders/GLSL/Stencil.glsl:
--------------------------------------------------------------------------------
1 | #include "Uniforms.glsl"
2 | #include "Transform.glsl"
3 |
4 | void VS()
5 | {
6 | mat4 modelMatrix = iModelMatrix;
7 | vec3 worldPos = GetWorldPos(modelMatrix);
8 | gl_Position = GetClipPos(worldPos);
9 | }
10 |
11 | void PS()
12 | {
13 | gl_FragColor = vec4(1.0);
14 | }
15 |
16 |
--------------------------------------------------------------------------------
/ViewerAssets/RawAssets/Techniques/DiffAlphaTranslucent.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
--------------------------------------------------------------------------------
/ViewerAssets/RawAssets/Techniques/NoTextureEnvCubeAOAlpha.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
--------------------------------------------------------------------------------
/ViewerAssets/RawAssets/Techniques/DiffEnvCubeAlpha.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
--------------------------------------------------------------------------------
/ViewerAssets/RawAssets/Techniques/DiffLightMapAlpha.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
--------------------------------------------------------------------------------
/ViewerAssets/RawAssets/Techniques/DiffNormalAlpha.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
--------------------------------------------------------------------------------
/ViewerAssets/RawAssets/Techniques/PBR/PBRDiffNormalAlpha.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
--------------------------------------------------------------------------------
/UrhoSharp.Viewer.Wpf/App.xaml:
--------------------------------------------------------------------------------
1 |
5 |
6 |
7 |
8 |
9 |
--------------------------------------------------------------------------------
/ViewerAssets/RawAssets/Techniques/NoTextureNormalPackedAlpha.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
--------------------------------------------------------------------------------
/ViewerAssets/RawAssets/Techniques/PBR/DiffNormalSpecEmissiveAlpha.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
--------------------------------------------------------------------------------
/ViewerAssets/RawAssets/Techniques/PBR/PBRMetallicRoughDiffSpecAlpha.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
--------------------------------------------------------------------------------
/ViewerAssets/RawAssets/Techniques/DiffEnvCubeAOAlpha.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
--------------------------------------------------------------------------------
/ViewerAssets/RawAssets/Techniques/DiffNormalSpecAlpha.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
--------------------------------------------------------------------------------
/ViewerAssets/RawAssets/Techniques/DiffNormalPackedAlpha.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
--------------------------------------------------------------------------------
/ViewerAssets/RawAssets/Techniques/PBR/PBRDiffNormalEmissiveAlpha.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
--------------------------------------------------------------------------------
/ViewerAssets/RawAssets/Techniques/DiffNormalAOAlpha.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
--------------------------------------------------------------------------------
/ViewerAssets/RawAssets/Techniques/DiffNormalEmissiveAlpha.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
--------------------------------------------------------------------------------
/ViewerAssets/RawAssets/Techniques/DiffNormalPackedSpecAlpha.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
--------------------------------------------------------------------------------
/ViewerAssets/RawAssets/Techniques/PBR/PBRMetallicRoughDiffNormalSpecEmissiveAlpha.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
--------------------------------------------------------------------------------
/ViewerAssets/RawAssets/Techniques/DiffNormalAlphaTranslucent.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
--------------------------------------------------------------------------------
/ViewerAssets/RawAssets/Techniques/DiffNormalSpecAOAlpha.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
--------------------------------------------------------------------------------
/ViewerAssets/RawAssets/Techniques/DiffNormalSpecEmissiveAlpha.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
--------------------------------------------------------------------------------
/ViewerAssets/RawAssets/Techniques/DiffNormalPackedAOAlpha.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
--------------------------------------------------------------------------------
/ViewerAssets/RawAssets/Techniques/DiffNormalPackedEmissiveAlpha.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
--------------------------------------------------------------------------------
/ViewerAssets/RawAssets/Techniques/DiffNormalPackedSpecAOAlpha.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
--------------------------------------------------------------------------------
/ViewerAssets/RawAssets/Techniques/DiffNormalPackedSpecEmissiveAlpha.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
--------------------------------------------------------------------------------
/ViewerAssets/RawAssets/Shaders/HLSL/Stencil.hlsl:
--------------------------------------------------------------------------------
1 | #include "Uniforms.hlsl"
2 | #include "Transform.hlsl"
3 |
4 | void VS(float4 iPos : POSITION,
5 | out float4 oPos : OUTPOSITION)
6 | {
7 | float4x3 modelMatrix = iModelMatrix;
8 | float3 worldPos = GetWorldPos(modelMatrix);
9 | oPos = GetClipPos(worldPos);
10 | }
11 |
12 | void PS(out float4 oColor : OUTCOLOR0)
13 | {
14 | oColor = 1.0;
15 | }
16 |
--------------------------------------------------------------------------------
/ViewerAssets/RawAssets/Techniques/DiffNormalPackedAlphaTranslucent.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
--------------------------------------------------------------------------------
/ViewerAssets/RawAssets/Techniques/VegetationDiffUnlit.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
--------------------------------------------------------------------------------
/ViewerAssets/RawAssets/Techniques/DiffNormalEnvCubeAlpha.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | ## UrhoAssetImporter - a simple UrhoSharp assets viewer + AssetImporter
2 |
3 | Supported formats:
4 | - .obj, .dae, .fbx, .blend, .3ds, .lwo, [etc](http://assimp.sourceforge.net/main_features_formats.html).
5 | - Urho3D Materials, Particles, Prefabs, Models, etc
6 |
7 | Supported platforms:
8 | - Windows (WPF)
9 | - macOS (Cocoa)
10 |
11 | 
12 |
13 | 
14 |
--------------------------------------------------------------------------------
/ViewerAssets/RawAssets/Techniques/DiffNormalPackedEnvCubeAlpha.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
--------------------------------------------------------------------------------
/UrhoSharp.Viewer.Core/IEditor.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Text;
5 | using System.Threading.Tasks;
6 | using Urho;
7 |
8 | namespace UrhoSharp.Viewer.Core
9 | {
10 | public interface IEditor
11 | {
12 | void HighlightXmlForNode(string node);
13 |
14 | void DisplayModelScale(float scale);
15 |
16 | void DispatchToUI(Action action);
17 |
18 | IConfig Config { get; }
19 | }
20 | }
21 |
--------------------------------------------------------------------------------
/UrhoSharp.Viewer.Wpf/Properties/Settings.settings:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
--------------------------------------------------------------------------------
/ViewerAssets/RawAssets/Shaders/HLSL/ClearFramebuffer.hlsl:
--------------------------------------------------------------------------------
1 | #include "Uniforms.hlsl"
2 | #include "Samplers.hlsl"
3 | #include "Transform.hlsl"
4 | #include "ScreenPos.hlsl"
5 |
6 | void VS(float4 iPos : POSITION,
7 | out float4 oPos : OUTPOSITION)
8 | {
9 | float4x3 modelMatrix = iModelMatrix;
10 | float3 worldPos = GetWorldPos(modelMatrix);
11 | oPos = GetClipPos(worldPos);
12 | }
13 |
14 | void PS(out float4 oColor : OUTCOLOR0)
15 | {
16 | oColor = cMatDiffColor;
17 | }
18 |
--------------------------------------------------------------------------------
/ViewerAssets/RawAssets/Techniques/VegetationDiffUnlitAlphaMask.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
--------------------------------------------------------------------------------
/ViewerAssets/RawAssets/Shaders/GLSL/Skybox.glsl:
--------------------------------------------------------------------------------
1 | #include "Uniforms.glsl"
2 | #include "Samplers.glsl"
3 | #include "Transform.glsl"
4 |
5 | varying vec3 vTexCoord;
6 |
7 | void VS()
8 | {
9 | mat4 modelMatrix = iModelMatrix;
10 | vec3 worldPos = GetWorldPos(modelMatrix);
11 | gl_Position = GetClipPos(worldPos);
12 | gl_Position.z = gl_Position.w;
13 | vTexCoord = iPos.xyz;
14 | }
15 |
16 | void PS()
17 | {
18 | gl_FragColor = cMatDiffColor * textureCube(sDiffCubeMap, vTexCoord);
19 | }
20 |
--------------------------------------------------------------------------------
/ViewerAssets/RawAssets/Techniques/PBR/PBRDiff.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
--------------------------------------------------------------------------------
/ViewerAssets/RawAssets/Shaders/GLSL/CopyFramebuffer.glsl:
--------------------------------------------------------------------------------
1 | #include "Uniforms.glsl"
2 | #include "Samplers.glsl"
3 | #include "Transform.glsl"
4 | #include "ScreenPos.glsl"
5 |
6 | varying vec2 vScreenPos;
7 |
8 | void VS()
9 | {
10 | mat4 modelMatrix = iModelMatrix;
11 | vec3 worldPos = GetWorldPos(modelMatrix);
12 | gl_Position = GetClipPos(worldPos);
13 | vScreenPos = GetScreenPosPreDiv(gl_Position);
14 | }
15 |
16 | void PS()
17 | {
18 | gl_FragColor = texture2D(sDiffMap, vScreenPos);
19 | }
20 |
21 |
--------------------------------------------------------------------------------
/ViewerAssets/RawAssets/Techniques/PBR/DiffNormalSpecEmissive.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | >
4 |
5 |
6 |
7 |
8 |
9 |
--------------------------------------------------------------------------------
/ViewerAssets/RawAssets/Techniques/PBR/PBRDiffNormalEmissive.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
--------------------------------------------------------------------------------
/ViewerAssets/RawAssets/Techniques/PBR/PBRDiffNormal.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
--------------------------------------------------------------------------------
/ViewerAssets/RawAssets/Techniques/PBR/PBRMetallicRoughDiffSpec.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
--------------------------------------------------------------------------------
/UrhoSharp.Viewer.Core/Previewers/ScenePreviewer.cs:
--------------------------------------------------------------------------------
1 | using Urho;
2 |
3 | namespace UrhoSharp.Viewer.Core.Previewers
4 | {
5 | public class ScenePreviewer : AbstractPreviewer
6 | {
7 | public ScenePreviewer(UrhoScene urhoApp) : base(urhoApp) { }
8 |
9 | protected override async void OnShow(Node node, Asset asset)
10 | {
11 | App.Scene.Remove();
12 | App.CreateScene(asset.RelativePathToAsset);
13 | }
14 |
15 | protected override void OnStop()
16 | {
17 | App.Scene.Remove();
18 | App.CreateScene(null);
19 | }
20 | }
21 | }
--------------------------------------------------------------------------------
/ViewerAssets/RawAssets/Techniques/PBR/PBRMetallicRoughDiffNormalSpec.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
--------------------------------------------------------------------------------
/ViewerAssets/RawAssets/Techniques/PBR/PBRNoTexture.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
--------------------------------------------------------------------------------
/UrhoSharp.Viewer.Wpf/UrhoSharpReadme.txt:
--------------------------------------------------------------------------------
1 | Use the following code snippet in order to run your game application:
2 |
3 | UrhoEngine.Init();
4 | new MyGame().Run();
5 |
6 |
7 | If you have some custom assets (built-in are not enough for you):
8 |
9 | new MyGame(new ApplicationOptions("Data")).Run();
10 |
11 | if pathToAssets is null - current directory will be used. The pathToAssets should contain "Data" folder with all your assets.
12 |
13 |
14 |
15 |
16 | CoreData assets and native libs for OSX (fat) and Windows (x64 only) are added via .targets file by the nuget package.
--------------------------------------------------------------------------------
/ViewerAssets/RawAssets/Techniques/Diff.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
--------------------------------------------------------------------------------
/ViewerAssets/RawAssets/Techniques/NoTextureAO.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
--------------------------------------------------------------------------------
/ViewerAssets/RawAssets/Techniques/TerrainBlend.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
--------------------------------------------------------------------------------
/ViewerAssets/RawAssets/Techniques/DiffEmissive.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
--------------------------------------------------------------------------------
/ViewerAssets/RawAssets/Techniques/NoTexture.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
--------------------------------------------------------------------------------
/ViewerAssets/RawAssets/Techniques/PBR/PBRMetallicRoughDiffNormalSpecEmissive.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
--------------------------------------------------------------------------------
/ViewerAssets/RawAssets/Shaders/GLSL/Skydome.glsl:
--------------------------------------------------------------------------------
1 | #include "Uniforms.glsl"
2 | #include "Samplers.glsl"
3 | #include "Transform.glsl"
4 |
5 | varying vec2 vTexCoord;
6 |
7 | uniform mat4 gl_ModelViewMatrix;
8 | uniform mat4 gl_ProjectionMatrix;
9 |
10 | void VS()
11 | {
12 | mat4 modelMatrix = iModelMatrix;
13 | vec3 worldPos = GetWorldPos(modelMatrix);
14 | gl_Position = GetClipPos(worldPos);
15 | gl_Position.z = gl_Position.w;
16 | vTexCoord = iTexCoord.xy;
17 | }
18 |
19 | void PS()
20 | {
21 | gl_FragColor = texture2D(sDiffMap, vTexCoord);
22 | }
23 |
--------------------------------------------------------------------------------
/ViewerAssets/RawAssets/Techniques/DiffAO.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
--------------------------------------------------------------------------------
/ViewerAssets/RawAssets/Shaders/GLSL/GammaCorrection.glsl:
--------------------------------------------------------------------------------
1 | #include "Uniforms.glsl"
2 | #include "Samplers.glsl"
3 | #include "Transform.glsl"
4 | #include "ScreenPos.glsl"
5 | #include "PostProcess.glsl"
6 |
7 | varying vec2 vScreenPos;
8 |
9 | void VS()
10 | {
11 | mat4 modelMatrix = iModelMatrix;
12 | vec3 worldPos = GetWorldPos(modelMatrix);
13 | gl_Position = GetClipPos(worldPos);
14 | vScreenPos = GetScreenPosPreDiv(gl_Position);
15 | }
16 |
17 | void PS()
18 | {
19 | vec3 color = texture2D(sDiffMap, vScreenPos).rgb;
20 | gl_FragColor = vec4(ToInverseGamma(color), 1.0);
21 | }
22 |
--------------------------------------------------------------------------------
/ViewerAssets/RawAssets/Shaders/GLSL/Urho2D.glsl:
--------------------------------------------------------------------------------
1 | #include "Uniforms.glsl"
2 | #include "Samplers.glsl"
3 | #include "Transform.glsl"
4 |
5 | varying vec2 vTexCoord;
6 | varying vec4 vColor;
7 |
8 | void VS()
9 | {
10 | mat4 modelMatrix = iModelMatrix;
11 | vec3 worldPos = GetWorldPos(modelMatrix);
12 | gl_Position = GetClipPos(worldPos);
13 |
14 | vTexCoord = iTexCoord;
15 | vColor = iColor;
16 | }
17 |
18 | void PS()
19 | {
20 | vec4 diffColor = cMatDiffColor * vColor;
21 | vec4 diffInput = texture2D(sDiffMap, vTexCoord);
22 | gl_FragColor = diffColor * diffInput;
23 | }
24 |
--------------------------------------------------------------------------------
/ViewerAssets/RawAssets/Techniques/VegetationDiff.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
--------------------------------------------------------------------------------
/ViewerAssets/RawAssets/Techniques/DiffVCol.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
--------------------------------------------------------------------------------
/ViewerAssets/RawAssets/Shaders/GLSL/ColorCorrection.glsl:
--------------------------------------------------------------------------------
1 | #include "Uniforms.glsl"
2 | #include "Samplers.glsl"
3 | #include "Transform.glsl"
4 | #include "ScreenPos.glsl"
5 | #include "PostProcess.glsl"
6 |
7 | varying vec2 vScreenPos;
8 |
9 | void VS()
10 | {
11 | mat4 modelMatrix = iModelMatrix;
12 | vec3 worldPos = GetWorldPos(modelMatrix);
13 | gl_Position = GetClipPos(worldPos);
14 | vScreenPos = GetScreenPosPreDiv(gl_Position);
15 | }
16 |
17 | void PS()
18 | {
19 | vec3 color = texture2D(sDiffMap, vScreenPos).rgb;
20 | gl_FragColor = vec4(ColorCorrection(color, sVolumeMap), 1.0);
21 | }
22 |
--------------------------------------------------------------------------------
/ViewerAssets/RawAssets/Techniques/NoTextureVCol.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
--------------------------------------------------------------------------------
/ViewerAssets/RawAssets/Techniques/NoTextureEnvCube.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
--------------------------------------------------------------------------------
/ViewerAssets/RawAssets/RenderPaths/Forward.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
--------------------------------------------------------------------------------
/ViewerAssets/RawAssets/Shaders/HLSL/CopyFramebuffer.hlsl:
--------------------------------------------------------------------------------
1 | #include "Uniforms.hlsl"
2 | #include "Samplers.hlsl"
3 | #include "Transform.hlsl"
4 | #include "ScreenPos.hlsl"
5 |
6 | void VS(float4 iPos : POSITION,
7 | out float2 oScreenPos : TEXCOORD0,
8 | out float4 oPos : OUTPOSITION)
9 | {
10 | float4x3 modelMatrix = iModelMatrix;
11 | float3 worldPos = GetWorldPos(modelMatrix);
12 | oPos = GetClipPos(worldPos);
13 | oScreenPos = GetScreenPosPreDiv(oPos);
14 | }
15 |
16 | void PS(float2 iScreenPos : TEXCOORD0,
17 | out float4 oColor : OUTCOLOR0)
18 | {
19 | oColor = Sample2D(DiffMap, iScreenPos);
20 | }
21 |
--------------------------------------------------------------------------------
/ViewerAssets/RawAssets/Shaders/HLSL/Skybox.hlsl:
--------------------------------------------------------------------------------
1 | #include "Uniforms.hlsl"
2 | #include "Samplers.hlsl"
3 | #include "Transform.hlsl"
4 |
5 | void VS(float4 iPos : POSITION,
6 | out float3 oTexCoord : TEXCOORD0,
7 | out float4 oPos : OUTPOSITION)
8 | {
9 | float4x3 modelMatrix = iModelMatrix;
10 | float3 worldPos = GetWorldPos(modelMatrix);
11 | oPos = GetClipPos(worldPos);
12 |
13 | oPos.z = oPos.w;
14 | oTexCoord = iPos.xyz;
15 | }
16 |
17 | void PS(float3 iTexCoord : TEXCOORD0,
18 | out float4 oColor : OUTCOLOR0)
19 | {
20 | oColor = cMatDiffColor * SampleCube(DiffCubeMap, iTexCoord);
21 | }
22 |
--------------------------------------------------------------------------------
/ViewerAssets/RawAssets/Techniques/DiffLightMap.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
--------------------------------------------------------------------------------
/ViewerAssets/RawAssets/Techniques/DiffSpec.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
--------------------------------------------------------------------------------
/ViewerAssets/RawAssets/Techniques/DiffEnvCube.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
--------------------------------------------------------------------------------
/ViewerAssets/RawAssets/Shaders/GLSL/GreyScale.glsl:
--------------------------------------------------------------------------------
1 | #include "Uniforms.glsl"
2 | #include "Samplers.glsl"
3 | #include "Transform.glsl"
4 | #include "ScreenPos.glsl"
5 | #include "Lighting.glsl"
6 |
7 | varying vec2 vScreenPos;
8 |
9 | void VS()
10 | {
11 | mat4 modelMatrix = iModelMatrix;
12 | vec3 worldPos = GetWorldPos(modelMatrix);
13 | gl_Position = GetClipPos(worldPos);
14 | vScreenPos = GetScreenPosPreDiv(gl_Position);
15 | }
16 |
17 | void PS()
18 | {
19 | vec3 rgb = texture2D(sDiffMap, vScreenPos).rgb;
20 | float intensity = GetIntensity(rgb);
21 | gl_FragColor = vec4(intensity, intensity, intensity, 1.0);
22 | }
23 |
--------------------------------------------------------------------------------
/ViewerAssets/RawAssets/Techniques/NoTextureEnvCubeAO.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
--------------------------------------------------------------------------------
/ViewerAssets/RawAssets/Techniques/DiffAlphaMask.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
--------------------------------------------------------------------------------
/ViewerAssets/RawAssets/Shaders/GLSL/Depth.glsl:
--------------------------------------------------------------------------------
1 | #include "Uniforms.glsl"
2 | #include "Samplers.glsl"
3 | #include "Transform.glsl"
4 |
5 | varying vec3 vTexCoord;
6 |
7 | void VS()
8 | {
9 | mat4 modelMatrix = iModelMatrix;
10 | vec3 worldPos = GetWorldPos(modelMatrix);
11 | gl_Position = GetClipPos(worldPos);
12 | vTexCoord = vec3(GetTexCoord(iTexCoord), GetDepth(gl_Position));
13 | }
14 |
15 | void PS()
16 | {
17 | #ifdef ALPHAMASK
18 | float alpha = texture2D(sDiffMap, vTexCoord.xy).a;
19 | if (alpha < 0.5)
20 | discard;
21 | #endif
22 |
23 | gl_FragColor = vec4(EncodeDepth(vTexCoord.z), 1.0);
24 | }
25 |
--------------------------------------------------------------------------------
/ViewerAssets/RawAssets/Techniques/DiffEnvCubeAO.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
--------------------------------------------------------------------------------
/ViewerAssets/RawAssets/Techniques/DiffAOAlphaMask.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
--------------------------------------------------------------------------------
/ViewerAssets/RawAssets/Shaders/HLSL/Skydome.hlsl:
--------------------------------------------------------------------------------
1 | #include "Uniforms.hlsl"
2 | #include "Samplers.hlsl"
3 | #include "Transform.hlsl"
4 |
5 | void VS(float4 iPos : POSITION,
6 | float2 iTexCoord: TEXCOORD0,
7 | out float2 oTexCoord : TEXCOORD0,
8 | out float4 oPos : OUTPOSITION)
9 | {
10 | float4x3 modelMatrix = iModelMatrix;
11 | float3 worldPos = GetWorldPos(modelMatrix);
12 | oPos = GetClipPos(worldPos);
13 |
14 | oPos.z = oPos.w;
15 | oTexCoord = iTexCoord;
16 | }
17 |
18 | void PS(float2 iTexCoord : TEXCOORD0,
19 | out float4 oColor : OUTCOLOR0)
20 | {
21 | oColor = cMatDiffColor * Sample2D(DiffMap, iTexCoord);
22 | }
23 |
--------------------------------------------------------------------------------
/UrhoSharp.Viewer.Core/Previewers/TmxPreviewer.cs:
--------------------------------------------------------------------------------
1 | using Urho;
2 | using Urho.Urho2D;
3 |
4 | namespace UrhoSharp.Viewer.Core.Previewers
5 | {
6 | public class TmxPreviewer : AbstractPreviewer
7 | {
8 | public TmxPreviewer(UrhoScene urhoApp) : base(urhoApp) { }
9 |
10 | public override bool RotateRootNode => false;
11 |
12 | protected override void OnShow(Node node, Asset asset)
13 | {
14 | TileMap2D tileMap = node.CreateComponent();
15 | TmxFile2D tmxFile = ResourceCache.GetTmxFile2D(asset.RelativePathToAsset);
16 | tileMap.TmxFile = tmxFile;
17 | }
18 |
19 | protected override void OnStop()
20 | {
21 | base.OnStop();
22 | }
23 | }
24 | }
25 |
--------------------------------------------------------------------------------
/ViewerAssets/RawAssets/Techniques/VegetationDiffAlphaMask.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
--------------------------------------------------------------------------------
/ViewerAssets/RawAssets/Techniques/DiffNormalAO.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
--------------------------------------------------------------------------------
/ViewerAssets/RawAssets/Techniques/DiffNormalEmissive.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
--------------------------------------------------------------------------------
/UrhoSharp.Viewer.Core/Previewers/TexturePreviewer.cs:
--------------------------------------------------------------------------------
1 | using Urho;
2 |
3 | namespace UrhoSharp.Viewer.Core.Previewers
4 | {
5 | public class TexturePreviewer : AbstractPreviewer
6 | {
7 | public TexturePreviewer(UrhoScene urhoApp) : base(urhoApp) {}
8 |
9 | protected override void OnShow(Node node, Asset asset)
10 | {
11 | var modelNode = node.CreateChild();
12 | modelNode.SetScale(2f);
13 | modelNode.Rotate(new Quaternion(30, 30, 30), TransformSpace.Local);
14 | var staticModel = modelNode.CreateComponent();
15 | staticModel.Model = CoreAssets.Models.Sphere;
16 | staticModel.SetMaterial(Material.FromImage(asset.RelativePathToAsset));
17 | }
18 | }
19 | }
20 |
--------------------------------------------------------------------------------
/UrhoSharp.Viewer.Core/Previewers/UIPreviewer.cs:
--------------------------------------------------------------------------------
1 | using Urho;
2 |
3 | namespace UrhoSharp.Viewer.Core.Previewers
4 | {
5 | public class UIPreviewer : AbstractPreviewer
6 | {
7 | public UIPreviewer(UrhoScene urhoApp) : base(urhoApp) { }
8 |
9 | protected override void OnShow(Node node, Asset asset)
10 | {
11 | App.UI.Root.SetDefaultStyle(ResourceCache.GetXmlFile("UI/DefaultStyle.xml"));
12 | App.UI.LoadLayoutToElement(App.UI.Root, ResourceCache, asset.RelativePathToAsset);
13 | }
14 |
15 | protected override void OnStop()
16 | {
17 | base.OnStop();
18 | //App.UI.Root.RemoveAllChildren(); //NOTE: this will also remove MonoDebugHud (FPS counter)
19 | }
20 | }
21 | }
22 |
23 |
--------------------------------------------------------------------------------
/ViewerAssets/RawAssets/Techniques/DiffAlphaMaskTranslucent.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
--------------------------------------------------------------------------------
/ViewerAssets/RawAssets/Techniques/NoTextureNormal.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
--------------------------------------------------------------------------------
/ViewerAssets/RawAssets/Techniques/DiffSpecAlphaMask.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
--------------------------------------------------------------------------------
/UrhoSharp.Viewer.Cocoa/AppDelegate.cs:
--------------------------------------------------------------------------------
1 | using AppKit;
2 | using Foundation;
3 |
4 | namespace UrhoSharp.Viewer.Cocoa
5 | {
6 | [Register("AppDelegate")]
7 | public class AppDelegate : NSApplicationDelegate
8 | {
9 | public AppDelegate()
10 | {
11 | }
12 |
13 | public override void DidFinishLaunching(NSNotification notification)
14 | {
15 | // Insert code here to initialize your application
16 | }
17 |
18 | public override void WillTerminate(NSNotification notification)
19 | {
20 | // Insert code here to tear down your application
21 | }
22 |
23 | public override bool ApplicationShouldTerminateAfterLastWindowClosed(NSApplication sender)
24 | {
25 | return true;
26 | }
27 | }
28 | }
29 |
--------------------------------------------------------------------------------
/UrhoSharp.Viewer.Core/Previewers/SdfFontsPreviewer.cs:
--------------------------------------------------------------------------------
1 | using Urho;
2 | using Urho.Gui;
3 |
4 | namespace UrhoSharp.Viewer.Core.Previewers
5 | {
6 | public class SdfFontsPreviewer : AbstractPreviewer
7 | {
8 | public SdfFontsPreviewer(UrhoScene urhoApp) : base(urhoApp) { }
9 |
10 | protected override void OnShow(Node node, Asset asset)
11 | {
12 | var text = node.CreateComponent();
13 | text.SetFont(ResourceCache.GetFont(asset.RelativePathToAsset), 24);
14 | text.SetColor(Color.Blue);
15 | text.Text = "The quick brown fox\njumps over the lazy dog";
16 | text.HorizontalAlignment = HorizontalAlignment.Center;
17 | text.VerticalAlignment = VerticalAlignment.Center;
18 | }
19 | }
20 | }
21 |
--------------------------------------------------------------------------------
/ViewerAssets/RawAssets/Techniques/DiffNormal.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
--------------------------------------------------------------------------------
/ViewerAssets/RawAssets/Techniques/DiffNormalSpecAO.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
--------------------------------------------------------------------------------
/ViewerAssets/RawAssets/Techniques/DiffNormalSpecEmissive.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
--------------------------------------------------------------------------------
/ViewerAssets/RawAssets/Shaders/HLSL/Fog.hlsl:
--------------------------------------------------------------------------------
1 | #ifdef COMPILEPS
2 | float3 GetFog(float3 color, float fogFactor)
3 | {
4 | return lerp(cFogColor, color, fogFactor);
5 | }
6 |
7 | float3 GetLitFog(float3 color, float fogFactor)
8 | {
9 | return color * fogFactor;
10 | }
11 |
12 | float GetFogFactor(float depth)
13 | {
14 | return saturate((cFogParams.x - depth) * cFogParams.y);
15 | }
16 |
17 | float GetHeightFogFactor(float depth, float height)
18 | {
19 | float fogFactor = GetFogFactor(depth);
20 | float heightFogFactor = (height - cFogParams.z) * cFogParams.w;
21 | heightFogFactor = 1.0 - saturate(exp(-(heightFogFactor * heightFogFactor)));
22 | return min(heightFogFactor, fogFactor);
23 | }
24 | #endif
25 |
--------------------------------------------------------------------------------
/ViewerAssets/RawAssets/Shaders/HLSL/GammaCorrection.hlsl:
--------------------------------------------------------------------------------
1 | #include "Uniforms.hlsl"
2 | #include "Transform.hlsl"
3 | #include "Samplers.hlsl"
4 | #include "ScreenPos.hlsl"
5 | #include "PostProcess.hlsl"
6 |
7 | void VS(float4 iPos : POSITION,
8 | out float2 oScreenPos : TEXCOORD0,
9 | out float4 oPos : OUTPOSITION)
10 | {
11 | float4x3 modelMatrix = iModelMatrix;
12 | float3 worldPos = GetWorldPos(modelMatrix);
13 | oPos = GetClipPos(worldPos);
14 | oScreenPos = GetScreenPosPreDiv(oPos);
15 | }
16 |
17 | void PS(float2 iScreenPos : TEXCOORD0,
18 | out float4 oColor : OUTCOLOR0)
19 | {
20 | float3 color = Sample2D(DiffMap, iScreenPos).rgb;
21 | oColor = float4(ToInverseGamma(color), 1.0);
22 | }
23 |
--------------------------------------------------------------------------------
/ViewerAssets/RawAssets/Shaders/GLSL/Fog.glsl:
--------------------------------------------------------------------------------
1 | #ifdef COMPILEPS
2 | vec3 GetFog(vec3 color, float fogFactor)
3 | {
4 | return mix(cFogColor, color, fogFactor);
5 | }
6 |
7 | vec3 GetLitFog(vec3 color, float fogFactor)
8 | {
9 | return color * fogFactor;
10 | }
11 |
12 | float GetFogFactor(float depth)
13 | {
14 | return clamp((cFogParams.x - depth) * cFogParams.y, 0.0, 1.0);
15 | }
16 |
17 | float GetHeightFogFactor(float depth, float height)
18 | {
19 | float fogFactor = GetFogFactor(depth);
20 | float heightFogFactor = (height - cFogParams.z) * cFogParams.w;
21 | heightFogFactor = 1.0 - clamp(exp(-(heightFogFactor * heightFogFactor)), 0.0, 1.0);
22 | return min(heightFogFactor, fogFactor);
23 | }
24 | #endif
25 |
--------------------------------------------------------------------------------
/ViewerAssets/RawAssets/Techniques/DiffNormalPackedAO.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
--------------------------------------------------------------------------------
/ViewerAssets/RawAssets/Techniques/DiffNormalPackedEmissive.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
--------------------------------------------------------------------------------
/ViewerAssets/RawAssets/Techniques/DiffNormalSpec.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
--------------------------------------------------------------------------------
/ViewerAssets/RawAssets/Techniques/NoTextureNormalPacked.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
--------------------------------------------------------------------------------
/UrhoSharp.Viewer.Core/Previewers/AnimationSet2DPreviewer.cs:
--------------------------------------------------------------------------------
1 | using Urho;
2 | using Urho.Urho2D;
3 |
4 | namespace UrhoSharp.Viewer.Core.Previewers
5 | {
6 | public class AnimationSet2DPreviewer : AbstractPreviewer
7 | {
8 | public AnimationSet2DPreviewer(UrhoScene urhoApp) : base(urhoApp) {}
9 |
10 | public override bool RotateRootNode => false;
11 |
12 | protected override void OnShow(Node node, Asset asset)
13 | {
14 | AnimationSet2D animationSet = ResourceCache.GetAnimationSet2D(asset.RelativePathToAsset);
15 | AnimatedSprite2D animatedSprite = node.CreateComponent();
16 | animatedSprite.AnimationSet = animationSet;
17 | animatedSprite.SetAnimation(animationSet.GetAnimation(0), LoopMode2D.Default);
18 | }
19 | }
20 | }
21 |
--------------------------------------------------------------------------------
/ViewerAssets/RawAssets/Techniques/DiffNormalAOAlphaMask.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
--------------------------------------------------------------------------------
/ViewerAssets/RawAssets/Techniques/DiffNormalPackedSpecAO.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
--------------------------------------------------------------------------------
/ViewerAssets/RawAssets/Techniques/DiffNormalPackedSpecEmissive.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
--------------------------------------------------------------------------------
/ViewerAssets/RawAssets/Shaders/HLSL/GreyScale.hlsl:
--------------------------------------------------------------------------------
1 | #include "Uniforms.hlsl"
2 | #include "Samplers.hlsl"
3 | #include "Transform.hlsl"
4 | #include "ScreenPos.hlsl"
5 | #include "Lighting.hlsl"
6 |
7 | void VS(float4 iPos : POSITION,
8 | out float2 oScreenPos : TEXCOORD0,
9 | out float4 oPos : OUTPOSITION)
10 | {
11 | float4x3 modelMatrix = iModelMatrix;
12 | float3 worldPos = GetWorldPos(modelMatrix);
13 | oPos = GetClipPos(worldPos);
14 | oScreenPos = GetScreenPosPreDiv(oPos);
15 | }
16 |
17 | void PS(float2 iScreenPos : TEXCOORD0,
18 | out float4 oColor : OUTCOLOR0)
19 | {
20 | float3 rgb = Sample2D(DiffMap, iScreenPos).rgb;
21 | float intensity = GetIntensity(rgb);
22 | oColor = float4(intensity, intensity, intensity, 1.0);
23 | }
24 |
--------------------------------------------------------------------------------
/ViewerAssets/RawAssets/Techniques/DiffNormalPacked.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
--------------------------------------------------------------------------------
/ViewerAssets/RawAssets/Techniques/DiffNormalEnvCube.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
--------------------------------------------------------------------------------
/ViewerAssets/RawAssets/Materials/DefaulPreviewerMaterial.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
--------------------------------------------------------------------------------
/ViewerAssets/RawAssets/Techniques/DiffNormalAlphaMask.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
--------------------------------------------------------------------------------
/ViewerAssets/RawAssets/Techniques/DiffNormalSpecAOAlphaMask.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
--------------------------------------------------------------------------------
/ViewerAssets/RawAssets/Shaders/GLSL/VegetationShadow.glsl:
--------------------------------------------------------------------------------
1 | #include "Uniforms.glsl"
2 | #include "Transform.glsl"
3 |
4 | uniform float cWindHeightFactor;
5 | uniform float cWindHeightPivot;
6 | uniform float cWindPeriod;
7 | uniform vec2 cWindWorldSpacing;
8 |
9 | varying vec2 vTexCoord;
10 |
11 | void VS()
12 | {
13 | mat4 modelMatrix = iModelMatrix;
14 | vec3 worldPos = GetWorldPos(modelMatrix);
15 |
16 | float windStrength = max(iPos.y - cWindHeightPivot, 0.0) * cWindHeightFactor;
17 | float windPeriod = cElapsedTime * cWindPeriod + dot(worldPos.xz, cWindWorldSpacing);
18 | worldPos.x += windStrength * sin(windPeriod);
19 | worldPos.z -= windStrength * cos(windPeriod);
20 |
21 | gl_Position = GetClipPos(worldPos);
22 | vTexCoord = GetTexCoord(iTexCoord);
23 | }
24 |
25 |
--------------------------------------------------------------------------------
/ViewerAssets/RawAssets/Techniques/DiffNormalPackedAOAlphaMask.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
--------------------------------------------------------------------------------
/ViewerAssets/RawAssets/Techniques/DiffNormalPackedSpec.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
--------------------------------------------------------------------------------
/ViewerAssets/RawAssets/Shaders/GLSL/VegetationDepth.glsl:
--------------------------------------------------------------------------------
1 | #include "Uniforms.glsl"
2 | #include "Transform.glsl"
3 |
4 | uniform float cWindHeightFactor;
5 | uniform float cWindHeightPivot;
6 | uniform float cWindPeriod;
7 | uniform vec2 cWindWorldSpacing;
8 |
9 | varying vec3 vTexCoord;
10 |
11 | void VS()
12 | {
13 | mat4 modelMatrix = iModelMatrix;
14 | vec3 worldPos = GetWorldPos(modelMatrix);
15 |
16 | float windStrength = max(iPos.y - cWindHeightPivot, 0.0) * cWindHeightFactor;
17 | float windPeriod = cElapsedTime * cWindPeriod + dot(worldPos.xz, cWindWorldSpacing);
18 | worldPos.x += windStrength * sin(windPeriod);
19 | worldPos.z -= windStrength * cos(windPeriod);
20 |
21 | gl_Position = GetClipPos(worldPos);
22 | vTexCoord = vec3(GetTexCoord(iTexCoord), GetDepth(gl_Position));
23 | }
24 |
25 |
--------------------------------------------------------------------------------
/ViewerAssets/RawAssets/Techniques/DiffNormalSpecAlphaMask.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
--------------------------------------------------------------------------------
/ViewerAssets/RawAssets/Techniques/DiffNormalAlphaMaskTranslucent.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
--------------------------------------------------------------------------------
/ViewerAssets/RawAssets/Techniques/DiffNormalPackedSpecAOAlphaMask.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
--------------------------------------------------------------------------------
/ViewerAssets/RawAssets/Techniques/DiffNormalPackedAlphaMask.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
--------------------------------------------------------------------------------
/ViewerAssets/RawAssets/Techniques/DiffNormalPackedEnvCube.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
--------------------------------------------------------------------------------
/ViewerAssets/RawAssets/Shaders/HLSL/Urho2D.hlsl:
--------------------------------------------------------------------------------
1 | #include "Uniforms.hlsl"
2 | #include "Samplers.hlsl"
3 | #include "Transform.hlsl"
4 |
5 | void VS(float4 iPos : POSITION,
6 | float2 iTexCoord : TEXCOORD0,
7 | float4 iColor : COLOR0,
8 | out float4 oColor : COLOR0,
9 | out float2 oTexCoord : TEXCOORD0,
10 | out float4 oPos : OUTPOSITION)
11 | {
12 | float4x3 modelMatrix = iModelMatrix;
13 | float3 worldPos = GetWorldPos(modelMatrix);
14 | oPos = GetClipPos(worldPos);
15 |
16 | oColor = iColor;
17 | oTexCoord = iTexCoord;
18 | }
19 |
20 | void PS(float4 iColor : COLOR0,
21 | float2 iTexCoord : TEXCOORD0,
22 | out float4 oColor : OUTCOLOR0)
23 | {
24 | float4 diffColor = cMatDiffColor * iColor;
25 | float4 diffInput = Sample2D(DiffMap, iTexCoord);
26 | oColor = diffColor * diffInput;
27 | }
28 |
--------------------------------------------------------------------------------
/ViewerAssets/RawAssets/RenderPaths/ForwardDepth.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
--------------------------------------------------------------------------------
/ViewerAssets/RawAssets/Shaders/HLSL/ColorCorrection.hlsl:
--------------------------------------------------------------------------------
1 | #include "Uniforms.hlsl"
2 | #include "Transform.hlsl"
3 | #include "Samplers.hlsl"
4 | #include "ScreenPos.hlsl"
5 | #include "PostProcess.hlsl"
6 |
7 | void VS(float4 iPos : POSITION,
8 | out float2 oScreenPos : TEXCOORD0,
9 | out float4 oPos : OUTPOSITION)
10 | {
11 | float4x3 modelMatrix = iModelMatrix;
12 | float3 worldPos = GetWorldPos(modelMatrix);
13 | oPos = GetClipPos(worldPos);
14 | oScreenPos = GetScreenPosPreDiv(oPos);
15 | }
16 |
17 | void PS(float2 iScreenPos : TEXCOORD0,
18 | out float4 oColor : OUTCOLOR0)
19 | {
20 | float3 color = Sample2D(DiffMap, iScreenPos).rgb;
21 | #ifndef D3D11
22 | oColor = float4(ColorCorrection(color, sVolumeMap), 1.0);
23 | #else
24 | oColor = float4(ColorCorrection(color, tVolumeMap, sVolumeMap), 1.0);
25 | #endif
26 | }
27 |
--------------------------------------------------------------------------------
/ViewerAssets/RawAssets/Techniques/DiffNormalPackedSpecAlphaMask.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
--------------------------------------------------------------------------------
/ViewerAssets/RawAssets/Techniques/DiffNormalPackedAlphaMaskTranslucent.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
--------------------------------------------------------------------------------
/UrhoSharp.Viewer.Wpf/SolutionItem.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.IO;
4 |
5 | namespace UrhoSharp.Viewer.Wpf
6 | {
7 | public class SolutionItem
8 | {
9 | public bool IsFolder { get; }
10 | public string Path { get; }
11 | public string Name { get; }
12 | public List Children { get; } = new List();
13 |
14 | public SolutionItem(bool isFolder, string path)
15 | {
16 | IsFolder = isFolder;
17 | Path = path;
18 | Name = System.IO.Path.GetFileName(path);
19 | if (isFolder)
20 | {
21 | try
22 | {
23 | foreach (var file in Directory.GetFiles(path))
24 | Children.Add(new SolutionItem(false, file));
25 | }
26 | catch { }
27 |
28 | try
29 | {
30 | foreach (var subDir in Directory.GetDirectories(path))
31 | Children.Add(new SolutionItem(true, subDir));
32 | }
33 | catch { }
34 | }
35 | }
36 | }
37 | }
38 |
--------------------------------------------------------------------------------
/ViewerAssets/RawAssets/RenderPaths/ForwardHWDepth.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
--------------------------------------------------------------------------------
/UrhoSharp.Viewer.Core/Utils/NodeUtils.cs:
--------------------------------------------------------------------------------
1 | using System.Collections.Generic;
2 | using System.Linq;
3 | using Urho;
4 |
5 | namespace UrhoSharp.Viewer.Core.Utils
6 | {
7 | public static class NodeUtils
8 | {
9 | public static void SetScaleBasedOnBoundingBox(this Node node, float referenceScale)
10 | {
11 | var maxBoundingBoxSize = GetAllComponentsRecursive(node)
12 | .Where(c => c is Drawable)
13 | .Select(c => ((Drawable)c).WorldBoundingBox.Size.Length)
14 | .DefaultIfEmpty()
15 | .Max();
16 |
17 | if (maxBoundingBoxSize > 0)
18 | {
19 | node.SetScale(referenceScale / maxBoundingBoxSize);
20 | }
21 | }
22 |
23 | static IEnumerable GetAllComponentsRecursive(this Node node)
24 | {
25 | foreach (var component in node.Components)
26 | yield return component;
27 |
28 | foreach (var child in node.Children)
29 | foreach (var childComponent in GetAllComponentsRecursive(child))
30 | yield return childComponent;
31 | }
32 | }
33 | }
34 |
--------------------------------------------------------------------------------
/ViewerAssets/RawAssets/Shaders/GLSL/Shadow.glsl:
--------------------------------------------------------------------------------
1 | #include "Uniforms.glsl"
2 | #include "Samplers.glsl"
3 | #include "Transform.glsl"
4 |
5 | #ifdef VSM_SHADOW
6 | varying vec3 vTexCoord;
7 | #else
8 | varying vec2 vTexCoord;
9 | #endif
10 |
11 | void VS()
12 | {
13 | mat4 modelMatrix = iModelMatrix;
14 | vec3 worldPos = GetWorldPos(modelMatrix);
15 | gl_Position = GetClipPos(worldPos);
16 | #ifdef VSM_SHADOW
17 | vTexCoord = vec3(GetTexCoord(iTexCoord), gl_Position.z / gl_Position.w * 0.5 + 0.5);
18 | #else
19 | vTexCoord = GetTexCoord(iTexCoord);
20 | #endif
21 | }
22 |
23 | void PS()
24 | {
25 | #ifdef ALPHAMASK
26 | float alpha = texture2D(sDiffMap, vTexCoord.xy).a;
27 | if (alpha < 0.5)
28 | discard;
29 | #endif
30 |
31 | #ifdef VSM_SHADOW
32 | float depth = vTexCoord.z;
33 | gl_FragColor = vec4(depth, depth * depth, 1.0, 1.0);
34 | #else
35 | gl_FragColor = vec4(1.0);
36 | #endif
37 | }
38 |
--------------------------------------------------------------------------------
/UrhoSharp.Viewer.Wpf/App.config:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
--------------------------------------------------------------------------------
/UrhoSharp.Viewer.Core/Previewers/Particle3DPreviewer.cs:
--------------------------------------------------------------------------------
1 | using Urho;
2 | using Urho.Actions;
3 |
4 | namespace UrhoSharp.Viewer.Core.Previewers
5 | {
6 | public class Particle3DPreviewer : AbstractPreviewer
7 | {
8 | public Particle3DPreviewer(UrhoScene urhoApp) : base(urhoApp) { }
9 |
10 | protected override void OnShow(Node node, Asset asset)
11 | {
12 | node.SetScale(1f);
13 | ParticleEffect particleEffect = ResourceCache.GetParticleEffect(asset.RelativePathToAsset);
14 | if (particleEffect == null)
15 | return;
16 |
17 | ParticleEmitter particleEmitter = node.CreateComponent();
18 | particleEmitter.Effect = particleEffect;
19 | App.Viewport.SetClearColor(Color.Black);
20 |
21 | //TODO: remove it and let user to control position by mouse
22 | node.RunActions(new RepeatForever(new RotateAroundBy(0.5f, new Vector3(1, 0, 0), 0, 0, 90, TransformSpace.Parent)));
23 | }
24 |
25 | protected override void OnStop()
26 | {
27 | App.ResetClearColor();
28 | }
29 | }
30 | }
--------------------------------------------------------------------------------
/UrhoSharp.Viewer.Core/Previewers/RenderPathPreviewer.cs:
--------------------------------------------------------------------------------
1 | using Urho;
2 |
3 | namespace UrhoSharp.Viewer.Core.Previewers
4 | {
5 | public class RenderPathPreviewer : AbstractPreviewer
6 | {
7 | RenderPath oldRp;
8 |
9 | public RenderPathPreviewer(UrhoScene urhoApp) : base(urhoApp) {}
10 |
11 | protected override void OnShow(Node node, Asset asset)
12 | {
13 | oldRp = App.Viewport.RenderPath.Clone();
14 | RenderPath customRp = oldRp.Clone();
15 | customRp.Append(ResourceCache.GetXmlFile(asset.RelativePathToAsset));
16 | App.Viewport.RenderPath = customRp;
17 |
18 | var model = node.CreateComponent();
19 | model.Model = ResourceCache.GetModel("Models/TeaPot.mdl");
20 | model.SetMaterial(ResourceCache.GetMaterial("Materials/DefaulPreviewerMaterial.xml"));
21 |
22 | node.SetScale(5f);
23 | node.Rotation = new Quaternion(20, 150, 20);
24 | }
25 |
26 | protected override void OnStop()
27 | {
28 | base.OnStop();
29 | App.Viewport.RenderPath = oldRp;
30 | }
31 | }
32 | }
--------------------------------------------------------------------------------
/UrhoSharp.Viewer.Cocoa/ViewController.designer.cs:
--------------------------------------------------------------------------------
1 | // WARNING
2 | //
3 | // This file has been generated automatically by Xamarin Studio to store outlets and
4 | // actions made in the UI designer. If it is removed, they will be lost.
5 | // Manual changes to this file may not be handled correctly.
6 | //
7 | using Foundation;
8 | using System.CodeDom.Compiler;
9 |
10 | namespace UrhoSharp.Viewer.Cocoa
11 | {
12 | [Register ("ViewController")]
13 | partial class ViewController
14 | {
15 | [Outlet]
16 | AppKit.NSTextField PathLabel { get; set; }
17 |
18 | [Outlet]
19 | AppKit.NSView UrhoSurfacePlaceholder { get; set; }
20 |
21 | [Action ("OpenFileButton:")]
22 | partial void OpenFileButton (Foundation.NSObject sender);
23 |
24 | void ReleaseDesignerOutlets ()
25 | {
26 | if (PathLabel != null) {
27 | PathLabel.Dispose ();
28 | PathLabel = null;
29 | }
30 |
31 | if (UrhoSurfacePlaceholder != null) {
32 | UrhoSurfacePlaceholder.Dispose ();
33 | UrhoSurfacePlaceholder = null;
34 | }
35 | }
36 | }
37 | }
38 |
--------------------------------------------------------------------------------
/UrhoSharp.Viewer.Core/Previewers/Particle2DPreviewer.cs:
--------------------------------------------------------------------------------
1 | using Urho;
2 | using Urho.Actions;
3 | using Urho.Urho2D;
4 |
5 | namespace UrhoSharp.Viewer.Core.Previewers
6 | {
7 | public class Particle2DPreviewer : AbstractPreviewer
8 | {
9 | public Particle2DPreviewer(UrhoScene urhoApp) : base(urhoApp) { }
10 |
11 | protected override void OnShow(Node node, Asset asset)
12 | {
13 | node.SetScale(1f);
14 | ParticleEffect2D particleEffect = ResourceCache.GetParticleEffect2D(asset.RelativePathToAsset);
15 | if (particleEffect == null)
16 | return;
17 |
18 | ParticleEmitter2D particleEmitter = node.CreateComponent();
19 | particleEmitter.Effect = particleEffect;
20 | App.Viewport.SetClearColor(Color.Black);
21 |
22 | //TODO: remove it and let user to control position by mouse
23 | node.RunActions(new RepeatForever(new RotateAroundBy(0.5f, new Vector3(1, 0, 0), 0, 0, 90, TransformSpace.Parent)));
24 | }
25 |
26 | protected override void OnStop()
27 | {
28 | App.ResetClearColor();
29 | }
30 | }
31 | }
32 |
--------------------------------------------------------------------------------
/UrhoSharp.Viewer.Core/Utils/StringUtils.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Linq;
3 |
4 | namespace UrhoSharp.Viewer.Core.Utils
5 | {
6 | public static class StringUtils
7 | {
8 | public static bool IsAnyOf(this string str, params string[] args)
9 | {
10 | var lowerStr = str.ToLowerInvariant();
11 | foreach (var item in args)
12 | {
13 | if (item.ToLowerInvariant() == lowerStr)
14 | return true;
15 | }
16 | return false;
17 | }
18 |
19 | public static string[] WordWrap(this string str, int maxLength)
20 | {
21 | int chars = 0;
22 | return str.Split(new[] {' '}, StringSplitOptions.RemoveEmptyEntries)
23 | .GroupBy(w => (chars += w.Length + 1) / maxLength)
24 | .Select(g => CutIfLonger(string.Join(" ", g), maxLength, true))
25 | .ToArray();
26 | }
27 |
28 | public static string CutIfLonger(this string str, int length, bool useThreedots = false)
29 | {
30 | if (string.IsNullOrEmpty(str) || str.Length <= length)
31 | return str;
32 |
33 | if (useThreedots)
34 | return str.Substring(0, length - 3) + "...";
35 | return str.Substring(0, length);
36 | }
37 | }
38 | }
39 |
--------------------------------------------------------------------------------
/LICENSE:
--------------------------------------------------------------------------------
1 | MIT License
2 |
3 | Copyright (c) 2017 Egor Bogatov
4 |
5 | Permission is hereby granted, free of charge, to any person obtaining a copy
6 | of this software and associated documentation files (the "Software"), to deal
7 | in the Software without restriction, including without limitation the rights
8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 | copies of the Software, and to permit persons to whom the Software is
10 | furnished to do so, subject to the following conditions:
11 |
12 | The above copyright notice and this permission notice shall be included in all
13 | copies or substantial portions of the Software.
14 |
15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21 | SOFTWARE.
22 |
--------------------------------------------------------------------------------
/UrhoSharp.Viewer.Cocoa/Info.plist:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | CFBundleName
6 | UrhoSharp.Viewer.Mac
7 | CFBundleIdentifier
8 | com.xamarin.urhosharp-viewer-mac
9 | CFBundleShortVersionString
10 | 1.0
11 | CFBundleVersion
12 | 1
13 | LSMinimumSystemVersion
14 | 10.12
15 | CFBundleDevelopmentRegion
16 | en
17 | CFBundleInfoDictionaryVersion
18 | 6.0
19 | CFBundlePackageType
20 | APPL
21 | CFBundleSignature
22 | ????
23 | NSHumanReadableCopyright
24 | egorb
25 | NSPrincipalClass
26 | NSApplication
27 | NSMainStoryboardFile
28 | Main
29 | XSAppIconAssets
30 | Assets.xcassets/AppIcon.appiconset
31 |
32 |
33 |
34 |
--------------------------------------------------------------------------------
/UrhoSharp.Viewer.Core/Utils/ProcessUtils.cs:
--------------------------------------------------------------------------------
1 | using System.Diagnostics;
2 | using System.Threading;
3 | using Microsoft.Win32.SafeHandles;
4 |
5 | namespace UrhoSharp.Viewer.Core.Utils
6 | {
7 | public static class ProcessUtils
8 | {
9 | public static bool StartCancellableProcess(string file, string args, CancellationToken token)
10 | {
11 | var processInfo = new ProcessStartInfo
12 | {
13 | FileName = file,
14 | WindowStyle = ProcessWindowStyle.Hidden,
15 | Arguments = args,
16 | };
17 | var process = new Process { StartInfo = processInfo };
18 | process.Start();
19 |
20 | using (var waitHandle = new SafeWaitHandle(process.Handle, false))
21 | {
22 | using (var processFinishedEvent = new ManualResetEvent(false))
23 | {
24 | processFinishedEvent.SafeWaitHandle = waitHandle;
25 | int index = WaitHandle.WaitAny(new[] { processFinishedEvent, token.WaitHandle });
26 | if (index == 1)
27 | {
28 | process.Kill();
29 | Debug.WriteLine($"Process {file} {args} is terminated");
30 | return false;
31 | }
32 | }
33 | }
34 | return !token.IsCancellationRequested;
35 | }
36 | }
37 | }
38 |
--------------------------------------------------------------------------------
/ViewerAssets/RawAssets/Shaders/GLSL/ShadowBlur.glsl:
--------------------------------------------------------------------------------
1 | #include "Uniforms.glsl"
2 | #include "Samplers.glsl"
3 | #include "Transform.glsl"
4 | #include "ScreenPos.glsl"
5 |
6 | #ifdef COMPILEPS
7 | uniform vec2 cBlurOffsets;
8 | #endif
9 |
10 | varying vec2 vScreenPos;
11 |
12 | void VS()
13 | {
14 | mat4 modelMatrix = iModelMatrix;
15 | vec3 worldPos = GetWorldPos(modelMatrix);
16 | gl_Position = GetClipPos(worldPos);
17 | vScreenPos = GetScreenPosPreDiv(gl_Position);
18 | }
19 |
20 | void PS()
21 | {
22 | vec2 color = vec2(0.0);
23 |
24 | color += 0.015625 * texture2D(sDiffMap, vScreenPos + vec2(-3.0) * cBlurOffsets).rg;
25 | color += 0.09375 * texture2D(sDiffMap, vScreenPos + vec2(-2.0) * cBlurOffsets).rg;
26 | color += 0.234375 * texture2D(sDiffMap, vScreenPos + vec2(-1.0) * cBlurOffsets).rg;
27 | color += 0.3125 * texture2D(sDiffMap, vScreenPos).rg;
28 | color += 0.234375 * texture2D(sDiffMap, vScreenPos + vec2(1.0) * cBlurOffsets).rg;
29 | color += 0.09375 * texture2D(sDiffMap, vScreenPos + vec2(2.0) * cBlurOffsets).rg;
30 | color += 0.015625 * texture2D(sDiffMap, vScreenPos + vec2(3.0) * cBlurOffsets).rg;
31 |
32 | gl_FragColor = vec4(color, 0.0, 0.0);
33 | }
34 |
35 |
--------------------------------------------------------------------------------
/ViewerAssets/RawAssets/Shaders/HLSL/Depth.hlsl:
--------------------------------------------------------------------------------
1 | #include "Uniforms.hlsl"
2 | #include "Samplers.hlsl"
3 | #include "Transform.hlsl"
4 |
5 | void VS(float4 iPos : POSITION,
6 | #ifdef SKINNED
7 | float4 iBlendWeights : BLENDWEIGHT,
8 | int4 iBlendIndices : BLENDINDICES,
9 | #endif
10 | #ifdef INSTANCED
11 | float4x3 iModelInstance : TEXCOORD4,
12 | #endif
13 | #ifndef NOUV
14 | float2 iTexCoord : TEXCOORD0,
15 | #endif
16 | out float3 oTexCoord : TEXCOORD0,
17 | out float4 oPos : OUTPOSITION)
18 | {
19 | // Define a 0,0 UV coord if not expected from the vertex data
20 | #ifdef NOUV
21 | float2 iTexCoord = float2(0.0, 0.0);
22 | #endif
23 |
24 | float4x3 modelMatrix = iModelMatrix;
25 | float3 worldPos = GetWorldPos(modelMatrix);
26 | oPos = GetClipPos(worldPos);
27 | oTexCoord = float3(GetTexCoord(iTexCoord), GetDepth(oPos));
28 | }
29 |
30 | void PS(
31 | float3 iTexCoord : TEXCOORD0,
32 | out float4 oColor : OUTCOLOR0)
33 | {
34 | #ifdef ALPHAMASK
35 | float alpha = Sample2D(sDiffMap, iTexCoord.xy).a;
36 | if (alpha < 0.5)
37 | discard;
38 | #endif
39 |
40 | oColor = iTexCoord.z;
41 | }
42 |
--------------------------------------------------------------------------------
/UrhoSharp.Viewer.Core/Asset.cs:
--------------------------------------------------------------------------------
1 | using System.IO;
2 |
3 | namespace UrhoSharp.Viewer.Core
4 | {
5 | public class Asset
6 | {
7 | public AssetsType Type { get; }
8 | public string RootDirectory { get; }
9 | public string RelativePathToAsset { get; }
10 | public string FullPathToAsset { get; }
11 | public string OriginalFile { get; }
12 | public string AssetFileName { get; }
13 |
14 | public Asset(AssetsType type, string rootDirectory, string relativePathToAsset, string originalFile = null)
15 | {
16 | Type = type;
17 | RootDirectory = rootDirectory;
18 | RelativePathToAsset = relativePathToAsset;
19 | FullPathToAsset = Path.Combine(rootDirectory, relativePathToAsset);
20 | AssetFileName = Path.GetFileName(relativePathToAsset);
21 | OriginalFile = originalFile ?? FullPathToAsset;
22 | }
23 |
24 | public override string ToString() => $"Asset type={Type}, RootDir={RootDirectory}, RelativePath={RelativePathToAsset}";
25 | }
26 |
27 | public enum AssetsType
28 | {
29 | Unknown,
30 | Material,
31 | Model,
32 | AnimatedModel,
33 | Texture,
34 | Particle2D,
35 | Particle3D,
36 | Scene,
37 | UI,
38 | RenderPath,
39 | AnimationSet2D,
40 | Tmx,
41 | Prefab,
42 | SdfFont,
43 | SupportedByAssimp
44 | }
45 | }
--------------------------------------------------------------------------------
/ViewerAssets/RawAssets/RenderPaths/Deferred.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
--------------------------------------------------------------------------------
/ViewerAssets/RawAssets/Shaders/GLSL/Tonemap.glsl:
--------------------------------------------------------------------------------
1 | #include "Uniforms.glsl"
2 | #include "Samplers.glsl"
3 | #include "Transform.glsl"
4 | #include "ScreenPos.glsl"
5 | #include "PostProcess.glsl"
6 |
7 | varying vec2 vScreenPos;
8 |
9 | #ifdef COMPILEPS
10 | uniform float cTonemapExposureBias;
11 | uniform float cTonemapMaxWhite;
12 | #endif
13 |
14 | void VS()
15 | {
16 | mat4 modelMatrix = iModelMatrix;
17 | vec3 worldPos = GetWorldPos(modelMatrix);
18 | gl_Position = GetClipPos(worldPos);
19 | vScreenPos = GetScreenPosPreDiv(gl_Position);
20 | }
21 |
22 | void PS()
23 | {
24 | #ifdef REINHARDEQ3
25 | vec3 color = ReinhardEq3Tonemap(max(texture2D(sDiffMap, vScreenPos).rgb * cTonemapExposureBias, 0.0));
26 | gl_FragColor = vec4(color, 1.0);
27 | #endif
28 |
29 | #ifdef REINHARDEQ4
30 | vec3 color = ReinhardEq4Tonemap(max(texture2D(sDiffMap, vScreenPos).rgb * cTonemapExposureBias, 0.0), cTonemapMaxWhite);
31 | gl_FragColor = vec4(color, 1.0);
32 | #endif
33 |
34 | #ifdef UNCHARTED2
35 | vec3 color = Uncharted2Tonemap(max(texture2D(sDiffMap, vScreenPos).rgb * cTonemapExposureBias, 0.0)) /
36 | Uncharted2Tonemap(vec3(cTonemapMaxWhite, cTonemapMaxWhite, cTonemapMaxWhite));
37 | gl_FragColor = vec4(color, 1.0);
38 | #endif
39 | }
40 |
41 |
--------------------------------------------------------------------------------
/ViewerAssets/RawAssets/RenderPaths/Prepass.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
--------------------------------------------------------------------------------
/ViewerAssets/RawAssets/Shaders/GLSL/Blur.glsl:
--------------------------------------------------------------------------------
1 | #include "Uniforms.glsl"
2 | #include "Samplers.glsl"
3 | #include "Transform.glsl"
4 | #include "ScreenPos.glsl"
5 | #include "PostProcess.glsl"
6 |
7 | varying vec2 vTexCoord;
8 | varying vec2 vScreenPos;
9 |
10 | #ifdef COMPILEPS
11 | uniform vec2 cBlurDir;
12 | uniform float cBlurRadius;
13 | uniform float cBlurSigma;
14 | uniform vec2 cBlurHInvSize;
15 | #endif
16 |
17 | void VS()
18 | {
19 | mat4 modelMatrix = iModelMatrix;
20 | vec3 worldPos = GetWorldPos(modelMatrix);
21 | gl_Position = GetClipPos(worldPos);
22 | vTexCoord = GetQuadTexCoord(gl_Position);
23 | vScreenPos = GetScreenPosPreDiv(gl_Position);
24 | }
25 |
26 | void PS()
27 | {
28 | #ifdef BLUR3
29 | gl_FragColor = GaussianBlur(3, cBlurDir, cBlurHInvSize * cBlurRadius, cBlurSigma, sDiffMap, vTexCoord);
30 | #endif
31 |
32 | #ifdef BLUR5
33 | gl_FragColor = GaussianBlur(5, cBlurDir, cBlurHInvSize * cBlurRadius, cBlurSigma, sDiffMap, vTexCoord);
34 | #endif
35 |
36 | #ifdef BLUR7
37 | gl_FragColor = GaussianBlur(7, cBlurDir, cBlurHInvSize * cBlurRadius, cBlurSigma, sDiffMap, vTexCoord);
38 | #endif
39 |
40 | #ifdef BLUR9
41 | gl_FragColor = GaussianBlur(9, cBlurDir, cBlurHInvSize * cBlurRadius, cBlurSigma, sDiffMap, vTexCoord);
42 | #endif
43 | }
44 |
--------------------------------------------------------------------------------
/ViewerAssets/RawAssets/Shaders/HLSL/VegetationShadow.hlsl:
--------------------------------------------------------------------------------
1 | #include "Uniforms.hlsl"
2 | #include "Samplers.hlsl"
3 | #include "Transform.hlsl"
4 |
5 | #ifndef D3D11
6 |
7 | // D3D9 uniforms
8 | uniform float cWindHeightFactor;
9 | uniform float cWindHeightPivot;
10 | uniform float cWindPeriod;
11 | uniform float2 cWindWorldSpacing;
12 |
13 | #else
14 |
15 | // D3D11 constant buffer
16 | cbuffer CustomVS : register(b6)
17 | {
18 | float cWindHeightFactor;
19 | float cWindHeightPivot;
20 | float cWindPeriod;
21 | float2 cWindWorldSpacing;
22 | }
23 |
24 | #endif
25 |
26 | void VS(float4 iPos : POSITION,
27 | #ifdef SKINNED
28 | float4 iBlendWeights : BLENDWEIGHT,
29 | int4 iBlendIndices : BLENDINDICES,
30 | #endif
31 | #ifdef INSTANCED
32 | float4x3 iModelInstance : TEXCOORD4,
33 | #endif
34 | float2 iTexCoord : TEXCOORD0,
35 | out float2 oTexCoord : TEXCOORD0,
36 | out float4 oPos : OUTPOSITION)
37 | {
38 | float4x3 modelMatrix = iModelMatrix;
39 | float3 worldPos = GetWorldPos(modelMatrix);
40 |
41 | float windStrength = max(iPos.y - cWindHeightPivot, 0.0) * cWindHeightFactor;
42 | float windPeriod = cElapsedTime * cWindPeriod + dot(worldPos.xz, cWindWorldSpacing);
43 | worldPos.x += windStrength * sin(windPeriod);
44 | worldPos.z -= windStrength * cos(windPeriod);
45 |
46 | oPos = GetClipPos(worldPos);
47 | oTexCoord = GetTexCoord(iTexCoord);
48 | }
49 |
--------------------------------------------------------------------------------
/ViewerAssets/RawAssets/RenderPaths/PrepassHWDepth.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
--------------------------------------------------------------------------------
/ViewerAssets/RawAssets/Shaders/GLSL/Basic.glsl:
--------------------------------------------------------------------------------
1 | #include "Uniforms.glsl"
2 | #include "Samplers.glsl"
3 | #include "Transform.glsl"
4 |
5 | #if defined(DIFFMAP) || defined(ALPHAMAP)
6 | varying vec2 vTexCoord;
7 | #endif
8 | #ifdef VERTEXCOLOR
9 | varying vec4 vColor;
10 | #endif
11 |
12 | void VS()
13 | {
14 | mat4 modelMatrix = iModelMatrix;
15 | vec3 worldPos = GetWorldPos(modelMatrix);
16 | gl_Position = GetClipPos(worldPos);
17 |
18 | #ifdef DIFFMAP
19 | vTexCoord = iTexCoord;
20 | #endif
21 | #ifdef VERTEXCOLOR
22 | vColor = iColor;
23 | #endif
24 | }
25 |
26 | void PS()
27 | {
28 | vec4 diffColor = cMatDiffColor;
29 |
30 | #ifdef VERTEXCOLOR
31 | diffColor *= vColor;
32 | #endif
33 |
34 | #if (!defined(DIFFMAP)) && (!defined(ALPHAMAP))
35 | gl_FragColor = diffColor;
36 | #endif
37 | #ifdef DIFFMAP
38 | vec4 diffInput = texture2D(sDiffMap, vTexCoord);
39 | #ifdef ALPHAMASK
40 | if (diffInput.a < 0.5)
41 | discard;
42 | #endif
43 | gl_FragColor = diffColor * diffInput;
44 | #endif
45 | #ifdef ALPHAMAP
46 | #ifdef GL3
47 | float alphaInput = texture2D(sDiffMap, vTexCoord).r;
48 | #else
49 | float alphaInput = texture2D(sDiffMap, vTexCoord).a;
50 | #endif
51 | gl_FragColor = vec4(diffColor.rgb, diffColor.a * alphaInput);
52 | #endif
53 | }
54 |
--------------------------------------------------------------------------------
/ViewerAssets/RawAssets/Shaders/HLSL/VegetationDepth.hlsl:
--------------------------------------------------------------------------------
1 | #include "Uniforms.hlsl"
2 | #include "Samplers.hlsl"
3 | #include "Transform.hlsl"
4 |
5 | #ifndef D3D11
6 |
7 | // D3D9 uniforms
8 | uniform float cWindHeightFactor;
9 | uniform float cWindHeightPivot;
10 | uniform float cWindPeriod;
11 | uniform float2 cWindWorldSpacing;
12 |
13 | #else
14 |
15 | // D3D11 constant buffer
16 | cbuffer CustomVS : register(b6)
17 | {
18 | float cWindHeightFactor;
19 | float cWindHeightPivot;
20 | float cWindPeriod;
21 | float2 cWindWorldSpacing;
22 | }
23 |
24 | #endif
25 |
26 | void VS(float4 iPos : POSITION,
27 | #ifdef SKINNED
28 | float4 iBlendWeights : BLENDWEIGHT,
29 | int4 iBlendIndices : BLENDINDICES,
30 | #endif
31 | #ifdef INSTANCED
32 | float4x3 iModelInstance : TEXCOORD4,
33 | #endif
34 | float2 iTexCoord : TEXCOORD0,
35 | out float3 oTexCoord : TEXCOORD0,
36 | out float4 oPos : OUTPOSITION)
37 | {
38 | float4x3 modelMatrix = iModelMatrix;
39 | float3 worldPos = GetWorldPos(modelMatrix);
40 |
41 | float windStrength = max(iPos.y - cWindHeightPivot, 0.0) * cWindHeightFactor;
42 | float windPeriod = cElapsedTime * cWindPeriod + dot(worldPos.xz, cWindWorldSpacing);
43 | worldPos.x += windStrength * sin(windPeriod);
44 | worldPos.z -= windStrength * cos(windPeriod);
45 |
46 | oPos = GetClipPos(worldPos);
47 | oTexCoord = float3(GetTexCoord(iTexCoord), GetDepth(oPos));
48 | }
49 |
--------------------------------------------------------------------------------
/ViewerAssets/RawAssets/Shaders/HLSL/ShadowBlur.hlsl:
--------------------------------------------------------------------------------
1 | #include "Uniforms.hlsl"
2 | #include "Samplers.hlsl"
3 | #include "Transform.hlsl"
4 | #include "ScreenPos.hlsl"
5 |
6 | #ifndef D3D11
7 |
8 | // D3D9 uniforms
9 | uniform float2 cBlurOffsets;
10 |
11 | #else
12 |
13 | #ifdef COMPILEPS
14 | // D3D11 constant buffers
15 | cbuffer CustomPS : register(b6)
16 | {
17 | float2 cBlurOffsets;
18 | }
19 | #endif
20 |
21 | #endif
22 |
23 | void VS(float4 iPos : POSITION,
24 | out float2 oScreenPos : TEXCOORD0,
25 | out float4 oPos : OUTPOSITION)
26 | {
27 | float4x3 modelMatrix = iModelMatrix;
28 | float3 worldPos = GetWorldPos(modelMatrix);
29 | oPos = GetClipPos(worldPos);
30 | oScreenPos = GetScreenPosPreDiv(oPos);
31 | }
32 |
33 | void PS(float2 iScreenPos : TEXCOORD0,
34 | out float4 oColor : OUTCOLOR0)
35 | {
36 | float2 color = 0.0;
37 |
38 | color += 0.015625 * Sample2D(DiffMap, iScreenPos - 3.0 * cBlurOffsets).rg;
39 | color += 0.09375 * Sample2D(DiffMap, iScreenPos - 2.0 * cBlurOffsets).rg;
40 | color += 0.234375 * Sample2D(DiffMap, iScreenPos - cBlurOffsets).rg;
41 | color += 0.3125 * Sample2D(DiffMap, iScreenPos).rg;
42 | color += 0.234375 * Sample2D(DiffMap, iScreenPos + cBlurOffsets).rg;
43 | color += 0.09375 * Sample2D(DiffMap, iScreenPos + 2.0 * cBlurOffsets).rg;
44 | color += 0.015625 * Sample2D(DiffMap, iScreenPos + 3.0 * cBlurOffsets).rg;
45 |
46 | oColor = float4(color, 0.0, 0.0);
47 | }
48 |
49 |
--------------------------------------------------------------------------------
/UrhoSharp.Viewer.Core/Previewers/AbstractPreviewer.cs:
--------------------------------------------------------------------------------
1 | using Urho;
2 | using Urho.Resources;
3 |
4 | namespace UrhoSharp.Viewer.Core.Previewers
5 | {
6 | public abstract class AbstractPreviewer
7 | {
8 | protected UrhoScene App { get; }
9 | protected ResourceCache ResourceCache => App.ResourceCache;
10 | protected Node Node { get; private set; }
11 | protected Scene Scene => Node?.Scene;
12 | protected Asset Asset { get; private set; }
13 | protected IEditor Editor { get; private set; }
14 |
15 | protected AbstractPreviewer(UrhoScene urhoApp)
16 | {
17 | App = urhoApp;
18 | }
19 |
20 | protected abstract void OnShow(Node node, Asset asset);
21 |
22 | protected virtual void OnStop() {}
23 |
24 | public virtual bool RotateRootNode => true;
25 |
26 | public void Show(Node node, Asset asset, IEditor editor)
27 | {
28 | Node = node;
29 | Asset = asset;
30 | Editor = editor;
31 | Editor?.DispatchToUI(() => Editor.DisplayModelScale(0f));
32 | OnShow(node, asset);
33 | App.Update += OnUpdate;
34 | }
35 |
36 | public void Stop()
37 | {
38 | App.Update -= OnUpdate;
39 | OnStop();
40 | }
41 |
42 | protected Material CreateDefaultMaterial()
43 | {
44 | var material = ResourceCache.GetMaterial("Materials/DefaulPreviewerMaterial.xml").Clone(string.Empty);
45 | //material.SetShaderParameter("MatSpecColor", Color.Green);
46 | return material;
47 | }
48 |
49 | protected virtual void OnUpdate(UpdateEventArgs e) { }
50 | }
51 | }
--------------------------------------------------------------------------------
/ViewerAssets/RawAssets/RenderPaths/DeferredHWDepth.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
--------------------------------------------------------------------------------
/UrhoSharp.Viewer.Core/Previewers/StaticModelPreviewer.cs:
--------------------------------------------------------------------------------
1 | using System.IO;
2 | using System.Linq;
3 | using Urho;
4 | using UrhoSharp.Viewer.Core.Components;
5 | using UrhoSharp.Viewer.Core.Utils;
6 |
7 | namespace UrhoSharp.Viewer.Core.Previewers
8 | {
9 | public class StaticModelPreviewer : AbstractPreviewer
10 | {
11 | public StaticModelPreviewer(UrhoScene urhoApp) : base(urhoApp) {}
12 |
13 | protected override void OnShow(Node node, Asset asset)
14 | {
15 | node.CreateComponent();
16 | StaticModel model = node.CreateComponent();
17 | model.Model = ResourceCache.GetModel(asset.RelativePathToAsset);
18 |
19 | // try to find a material with the same name:
20 | var materials = FsUtils.FindFiles(asset.RootDirectory, f => {
21 | var extension = Path.GetExtension(f).ToLowerInvariant();
22 | if (extension != ".xml") return false;
23 | var fileName = Path.GetFileNameWithoutExtension(f);
24 | if (fileName.Equals(Path.GetFileNameWithoutExtension(asset.AssetFileName),
25 | System.StringComparison.InvariantCultureIgnoreCase))
26 | return true;
27 | return false;
28 | })
29 | .OrderByDescending(f => f.ToLowerInvariant().Contains("material"))
30 | .ToArray();
31 |
32 | model.SetMaterial(materials.Any() ? ResourceCache.GetMaterial(materials.First()) : CreateDefaultMaterial());
33 | node.SetScaleBasedOnBoundingBox(60);
34 | var scaledTo = node.Scale.X;
35 | Editor?.DispatchToUI(() => Editor.DisplayModelScale(scaledTo));
36 | }
37 | }
38 | }
39 |
--------------------------------------------------------------------------------
/UrhoSharp.Viewer.Core/Components/Gizmo.cs:
--------------------------------------------------------------------------------
1 | using Urho;
2 |
3 | namespace UrhoSharp.Viewer.Core.Components
4 | {
5 | public class Gizmo : Component
6 | {
7 | Node nodeToSync;
8 |
9 | public Gizmo()
10 | {
11 | ReceiveSceneUpdates = true;
12 | }
13 |
14 | public override void OnAttachedToNode(Node node)
15 | {
16 | CustomGeometry geom = node.CreateComponent();
17 | geom.BeginGeometry(0, PrimitiveType.LineList);
18 | var material = new Material();
19 | material.SetTechnique(0, CoreAssets.Techniques.NoTextureUnlitVCol, 1, 1);
20 | geom.SetMaterial(material);
21 |
22 |
23 | float size = 1;
24 |
25 | //x
26 | geom.DefineVertex(Vector3.Zero);
27 | geom.DefineColor(Color.Red);
28 | geom.DefineVertex(Vector3.UnitX * size);
29 | geom.DefineColor(Color.Red);
30 | //y
31 | geom.DefineVertex(Vector3.Zero);
32 | geom.DefineColor(Color.Green);
33 | geom.DefineVertex(Vector3.UnitY * size);
34 | geom.DefineColor(Color.Green);
35 | //z
36 | geom.DefineVertex(Vector3.Zero);
37 | geom.DefineColor(Color.Blue);
38 | geom.DefineVertex(Vector3.UnitZ * size);
39 | geom.DefineColor(Color.Blue);
40 |
41 | geom.Commit();
42 |
43 | base.OnAttachedToNode(node);
44 | }
45 |
46 | protected override void OnUpdate(float timeStep)
47 | {
48 | if (nodeToSync != null)
49 | Node.SetWorldRotation(nodeToSync.WorldRotation);
50 | base.OnUpdate(timeStep);
51 | }
52 |
53 | public void SyncronizeRotationWith(Node node)
54 | {
55 | nodeToSync = node;
56 | }
57 | }
58 | }
59 |
--------------------------------------------------------------------------------
/UrhoSharp.Viewer.Core/Properties/AssemblyInfo.cs:
--------------------------------------------------------------------------------
1 | using System.Reflection;
2 | using System.Runtime.CompilerServices;
3 | using System.Runtime.InteropServices;
4 |
5 | // General Information about an assembly is controlled through the following
6 | // set of attributes. Change these attribute values to modify the information
7 | // associated with an assembly.
8 | [assembly: AssemblyTitle("UrhoSharp.Previewer.Core")]
9 | [assembly: AssemblyDescription("")]
10 | [assembly: AssemblyConfiguration("")]
11 | [assembly: AssemblyCompany("")]
12 | [assembly: AssemblyProduct("UrhoSharp.Previewer.Core")]
13 | [assembly: AssemblyCopyright("Copyright © 2016")]
14 | [assembly: AssemblyTrademark("")]
15 | [assembly: AssemblyCulture("")]
16 |
17 | // Setting ComVisible to false makes the types in this assembly not visible
18 | // to COM components. If you need to access a type in this assembly from
19 | // COM, set the ComVisible attribute to true on that type.
20 | [assembly: ComVisible(false)]
21 |
22 | // The following GUID is for the ID of the typelib if this project is exposed to COM
23 | [assembly: Guid("3019d9b3-3926-4be1-b8f7-e5aa3fb0486a")]
24 |
25 | // Version information for an assembly consists of the following four values:
26 | //
27 | // Major Version
28 | // Minor Version
29 | // Build Number
30 | // Revision
31 | //
32 | // You can specify all the values or you can default the Build and Revision Numbers
33 | // by using the '*' as shown below:
34 | // [assembly: AssemblyVersion("1.0.*")]
35 | [assembly: AssemblyVersion("1.0.0.0")]
36 | [assembly: AssemblyFileVersion("1.0.0.0")]
37 |
--------------------------------------------------------------------------------
/UrhoSharp.Viewer.Cocoa/Assets.xcassets/AppIcon.appiconset/Contents.json:
--------------------------------------------------------------------------------
1 | {
2 | "images": [
3 | {
4 | "filename": "AppIcon-16.png",
5 | "size": "16x16",
6 | "scale": "1x",
7 | "idiom": "mac"
8 | },
9 | {
10 | "filename": "AppIcon-16@2x.png",
11 | "size": "16x16",
12 | "scale": "2x",
13 | "idiom": "mac"
14 | },
15 | {
16 | "filename": "AppIcon-32.png",
17 | "size": "32x32",
18 | "scale": "1x",
19 | "idiom": "mac"
20 | },
21 | {
22 | "filename": "AppIcon-32@2x.png",
23 | "size": "32x32",
24 | "scale": "2x",
25 | "idiom": "mac"
26 | },
27 | {
28 | "filename": "AppIcon-128.png",
29 | "size": "128x128",
30 | "scale": "1x",
31 | "idiom": "mac"
32 | },
33 | {
34 | "filename": "AppIcon-128@2x.png",
35 | "size": "128x128",
36 | "scale": "2x",
37 | "idiom": "mac"
38 | },
39 | {
40 | "filename": "AppIcon-256.png",
41 | "size": "256x256",
42 | "scale": "1x",
43 | "idiom": "mac"
44 | },
45 | {
46 | "filename": "AppIcon-256@2x.png",
47 | "size": "256x256",
48 | "scale": "2x",
49 | "idiom": "mac"
50 | },
51 | {
52 | "filename": "AppIcon-512.png",
53 | "size": "512x512",
54 | "scale": "1x",
55 | "idiom": "mac"
56 | },
57 | {
58 | "filename": "AppIcon-512@2x.png",
59 | "size": "512x512",
60 | "scale": "2x",
61 | "idiom": "mac"
62 | }
63 | ],
64 | "info": {
65 | "version": 1,
66 | "author": "xcode"
67 | }
68 | }
--------------------------------------------------------------------------------
/ViewerAssets/RawAssets/Shaders/HLSL/Tonemap.hlsl:
--------------------------------------------------------------------------------
1 | #include "Uniforms.hlsl"
2 | #include "Transform.hlsl"
3 | #include "Samplers.hlsl"
4 | #include "ScreenPos.hlsl"
5 | #include "PostProcess.hlsl"
6 |
7 | #ifndef D3D11
8 |
9 | // D3D9 uniforms
10 | uniform float cTonemapExposureBias;
11 | uniform float cTonemapMaxWhite;
12 |
13 | #else
14 |
15 | #ifdef COMPILEPS
16 | // D3D11 constant buffers
17 | cbuffer CustomPS : register(b6)
18 | {
19 | float cTonemapExposureBias;
20 | float cTonemapMaxWhite;
21 | }
22 | #endif
23 |
24 | #endif
25 |
26 | void VS(float4 iPos : POSITION,
27 | out float2 oScreenPos : TEXCOORD0,
28 | out float4 oPos : OUTPOSITION)
29 | {
30 | float4x3 modelMatrix = iModelMatrix;
31 | float3 worldPos = GetWorldPos(modelMatrix);
32 | oPos = GetClipPos(worldPos);
33 | oScreenPos = GetScreenPosPreDiv(oPos);
34 | }
35 |
36 | void PS(float2 iScreenPos : TEXCOORD0,
37 | out float4 oColor : OUTCOLOR0)
38 | {
39 | #ifdef REINHARDEQ3
40 | float3 color = ReinhardEq3Tonemap(max(Sample2D(DiffMap, iScreenPos).rgb * cTonemapExposureBias, 0.0));
41 | oColor = float4(color, 1.0);
42 | #endif
43 |
44 | #ifdef REINHARDEQ4
45 | float3 color = ReinhardEq4Tonemap(max(Sample2D(DiffMap, iScreenPos).rgb * cTonemapExposureBias, 0.0), cTonemapMaxWhite);
46 | oColor = float4(color, 1.0);
47 | #endif
48 |
49 | #ifdef UNCHARTED2
50 | float3 color = Uncharted2Tonemap(max(Sample2D(DiffMap, iScreenPos).rgb * cTonemapExposureBias, 0.0)) /
51 | Uncharted2Tonemap(float3(cTonemapMaxWhite, cTonemapMaxWhite, cTonemapMaxWhite));
52 | oColor = float4(color, 1.0);
53 | #endif
54 | }
55 |
--------------------------------------------------------------------------------
/ViewerAssets/RawAssets/Shaders/GLSL/ScreenPos.glsl:
--------------------------------------------------------------------------------
1 | #ifdef COMPILEVS
2 | mat3 GetCameraRot()
3 | {
4 | return mat3(cViewInv[0][0], cViewInv[0][1], cViewInv[0][2],
5 | cViewInv[1][0], cViewInv[1][1], cViewInv[1][2],
6 | cViewInv[2][0], cViewInv[2][1], cViewInv[2][2]);
7 | }
8 |
9 | vec4 GetScreenPos(vec4 clipPos)
10 | {
11 | return vec4(
12 | clipPos.x * cGBufferOffsets.z + cGBufferOffsets.x * clipPos.w,
13 | clipPos.y * cGBufferOffsets.w + cGBufferOffsets.y * clipPos.w,
14 | 0.0,
15 | clipPos.w);
16 | }
17 |
18 | vec2 GetScreenPosPreDiv(vec4 clipPos)
19 | {
20 | return vec2(
21 | clipPos.x / clipPos.w * cGBufferOffsets.z + cGBufferOffsets.x,
22 | clipPos.y / clipPos.w * cGBufferOffsets.w + cGBufferOffsets.y);
23 | }
24 |
25 | vec2 GetQuadTexCoord(vec4 clipPos)
26 | {
27 | return vec2(
28 | clipPos.x / clipPos.w * 0.5 + 0.5,
29 | clipPos.y / clipPos.w * 0.5 + 0.5);
30 | }
31 |
32 | vec2 GetQuadTexCoordNoFlip(vec3 worldPos)
33 | {
34 | return vec2(
35 | worldPos.x * 0.5 + 0.5,
36 | -worldPos.y * 0.5 + 0.5);
37 | }
38 |
39 | vec3 GetFarRay(vec4 clipPos)
40 | {
41 | vec3 viewRay = vec3(
42 | clipPos.x / clipPos.w * cFrustumSize.x,
43 | clipPos.y / clipPos.w * cFrustumSize.y,
44 | cFrustumSize.z);
45 |
46 | return viewRay * GetCameraRot();
47 | }
48 |
49 | vec3 GetNearRay(vec4 clipPos)
50 | {
51 | vec3 viewRay = vec3(
52 | clipPos.x / clipPos.w * cFrustumSize.x,
53 | clipPos.y / clipPos.w * cFrustumSize.y,
54 | 0.0);
55 |
56 | return (viewRay * GetCameraRot()) * cDepthMode.x;
57 | }
58 | #endif
59 |
--------------------------------------------------------------------------------
/UrhoSharp.Viewer.Wpf/Properties/Settings.Designer.cs:
--------------------------------------------------------------------------------
1 | //------------------------------------------------------------------------------
2 | //
3 | // This code was generated by a tool.
4 | // Runtime Version:4.0.30319.42000
5 | //
6 | // Changes to this file may cause incorrect behavior and will be lost if
7 | // the code is regenerated.
8 | //
9 | //------------------------------------------------------------------------------
10 |
11 | namespace UrhoSharp.Viewer.Wpf.Properties {
12 |
13 |
14 | [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
15 | [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "14.0.0.0")]
16 | internal sealed partial class Settings : global::System.Configuration.ApplicationSettingsBase {
17 |
18 | private static Settings defaultInstance = ((Settings)(global::System.Configuration.ApplicationSettingsBase.Synchronized(new Settings())));
19 |
20 | public static Settings Default {
21 | get {
22 | return defaultInstance;
23 | }
24 | }
25 |
26 | [global::System.Configuration.UserScopedSettingAttribute()]
27 | [global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
28 | [global::System.Configuration.DefaultSettingValueAttribute("")]
29 | public string RootDir {
30 | get {
31 | return ((string)(this["RootDir"]));
32 | }
33 | set {
34 | this["RootDir"] = value;
35 | }
36 | }
37 | }
38 | }
39 |
--------------------------------------------------------------------------------
/ViewerAssets/RawAssets/Shaders/HLSL/Shadow.hlsl:
--------------------------------------------------------------------------------
1 | #include "Uniforms.hlsl"
2 | #include "Samplers.hlsl"
3 | #include "Transform.hlsl"
4 |
5 | void VS(float4 iPos : POSITION,
6 | #ifdef SKINNED
7 | float4 iBlendWeights : BLENDWEIGHT,
8 | int4 iBlendIndices : BLENDINDICES,
9 | #endif
10 | #ifdef INSTANCED
11 | float4x3 iModelInstance : TEXCOORD4,
12 | #endif
13 | #ifndef NOUV
14 | float2 iTexCoord : TEXCOORD0,
15 | #endif
16 | #ifdef VSM_SHADOW
17 | out float3 oTexCoord : TEXCOORD0,
18 | #else
19 | out float2 oTexCoord : TEXCOORD0,
20 | #endif
21 | out float4 oPos : OUTPOSITION)
22 | {
23 | // Define a 0,0 UV coord if not expected from the vertex data
24 | #ifdef NOUV
25 | float2 iTexCoord = float2(0.0, 0.0);
26 | #endif
27 |
28 | float4x3 modelMatrix = iModelMatrix;
29 | float3 worldPos = GetWorldPos(modelMatrix);
30 | oPos = GetClipPos(worldPos);
31 | #ifdef VSM_SHADOW
32 | oTexCoord = float3(GetTexCoord(iTexCoord), oPos.z/oPos.w);
33 | #else
34 | oTexCoord = GetTexCoord(iTexCoord);
35 | #endif
36 | }
37 |
38 | void PS(
39 | #ifdef VSM_SHADOW
40 | float3 iTexCoord : TEXCOORD0,
41 | #else
42 | float2 iTexCoord : TEXCOORD0,
43 | #endif
44 | out float4 oColor : OUTCOLOR0)
45 | {
46 | #ifdef ALPHAMASK
47 | float alpha = Sample2D(DiffMap, iTexCoord.xy).a;
48 | if (alpha < 0.5)
49 | discard;
50 | #endif
51 |
52 | #ifdef VSM_SHADOW
53 | float depth = iTexCoord.z;
54 | oColor = float4(depth, depth * depth, 1.0, 1.0);
55 | #else
56 | oColor = 1.0;
57 | #endif
58 | }
59 |
--------------------------------------------------------------------------------
/ViewerAssets/RawAssets/Shaders/HLSL/ScreenPos.hlsl:
--------------------------------------------------------------------------------
1 | #ifdef COMPILEVS
2 | float3x3 GetCameraRot()
3 | {
4 | return float3x3(cViewInv[0][0], cViewInv[0][1], cViewInv[0][2],
5 | cViewInv[1][0], cViewInv[1][1], cViewInv[1][2],
6 | cViewInv[2][0], cViewInv[2][1], cViewInv[2][2]);
7 | }
8 |
9 | float4 GetScreenPos(float4 clipPos)
10 | {
11 | return float4(
12 | clipPos.x * cGBufferOffsets.z + cGBufferOffsets.x * clipPos.w,
13 | -clipPos.y * cGBufferOffsets.w + cGBufferOffsets.y * clipPos.w,
14 | 0.0,
15 | clipPos.w);
16 | }
17 |
18 | float2 GetScreenPosPreDiv(float4 clipPos)
19 | {
20 | return float2(
21 | clipPos.x / clipPos.w * cGBufferOffsets.z + cGBufferOffsets.x,
22 | -clipPos.y / clipPos.w * cGBufferOffsets.w + cGBufferOffsets.y);
23 | }
24 |
25 | float2 GetQuadTexCoord(float4 clipPos)
26 | {
27 | return float2(
28 | clipPos.x / clipPos.w * 0.5 + 0.5,
29 | -clipPos.y / clipPos.w * 0.5 + 0.5);
30 | }
31 |
32 | float2 GetQuadTexCoordNoFlip(float3 worldPos)
33 | {
34 | return float2(
35 | worldPos.x * 0.5 + 0.5,
36 | -worldPos.y * 0.5 + 0.5);
37 | }
38 |
39 | float3 GetFarRay(float4 clipPos)
40 | {
41 | float3 viewRay = float3(
42 | clipPos.x / clipPos.w * cFrustumSize.x,
43 | clipPos.y / clipPos.w * cFrustumSize.y,
44 | cFrustumSize.z);
45 |
46 | return mul(viewRay, GetCameraRot());
47 | }
48 |
49 | float3 GetNearRay(float4 clipPos)
50 | {
51 | float3 viewRay = float3(
52 | clipPos.x / clipPos.w * cFrustumSize.x,
53 | clipPos.y / clipPos.w * cFrustumSize.y,
54 | 0.0);
55 |
56 | return mul(viewRay, GetCameraRot()) * cDepthMode.z;
57 | }
58 | #endif
59 |
--------------------------------------------------------------------------------
/UrhoSharp.Viewer.Core/Components/WirePlane.cs:
--------------------------------------------------------------------------------
1 | using Urho;
2 |
3 | namespace UrhoSharp.Viewer.Core.Components
4 | {
5 | public class WirePlane : Component
6 | {
7 | CustomGeometry geom;
8 | private int size = 25;
9 | private float scale = 0.5f;
10 |
11 | public int Size
12 | {
13 | get { return size; }
14 | set
15 | {
16 | size = value;
17 | Reload();
18 | }
19 | }
20 |
21 | public float Scale
22 | {
23 | get { return scale; }
24 | set
25 | {
26 | scale = value;
27 | Reload();
28 | }
29 | }
30 |
31 | public override void OnAttachedToNode(Node node)
32 | {
33 | base.OnAttachedToNode(node);
34 | Reload();
35 | }
36 |
37 | void Reload()
38 | {
39 | if (geom != null && !geom.IsDeleted)
40 | geom.Remove();
41 |
42 | if (Node == null || Node.IsDeleted)
43 | return;
44 |
45 | Color color = new Color(0.8f, 0.8f, 0.8f);
46 | geom = Node.CreateComponent();
47 | geom.BeginGeometry(0, PrimitiveType.LineList);
48 | var material = new Material();
49 | material.SetTechnique(0, CoreAssets.Techniques.NoTextureUnlitVCol, 1, 1);
50 | geom.SetMaterial(material);
51 |
52 | var halfSize = Size / 2;
53 | for (int i = -halfSize; i <= halfSize; i++)
54 | {
55 | //x
56 | geom.DefineVertex(new Vector3(i, 0, -halfSize) * Scale);
57 | geom.DefineColor(color);
58 | geom.DefineVertex(new Vector3(i, 0, halfSize) * Scale);
59 | geom.DefineColor(color);
60 |
61 | //z
62 | geom.DefineVertex(new Vector3(-halfSize, 0, i) * Scale);
63 | geom.DefineColor(color);
64 | geom.DefineVertex(new Vector3(halfSize, 0, i) * Scale);
65 | geom.DefineColor(color);
66 | }
67 |
68 | geom.Commit();
69 | }
70 | }
71 | }
72 |
--------------------------------------------------------------------------------
/ViewerAssets/RawAssets/Shaders/GLSL/Text.glsl:
--------------------------------------------------------------------------------
1 | #include "Uniforms.glsl"
2 | #include "Samplers.glsl"
3 | #include "Transform.glsl"
4 |
5 | varying vec2 vTexCoord;
6 | varying vec4 vColor;
7 |
8 | #ifdef TEXT_EFFECT_SHADOW
9 | uniform vec2 cShadowOffset;
10 | uniform vec4 cShadowColor;
11 | #endif
12 |
13 | #ifdef TEXT_EFFECT_STROKE
14 | uniform vec4 cStrokeColor;
15 | #endif
16 |
17 | void VS()
18 | {
19 | mat4 modelMatrix = iModelMatrix;
20 | vec3 worldPos = GetWorldPos(modelMatrix);
21 | gl_Position = GetClipPos(worldPos);
22 |
23 | vTexCoord = iTexCoord;
24 | vColor = iColor;
25 | }
26 |
27 | void PS()
28 | {
29 | gl_FragColor.rgb = vColor.rgb;
30 |
31 | #ifdef SIGNED_DISTANCE_FIELD
32 | float distance = texture2D(sDiffMap, vTexCoord).a;
33 | if (distance < 0.5)
34 | {
35 | #ifdef TEXT_EFFECT_SHADOW
36 | if (texture2D(sDiffMap, vTexCoord - cShadowOffset).a > 0.5)
37 | gl_FragColor = cShadowColor;
38 | else
39 | #endif
40 | gl_FragColor.a = 0.0;
41 | }
42 | else
43 | {
44 | #ifdef TEXT_EFFECT_STROKE
45 | if (distance < 0.525)
46 | gl_FragColor.rgb = cStrokeColor.rgb;
47 | #endif
48 |
49 | #ifdef TEXT_EFFECT_SHADOW
50 | if (texture2D(sDiffMap, vTexCoord + cShadowOffset).a < 0.5)
51 | gl_FragColor.a = vColor.a;
52 | else
53 | #endif
54 | gl_FragColor.a = vColor.a * smoothstep(0.5, 0.505, distance);
55 | }
56 | #else
57 | // Non-SDF font will likely be monochrome, in which case the alpha channel will be on the R channel on OpenGL 3
58 | #ifdef GL3
59 | gl_FragColor.a = vColor.a * texture2D(sDiffMap, vTexCoord).r;
60 | #else
61 | gl_FragColor.a = vColor.a * texture2D(sDiffMap, vTexCoord).a;
62 | #endif
63 | #endif
64 | }
65 |
--------------------------------------------------------------------------------
/ViewerAssets/RawAssets/RenderPaths/PBRDeferred.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
--------------------------------------------------------------------------------
/UrhoSharp.Viewer.Core/Previewers/AnimatedModelPreviewer.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.IO;
3 | using System.Linq;
4 | using Urho;
5 | using UrhoSharp.Viewer.Core.Components;
6 | using UrhoSharp.Viewer.Core.Utils;
7 |
8 | namespace UrhoSharp.Viewer.Core.Previewers
9 | {
10 | public class AnimatedModelPreviewer : AbstractPreviewer
11 | {
12 | AnimatedModel model;
13 |
14 | public AnimatedModelPreviewer(UrhoScene urhoApp) : base(urhoApp) {}
15 |
16 | protected override void OnShow(Node node, Asset asset)
17 | {
18 | node.CreateComponent();
19 | //Here we should find a model to apply ANI
20 | //TODO: ask user if not sure
21 | var modelName = Directory.GetFiles(Path.GetDirectoryName(asset.FullPathToAsset), "*.mdl")
22 | .Select(Path.GetFileNameWithoutExtension)
23 | .FirstOrDefault(f => asset.AssetFileName.StartsWith(f));
24 |
25 | if (string.IsNullOrEmpty(modelName))
26 | throw new Exception("Can't find a model to apply selected animation.");
27 |
28 | model = node.CreateComponent();
29 | model.Model = ResourceCache.GetModel(Path.Combine(Path.GetDirectoryName(asset.RelativePathToAsset), modelName + ".mdl"));
30 | model.SetMaterial(CreateDefaultMaterial());
31 |
32 | var walkAnimation = ResourceCache.GetAnimation(asset.RelativePathToAsset);
33 | var state = model.AddAnimationState(walkAnimation);
34 | if (state != null)
35 | {
36 | state.Weight = 1;
37 | state.Looped = true;
38 | }
39 | node.SetScaleBasedOnBoundingBox(60);
40 | var scaledTo = node.Scale.X;
41 | Editor?.DispatchToUI(() => Editor.DisplayModelScale(scaledTo));
42 | }
43 |
44 | protected override void OnUpdate(UpdateEventArgs e)
45 | {
46 | if (model.NumAnimationStates > 0)
47 | model?.AnimationStates?.FirstOrDefault()?.AddTime(e.TimeStep);
48 | }
49 | }
50 | }
51 |
--------------------------------------------------------------------------------
/ViewerAssets/RawAssets/Shaders/GLSL/Unlit.glsl:
--------------------------------------------------------------------------------
1 | #include "Uniforms.glsl"
2 | #include "Samplers.glsl"
3 | #include "Transform.glsl"
4 | #include "ScreenPos.glsl"
5 | #include "Fog.glsl"
6 |
7 | varying vec2 vTexCoord;
8 | varying vec4 vWorldPos;
9 | #ifdef VERTEXCOLOR
10 | varying vec4 vColor;
11 | #endif
12 |
13 | void VS()
14 | {
15 | mat4 modelMatrix = iModelMatrix;
16 | vec3 worldPos = GetWorldPos(modelMatrix);
17 | gl_Position = GetClipPos(worldPos);
18 | vTexCoord = GetTexCoord(iTexCoord);
19 | vWorldPos = vec4(worldPos, GetDepth(gl_Position));
20 |
21 | #ifdef VERTEXCOLOR
22 | vColor = iColor;
23 | #endif
24 | }
25 |
26 | void PS()
27 | {
28 | // Get material diffuse albedo
29 | #ifdef DIFFMAP
30 | vec4 diffColor = cMatDiffColor * texture2D(sDiffMap, vTexCoord);
31 | #ifdef ALPHAMASK
32 | if (diffColor.a < 0.5)
33 | discard;
34 | #endif
35 | #else
36 | vec4 diffColor = cMatDiffColor;
37 | #endif
38 |
39 | #ifdef VERTEXCOLOR
40 | diffColor *= vColor;
41 | #endif
42 |
43 | // Get fog factor
44 | #ifdef HEIGHTFOG
45 | float fogFactor = GetHeightFogFactor(vWorldPos.w, vWorldPos.y);
46 | #else
47 | float fogFactor = GetFogFactor(vWorldPos.w);
48 | #endif
49 |
50 | #if defined(PREPASS)
51 | // Fill light pre-pass G-Buffer
52 | gl_FragData[0] = vec4(0.5, 0.5, 0.5, 1.0);
53 | gl_FragData[1] = vec4(EncodeDepth(vWorldPos.w), 0.0);
54 | #elif defined(DEFERRED)
55 | gl_FragData[0] = vec4(GetFog(diffColor.rgb, fogFactor), diffColor.a);
56 | gl_FragData[1] = vec4(0.0, 0.0, 0.0, 0.0);
57 | gl_FragData[2] = vec4(0.5, 0.5, 0.5, 1.0);
58 | gl_FragData[3] = vec4(EncodeDepth(vWorldPos.w), 0.0);
59 | #else
60 | gl_FragColor = vec4(GetFog(diffColor.rgb, fogFactor), diffColor.a);
61 | #endif
62 | }
63 |
--------------------------------------------------------------------------------
/ViewerAssets/RawAssets/Shaders/HLSL/Text.hlsl:
--------------------------------------------------------------------------------
1 | #include "Uniforms.hlsl"
2 | #include "Samplers.hlsl"
3 | #include "Transform.hlsl"
4 |
5 | #ifndef D3D11
6 |
7 | // D3D9 uniforms
8 | uniform float2 cShadowOffset;
9 | uniform float4 cShadowColor;
10 | uniform float4 cStrokeColor;
11 |
12 | #else
13 |
14 | #ifdef COMPILEPS
15 | // D3D11 constant buffers
16 | cbuffer CustomPS : register(b6)
17 | {
18 | float2 cShadowOffset;
19 | float4 cShadowColor;
20 | float4 cStrokeColor;
21 | }
22 | #endif
23 |
24 | #endif
25 |
26 | void VS(float4 iPos : POSITION,
27 | float2 iTexCoord : TEXCOORD0,
28 | out float2 oTexCoord : TEXCOORD0,
29 | float4 iColor : COLOR0,
30 | out float4 oColor : COLOR0,
31 | out float4 oPos : OUTPOSITION)
32 | {
33 | float4x3 modelMatrix = iModelMatrix;
34 | float3 worldPos = GetWorldPos(modelMatrix);
35 | oPos = GetClipPos(worldPos);
36 | oColor = iColor;
37 | oTexCoord = iTexCoord;
38 | }
39 |
40 | void PS(float2 iTexCoord : TEXCOORD0,
41 | float4 iColor : COLOR0,
42 | out float4 oColor : OUTCOLOR0)
43 | {
44 | oColor.rgb = iColor.rgb;
45 |
46 | #ifdef SIGNED_DISTANCE_FIELD
47 | float distance = Sample2D(DiffMap, iTexCoord).a;
48 | if (distance < 0.5f)
49 | {
50 | #ifdef TEXT_EFFECT_SHADOW
51 | if (Sample2D(DiffMap, iTexCoord - cShadowOffset).a > 0.5f)
52 | oColor = cShadowColor;
53 | else
54 | #endif
55 | oColor.a = 0.0f;
56 | }
57 | else
58 | {
59 | #ifdef TEXT_EFFECT_STROKE
60 | if (distance < 0.525f)
61 | oColor.rgb = cStrokeColor.rgb;
62 | #endif
63 |
64 | #ifdef TEXT_EFFECT_SHADOW
65 | if (Sample2D(DiffMap, iTexCoord + cShadowOffset).a < 0.5f)
66 | oColor.a = iColor.a;
67 | else
68 | #endif
69 | oColor.a = iColor.a * smoothstep(0.5f, 0.505f, distance);
70 | }
71 | #else
72 | oColor.a = iColor.a * Sample2D(DiffMap, iTexCoord).a;
73 | #endif
74 | }
--------------------------------------------------------------------------------
/ViewerAssets/RawAssets/RenderPaths/PBRDeferredHWDepth.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
--------------------------------------------------------------------------------
/UrhoSharp.Viewer.sln:
--------------------------------------------------------------------------------
1 |
2 | Microsoft Visual Studio Solution File, Format Version 12.00
3 | # Visual Studio 14
4 | VisualStudioVersion = 14.0.25420.1
5 | MinimumVisualStudioVersion = 10.0.40219.1
6 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "UrhoSharp.Viewer.Core", "UrhoSharp.Viewer.Core\UrhoSharp.Viewer.Core.csproj", "{3019D9B3-3926-4BE1-B8F7-E5AA3FB0486A}"
7 | EndProject
8 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "UrhoSharp.Viewer.Wpf", "UrhoSharp.Viewer.Wpf\UrhoSharp.Viewer.Wpf.csproj", "{14EEA251-E8A8-4EAA-AD78-1CDC87B75C43}"
9 | EndProject
10 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "UrhoSharp.Viewer.Cocoa", "UrhoSharp.Viewer.Cocoa\UrhoSharp.Viewer.Cocoa.csproj", "{A28AF950-0D4C-4895-AA1E-AD33B253F9BF}"
11 | EndProject
12 | Global
13 | GlobalSection(SolutionConfigurationPlatforms) = preSolution
14 | Debug|Any CPU = Debug|Any CPU
15 | Release|Any CPU = Release|Any CPU
16 | EndGlobalSection
17 | GlobalSection(ProjectConfigurationPlatforms) = postSolution
18 | {3019D9B3-3926-4BE1-B8F7-E5AA3FB0486A}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
19 | {3019D9B3-3926-4BE1-B8F7-E5AA3FB0486A}.Debug|Any CPU.Build.0 = Debug|Any CPU
20 | {3019D9B3-3926-4BE1-B8F7-E5AA3FB0486A}.Release|Any CPU.ActiveCfg = Release|Any CPU
21 | {3019D9B3-3926-4BE1-B8F7-E5AA3FB0486A}.Release|Any CPU.Build.0 = Release|Any CPU
22 | {14EEA251-E8A8-4EAA-AD78-1CDC87B75C43}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
23 | {14EEA251-E8A8-4EAA-AD78-1CDC87B75C43}.Debug|Any CPU.Build.0 = Debug|Any CPU
24 | {14EEA251-E8A8-4EAA-AD78-1CDC87B75C43}.Release|Any CPU.ActiveCfg = Release|Any CPU
25 | {14EEA251-E8A8-4EAA-AD78-1CDC87B75C43}.Release|Any CPU.Build.0 = Release|Any CPU
26 | {A28AF950-0D4C-4895-AA1E-AD33B253F9BF}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
27 | {A28AF950-0D4C-4895-AA1E-AD33B253F9BF}.Debug|Any CPU.Build.0 = Debug|Any CPU
28 | {A28AF950-0D4C-4895-AA1E-AD33B253F9BF}.Release|Any CPU.ActiveCfg = Release|Any CPU
29 | {A28AF950-0D4C-4895-AA1E-AD33B253F9BF}.Release|Any CPU.Build.0 = Release|Any CPU
30 | EndGlobalSection
31 | GlobalSection(SolutionProperties) = preSolution
32 | HideSolutionNode = FALSE
33 | EndGlobalSection
34 | EndGlobal
35 |
--------------------------------------------------------------------------------
/UrhoSharp.Viewer.Wpf/ItemIconConverter.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Drawing;
3 | using System.Globalization;
4 | using System.Runtime.InteropServices;
5 | using System.Windows;
6 | using System.Windows.Data;
7 | using System.Windows.Media;
8 | using System.Windows.Media.Imaging;
9 |
10 | namespace UrhoSharp.Viewer.Wpf
11 | {
12 | public class ItemIconConverter : IValueConverter
13 | {
14 | public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
15 | {
16 | try
17 | {
18 | return GetRegisteredIcon(value.ToString(), 16, 16);
19 | }
20 | catch (Exception exc)
21 | {
22 | return null;
23 | }
24 | }
25 |
26 | public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
27 | {
28 | return null;
29 | }
30 |
31 | public static ImageSource GetRegisteredIcon(string filePath, int width, int height)
32 | {
33 | var shinfo = new SHfileInfo();
34 | const uint SHGFI_ICON = 0x100;
35 | const uint SHGFI_SMALLICON = 0x1;
36 |
37 | SHGetFileInfo(filePath, 0, ref shinfo, (uint)Marshal.SizeOf(shinfo), SHGFI_ICON | SHGFI_SMALLICON);
38 | var icon = Icon.FromHandle(shinfo.hIcon);
39 | var hBitmap = icon.ToBitmap().GetHbitmap();
40 | var bmpSource = System.Windows.Interop.Imaging.CreateBitmapSourceFromHBitmap(
41 | hBitmap, IntPtr.Zero, Int32Rect.Empty, BitmapSizeOptions.FromWidthAndHeight(width, height));
42 |
43 | DeleteObject(hBitmap);
44 | return bmpSource;
45 | }
46 |
47 | [DllImport("gdi32.dll", SetLastError = true)]
48 | static extern bool DeleteObject(IntPtr hObject);
49 |
50 | [DllImport("shell32.dll")]
51 | public static extern IntPtr SHGetFileInfo(string pszPath, uint dwFileAttributes, ref SHfileInfo psfi, uint cbSizeFileInfo, uint uFlags);
52 |
53 | [StructLayout(LayoutKind.Sequential)]
54 | public struct SHfileInfo
55 | {
56 | public IntPtr hIcon;
57 | public int iIcon;
58 | public uint dwAttributes;
59 | [MarshalAs(UnmanagedType.ByValTStr, SizeConst = 260)]
60 | public string szDisplayName;
61 | [MarshalAs(UnmanagedType.ByValTStr, SizeConst = 80)]
62 | public string szTypeName;
63 | }
64 | }
65 | }
66 |
--------------------------------------------------------------------------------
/UrhoSharp.Viewer.Core/Utils/FsUtils.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.IO;
4 | using System.Reflection;
5 |
6 | namespace UrhoSharp.Viewer.Core.Utils
7 | {
8 | public static class FsUtils
9 | {
10 | public static IEnumerable FindFiles(string folder, Func predicate)
11 | {
12 | foreach (var file in Directory.GetFiles(folder))
13 | if (predicate(file))
14 | yield return file;
15 |
16 | foreach (var subDir in Directory.GetDirectories(folder))
17 | foreach (var item in FindFiles(subDir, predicate))
18 | yield return item;
19 | }
20 |
21 | public static bool SplitPath(string path, string byDirectory, out string left, out string right)
22 | {
23 | left = null;
24 | right = null;
25 | var separator = Path.DirectorySeparatorChar;
26 | byDirectory = separator + byDirectory + separator;
27 |
28 | var index = path.LastIndexOf(byDirectory, StringComparison.InvariantCultureIgnoreCase);
29 | if (index >= 0)
30 | {
31 | left = path.Substring(0, index + byDirectory.Length);
32 | right = path.Substring(index + byDirectory.Length);
33 | return true;
34 | }
35 | return false;
36 | }
37 |
38 | public static string FindFolder(string path, string suffix)
39 | {
40 | var separator = Path.DirectorySeparatorChar;
41 | var endIndex = path.LastIndexOf(suffix + separator, StringComparison.InvariantCultureIgnoreCase);
42 | if (endIndex <= 0) return null;
43 | var beginIndex = path.Substring(0, endIndex + suffix.Length).LastIndexOf(separator);
44 | if (beginIndex <= 0) return null;
45 | var result = path.Substring(beginIndex + 1, endIndex - beginIndex + suffix.Length - 1);
46 | return result;
47 | }
48 |
49 | public static void CopyEmbeddedResourceTo(this Assembly asm, string resource, string destination = null, bool overwrite = false)
50 | {
51 | if (destination == null)
52 | destination = resource;
53 |
54 | if (File.Exists(destination) && !overwrite)
55 | return;
56 |
57 | using (Stream input = asm.GetManifestResourceStream(asm.GetName().Name + "." + resource))
58 | using (Stream output = File.Create(destination))
59 | input.CopyTo(output);
60 | }
61 | }
62 | }
63 |
--------------------------------------------------------------------------------
/UrhoSharp.Viewer.Core/Previewers/MaterialPreviewer.cs:
--------------------------------------------------------------------------------
1 | using System.Linq;
2 | using Urho;
3 |
4 | namespace UrhoSharp.Viewer.Core.Previewers
5 | {
6 | public class MaterialPreviewer : AbstractPreviewer
7 | {
8 | StaticModel staticModel = null;
9 | int currentModelIndex = 0;
10 |
11 | public MaterialPreviewer(UrhoScene urhoApp) : base(urhoApp) {}
12 |
13 | protected override void OnShow(Node node, Asset asset)
14 | {
15 | var material = ResourceCache.GetMaterial(asset.RelativePathToAsset);
16 |
17 | var modelNode = node.CreateChild();
18 | modelNode.SetScale(2f);
19 | modelNode.Rotate(new Quaternion(30, 30, 30), TransformSpace.Local);
20 | staticModel = modelNode.CreateComponent();
21 |
22 | //NOTE: this code went to Urho, will be replaced with the next Nuget update
23 | Technique[] result = new Technique[material.NumTechniques];
24 | for (uint i = 0; i < material.NumTechniques; i++)
25 | result[i] = material.GetTechnique(i);
26 |
27 | if (result.Any(t => t.Name.Contains(nameof(CoreAssets.Techniques.DiffSkybox))))
28 | {
29 | var skyNode = node.CreateChild();
30 | var skybox = skyNode.CreateComponent();
31 | skybox.Model = CoreAssets.Models.Box;
32 | skybox.SetMaterial(ResourceCache.GetMaterial(asset.RelativePathToAsset));
33 | staticModel.Model = CoreAssets.Models.Box;
34 | }
35 | else
36 | {
37 | staticModel.Model = CoreAssets.Models.Sphere;
38 | }
39 | staticModel.SetMaterial(material);
40 | App.Input.KeyDown += OnKeyDown;
41 | }
42 |
43 | protected override void OnStop()
44 | {
45 | App.Input.KeyDown -= OnKeyDown;
46 | base.OnStop();
47 | }
48 |
49 | void OnKeyDown(KeyDownEventArgs e)
50 | {
51 | if (e.Key == Key.F)
52 | {
53 | currentModelIndex++;
54 | switch (currentModelIndex)
55 | {
56 | case 0:
57 | staticModel.Model = CoreAssets.Models.Sphere;
58 | break;
59 | case 1:
60 | staticModel.Model = CoreAssets.Models.Box;
61 | break;
62 | case 2:
63 | staticModel.Model = CoreAssets.Models.Cylinder;
64 | break;
65 | case 3:
66 | staticModel.Model = CoreAssets.Models.Cone;
67 | currentModelIndex = -1;
68 | break;
69 | }
70 | }
71 | }
72 | }
73 | }
74 |
--------------------------------------------------------------------------------
/ViewerAssets/RawAssets/Shaders/HLSL/Blur.hlsl:
--------------------------------------------------------------------------------
1 | #include "Uniforms.hlsl"
2 | #include "Transform.hlsl"
3 | #include "Samplers.hlsl"
4 | #include "ScreenPos.hlsl"
5 | #include "PostProcess.hlsl"
6 |
7 | uniform float2 cBlurDir;
8 | uniform float cBlurRadius;
9 | uniform float cBlurSigma;
10 | uniform float2 cBlurHOffsets;
11 | uniform float2 cBlurHInvSize;
12 |
13 | void VS(float4 iPos : POSITION,
14 | out float2 oTexCoord : TEXCOORD0,
15 | out float2 oScreenPos : TEXCOORD1,
16 | out float4 oPos : OUTPOSITION)
17 | {
18 | float4x3 modelMatrix = iModelMatrix;
19 | float3 worldPos = GetWorldPos(modelMatrix);
20 | oPos = GetClipPos(worldPos);
21 | oTexCoord = GetQuadTexCoord(oPos) + cBlurHOffsets;
22 | oScreenPos = GetScreenPosPreDiv(oPos);
23 | }
24 |
25 | void PS(float2 iTexCoord : TEXCOORD0,
26 | float2 iScreenPos : TEXCOORD1,
27 | out float4 oColor : OUTCOLOR0)
28 | {
29 | #ifdef BLUR3
30 | #ifndef D3D11
31 | oColor = GaussianBlur(3, cBlurDir, cBlurHInvSize * cBlurRadius, cBlurSigma, sDiffMap, iTexCoord);
32 | #else
33 | oColor = GaussianBlur(3, cBlurDir, cBlurHInvSize * cBlurRadius, cBlurSigma, tDiffMap, sDiffMap, iTexCoord);
34 | #endif
35 | #endif
36 |
37 | #ifdef BLUR5
38 | #ifndef D3D11
39 | oColor = GaussianBlur(5, cBlurDir, cBlurHInvSize * cBlurRadius, cBlurSigma, sDiffMap, iTexCoord);
40 | #else
41 | oColor = GaussianBlur(5, cBlurDir, cBlurHInvSize * cBlurRadius, cBlurSigma, tDiffMap, sDiffMap, iTexCoord);
42 | #endif
43 | #endif
44 |
45 | #ifdef BLUR7
46 | #ifndef D3D11
47 | oColor = GaussianBlur(7, cBlurDir, cBlurHInvSize * cBlurRadius, cBlurSigma, sDiffMap, iTexCoord);
48 | #else
49 | oColor = GaussianBlur(7, cBlurDir, cBlurHInvSize * cBlurRadius, cBlurSigma, tDiffMap, sDiffMap, iTexCoord);
50 | #endif
51 | #endif
52 |
53 | #ifdef BLUR9
54 | #ifndef D3D11
55 | oColor = GaussianBlur(9, cBlurDir, cBlurHInvSize * cBlurRadius, cBlurSigma, sDiffMap, iTexCoord);
56 | #else
57 | oColor = GaussianBlur(9, cBlurDir, cBlurHInvSize * cBlurRadius, cBlurSigma, tDiffMap, sDiffMap, iTexCoord);
58 | #endif
59 | #endif
60 | }
61 |
--------------------------------------------------------------------------------
/ViewerAssets/RawAssets/Shaders/GLSL/Bloom.glsl:
--------------------------------------------------------------------------------
1 | #include "Uniforms.glsl"
2 | #include "Samplers.glsl"
3 | #include "Transform.glsl"
4 | #include "ScreenPos.glsl"
5 |
6 | varying vec2 vTexCoord;
7 | varying vec2 vScreenPos;
8 |
9 | #ifdef COMPILEPS
10 | uniform float cBloomThreshold;
11 | uniform vec2 cBloomMix;
12 | uniform vec2 cBlurHInvSize;
13 | #endif
14 |
15 | void VS()
16 | {
17 | mat4 modelMatrix = iModelMatrix;
18 | vec3 worldPos = GetWorldPos(modelMatrix);
19 | gl_Position = GetClipPos(worldPos);
20 | vTexCoord = GetQuadTexCoord(gl_Position);
21 | vScreenPos = GetScreenPosPreDiv(gl_Position);
22 | }
23 |
24 | void PS()
25 | {
26 | #ifdef BRIGHT
27 | vec3 rgb = texture2D(sDiffMap, vScreenPos).rgb;
28 | gl_FragColor = vec4((rgb - vec3(cBloomThreshold, cBloomThreshold, cBloomThreshold)) / (1.0 - cBloomThreshold), 1.0);
29 | #endif
30 |
31 | #ifdef BLURH
32 | vec3 rgb = texture2D(sDiffMap, vTexCoord + vec2(-2.0, 0.0) * cBlurHInvSize).rgb * 0.1;
33 | rgb += texture2D(sDiffMap, vTexCoord + vec2(-1.0, 0.0) * cBlurHInvSize).rgb * 0.25;
34 | rgb += texture2D(sDiffMap, vTexCoord + vec2(0.0, 0.0) * cBlurHInvSize).rgb * 0.3;
35 | rgb += texture2D(sDiffMap, vTexCoord + vec2(1.0, 0.0) * cBlurHInvSize).rgb * 0.25;
36 | rgb += texture2D(sDiffMap, vTexCoord + vec2(2.0, 0.0) * cBlurHInvSize).rgb * 0.1;
37 | gl_FragColor = vec4(rgb, 1.0);
38 | #endif
39 |
40 | #ifdef BLURV
41 | vec3 rgb = texture2D(sDiffMap, vTexCoord + vec2(0.0, -2.0) * cBlurHInvSize).rgb * 0.1;
42 | rgb += texture2D(sDiffMap, vTexCoord + vec2(0.0, -1.0) * cBlurHInvSize).rgb * 0.25;
43 | rgb += texture2D(sDiffMap, vTexCoord + vec2(0.0, 0.0) * cBlurHInvSize).rgb * 0.3;
44 | rgb += texture2D(sDiffMap, vTexCoord + vec2(0.0, 1.0) * cBlurHInvSize).rgb * 0.25;
45 | rgb += texture2D(sDiffMap, vTexCoord + vec2(0.0, 2.0) * cBlurHInvSize).rgb * 0.1;
46 | gl_FragColor = vec4(rgb, 1.0);
47 | #endif
48 |
49 | #ifdef COMBINE
50 | vec3 original = texture2D(sDiffMap, vScreenPos).rgb * cBloomMix.x;
51 | vec3 bloom = texture2D(sNormalMap, vTexCoord).rgb * cBloomMix.y;
52 | // Prevent oversaturation
53 | original *= max(vec3(1.0) - bloom, vec3(0.0));
54 | gl_FragColor = vec4(original + bloom, 1.0);
55 | #endif
56 | }
57 |
58 |
--------------------------------------------------------------------------------
/ViewerAssets/RawAssets/Shaders/GLSL/Water.glsl:
--------------------------------------------------------------------------------
1 | #include "Uniforms.glsl"
2 | #include "Samplers.glsl"
3 | #include "Transform.glsl"
4 | #include "ScreenPos.glsl"
5 | #include "Fog.glsl"
6 |
7 | varying vec4 vScreenPos;
8 | varying vec2 vReflectUV;
9 | varying vec2 vWaterUV;
10 | varying vec3 vNormal;
11 | varying vec4 vEyeVec;
12 |
13 | #ifdef COMPILEVS
14 | uniform vec2 cNoiseSpeed;
15 | uniform float cNoiseTiling;
16 | #endif
17 | #ifdef COMPILEPS
18 | uniform float cNoiseStrength;
19 | uniform float cFresnelPower;
20 | uniform vec3 cWaterTint;
21 | #endif
22 |
23 | void VS()
24 | {
25 | mat4 modelMatrix = iModelMatrix;
26 | vec3 worldPos = GetWorldPos(modelMatrix);
27 | gl_Position = GetClipPos(worldPos);
28 | vScreenPos = GetScreenPos(gl_Position);
29 | // GetQuadTexCoord() returns a vec2 that is OK for quad rendering; multiply it with output W
30 | // coordinate to make it work with arbitrary meshes such as the water plane (perform divide in pixel shader)
31 | // Also because the quadTexCoord is based on the clip position, and Y is flipped when rendering to a texture
32 | // on OpenGL, must flip again to cancel it out
33 | vReflectUV = GetQuadTexCoord(gl_Position);
34 | vReflectUV.y = 1.0 - vReflectUV.y;
35 | vReflectUV *= gl_Position.w;
36 | vWaterUV = iTexCoord * cNoiseTiling + cElapsedTime * cNoiseSpeed;
37 | vNormal = GetWorldNormal(modelMatrix);
38 | vEyeVec = vec4(cCameraPos - worldPos, GetDepth(gl_Position));
39 | }
40 |
41 | void PS()
42 | {
43 | vec2 refractUV = vScreenPos.xy / vScreenPos.w;
44 | vec2 reflectUV = vReflectUV.xy / vScreenPos.w;
45 |
46 | vec2 noise = (texture2D(sNormalMap, vWaterUV).rg - 0.5) * cNoiseStrength;
47 | refractUV += noise;
48 | // Do not shift reflect UV coordinate upward, because it will reveal the clipping of geometry below water
49 | if (noise.y < 0.0)
50 | noise.y = 0.0;
51 | reflectUV += noise;
52 |
53 | float fresnel = pow(1.0 - clamp(dot(normalize(vEyeVec.xyz), vNormal), 0.0, 1.0), cFresnelPower);
54 | vec3 refractColor = texture2D(sEnvMap, refractUV).rgb * cWaterTint;
55 | vec3 reflectColor = texture2D(sDiffMap, reflectUV).rgb;
56 | vec3 finalColor = mix(refractColor, reflectColor, fresnel);
57 |
58 | gl_FragColor = vec4(GetFog(finalColor, GetFogFactor(vEyeVec.w)), 1.0);
59 | }
60 |
--------------------------------------------------------------------------------
/ViewerAssets/RawAssets/Shaders/HLSL/Bloom.hlsl:
--------------------------------------------------------------------------------
1 | #include "Uniforms.hlsl"
2 | #include "Transform.hlsl"
3 | #include "Samplers.hlsl"
4 | #include "ScreenPos.hlsl"
5 |
6 | #ifndef D3D11
7 |
8 | // D3D9 uniforms
9 | uniform float cBloomThreshold;
10 | uniform float2 cBloomMix;
11 | uniform float2 cBlurHOffsets;
12 | uniform float2 cBlurHInvSize;
13 |
14 | #else
15 |
16 | // D3D11 constant buffers
17 | #ifdef COMPILEVS
18 | cbuffer CustomVS : register(b6)
19 | {
20 | float2 cBlurHOffsets;
21 | }
22 | #else
23 | cbuffer CustomPS : register(b6)
24 | {
25 | float cBloomThreshold;
26 | float2 cBloomMix;
27 | float2 cBlurHInvSize;
28 | }
29 | #endif
30 |
31 | #endif
32 |
33 | static const float offsets[5] = {
34 | 2.0,
35 | 1.0,
36 | 0.0,
37 | -1.0,
38 | -2.0,
39 | };
40 |
41 | static const float weights[5] = {
42 | 0.1,
43 | 0.25,
44 | 0.3,
45 | 0.25,
46 | 0.1
47 | };
48 |
49 | void VS(float4 iPos : POSITION,
50 | out float2 oTexCoord : TEXCOORD0,
51 | out float2 oScreenPos : TEXCOORD1,
52 | out float4 oPos : OUTPOSITION)
53 | {
54 | float4x3 modelMatrix = iModelMatrix;
55 | float3 worldPos = GetWorldPos(modelMatrix);
56 | oPos = GetClipPos(worldPos);
57 | oTexCoord = GetQuadTexCoord(oPos) + cBlurHOffsets;
58 | oScreenPos = GetScreenPosPreDiv(oPos);
59 | }
60 |
61 | void PS(float2 iTexCoord : TEXCOORD0,
62 | float2 iScreenPos : TEXCOORD1,
63 | out float4 oColor : OUTCOLOR0)
64 | {
65 | #ifdef BRIGHT
66 | float3 rgb = Sample2D(DiffMap, iScreenPos).rgb;
67 | oColor = float4((rgb - cBloomThreshold) / (1.0 - cBloomThreshold), 1.0);
68 | #endif
69 |
70 | #ifdef BLURH
71 | float3 rgb = 0.0;
72 | for (int i = 0; i < 5; ++i)
73 | rgb += Sample2D(DiffMap, iTexCoord + (float2(offsets[i], 0.0)) * cBlurHInvSize).rgb * weights[i];
74 | oColor = float4(rgb, 1.0);
75 | #endif
76 |
77 | #ifdef BLURV
78 | float3 rgb = 0.0;
79 | for (int i = 0; i < 5; ++i)
80 | rgb += Sample2D(DiffMap, iTexCoord + (float2(0.0, offsets[i])) * cBlurHInvSize).rgb * weights[i];
81 | oColor = float4(rgb, 1.0);
82 | #endif
83 |
84 | #ifdef COMBINE
85 | float3 original = Sample2D(DiffMap, iScreenPos).rgb * cBloomMix.x;
86 | float3 bloom = Sample2D(NormalMap, iTexCoord).rgb * cBloomMix.y;
87 | // Prevent oversaturation
88 | original *= saturate(1.0 - bloom);
89 | oColor = float4(original + bloom, 1.0);
90 | #endif
91 | }
92 |
--------------------------------------------------------------------------------
/UrhoSharp.Viewer.Core/AssimpTool.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Diagnostics;
3 | using System.IO;
4 | using System.Reflection;
5 | using System.Threading;
6 | using System.Threading.Tasks;
7 | using UrhoSharp.Viewer.Core.Utils;
8 |
9 | namespace UrhoSharp.Viewer.Core
10 | {
11 | ///
12 | /// Wrapper for Urho's AssetImporter (Assimp - http://www.assimp.org/)
13 | ///
14 | public class AssimpTool
15 | {
16 | static bool installed;
17 | static string directory;
18 | static string assimpExecPath;
19 |
20 | // File formats supported by Assimp http://assimp.sourceforge.net/main_features_formats.html
21 | // NOTE: don't forget to register new formats via attributes in VS (see PreviewerPackage)
22 | public string[] ModelFormats = { ".obj", ".dae", ".fbx", ".blend", ".3ds", ".ase", ".stl", ".lwo", ".lxo", ".x" };
23 | public string[] RareModelFormats = { ".glb", ".gltf", ".ifc", ".xgl", ".zgl", ".ply", ".dxf", ".ac", ".ms3d", ".cob", ".scn" };
24 |
25 | public async Task ConvertToPrefab(string file, CancellationToken token, bool asPrefab = true)
26 | {
27 | InstallIfNeeded();
28 | string outputDir = Path.Combine(directory, Guid.NewGuid().ToString("N").Substring(0, 7) + "_UrhoData");
29 | string prefabFileName = "Prefab.xml";
30 | string assimpArgs = $"{(asPrefab ? "node" : "scene")} \"{file}\" \"{Path.Combine(outputDir, prefabFileName)}\"";
31 |
32 | bool success = await Task.Run(() => ProcessUtils.StartCancellableProcess(assimpExecPath, assimpArgs, token));
33 | if (!success)
34 | throw new OperationCanceledException();
35 |
36 | if (!File.Exists(Path.Combine(outputDir, prefabFileName)))
37 | throw new InvalidOperationException("AssetImporter failed.");
38 |
39 | return new Asset(asPrefab ? AssetsType.Prefab : AssetsType.Scene, outputDir, prefabFileName, file);
40 | }
41 |
42 | void InstallIfNeeded()
43 | {
44 | if (installed)
45 | return;
46 |
47 | bool isWin = Environment.OSVersion.Platform == PlatformID.Win32NT;
48 | string assimpExeName = isWin ? "AssetImporter_Win64.exe" : "AssetImporter_macOS";
49 | directory = Path.Combine(Path.GetTempPath(), "UrhoSharpAssimpTemp");
50 | if (!Directory.Exists(directory))
51 | Directory.CreateDirectory(directory);
52 | assimpExecPath = Path.Combine(directory, assimpExeName);
53 | GetType().Assembly.CopyEmbeddedResourceTo(assimpExeName, assimpExecPath, true);
54 | if (!isWin)
55 | Process.Start("chmod", $"777 \"{assimpExecPath}\"");
56 | installed = true;
57 | }
58 | }
59 | }
60 |
--------------------------------------------------------------------------------
/UrhoSharp.Viewer.Wpf/Properties/AssemblyInfo.cs:
--------------------------------------------------------------------------------
1 | using System.Reflection;
2 | using System.Resources;
3 | using System.Runtime.CompilerServices;
4 | using System.Runtime.InteropServices;
5 | using System.Windows;
6 |
7 | // General Information about an assembly is controlled through the following
8 | // set of attributes. Change these attribute values to modify the information
9 | // associated with an assembly.
10 | [assembly: AssemblyTitle("UrhoSharp.Previewer.Wpf")]
11 | [assembly: AssemblyDescription("")]
12 | [assembly: AssemblyConfiguration("")]
13 | [assembly: AssemblyCompany("")]
14 | [assembly: AssemblyProduct("UrhoSharp.Previewer.Wpf")]
15 | [assembly: AssemblyCopyright("Copyright © Egor Bogatov 2017")]
16 | [assembly: AssemblyTrademark("")]
17 | [assembly: AssemblyCulture("")]
18 |
19 | // Setting ComVisible to false makes the types in this assembly not visible
20 | // to COM components. If you need to access a type in this assembly from
21 | // COM, set the ComVisible attribute to true on that type.
22 | [assembly: ComVisible(false)]
23 |
24 | //In order to begin building localizable applications, set
25 | //CultureYouAreCodingWith in your .csproj file
26 | //inside a . For example, if you are using US english
27 | //in your source files, set the to en-US. Then uncomment
28 | //the NeutralResourceLanguage attribute below. Update the "en-US" in
29 | //the line below to match the UICulture setting in the project file.
30 |
31 | //[assembly: NeutralResourcesLanguage("en-US", UltimateResourceFallbackLocation.Satellite)]
32 |
33 |
34 | [assembly: ThemeInfo(
35 | ResourceDictionaryLocation.None, //where theme specific resource dictionaries are located
36 | //(used if a resource is not found in the page,
37 | // or application resource dictionaries)
38 | ResourceDictionaryLocation.SourceAssembly //where the generic resource dictionary is located
39 | //(used if a resource is not found in the page,
40 | // app, or any theme specific resource dictionaries)
41 | )]
42 |
43 |
44 | // Version information for an assembly consists of the following four values:
45 | //
46 | // Major Version
47 | // Minor Version
48 | // Build Number
49 | // Revision
50 | //
51 | // You can specify all the values or you can default the Build and Revision Numbers
52 | // by using the '*' as shown below:
53 | // [assembly: AssemblyVersion("1.0.*")]
54 | [assembly: AssemblyVersion("1.0.0.0")]
55 | [assembly: AssemblyFileVersion("1.0.0.0")]
56 |
--------------------------------------------------------------------------------
/ViewerAssets/RawAssets/Shaders/HLSL/Basic.hlsl:
--------------------------------------------------------------------------------
1 | #include "Uniforms.hlsl"
2 | #include "Samplers.hlsl"
3 | #include "Transform.hlsl"
4 |
5 | void VS(float4 iPos : POSITION,
6 | #ifdef DIFFMAP
7 | float2 iTexCoord : TEXCOORD0,
8 | #endif
9 | #ifdef VERTEXCOLOR
10 | float4 iColor : COLOR0,
11 | #endif
12 | #ifdef SKINNED
13 | float4 iBlendWeights : BLENDWEIGHT,
14 | int4 iBlendIndices : BLENDINDICES,
15 | #endif
16 | #ifdef INSTANCED
17 | float4x3 iModelInstance : TEXCOORD4,
18 | #endif
19 | #if defined(BILLBOARD) || defined(DIRBILLBOARD)
20 | float2 iSize : TEXCOORD1,
21 | #endif
22 | #ifdef DIRBILLBOARD
23 | float3 iNormal : NORMAL,
24 | float4 iTangent : TANGENT,
25 | #endif
26 | #ifdef DIFFMAP
27 | out float2 oTexCoord : TEXCOORD0,
28 | #endif
29 | #ifdef VERTEXCOLOR
30 | out float4 oColor : COLOR0,
31 | #endif
32 | #if defined(D3D11) && defined(CLIPPLANE)
33 | out float oClip : SV_CLIPDISTANCE0,
34 | #endif
35 | out float4 oPos : OUTPOSITION)
36 | {
37 | float4x3 modelMatrix = iModelMatrix;
38 | float3 worldPos = GetWorldPos(modelMatrix);
39 | oPos = GetClipPos(worldPos);
40 |
41 | #if defined(D3D11) && defined(CLIPPLANE)
42 | oClip = dot(oPos, cClipPlane);
43 | #endif
44 |
45 | #ifdef VERTEXCOLOR
46 | oColor = iColor;
47 | #endif
48 | #ifdef DIFFMAP
49 | oTexCoord = iTexCoord;
50 | #endif
51 | }
52 |
53 | void PS(
54 | #if defined(DIFFMAP) || defined(ALPHAMAP)
55 | float2 iTexCoord : TEXCOORD0,
56 | #endif
57 | #ifdef VERTEXCOLOR
58 | float4 iColor : COLOR0,
59 | #endif
60 | #if defined(D3D11) && defined(CLIPPLANE)
61 | float iClip : SV_CLIPDISTANCE0,
62 | #endif
63 | out float4 oColor : OUTCOLOR0)
64 | {
65 | float4 diffColor = cMatDiffColor;
66 |
67 | #ifdef VERTEXCOLOR
68 | diffColor *= iColor;
69 | #endif
70 |
71 | #if (!defined(DIFFMAP)) && (!defined(ALPHAMAP))
72 | oColor = diffColor;
73 | #endif
74 | #ifdef DIFFMAP
75 | float4 diffInput = Sample2D(DiffMap, iTexCoord);
76 | #ifdef ALPHAMASK
77 | if (diffInput.a < 0.5)
78 | discard;
79 | #endif
80 | oColor = diffColor * diffInput;
81 | #endif
82 | #ifdef ALPHAMAP
83 | float alphaInput = Sample2D(DiffMap, iTexCoord).a;
84 | oColor = float4(diffColor.rgb, diffColor.a * alphaInput);
85 | #endif
86 | }
87 |
--------------------------------------------------------------------------------
/ViewerAssets/RawAssets/Shaders/GLSL/BloomHDR.glsl:
--------------------------------------------------------------------------------
1 | #include "Uniforms.glsl"
2 | #include "Samplers.glsl"
3 | #include "Transform.glsl"
4 | #include "ScreenPos.glsl"
5 | #include "PostProcess.glsl"
6 |
7 | varying vec2 vTexCoord;
8 | varying vec2 vScreenPos;
9 |
10 | #ifdef COMPILEPS
11 | uniform float cBloomHDRThreshold;
12 | uniform float cBloomHDRBlurSigma;
13 | uniform float cBloomHDRBlurRadius;
14 | uniform vec2 cBloomHDRBlurDir;
15 | uniform vec2 cBloomHDRMix;
16 | uniform vec2 cBright2InvSize;
17 | uniform vec2 cBright4InvSize;
18 | uniform vec2 cBright8InvSize;
19 | uniform vec2 cBright16InvSize;
20 |
21 | const int BlurKernelSize = 5;
22 | #endif
23 |
24 | void VS()
25 | {
26 | mat4 modelMatrix = iModelMatrix;
27 | vec3 worldPos = GetWorldPos(modelMatrix);
28 | gl_Position = GetClipPos(worldPos);
29 | vTexCoord = GetQuadTexCoord(gl_Position);
30 | vScreenPos = GetScreenPosPreDiv(gl_Position);
31 | }
32 |
33 | void PS()
34 | {
35 | #ifdef BRIGHT
36 | vec3 color = texture2D(sDiffMap, vScreenPos).rgb;
37 | gl_FragColor = vec4(max(color - cBloomHDRThreshold, 0.0), 1.0);
38 | #endif
39 |
40 | #ifdef BLUR16
41 | gl_FragColor = GaussianBlur(BlurKernelSize, cBloomHDRBlurDir, cBright16InvSize * cBloomHDRBlurRadius, cBloomHDRBlurSigma, sDiffMap, vScreenPos);
42 | #endif
43 |
44 | #ifdef BLUR8
45 | gl_FragColor = GaussianBlur(BlurKernelSize, cBloomHDRBlurDir, cBright8InvSize * cBloomHDRBlurRadius, cBloomHDRBlurSigma, sDiffMap, vScreenPos);
46 | #endif
47 |
48 | #ifdef BLUR4
49 | gl_FragColor = GaussianBlur(BlurKernelSize, cBloomHDRBlurDir, cBright4InvSize * cBloomHDRBlurRadius, cBloomHDRBlurSigma, sDiffMap, vScreenPos);
50 | #endif
51 |
52 | #ifdef BLUR2
53 | gl_FragColor = GaussianBlur(BlurKernelSize, cBloomHDRBlurDir, cBright2InvSize * cBloomHDRBlurRadius, cBloomHDRBlurSigma, sDiffMap, vScreenPos);
54 | #endif
55 |
56 | #ifdef COMBINE16
57 | gl_FragColor = texture2D(sDiffMap, vScreenPos) + texture2D(sNormalMap, vTexCoord);
58 | #endif
59 |
60 | #ifdef COMBINE8
61 | gl_FragColor = texture2D(sDiffMap, vScreenPos) + texture2D(sNormalMap, vTexCoord);
62 | #endif
63 |
64 | #ifdef COMBINE4
65 | gl_FragColor = texture2D(sDiffMap, vScreenPos) + texture2D(sNormalMap, vTexCoord);
66 | #endif
67 |
68 | #ifdef COMBINE2
69 | vec3 color = texture2D(sDiffMap, vScreenPos).rgb * cBloomHDRMix.x;
70 | vec3 bloom = texture2D(sNormalMap, vTexCoord).rgb * cBloomHDRMix.y;
71 | gl_FragColor = vec4(color + bloom, 1.0);
72 | #endif
73 | }
74 |
--------------------------------------------------------------------------------
/ViewerAssets/RawAssets/Shaders/GLSL/Samplers.glsl:
--------------------------------------------------------------------------------
1 | #ifdef COMPILEPS
2 | uniform sampler2D sDiffMap;
3 | uniform samplerCube sDiffCubeMap;
4 | uniform sampler2D sNormalMap;
5 | uniform sampler2D sSpecMap;
6 | uniform sampler2D sEmissiveMap;
7 | uniform sampler2D sEnvMap;
8 | uniform samplerCube sEnvCubeMap;
9 | uniform sampler2D sLightRampMap;
10 | uniform sampler2D sLightSpotMap;
11 | uniform samplerCube sLightCubeMap;
12 | #ifndef GL_ES
13 | uniform sampler3D sVolumeMap;
14 | uniform sampler2D sAlbedoBuffer;
15 | uniform sampler2D sNormalBuffer;
16 | uniform sampler2D sDepthBuffer;
17 | uniform sampler2D sLightBuffer;
18 | #ifdef VSM_SHADOW
19 | uniform sampler2D sShadowMap;
20 | #else
21 | uniform sampler2DShadow sShadowMap;
22 | #endif
23 | uniform samplerCube sFaceSelectCubeMap;
24 | uniform samplerCube sIndirectionCubeMap;
25 | uniform samplerCube sZoneCubeMap;
26 | uniform sampler3D sZoneVolumeMap;
27 | #else
28 | uniform sampler2D sShadowMap;
29 | #endif
30 |
31 | #ifdef GL3
32 | #define texture2D texture
33 | #define texture2DProj textureProj
34 | #define texture3D texture
35 | #define textureCube texture
36 | #define texture2DLod textureLod
37 | #define texture2DLodOffset textureLodOffset
38 | #endif
39 |
40 | vec3 DecodeNormal(vec4 normalInput)
41 | {
42 | #ifdef PACKEDNORMAL
43 | vec3 normal;
44 | normal.xy = normalInput.ag * 2.0 - 1.0;
45 | normal.z = sqrt(max(1.0 - dot(normal.xy, normal.xy), 0.0));
46 | return normal;
47 | #else
48 | return normalize(normalInput.rgb * 2.0 - 1.0);
49 | #endif
50 | }
51 |
52 | vec3 EncodeDepth(float depth)
53 | {
54 | #ifndef GL3
55 | vec3 ret;
56 | depth *= 255.0;
57 | ret.x = floor(depth);
58 | depth = (depth - ret.x) * 255.0;
59 | ret.y = floor(depth);
60 | ret.z = (depth - ret.y);
61 | ret.xy *= 1.0 / 255.0;
62 | return ret;
63 | #else
64 | // OpenGL 3 can use different MRT formats, so no need for encoding
65 | return vec3(depth, 0.0, 0.0);
66 | #endif
67 | }
68 |
69 | float DecodeDepth(vec3 depth)
70 | {
71 | #ifndef GL3
72 | const vec3 dotValues = vec3(1.0, 1.0 / 255.0, 1.0 / (255.0 * 255.0));
73 | return dot(depth, dotValues);
74 | #else
75 | // OpenGL 3 can use different MRT formats, so no need for encoding
76 | return depth.r;
77 | #endif
78 | }
79 |
80 | float ReconstructDepth(float hwDepth)
81 | {
82 | return dot(vec2(hwDepth, cDepthReconstruct.y / (hwDepth - cDepthReconstruct.x)), cDepthReconstruct.zw);
83 | }
84 | #endif
85 |
--------------------------------------------------------------------------------
/UrhoSharp.Viewer.Cocoa/ViewController.cs:
--------------------------------------------------------------------------------
1 | using System;
2 |
3 | using AppKit;
4 | using Foundation;
5 | using Urho;
6 | using UrhoSharp.Viewer.Core;
7 | using System.Threading.Tasks;
8 | using CoreGraphics;
9 |
10 | namespace UrhoSharp.Viewer.Cocoa
11 | {
12 | public partial class ViewController : NSViewController, IEditor
13 | {
14 | PreviewerApplication previewer;
15 | UrhoSurface urhoSurface;
16 |
17 | public ViewController(IntPtr handle) : base(handle)
18 | {
19 | }
20 |
21 | public override async void ViewDidLoad()
22 | {
23 | base.ViewDidLoad();
24 |
25 | urhoSurface = new UrhoSurface();
26 | urhoSurface.Frame = UrhoSurfacePlaceholder.Frame;
27 | urhoSurface.AutoresizingMask = NSViewResizingMask.WidthSizable | NSViewResizingMask.HeightSizable;
28 | UrhoSurfacePlaceholder.AddSubview(urhoSurface);
29 |
30 |
31 | previewer = new PreviewerApplication(new AssetsResolver { AssetsImporterFormats = true, AssetsImporterRareFormats = true, Images = true });
32 | previewer.SurfaceRecreationRequested += OnSurfaceRequested;
33 | }
34 |
35 | partial void OpenFileButton(Foundation.NSObject sender)
36 | {
37 | var dlg = NSOpenPanel.OpenPanel;
38 | dlg.CanChooseFiles = true;
39 | dlg.CanChooseDirectories = false;
40 | dlg.AllowsMultipleSelection = false;
41 | dlg.Title = "Choose any format Urho3D and Assetimp support";
42 |
43 | if (dlg.RunModal() == 1)
44 | {
45 | PathLabel.StringValue = dlg.Filename;
46 | Run(dlg.Filename);
47 | }
48 | }
49 |
50 | void Run(string file)
51 | {
52 | previewer.Show(file, this, (int)UrhoSurfacePlaceholder.Frame.Width, (int)UrhoSurfacePlaceholder.Frame.Height);
53 | }
54 |
55 | IntPtr OnSurfaceRequested()
56 | {
57 | return urhoSurface.Handle;
58 | }
59 |
60 | public override NSObject RepresentedObject
61 | {
62 | get
63 | {
64 | return base.RepresentedObject;
65 | }
66 | set
67 | {
68 | base.RepresentedObject = value;
69 | // Update the view, if already loaded.
70 | }
71 | }
72 |
73 | public void HighlightXmlForNode(string node)
74 | {
75 | }
76 |
77 | public void DispatchToUI(Action action)
78 | {
79 | }
80 |
81 | IConfig Config { get; }
82 | }
83 |
84 |
85 |
86 | public class UrhoSurface : NSView
87 | {
88 | public override async void ViewDidMoveToWindow()
89 | {
90 | base.ViewDidMoveToWindow();
91 | PostsFrameChangedNotifications = true;
92 | PostsBoundsChangedNotifications = true;
93 | }
94 |
95 | public override async void SetFrameSize(CoreGraphics.CGSize newSize)
96 | {
97 | base.SetFrameSize(newSize);
98 | if (Application.HasCurrent)
99 | NSOpenGLContext.CurrentContext?.Update();
100 | }
101 | }
102 | }
103 |
--------------------------------------------------------------------------------
/ViewerAssets/RawAssets/Shaders/GLSL/AutoExposure.glsl:
--------------------------------------------------------------------------------
1 | #include "Uniforms.glsl"
2 | #include "Samplers.glsl"
3 | #include "Transform.glsl"
4 | #include "ScreenPos.glsl"
5 | #include "PostProcess.glsl"
6 |
7 | varying vec2 vTexCoord;
8 | varying vec2 vScreenPos;
9 |
10 | #ifdef COMPILEPS
11 | uniform float cAutoExposureAdaptRate;
12 | uniform vec2 cAutoExposureLumRange;
13 | uniform float cAutoExposureMiddleGrey;
14 | uniform vec2 cHDR128InvSize;
15 | uniform vec2 cLum64InvSize;
16 | uniform vec2 cLum16InvSize;
17 | uniform vec2 cLum4InvSize;
18 |
19 | float GatherAvgLum(sampler2D texSampler, vec2 texCoord, vec2 texelSize)
20 | {
21 | float lumAvg = 0.0;
22 | lumAvg += texture2D(texSampler, texCoord + vec2(1.0, -1.0) * texelSize).r;
23 | lumAvg += texture2D(texSampler, texCoord + vec2(-1.0, 1.0) * texelSize).r;
24 | lumAvg += texture2D(texSampler, texCoord + vec2(1.0, 1.0) * texelSize).r;
25 | lumAvg += texture2D(texSampler, texCoord + vec2(1.0, -1.0) * texelSize).r;
26 | return lumAvg / 4.0;
27 | }
28 | #endif
29 |
30 | void VS()
31 | {
32 | mat4 modelMatrix = iModelMatrix;
33 | vec3 worldPos = GetWorldPos(modelMatrix);
34 | gl_Position = GetClipPos(worldPos);
35 | vTexCoord = GetQuadTexCoord(gl_Position);
36 | vScreenPos = GetScreenPosPreDiv(gl_Position);
37 | }
38 |
39 | void PS()
40 | {
41 | #ifdef LUMINANCE64
42 | float logLumSum = 0.0;
43 | logLumSum += log(dot(texture2D(sDiffMap, vTexCoord + vec2(-1.0, -1.0) * cHDR128InvSize).rgb, LumWeights) + 1e-5);
44 | logLumSum += log(dot(texture2D(sDiffMap, vTexCoord + vec2(-1.0, 1.0) * cHDR128InvSize).rgb, LumWeights) + 1e-5);
45 | logLumSum += log(dot(texture2D(sDiffMap, vTexCoord + vec2(1.0, 1.0) * cHDR128InvSize).rgb, LumWeights) + 1e-5);
46 | logLumSum += log(dot(texture2D(sDiffMap, vTexCoord + vec2(1.0, -1.0) * cHDR128InvSize).rgb, LumWeights) + 1e-5);
47 | gl_FragColor.r = logLumSum;
48 | #endif
49 |
50 | #ifdef LUMINANCE16
51 | gl_FragColor.r = GatherAvgLum(sDiffMap, vTexCoord, cLum64InvSize);
52 | #endif
53 |
54 | #ifdef LUMINANCE4
55 | gl_FragColor.r = GatherAvgLum(sDiffMap, vTexCoord, cLum16InvSize);
56 | #endif
57 |
58 | #ifdef LUMINANCE1
59 | gl_FragColor.r = exp(GatherAvgLum(sDiffMap, vTexCoord, cLum4InvSize) / 16.0);
60 | #endif
61 |
62 | #ifdef ADAPTLUMINANCE
63 | float adaptedLum = texture2D(sDiffMap, vTexCoord).r;
64 | float lum = clamp(texture2D(sNormalMap, vTexCoord).r, cAutoExposureLumRange.x, cAutoExposureLumRange.y);
65 | gl_FragColor.r = adaptedLum + (lum - adaptedLum) * (1.0 - exp(-cDeltaTimePS * cAutoExposureAdaptRate));
66 | #endif
67 |
68 | #ifdef EXPOSE
69 | vec3 color = texture2D(sDiffMap, vScreenPos).rgb;
70 | float adaptedLum = texture2D(sNormalMap, vTexCoord).r;
71 | gl_FragColor = vec4(color * (cAutoExposureMiddleGrey / adaptedLum), 1.0);
72 | #endif
73 | }
74 |
--------------------------------------------------------------------------------
/ViewerAssets/RawAssets/Shaders/GLSL/PostProcess.glsl:
--------------------------------------------------------------------------------
1 | #ifdef COMPILEPS
2 | const float PI = 3.14159265;
3 |
4 | vec2 Noise(vec2 coord)
5 | {
6 | float noiseX = clamp(fract(sin(dot(coord, vec2(12.9898, 78.233))) * 43758.5453), 0.0, 1.0);
7 | float noiseY = clamp(fract(sin(dot(coord, vec2(12.9898, 78.233) * 2.0)) * 43758.5453), 0.0, 1.0);
8 | return vec2(noiseX, noiseY);
9 | }
10 |
11 | // Adapted: http://callumhay.blogspot.com/2010/09/gaussian-blur-shader-glsl.html
12 | vec4 GaussianBlur(int blurKernelSize, vec2 blurDir, vec2 blurRadius, float sigma, sampler2D texSampler, vec2 texCoord)
13 | {
14 | int blurKernelSizeHalfSize = blurKernelSize / 2;
15 |
16 | // Incremental Gaussian Coefficent Calculation (See GPU Gems 3 pp. 877 - 889)
17 | vec3 gaussCoeff;
18 | gaussCoeff.x = 1.0 / (sqrt(2.0 * PI) * sigma);
19 | gaussCoeff.y = exp(-0.5 / (sigma * sigma));
20 | gaussCoeff.z = gaussCoeff.y * gaussCoeff.y;
21 |
22 | vec2 blurVec = blurRadius * blurDir;
23 | vec4 avgValue = vec4(0.0);
24 | float gaussCoeffSum = 0.0;
25 |
26 | avgValue += texture2D(texSampler, texCoord) * gaussCoeff.x;
27 | gaussCoeffSum += gaussCoeff.x;
28 | gaussCoeff.xy *= gaussCoeff.yz;
29 |
30 | for (int i = 1; i <= blurKernelSizeHalfSize; i++)
31 | {
32 | avgValue += texture2D(texSampler, texCoord - float(i) * blurVec) * gaussCoeff.x;
33 | avgValue += texture2D(texSampler, texCoord + float(i) * blurVec) * gaussCoeff.x;
34 |
35 | gaussCoeffSum += 2.0 * gaussCoeff.x;
36 | gaussCoeff.xy *= gaussCoeff.yz;
37 | }
38 |
39 | return avgValue / gaussCoeffSum;
40 | }
41 |
42 | const vec3 LumWeights = vec3(0.2126, 0.7152, 0.0722);
43 |
44 | vec3 ReinhardEq3Tonemap(vec3 x)
45 | {
46 | return x / (1.0 + x);
47 | }
48 |
49 | vec3 ReinhardEq4Tonemap(vec3 x, float white)
50 | {
51 | return x * (1.0 + x / white) / (1.0 + x);
52 | }
53 |
54 | // Unchared2 tone mapping (See http://filmicgames.com)
55 | const float A = 0.15;
56 | const float B = 0.50;
57 | const float C = 0.10;
58 | const float D = 0.20;
59 | const float E = 0.02;
60 | const float F = 0.30;
61 |
62 | vec3 Uncharted2Tonemap(vec3 x)
63 | {
64 | return ((x*(A*x+C*B)+D*E)/(x*(A*x+B)+D*F))-E/F;
65 | }
66 |
67 | #ifndef GL_ES
68 | vec3 ColorCorrection(vec3 color, sampler3D lut)
69 | {
70 | float lutSize = 16.0;
71 | float scale = (lutSize - 1.0) / lutSize;
72 | float offset = 1.0 / (2.0 * lutSize);
73 | return texture3D(lut, clamp(color, 0.0, 1.0) * scale + offset).rgb;
74 | }
75 | #endif
76 |
77 | const float Gamma = 2.2;
78 | const float InverseGamma = 1.0 / 2.2;
79 |
80 | vec3 ToGamma(vec3 color)
81 | {
82 | return vec3(pow(color.r, Gamma), pow(color.g, Gamma), pow(color.b, Gamma));
83 | }
84 |
85 | vec3 ToInverseGamma(vec3 color)
86 | {
87 | return vec3(pow(color.r, InverseGamma), pow(color.g, InverseGamma), pow(color.b, InverseGamma));
88 | }
89 | #endif
90 |
--------------------------------------------------------------------------------
/UrhoSharp.Viewer.Wpf/Properties/Resources.Designer.cs:
--------------------------------------------------------------------------------
1 | //------------------------------------------------------------------------------
2 | //
3 | // This code was generated by a tool.
4 | // Runtime Version:4.0.30319.42000
5 | //
6 | // Changes to this file may cause incorrect behavior and will be lost if
7 | // the code is regenerated.
8 | //
9 | //------------------------------------------------------------------------------
10 |
11 | namespace UrhoSharp.Viewer.Wpf.Properties {
12 | using System;
13 |
14 |
15 | ///
16 | /// A strongly-typed resource class, for looking up localized strings, etc.
17 | ///
18 | // This class was auto-generated by the StronglyTypedResourceBuilder
19 | // class via a tool like ResGen or Visual Studio.
20 | // To add or remove a member, edit your .ResX file then rerun ResGen
21 | // with the /str option, or rebuild your VS project.
22 | [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "4.0.0.0")]
23 | [global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
24 | [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
25 | internal class Resources {
26 |
27 | private static global::System.Resources.ResourceManager resourceMan;
28 |
29 | private static global::System.Globalization.CultureInfo resourceCulture;
30 |
31 | [global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")]
32 | internal Resources() {
33 | }
34 |
35 | ///
36 | /// Returns the cached ResourceManager instance used by this class.
37 | ///
38 | [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
39 | internal static global::System.Resources.ResourceManager ResourceManager {
40 | get {
41 | if (object.ReferenceEquals(resourceMan, null)) {
42 | global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("UrhoSharp.Viewer.Wpf.Properties.Resources", typeof(Resources).Assembly);
43 | resourceMan = temp;
44 | }
45 | return resourceMan;
46 | }
47 | }
48 |
49 | ///
50 | /// Overrides the current thread's CurrentUICulture property for all
51 | /// resource lookups using this strongly typed resource class.
52 | ///
53 | [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
54 | internal static global::System.Globalization.CultureInfo Culture {
55 | get {
56 | return resourceCulture;
57 | }
58 | set {
59 | resourceCulture = value;
60 | }
61 | }
62 | }
63 | }
64 |
--------------------------------------------------------------------------------