-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add an example of passing packed struct arrays to WebGL
- Loading branch information
Showing
10 changed files
with
913 additions
and
0 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,71 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<Project ToolsVersion="4.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> | ||
<PropertyGroup> | ||
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration> | ||
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform> | ||
<ProductVersion>8.0.30703</ProductVersion> | ||
<SchemaVersion>2.0</SchemaVersion> | ||
<ProjectGuid>{E2DB486A-BB4C-4627-934A-DC1910F5E66E}</ProjectGuid> | ||
<OutputType>Library</OutputType> | ||
<AppDesignerFolder>Properties</AppDesignerFolder> | ||
<RootNamespace>WebGL</RootNamespace> | ||
<AssemblyName>WebGL_Vertex_Structs</AssemblyName> | ||
<TargetFrameworkVersion>v4.0</TargetFrameworkVersion> | ||
<FileAlignment>512</FileAlignment> | ||
</PropertyGroup> | ||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' "> | ||
<DebugSymbols>true</DebugSymbols> | ||
<DebugType>full</DebugType> | ||
<Optimize>false</Optimize> | ||
<OutputPath>bin\</OutputPath> | ||
<DefineConstants>DEBUG;TRACE</DefineConstants> | ||
<ErrorReport>prompt</ErrorReport> | ||
<WarningLevel>4</WarningLevel> | ||
<AllowUnsafeBlocks>true</AllowUnsafeBlocks> | ||
</PropertyGroup> | ||
<PropertyGroup> | ||
<RunPostBuildEvent>Always</RunPostBuildEvent> | ||
</PropertyGroup> | ||
<ItemGroup> | ||
<Reference Include="JSIL.Meta"> | ||
<HintPath>..\..\bin\JSIL.Meta.dll</HintPath> | ||
</Reference> | ||
<Reference Include="System" /> | ||
<Reference Include="System.Core" /> | ||
<Reference Include="Microsoft.CSharp" /> | ||
</ItemGroup> | ||
<ItemGroup> | ||
<Compile Include="Page.cs" /> | ||
</ItemGroup> | ||
<ItemGroup> | ||
<Folder Include="Properties\" /> | ||
</ItemGroup> | ||
<ItemGroup> | ||
<None Include="crate.fs"> | ||
<CopyToOutputDirectory>Always</CopyToOutputDirectory> | ||
</None> | ||
<None Include="crate.vs"> | ||
<CopyToOutputDirectory>Always</CopyToOutputDirectory> | ||
</None> | ||
</ItemGroup> | ||
<ItemGroup> | ||
<Content Include="crate.png"> | ||
<CopyToOutputDirectory>Always</CopyToOutputDirectory> | ||
</Content> | ||
<Content Include="glMatrix-0.9.5.min.js"> | ||
<CopyToOutputDirectory>Always</CopyToOutputDirectory> | ||
</Content> | ||
<Content Include="webgl-utils.js"> | ||
<CopyToOutputDirectory>Always</CopyToOutputDirectory> | ||
</Content> | ||
</ItemGroup> | ||
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" /> | ||
<!-- Don't edit this build event by hand! The condition ensures that when VS kicks off a JSILc build, JSILc won't then kick off another JSILc build recursively, forever... --> | ||
<PropertyGroup Condition="$(JSIL) != 'building'"> | ||
<PostBuildEvent> | ||
del $(SolutionDir)..\..\jsil.org\demos\WebGL_Vertex_Structs\*.js | ||
copy $(SolutionDir)Page.cs $(SolutionDir)..\..\jsil.org\demos\WebGL_Vertex_Structs\Page.cs | ||
$(SolutionDir)..\..\bin\JSILc.exe $(SolutionPath) | ||
</PostBuildEvent> | ||
</PropertyGroup> | ||
</Project> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
|
||
Microsoft Visual Studio Solution File, Format Version 11.00 | ||
# Visual Studio 2010 | ||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "WebGL_Vertex_Structs", "WebGL_Vertex_Structs.csproj", "{E2DB486A-BB4C-4627-934A-DC1910F5E66E}" | ||
EndProject | ||
Global | ||
GlobalSection(SolutionConfigurationPlatforms) = preSolution | ||
Debug|Any CPU = Debug|Any CPU | ||
EndGlobalSection | ||
GlobalSection(ProjectConfigurationPlatforms) = postSolution | ||
{E2DB486A-BB4C-4627-934A-DC1910F5E66E}.Debug|Any CPU.ActiveCfg = Debug|Any CPU | ||
{E2DB486A-BB4C-4627-934A-DC1910F5E66E}.Debug|Any CPU.Build.0 = Debug|Any CPU | ||
EndGlobalSection | ||
GlobalSection(SolutionProperties) = preSolution | ||
HideSolutionNode = FALSE | ||
EndGlobalSection | ||
EndGlobal |
14 changes: 14 additions & 0 deletions
14
Examples/WebGL_Vertex_Structs/WebGL_Vertex_Structs.sln.jsilconfig
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
{ | ||
"FrameworkVersion": 4.0, | ||
"OutputDirectory": "%configdirectory%/../../jsil.org/demos/WebGL_Vertex_Structs", | ||
"Assemblies": { | ||
"Ignored": [ | ||
"System.Dynamic,", | ||
"System.Core,", | ||
"System.Configuration,", | ||
"System.Numerics,", | ||
"Microsoft.CSharp,", | ||
"System.Xml," | ||
] | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
precision mediump float; | ||
|
||
varying vec2 vTextureCoord; | ||
varying vec3 vLightWeighting; | ||
|
||
uniform sampler2D uSampler; | ||
|
||
void main(void) { | ||
vec4 textureColor = texture2D(uSampler, vec2(vTextureCoord.s, vTextureCoord.t)); | ||
gl_FragColor = vec4(textureColor.rgb * vLightWeighting, textureColor.a); | ||
} |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
attribute vec3 aVertexPosition; | ||
attribute vec3 aVertexNormal; | ||
attribute vec2 aTextureCoord; | ||
|
||
uniform mat4 uMVMatrix; | ||
uniform mat4 uPMatrix; | ||
uniform mat3 uNMatrix; | ||
|
||
uniform vec3 uAmbientColor; | ||
|
||
uniform vec3 uLightingDirection; | ||
uniform vec3 uDirectionalColor; | ||
|
||
uniform bool uUseLighting; | ||
|
||
varying vec2 vTextureCoord; | ||
varying vec3 vLightWeighting; | ||
|
||
void main(void) { | ||
gl_Position = uPMatrix * uMVMatrix * vec4(aVertexPosition, 1.0); | ||
vTextureCoord = aTextureCoord; | ||
|
||
if (!uUseLighting) { | ||
vLightWeighting = vec3(1.0, 1.0, 1.0); | ||
} else { | ||
vec3 transformedNormal = uNMatrix * aVertexNormal; | ||
float directionalLightWeighting = max(dot(transformedNormal, uLightingDirection), 0.0); | ||
vLightWeighting = uAmbientColor + uDirectionalColor * directionalLightWeighting; | ||
} | ||
} |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Oops, something went wrong.