-
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.
Merge pull request #9 from wutipong/feature/sample-scene
Feature/sample scene
- Loading branch information
Showing
14 changed files
with
664 additions
and
265 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,38 +1,27 @@ | ||
/* | ||
* Copyright (c) 2017-2022 The Forge Interactive Inc. | ||
* | ||
* This file is part of The-Forge | ||
* (see https://github.com/ConfettiFX/The-Forge). | ||
* | ||
* Licensed to the Apache Software Foundation (ASF) under one | ||
* or more contributor license agreements. See the NOTICE file | ||
* distributed with this work for additional information | ||
* regarding copyright ownership. The ASF licenses this file | ||
* to you under the Apache License, Version 2.0 (the | ||
* "License"); you may not use this file except in compliance | ||
* with the License. You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, | ||
* software distributed under the License is distributed on an | ||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY | ||
* KIND, either express or implied. See the License for the | ||
* specific language governing permissions and limitations | ||
* under the License. | ||
*/ | ||
|
||
// Shader for simple shading with a point light | ||
// for planets in Unit Test 12 - Transformations | ||
RES(Tex2D(float), lightMap, UPDATE_FREQ_NONE, t0, binding = 0); | ||
RES(SamplerState, uSampler, UPDATE_FREQ_NONE, s0, binding = 1); | ||
|
||
STRUCT(VSOutput) | ||
{ | ||
DATA(float4, Position, SV_Position); | ||
DATA(float4, Color, COLOR); | ||
DATA(float2, LightmapPos, TEXCOORD0); | ||
DATA(float, LightmapHeight, TEXCOORD1); | ||
}; | ||
|
||
float4 PS_MAIN( VSOutput In ) | ||
float4 PS_MAIN(VSOutput In) | ||
{ | ||
INIT_MAIN; | ||
|
||
float2 coord = (In.LightmapPos + float2(1, 1)) / float2(2, 2); | ||
coord.y = 1 - coord.y; | ||
|
||
float4 litDepth = SampleTex2D(Get(lightMap), Get(uSampler), coord); | ||
|
||
if (litDepth.x > In.LightmapHeight + 0.05) | ||
{ | ||
In.Color -= float4(0.8, 0.8, 0.8, 0.0); | ||
} | ||
|
||
RETURN(In.Color); | ||
} |
This file was deleted.
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,23 @@ | ||
#include "quad_resource.fsl" | ||
|
||
VSOutput VS_MAIN(VSInput In, SV_InstanceID(uint) InstanceID) | ||
{ | ||
INIT_MAIN; | ||
VSOutput Out; | ||
|
||
#if VR_MULTIVIEW_ENABLED | ||
float4x4 wvp = mul(Get(mvp)[VR_VIEW_ID], Get(toWorld)); | ||
#else | ||
float4x4 wvp = mul(Get(mvp), Get(toWorld)); | ||
#endif | ||
Out.Position = mul(wvp, float4(In.Position.xyz, 1.0f)); | ||
Out.Color = Get(color); | ||
|
||
float4x4 lightWVP = mul(Get(lightProjView), Get(toWorld)); | ||
float4 lightSpacePos = mul(lightWVP, float4(In.Position.xyz, 1.0f)); | ||
|
||
Out.LightmapPos = lightSpacePos.xy; | ||
Out.LightmapHeight = lightSpacePos.z; | ||
|
||
RETURN(Out); | ||
} |
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 @@ | ||
#ifndef QUAD_RESOURCE | ||
#define QUAD_RESOURCE | ||
|
||
CBUFFER(uniformBlock, UPDATE_FREQ_PER_FRAME, b0, binding = 0) | ||
{ | ||
#if VR_MULTIVIEW_ENABLED | ||
DATA(float4x4, mvp[VR_MULTIVIEW_COUNT], None); | ||
#else | ||
DATA(float4x4, mvp, None); | ||
#endif | ||
DATA(float4x4, lightProjView, None); | ||
DATA(float4x4, toWorld, None); | ||
DATA(float4, color, None); | ||
}; | ||
|
||
STRUCT(VSInput) | ||
{ | ||
DATA(float3, Position, POSITION); | ||
DATA(float3, Normal, NORMAL); | ||
}; | ||
|
||
STRUCT(VSOutput) | ||
{ | ||
DATA(float4, Position, SV_Position); | ||
DATA(float4, Color, COLOR); | ||
DATA(float2, LightmapPos, TEXCOORD0); | ||
DATA(float, LightmapHeight, TEXCOORD1); | ||
}; | ||
|
||
#endif |
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 @@ | ||
#include "quad_resource.fsl" | ||
|
||
VSOutput VS_MAIN(VSInput In, SV_InstanceID(uint) InstanceID) | ||
{ | ||
INIT_MAIN; | ||
VSOutput Out; | ||
|
||
float4x4 tempMat = mul(Get(lightProjView), Get(toWorld)); | ||
|
||
Out.Position = mul(tempMat, float4(In.Position.xyz, 1.0f)); | ||
Out.Color = Get(color); | ||
|
||
RETURN(Out); | ||
} |
This file was deleted.
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,5 @@ | ||
void PS_MAIN() | ||
{ | ||
INIT_MAIN; | ||
RETURN(); | ||
} |
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,23 @@ | ||
#include "sphere_resource.fsl" | ||
|
||
VSOutput VS_MAIN(VSInput In, SV_InstanceID(uint) InstanceID) | ||
{ | ||
INIT_MAIN; | ||
VSOutput Out; | ||
|
||
#if VR_MULTIVIEW_ENABLED | ||
float4x4 wvp = mul(Get(mvp)[VR_VIEW_ID], Get(toWorld)[InstanceID]); | ||
#else | ||
float4x4 wvp = mul(Get(mvp), Get(toWorld)[InstanceID]); | ||
#endif | ||
Out.Position = mul(wvp, float4(In.Position.xyz, 1.0f)); | ||
Out.Color = Get(color)[InstanceID]; | ||
|
||
float4x4 lightWVP = mul(Get(lightProjView), Get(toWorld)[InstanceID]); | ||
float4 lightSpacePos = mul(lightWVP, float4(In.Position.xyz, 1.0f)); | ||
|
||
Out.LightmapPos = lightSpacePos.xy; | ||
Out.LightmapHeight = lightSpacePos.z; | ||
|
||
RETURN(Out); | ||
} |
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,35 @@ | ||
#ifndef SPHERE_RESOURCE | ||
#define SPHERE_RESOURCE | ||
|
||
#ifndef MAX_PLANETS | ||
#define MAX_PLANETS 768 | ||
#endif | ||
|
||
CBUFFER(uniformBlock, UPDATE_FREQ_PER_FRAME, b0, binding = 0) | ||
{ | ||
#if VR_MULTIVIEW_ENABLED | ||
DATA(float4x4, mvp[VR_MULTIVIEW_COUNT], None); | ||
#else | ||
DATA(float4x4, mvp, None); | ||
#endif | ||
DATA(float4x4, lightProjView, None); | ||
|
||
DATA(float4x4, toWorld[MAX_PLANETS], None); | ||
DATA(float4, color[MAX_PLANETS], None); | ||
}; | ||
|
||
STRUCT(VSInput) | ||
{ | ||
DATA(float3, Position, POSITION); | ||
DATA(float3, Normal, NORMAL); | ||
}; | ||
|
||
STRUCT(VSOutput) | ||
{ | ||
DATA(float4, Position, SV_Position); | ||
DATA(float4, Color, COLOR); | ||
DATA(float2, LightmapPos, TEXCOORD0); | ||
DATA(float, LightmapHeight, TEXCOORD1); | ||
}; | ||
|
||
#endif |
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,13 @@ | ||
#include "sphere_resource.fsl" | ||
|
||
VSOutput VS_MAIN(VSInput In, SV_InstanceID(uint) InstanceID) | ||
{ | ||
INIT_MAIN; | ||
VSOutput Out; | ||
|
||
float4x4 tempMat = mul(Get(lightProjView), Get(toWorld)[InstanceID]); | ||
Out.Position = mul(tempMat, float4(In.Position.xyz, 1.0f)); | ||
Out.Color = Get(color)[InstanceID]; | ||
|
||
RETURN(Out); | ||
} |
Oops, something went wrong.