Skip to content

Commit

Permalink
Unity reflections fix (#54)
Browse files Browse the repository at this point in the history
* Added shader for reflections from newest commit to fix problem with freeze

* CI: Add build

---------

Co-authored-by: Oldrich Krupauer <oldrich.krupauer@pm.me>
Co-authored-by: ItsOKayCZ <ItsOKayCZ@users.noreply.github.com>
  • Loading branch information
3 people authored Oct 25, 2024
1 parent 3db2aa4 commit b1d3c6f
Show file tree
Hide file tree
Showing 7 changed files with 17 additions and 3 deletions.
Binary file not shown.
Binary file not shown.
Binary file not shown.
2 changes: 1 addition & 1 deletion python_trainer/network.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ def __init__(self, visual_input_shape, nonvis_input_shape, device):
self.device = device

conv_1_args = {"kernels": 16, "kernel_size": 5, "stride": 1}
conv_2_args = {"kernels": 32, "kernel_size": 3, "stride": 1}
conv_2_args = {"kernels": 8, "kernel_size": 3, "stride": 1}
nonvis_dense_size = 8
encoding_size = 126

Expand Down
2 changes: 1 addition & 1 deletion python_trainer/variables.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
REDUCE_TEMPERATURE = 1 / 25
DISCOUNT = 0.95 # devalues future reward
LEARNING_RATE = 0.0005
NUM_TRAINING_EXAMPLES = 10000
NUM_TRAINING_EXAMPLES = 5000
MAX_TRAINED_EPOCHS = 500

# Reward
Expand Down
2 changes: 1 addition & 1 deletion unity_env/Assets/Materials/Road/Reflection.shader
Original file line number Diff line number Diff line change
Expand Up @@ -187,4 +187,4 @@ Shader "Custom/Reflection"
ENDCG
}
FallBack "Diffuse"
}
}
14 changes: 14 additions & 0 deletions unity_env/Assets/Scripts/TrainingReplicator.cs
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,20 @@ void Start()
ChangeCameraBackgroundColor();
}

void SetMaterial()
{
foreach (var mat in roadMaterials)
{
mat.SetFloat(
"_ReflectionStrength",
DataChannel.getParameter("reflectionStrength", 1f)
);
mat.SetFloat("_NoiseScaleX", DataChannel.getParameter("noiseScaleX", 0.4f));
mat.SetFloat("_NoiseScaleY", DataChannel.getParameter("noiseScaleY", 0.05f));
mat.SetFloat("_Speed", DataChannel.getParameter("noiseSpeed", 0.3f));
}
}

void Update()
{
if (randomBackgroundColor)
Expand Down

0 comments on commit b1d3c6f

Please sign in to comment.